babylon.module.d.ts 5.4 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module "babylonjs/Misc/observable" {
  50. import { Nullable } from "babylonjs/types";
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  162. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. readonly observers: Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module "babylonjs/Misc/domManagement" {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Extracts text content from a DOM element hierarchy
  284. * @param element defines the root element
  285. * @returns a string
  286. */
  287. static GetDOMTextContent(element: HTMLElement): string;
  288. }
  289. }
  290. declare module "babylonjs/Misc/logger" {
  291. /**
  292. * Logger used througouht the application to allow configuration of
  293. * the log level required for the messages.
  294. */
  295. export class Logger {
  296. /**
  297. * No log
  298. */
  299. static readonly NoneLogLevel: number;
  300. /**
  301. * Only message logs
  302. */
  303. static readonly MessageLogLevel: number;
  304. /**
  305. * Only warning logs
  306. */
  307. static readonly WarningLogLevel: number;
  308. /**
  309. * Only error logs
  310. */
  311. static readonly ErrorLogLevel: number;
  312. /**
  313. * All logs
  314. */
  315. static readonly AllLogLevel: number;
  316. private static _LogCache;
  317. /**
  318. * Gets a value indicating the number of loading errors
  319. * @ignorenaming
  320. */
  321. static errorsCount: number;
  322. /**
  323. * Callback called when a new log is added
  324. */
  325. static OnNewCacheEntry: (entry: string) => void;
  326. private static _AddLogEntry;
  327. private static _FormatMessage;
  328. private static _LogDisabled;
  329. private static _LogEnabled;
  330. private static _WarnDisabled;
  331. private static _WarnEnabled;
  332. private static _ErrorDisabled;
  333. private static _ErrorEnabled;
  334. /**
  335. * Log a message to the console
  336. */
  337. static Log: (message: string) => void;
  338. /**
  339. * Write a warning message to the console
  340. */
  341. static Warn: (message: string) => void;
  342. /**
  343. * Write an error message to the console
  344. */
  345. static Error: (message: string) => void;
  346. /**
  347. * Gets current log cache (list of logs)
  348. */
  349. static readonly LogCache: string;
  350. /**
  351. * Clears the log cache
  352. */
  353. static ClearLogCache(): void;
  354. /**
  355. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  356. */
  357. static LogLevels: number;
  358. }
  359. }
  360. declare module "babylonjs/Misc/typeStore" {
  361. /** @hidden */
  362. export class _TypeStore {
  363. /** @hidden */
  364. static RegisteredTypes: {
  365. [key: string]: Object;
  366. };
  367. /** @hidden */
  368. static GetClass(fqdn: string): any;
  369. }
  370. }
  371. declare module "babylonjs/Misc/deepCopier" {
  372. /**
  373. * Class containing a set of static utilities functions for deep copy.
  374. */
  375. export class DeepCopier {
  376. /**
  377. * Tries to copy an object by duplicating every property
  378. * @param source defines the source object
  379. * @param destination defines the target object
  380. * @param doNotCopyList defines a list of properties to avoid
  381. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  382. */
  383. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  384. }
  385. }
  386. declare module "babylonjs/Misc/precisionDate" {
  387. /**
  388. * Class containing a set of static utilities functions for precision date
  389. */
  390. export class PrecisionDate {
  391. /**
  392. * Gets either window.performance.now() if supported or Date.now() else
  393. */
  394. static readonly Now: number;
  395. }
  396. }
  397. declare module "babylonjs/Misc/devTools" {
  398. /** @hidden */
  399. export class _DevTools {
  400. static WarnImport(name: string): string;
  401. }
  402. }
  403. declare module "babylonjs/Misc/webRequest" {
  404. /**
  405. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  406. */
  407. export class WebRequest {
  408. private _xhr;
  409. /**
  410. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  411. * i.e. when loading files, where the server/service expects an Authorization header
  412. */
  413. static CustomRequestHeaders: {
  414. [key: string]: string;
  415. };
  416. /**
  417. * Add callback functions in this array to update all the requests before they get sent to the network
  418. */
  419. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  420. private _injectCustomRequestHeaders;
  421. /**
  422. * Gets or sets a function to be called when loading progress changes
  423. */
  424. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  425. /**
  426. * Returns client's state
  427. */
  428. readonly readyState: number;
  429. /**
  430. * Returns client's status
  431. */
  432. readonly status: number;
  433. /**
  434. * Returns client's status as a text
  435. */
  436. readonly statusText: string;
  437. /**
  438. * Returns client's response
  439. */
  440. readonly response: any;
  441. /**
  442. * Returns client's response url
  443. */
  444. readonly responseURL: string;
  445. /**
  446. * Returns client's response as text
  447. */
  448. readonly responseText: string;
  449. /**
  450. * Gets or sets the expected response type
  451. */
  452. responseType: XMLHttpRequestResponseType;
  453. /** @hidden */
  454. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  455. /** @hidden */
  456. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  457. /**
  458. * Cancels any network activity
  459. */
  460. abort(): void;
  461. /**
  462. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  463. * @param body defines an optional request body
  464. */
  465. send(body?: Document | BodyInit | null): void;
  466. /**
  467. * Sets the request method, request URL
  468. * @param method defines the method to use (GET, POST, etc..)
  469. * @param url defines the url to connect with
  470. */
  471. open(method: string, url: string): void;
  472. }
  473. }
  474. declare module "babylonjs/Misc/fileRequest" {
  475. import { Observable } from "babylonjs/Misc/observable";
  476. /**
  477. * File request interface
  478. */
  479. export interface IFileRequest {
  480. /**
  481. * Raised when the request is complete (success or error).
  482. */
  483. onCompleteObservable: Observable<IFileRequest>;
  484. /**
  485. * Aborts the request for a file.
  486. */
  487. abort: () => void;
  488. }
  489. }
  490. declare module "babylonjs/Misc/performanceMonitor" {
  491. /**
  492. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  493. */
  494. export class PerformanceMonitor {
  495. private _enabled;
  496. private _rollingFrameTime;
  497. private _lastFrameTimeMs;
  498. /**
  499. * constructor
  500. * @param frameSampleSize The number of samples required to saturate the sliding window
  501. */
  502. constructor(frameSampleSize?: number);
  503. /**
  504. * Samples current frame
  505. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  506. */
  507. sampleFrame(timeMs?: number): void;
  508. /**
  509. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  510. */
  511. readonly averageFrameTime: number;
  512. /**
  513. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  514. */
  515. readonly averageFrameTimeVariance: number;
  516. /**
  517. * Returns the frame time of the most recent frame
  518. */
  519. readonly instantaneousFrameTime: number;
  520. /**
  521. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  522. */
  523. readonly averageFPS: number;
  524. /**
  525. * Returns the average framerate in frames per second using the most recent frame time
  526. */
  527. readonly instantaneousFPS: number;
  528. /**
  529. * Returns true if enough samples have been taken to completely fill the sliding window
  530. */
  531. readonly isSaturated: boolean;
  532. /**
  533. * Enables contributions to the sliding window sample set
  534. */
  535. enable(): void;
  536. /**
  537. * Disables contributions to the sliding window sample set
  538. * Samples will not be interpolated over the disabled period
  539. */
  540. disable(): void;
  541. /**
  542. * Returns true if sampling is enabled
  543. */
  544. readonly isEnabled: boolean;
  545. /**
  546. * Resets performance monitor
  547. */
  548. reset(): void;
  549. }
  550. /**
  551. * RollingAverage
  552. *
  553. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  554. */
  555. export class RollingAverage {
  556. /**
  557. * Current average
  558. */
  559. average: number;
  560. /**
  561. * Current variance
  562. */
  563. variance: number;
  564. protected _samples: Array<number>;
  565. protected _sampleCount: number;
  566. protected _pos: number;
  567. protected _m2: number;
  568. /**
  569. * constructor
  570. * @param length The number of samples required to saturate the sliding window
  571. */
  572. constructor(length: number);
  573. /**
  574. * Adds a sample to the sample set
  575. * @param v The sample value
  576. */
  577. add(v: number): void;
  578. /**
  579. * Returns previously added values or null if outside of history or outside the sliding window domain
  580. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  581. * @return Value previously recorded with add() or null if outside of range
  582. */
  583. history(i: number): number;
  584. /**
  585. * Returns true if enough samples have been taken to completely fill the sliding window
  586. * @return true if sample-set saturated
  587. */
  588. isSaturated(): boolean;
  589. /**
  590. * Resets the rolling average (equivalent to 0 samples taken so far)
  591. */
  592. reset(): void;
  593. /**
  594. * Wraps a value around the sample range boundaries
  595. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  596. * @return Wrapped position in sample range
  597. */
  598. protected _wrapPosition(i: number): number;
  599. }
  600. }
  601. declare module "babylonjs/Misc/stringDictionary" {
  602. import { Nullable } from "babylonjs/types";
  603. /**
  604. * This class implement a typical dictionary using a string as key and the generic type T as value.
  605. * The underlying implementation relies on an associative array to ensure the best performances.
  606. * The value can be anything including 'null' but except 'undefined'
  607. */
  608. export class StringDictionary<T> {
  609. /**
  610. * This will clear this dictionary and copy the content from the 'source' one.
  611. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  612. * @param source the dictionary to take the content from and copy to this dictionary
  613. */
  614. copyFrom(source: StringDictionary<T>): void;
  615. /**
  616. * Get a value based from its key
  617. * @param key the given key to get the matching value from
  618. * @return the value if found, otherwise undefined is returned
  619. */
  620. get(key: string): T | undefined;
  621. /**
  622. * Get a value from its key or add it if it doesn't exist.
  623. * This method will ensure you that a given key/data will be present in the dictionary.
  624. * @param key the given key to get the matching value from
  625. * @param factory the factory that will create the value if the key is not present in the dictionary.
  626. * The factory will only be invoked if there's no data for the given key.
  627. * @return the value corresponding to the key.
  628. */
  629. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  630. /**
  631. * Get a value from its key if present in the dictionary otherwise add it
  632. * @param key the key to get the value from
  633. * @param val if there's no such key/value pair in the dictionary add it with this value
  634. * @return the value corresponding to the key
  635. */
  636. getOrAdd(key: string, val: T): T;
  637. /**
  638. * Check if there's a given key in the dictionary
  639. * @param key the key to check for
  640. * @return true if the key is present, false otherwise
  641. */
  642. contains(key: string): boolean;
  643. /**
  644. * Add a new key and its corresponding value
  645. * @param key the key to add
  646. * @param value the value corresponding to the key
  647. * @return true if the operation completed successfully, false if we couldn't insert the key/value because there was already this key in the dictionary
  648. */
  649. add(key: string, value: T): boolean;
  650. /**
  651. * Update a specific value associated to a key
  652. * @param key defines the key to use
  653. * @param value defines the value to store
  654. * @returns true if the value was updated (or false if the key was not found)
  655. */
  656. set(key: string, value: T): boolean;
  657. /**
  658. * Get the element of the given key and remove it from the dictionary
  659. * @param key defines the key to search
  660. * @returns the value associated with the key or null if not found
  661. */
  662. getAndRemove(key: string): Nullable<T>;
  663. /**
  664. * Remove a key/value from the dictionary.
  665. * @param key the key to remove
  666. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  667. */
  668. remove(key: string): boolean;
  669. /**
  670. * Clear the whole content of the dictionary
  671. */
  672. clear(): void;
  673. /**
  674. * Gets the current count
  675. */
  676. readonly count: number;
  677. /**
  678. * Execute a callback on each key/val of the dictionary.
  679. * Note that you can remove any element in this dictionary in the callback implementation
  680. * @param callback the callback to execute on a given key/value pair
  681. */
  682. forEach(callback: (key: string, val: T) => void): void;
  683. /**
  684. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  685. * If the callback returns null or undefined the method will iterate to the next key/value pair
  686. * Note that you can remove any element in this dictionary in the callback implementation
  687. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  688. * @returns the first item
  689. */
  690. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  691. private _count;
  692. private _data;
  693. }
  694. }
  695. declare module "babylonjs/Meshes/dataBuffer" {
  696. /**
  697. * Class used to store gfx data (like WebGLBuffer)
  698. */
  699. export class DataBuffer {
  700. /**
  701. * Gets or sets the number of objects referencing this buffer
  702. */
  703. references: number;
  704. /** Gets or sets the size of the underlying buffer */
  705. capacity: number;
  706. /**
  707. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  708. */
  709. is32Bits: boolean;
  710. /**
  711. * Gets the underlying buffer
  712. */
  713. readonly underlyingResource: any;
  714. }
  715. }
  716. declare module "babylonjs/Meshes/buffer" {
  717. import { Nullable, DataArray } from "babylonjs/types";
  718. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  719. /**
  720. * Class used to store data that will be store in GPU memory
  721. */
  722. export class Buffer {
  723. private _engine;
  724. private _buffer;
  725. /** @hidden */
  726. _data: Nullable<DataArray>;
  727. private _updatable;
  728. private _instanced;
  729. /**
  730. * Gets the byte stride.
  731. */
  732. readonly byteStride: number;
  733. /**
  734. * Constructor
  735. * @param engine the engine
  736. * @param data the data to use for this buffer
  737. * @param updatable whether the data is updatable
  738. * @param stride the stride (optional)
  739. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  740. * @param instanced whether the buffer is instanced (optional)
  741. * @param useBytes set to true if the stride in in bytes (optional)
  742. */
  743. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  744. /**
  745. * Create a new VertexBuffer based on the current buffer
  746. * @param kind defines the vertex buffer kind (position, normal, etc.)
  747. * @param offset defines offset in the buffer (0 by default)
  748. * @param size defines the size in floats of attributes (position is 3 for instance)
  749. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  750. * @param instanced defines if the vertex buffer contains indexed data
  751. * @param useBytes defines if the offset and stride are in bytes
  752. * @returns the new vertex buffer
  753. */
  754. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  755. /**
  756. * Gets a boolean indicating if the Buffer is updatable?
  757. * @returns true if the buffer is updatable
  758. */
  759. isUpdatable(): boolean;
  760. /**
  761. * Gets current buffer's data
  762. * @returns a DataArray or null
  763. */
  764. getData(): Nullable<DataArray>;
  765. /**
  766. * Gets underlying native buffer
  767. * @returns underlying native buffer
  768. */
  769. getBuffer(): Nullable<DataBuffer>;
  770. /**
  771. * Gets the stride in float32 units (i.e. byte stride / 4).
  772. * May not be an integer if the byte stride is not divisible by 4.
  773. * DEPRECATED. Use byteStride instead.
  774. * @returns the stride in float32 units
  775. */
  776. getStrideSize(): number;
  777. /**
  778. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  779. * @param data defines the data to store
  780. */
  781. create(data?: Nullable<DataArray>): void;
  782. /** @hidden */
  783. _rebuild(): void;
  784. /**
  785. * Update current buffer data
  786. * @param data defines the data to store
  787. */
  788. update(data: DataArray): void;
  789. /**
  790. * Updates the data directly.
  791. * @param data the new data
  792. * @param offset the new offset
  793. * @param vertexCount the vertex count (optional)
  794. * @param useBytes set to true if the offset is in bytes
  795. */
  796. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  797. /**
  798. * Release all resources
  799. */
  800. dispose(): void;
  801. }
  802. /**
  803. * Specialized buffer used to store vertex data
  804. */
  805. export class VertexBuffer {
  806. /** @hidden */
  807. _buffer: Buffer;
  808. private _kind;
  809. private _size;
  810. private _ownsBuffer;
  811. private _instanced;
  812. private _instanceDivisor;
  813. /**
  814. * The byte type.
  815. */
  816. static readonly BYTE: number;
  817. /**
  818. * The unsigned byte type.
  819. */
  820. static readonly UNSIGNED_BYTE: number;
  821. /**
  822. * The short type.
  823. */
  824. static readonly SHORT: number;
  825. /**
  826. * The unsigned short type.
  827. */
  828. static readonly UNSIGNED_SHORT: number;
  829. /**
  830. * The integer type.
  831. */
  832. static readonly INT: number;
  833. /**
  834. * The unsigned integer type.
  835. */
  836. static readonly UNSIGNED_INT: number;
  837. /**
  838. * The float type.
  839. */
  840. static readonly FLOAT: number;
  841. /**
  842. * Gets or sets the instance divisor when in instanced mode
  843. */
  844. instanceDivisor: number;
  845. /**
  846. * Gets the byte stride.
  847. */
  848. readonly byteStride: number;
  849. /**
  850. * Gets the byte offset.
  851. */
  852. readonly byteOffset: number;
  853. /**
  854. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  855. */
  856. readonly normalized: boolean;
  857. /**
  858. * Gets the data type of each component in the array.
  859. */
  860. readonly type: number;
  861. /**
  862. * Constructor
  863. * @param engine the engine
  864. * @param data the data to use for this vertex buffer
  865. * @param kind the vertex buffer kind
  866. * @param updatable whether the data is updatable
  867. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  868. * @param stride the stride (optional)
  869. * @param instanced whether the buffer is instanced (optional)
  870. * @param offset the offset of the data (optional)
  871. * @param size the number of components (optional)
  872. * @param type the type of the component (optional)
  873. * @param normalized whether the data contains normalized data (optional)
  874. * @param useBytes set to true if stride and offset are in bytes (optional)
  875. */
  876. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean);
  877. /** @hidden */
  878. _rebuild(): void;
  879. /**
  880. * Returns the kind of the VertexBuffer (string)
  881. * @returns a string
  882. */
  883. getKind(): string;
  884. /**
  885. * Gets a boolean indicating if the VertexBuffer is updatable?
  886. * @returns true if the buffer is updatable
  887. */
  888. isUpdatable(): boolean;
  889. /**
  890. * Gets current buffer's data
  891. * @returns a DataArray or null
  892. */
  893. getData(): Nullable<DataArray>;
  894. /**
  895. * Gets underlying native buffer
  896. * @returns underlying native buffer
  897. */
  898. getBuffer(): Nullable<DataBuffer>;
  899. /**
  900. * Gets the stride in float32 units (i.e. byte stride / 4).
  901. * May not be an integer if the byte stride is not divisible by 4.
  902. * DEPRECATED. Use byteStride instead.
  903. * @returns the stride in float32 units
  904. */
  905. getStrideSize(): number;
  906. /**
  907. * Returns the offset as a multiple of the type byte length.
  908. * DEPRECATED. Use byteOffset instead.
  909. * @returns the offset in bytes
  910. */
  911. getOffset(): number;
  912. /**
  913. * Returns the number of components per vertex attribute (integer)
  914. * @returns the size in float
  915. */
  916. getSize(): number;
  917. /**
  918. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  919. * @returns true if this buffer is instanced
  920. */
  921. getIsInstanced(): boolean;
  922. /**
  923. * Returns the instancing divisor, zero for non-instanced (integer).
  924. * @returns a number
  925. */
  926. getInstanceDivisor(): number;
  927. /**
  928. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  929. * @param data defines the data to store
  930. */
  931. create(data?: DataArray): void;
  932. /**
  933. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  934. * This function will create a new buffer if the current one is not updatable
  935. * @param data defines the data to store
  936. */
  937. update(data: DataArray): void;
  938. /**
  939. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  940. * Returns the directly updated WebGLBuffer.
  941. * @param data the new data
  942. * @param offset the new offset
  943. * @param useBytes set to true if the offset is in bytes
  944. */
  945. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  946. /**
  947. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  948. */
  949. dispose(): void;
  950. /**
  951. * Enumerates each value of this vertex buffer as numbers.
  952. * @param count the number of values to enumerate
  953. * @param callback the callback function called for each value
  954. */
  955. forEach(count: number, callback: (value: number, index: number) => void): void;
  956. /**
  957. * Positions
  958. */
  959. static readonly PositionKind: string;
  960. /**
  961. * Normals
  962. */
  963. static readonly NormalKind: string;
  964. /**
  965. * Tangents
  966. */
  967. static readonly TangentKind: string;
  968. /**
  969. * Texture coordinates
  970. */
  971. static readonly UVKind: string;
  972. /**
  973. * Texture coordinates 2
  974. */
  975. static readonly UV2Kind: string;
  976. /**
  977. * Texture coordinates 3
  978. */
  979. static readonly UV3Kind: string;
  980. /**
  981. * Texture coordinates 4
  982. */
  983. static readonly UV4Kind: string;
  984. /**
  985. * Texture coordinates 5
  986. */
  987. static readonly UV5Kind: string;
  988. /**
  989. * Texture coordinates 6
  990. */
  991. static readonly UV6Kind: string;
  992. /**
  993. * Colors
  994. */
  995. static readonly ColorKind: string;
  996. /**
  997. * Matrix indices (for bones)
  998. */
  999. static readonly MatricesIndicesKind: string;
  1000. /**
  1001. * Matrix weights (for bones)
  1002. */
  1003. static readonly MatricesWeightsKind: string;
  1004. /**
  1005. * Additional matrix indices (for bones)
  1006. */
  1007. static readonly MatricesIndicesExtraKind: string;
  1008. /**
  1009. * Additional matrix weights (for bones)
  1010. */
  1011. static readonly MatricesWeightsExtraKind: string;
  1012. /**
  1013. * Deduces the stride given a kind.
  1014. * @param kind The kind string to deduce
  1015. * @returns The deduced stride
  1016. */
  1017. static DeduceStride(kind: string): number;
  1018. /**
  1019. * Gets the byte length of the given type.
  1020. * @param type the type
  1021. * @returns the number of bytes
  1022. */
  1023. static GetTypeByteLength(type: number): number;
  1024. /**
  1025. * Enumerates each value of the given parameters as numbers.
  1026. * @param data the data to enumerate
  1027. * @param byteOffset the byte offset of the data
  1028. * @param byteStride the byte stride of the data
  1029. * @param componentCount the number of components per element
  1030. * @param componentType the type of the component
  1031. * @param count the number of values to enumerate
  1032. * @param normalized whether the data is normalized
  1033. * @param callback the callback function called for each value
  1034. */
  1035. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  1036. private static _GetFloatValue;
  1037. }
  1038. }
  1039. declare module "babylonjs/Maths/math.scalar" {
  1040. /**
  1041. * Scalar computation library
  1042. */
  1043. export class Scalar {
  1044. /**
  1045. * Two pi constants convenient for computation.
  1046. */
  1047. static TwoPi: number;
  1048. /**
  1049. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1050. * @param a number
  1051. * @param b number
  1052. * @param epsilon (default = 1.401298E-45)
  1053. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1054. */
  1055. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1056. /**
  1057. * Returns a string : the upper case translation of the number i to hexadecimal.
  1058. * @param i number
  1059. * @returns the upper case translation of the number i to hexadecimal.
  1060. */
  1061. static ToHex(i: number): string;
  1062. /**
  1063. * Returns -1 if value is negative and +1 is value is positive.
  1064. * @param value the value
  1065. * @returns the value itself if it's equal to zero.
  1066. */
  1067. static Sign(value: number): number;
  1068. /**
  1069. * Returns the value itself if it's between min and max.
  1070. * Returns min if the value is lower than min.
  1071. * Returns max if the value is greater than max.
  1072. * @param value the value to clmap
  1073. * @param min the min value to clamp to (default: 0)
  1074. * @param max the max value to clamp to (default: 1)
  1075. * @returns the clamped value
  1076. */
  1077. static Clamp(value: number, min?: number, max?: number): number;
  1078. /**
  1079. * the log2 of value.
  1080. * @param value the value to compute log2 of
  1081. * @returns the log2 of value.
  1082. */
  1083. static Log2(value: number): number;
  1084. /**
  1085. * Loops the value, so that it is never larger than length and never smaller than 0.
  1086. *
  1087. * This is similar to the modulo operator but it works with floating point numbers.
  1088. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1089. * With t = 5 and length = 2.5, the result would be 0.0.
  1090. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1091. * @param value the value
  1092. * @param length the length
  1093. * @returns the looped value
  1094. */
  1095. static Repeat(value: number, length: number): number;
  1096. /**
  1097. * Normalize the value between 0.0 and 1.0 using min and max values
  1098. * @param value value to normalize
  1099. * @param min max to normalize between
  1100. * @param max min to normalize between
  1101. * @returns the normalized value
  1102. */
  1103. static Normalize(value: number, min: number, max: number): number;
  1104. /**
  1105. * Denormalize the value from 0.0 and 1.0 using min and max values
  1106. * @param normalized value to denormalize
  1107. * @param min max to denormalize between
  1108. * @param max min to denormalize between
  1109. * @returns the denormalized value
  1110. */
  1111. static Denormalize(normalized: number, min: number, max: number): number;
  1112. /**
  1113. * Calculates the shortest difference between two given angles given in degrees.
  1114. * @param current current angle in degrees
  1115. * @param target target angle in degrees
  1116. * @returns the delta
  1117. */
  1118. static DeltaAngle(current: number, target: number): number;
  1119. /**
  1120. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1121. * @param tx value
  1122. * @param length length
  1123. * @returns The returned value will move back and forth between 0 and length
  1124. */
  1125. static PingPong(tx: number, length: number): number;
  1126. /**
  1127. * Interpolates between min and max with smoothing at the limits.
  1128. *
  1129. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1130. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1131. * @param from from
  1132. * @param to to
  1133. * @param tx value
  1134. * @returns the smooth stepped value
  1135. */
  1136. static SmoothStep(from: number, to: number, tx: number): number;
  1137. /**
  1138. * Moves a value current towards target.
  1139. *
  1140. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1141. * Negative values of maxDelta pushes the value away from target.
  1142. * @param current current value
  1143. * @param target target value
  1144. * @param maxDelta max distance to move
  1145. * @returns resulting value
  1146. */
  1147. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1148. /**
  1149. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1150. *
  1151. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1152. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1153. * @param current current value
  1154. * @param target target value
  1155. * @param maxDelta max distance to move
  1156. * @returns resulting angle
  1157. */
  1158. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1159. /**
  1160. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1161. * @param start start value
  1162. * @param end target value
  1163. * @param amount amount to lerp between
  1164. * @returns the lerped value
  1165. */
  1166. static Lerp(start: number, end: number, amount: number): number;
  1167. /**
  1168. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1169. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1170. * @param start start value
  1171. * @param end target value
  1172. * @param amount amount to lerp between
  1173. * @returns the lerped value
  1174. */
  1175. static LerpAngle(start: number, end: number, amount: number): number;
  1176. /**
  1177. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1178. * @param a start value
  1179. * @param b target value
  1180. * @param value value between a and b
  1181. * @returns the inverseLerp value
  1182. */
  1183. static InverseLerp(a: number, b: number, value: number): number;
  1184. /**
  1185. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1186. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1187. * @param value1 spline value
  1188. * @param tangent1 spline value
  1189. * @param value2 spline value
  1190. * @param tangent2 spline value
  1191. * @param amount input value
  1192. * @returns hermite result
  1193. */
  1194. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1195. /**
  1196. * Returns a random float number between and min and max values
  1197. * @param min min value of random
  1198. * @param max max value of random
  1199. * @returns random value
  1200. */
  1201. static RandomRange(min: number, max: number): number;
  1202. /**
  1203. * This function returns percentage of a number in a given range.
  1204. *
  1205. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1206. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1207. * @param number to convert to percentage
  1208. * @param min min range
  1209. * @param max max range
  1210. * @returns the percentage
  1211. */
  1212. static RangeToPercent(number: number, min: number, max: number): number;
  1213. /**
  1214. * This function returns number that corresponds to the percentage in a given range.
  1215. *
  1216. * PercentToRange(0.34,0,100) will return 34.
  1217. * @param percent to convert to number
  1218. * @param min min range
  1219. * @param max max range
  1220. * @returns the number
  1221. */
  1222. static PercentToRange(percent: number, min: number, max: number): number;
  1223. /**
  1224. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1225. * @param angle The angle to normalize in radian.
  1226. * @return The converted angle.
  1227. */
  1228. static NormalizeRadians(angle: number): number;
  1229. }
  1230. }
  1231. declare module "babylonjs/Maths/math.constants" {
  1232. /**
  1233. * Constant used to convert a value to gamma space
  1234. * @ignorenaming
  1235. */
  1236. export const ToGammaSpace: number;
  1237. /**
  1238. * Constant used to convert a value to linear space
  1239. * @ignorenaming
  1240. */
  1241. export const ToLinearSpace = 2.2;
  1242. /**
  1243. * Constant used to define the minimal number value in Babylon.js
  1244. * @ignorenaming
  1245. */
  1246. let Epsilon: number;
  1247. export { Epsilon };
  1248. }
  1249. declare module "babylonjs/Maths/math.viewport" {
  1250. /**
  1251. * Class used to represent a viewport on screen
  1252. */
  1253. export class Viewport {
  1254. /** viewport left coordinate */
  1255. x: number;
  1256. /** viewport top coordinate */
  1257. y: number;
  1258. /**viewport width */
  1259. width: number;
  1260. /** viewport height */
  1261. height: number;
  1262. /**
  1263. * Creates a Viewport object located at (x, y) and sized (width, height)
  1264. * @param x defines viewport left coordinate
  1265. * @param y defines viewport top coordinate
  1266. * @param width defines the viewport width
  1267. * @param height defines the viewport height
  1268. */
  1269. constructor(
  1270. /** viewport left coordinate */
  1271. x: number,
  1272. /** viewport top coordinate */
  1273. y: number,
  1274. /**viewport width */
  1275. width: number,
  1276. /** viewport height */
  1277. height: number);
  1278. /**
  1279. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1280. * @param renderWidth defines the rendering width
  1281. * @param renderHeight defines the rendering height
  1282. * @returns a new Viewport
  1283. */
  1284. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1285. /**
  1286. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1287. * @param renderWidth defines the rendering width
  1288. * @param renderHeight defines the rendering height
  1289. * @param ref defines the target viewport
  1290. * @returns the current viewport
  1291. */
  1292. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1293. /**
  1294. * Returns a new Viewport copied from the current one
  1295. * @returns a new Viewport
  1296. */
  1297. clone(): Viewport;
  1298. }
  1299. }
  1300. declare module "babylonjs/Misc/arrayTools" {
  1301. /**
  1302. * Class containing a set of static utilities functions for arrays.
  1303. */
  1304. export class ArrayTools {
  1305. /**
  1306. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1307. * @param size the number of element to construct and put in the array
  1308. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1309. * @returns a new array filled with new objects
  1310. */
  1311. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1312. }
  1313. }
  1314. declare module "babylonjs/Maths/math.like" {
  1315. import { float, int, DeepImmutable } from "babylonjs/types";
  1316. /**
  1317. * @hidden
  1318. */
  1319. export interface IColor4Like {
  1320. r: float;
  1321. g: float;
  1322. b: float;
  1323. a: float;
  1324. }
  1325. /**
  1326. * @hidden
  1327. */
  1328. export interface IColor3Like {
  1329. r: float;
  1330. g: float;
  1331. b: float;
  1332. }
  1333. /**
  1334. * @hidden
  1335. */
  1336. export interface IVector4Like {
  1337. x: float;
  1338. y: float;
  1339. z: float;
  1340. w: float;
  1341. }
  1342. /**
  1343. * @hidden
  1344. */
  1345. export interface IVector3Like {
  1346. x: float;
  1347. y: float;
  1348. z: float;
  1349. }
  1350. /**
  1351. * @hidden
  1352. */
  1353. export interface IVector2Like {
  1354. x: float;
  1355. y: float;
  1356. }
  1357. /**
  1358. * @hidden
  1359. */
  1360. export interface IMatrixLike {
  1361. toArray(): DeepImmutable<Float32Array>;
  1362. updateFlag: int;
  1363. }
  1364. /**
  1365. * @hidden
  1366. */
  1367. export interface IViewportLike {
  1368. x: float;
  1369. y: float;
  1370. width: float;
  1371. height: float;
  1372. }
  1373. /**
  1374. * @hidden
  1375. */
  1376. export interface IPlaneLike {
  1377. normal: IVector3Like;
  1378. d: float;
  1379. normalize(): void;
  1380. }
  1381. }
  1382. declare module "babylonjs/Maths/math.vector" {
  1383. import { Viewport } from "babylonjs/Maths/math.viewport";
  1384. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1385. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1386. /**
  1387. * Class representing a vector containing 2 coordinates
  1388. */
  1389. export class Vector2 {
  1390. /** defines the first coordinate */
  1391. x: number;
  1392. /** defines the second coordinate */
  1393. y: number;
  1394. /**
  1395. * Creates a new Vector2 from the given x and y coordinates
  1396. * @param x defines the first coordinate
  1397. * @param y defines the second coordinate
  1398. */
  1399. constructor(
  1400. /** defines the first coordinate */
  1401. x?: number,
  1402. /** defines the second coordinate */
  1403. y?: number);
  1404. /**
  1405. * Gets a string with the Vector2 coordinates
  1406. * @returns a string with the Vector2 coordinates
  1407. */
  1408. toString(): string;
  1409. /**
  1410. * Gets class name
  1411. * @returns the string "Vector2"
  1412. */
  1413. getClassName(): string;
  1414. /**
  1415. * Gets current vector hash code
  1416. * @returns the Vector2 hash code as a number
  1417. */
  1418. getHashCode(): number;
  1419. /**
  1420. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1421. * @param array defines the source array
  1422. * @param index defines the offset in source array
  1423. * @returns the current Vector2
  1424. */
  1425. toArray(array: FloatArray, index?: number): Vector2;
  1426. /**
  1427. * Copy the current vector to an array
  1428. * @returns a new array with 2 elements: the Vector2 coordinates.
  1429. */
  1430. asArray(): number[];
  1431. /**
  1432. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1433. * @param source defines the source Vector2
  1434. * @returns the current updated Vector2
  1435. */
  1436. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1437. /**
  1438. * Sets the Vector2 coordinates with the given floats
  1439. * @param x defines the first coordinate
  1440. * @param y defines the second coordinate
  1441. * @returns the current updated Vector2
  1442. */
  1443. copyFromFloats(x: number, y: number): Vector2;
  1444. /**
  1445. * Sets the Vector2 coordinates with the given floats
  1446. * @param x defines the first coordinate
  1447. * @param y defines the second coordinate
  1448. * @returns the current updated Vector2
  1449. */
  1450. set(x: number, y: number): Vector2;
  1451. /**
  1452. * Add another vector with the current one
  1453. * @param otherVector defines the other vector
  1454. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1455. */
  1456. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1457. /**
  1458. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1459. * @param otherVector defines the other vector
  1460. * @param result defines the target vector
  1461. * @returns the unmodified current Vector2
  1462. */
  1463. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1464. /**
  1465. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1466. * @param otherVector defines the other vector
  1467. * @returns the current updated Vector2
  1468. */
  1469. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1470. /**
  1471. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1472. * @param otherVector defines the other vector
  1473. * @returns a new Vector2
  1474. */
  1475. addVector3(otherVector: Vector3): Vector2;
  1476. /**
  1477. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1478. * @param otherVector defines the other vector
  1479. * @returns a new Vector2
  1480. */
  1481. subtract(otherVector: Vector2): Vector2;
  1482. /**
  1483. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1484. * @param otherVector defines the other vector
  1485. * @param result defines the target vector
  1486. * @returns the unmodified current Vector2
  1487. */
  1488. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1489. /**
  1490. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1491. * @param otherVector defines the other vector
  1492. * @returns the current updated Vector2
  1493. */
  1494. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1495. /**
  1496. * Multiplies in place the current Vector2 coordinates by the given ones
  1497. * @param otherVector defines the other vector
  1498. * @returns the current updated Vector2
  1499. */
  1500. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1501. /**
  1502. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  1503. * @param otherVector defines the other vector
  1504. * @returns a new Vector2
  1505. */
  1506. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  1507. /**
  1508. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  1509. * @param otherVector defines the other vector
  1510. * @param result defines the target vector
  1511. * @returns the unmodified current Vector2
  1512. */
  1513. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1514. /**
  1515. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  1516. * @param x defines the first coordinate
  1517. * @param y defines the second coordinate
  1518. * @returns a new Vector2
  1519. */
  1520. multiplyByFloats(x: number, y: number): Vector2;
  1521. /**
  1522. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  1523. * @param otherVector defines the other vector
  1524. * @returns a new Vector2
  1525. */
  1526. divide(otherVector: Vector2): Vector2;
  1527. /**
  1528. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  1529. * @param otherVector defines the other vector
  1530. * @param result defines the target vector
  1531. * @returns the unmodified current Vector2
  1532. */
  1533. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1534. /**
  1535. * Divides the current Vector2 coordinates by the given ones
  1536. * @param otherVector defines the other vector
  1537. * @returns the current updated Vector2
  1538. */
  1539. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1540. /**
  1541. * Gets a new Vector2 with current Vector2 negated coordinates
  1542. * @returns a new Vector2
  1543. */
  1544. negate(): Vector2;
  1545. /**
  1546. * Multiply the Vector2 coordinates by scale
  1547. * @param scale defines the scaling factor
  1548. * @returns the current updated Vector2
  1549. */
  1550. scaleInPlace(scale: number): Vector2;
  1551. /**
  1552. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1553. * @param scale defines the scaling factor
  1554. * @returns a new Vector2
  1555. */
  1556. scale(scale: number): Vector2;
  1557. /**
  1558. * Scale the current Vector2 values by a factor to a given Vector2
  1559. * @param scale defines the scale factor
  1560. * @param result defines the Vector2 object where to store the result
  1561. * @returns the unmodified current Vector2
  1562. */
  1563. scaleToRef(scale: number, result: Vector2): Vector2;
  1564. /**
  1565. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1566. * @param scale defines the scale factor
  1567. * @param result defines the Vector2 object where to store the result
  1568. * @returns the unmodified current Vector2
  1569. */
  1570. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1571. /**
  1572. * Gets a boolean if two vectors are equals
  1573. * @param otherVector defines the other vector
  1574. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1575. */
  1576. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1577. /**
  1578. * Gets a boolean if two vectors are equals (using an epsilon value)
  1579. * @param otherVector defines the other vector
  1580. * @param epsilon defines the minimal distance to consider equality
  1581. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1582. */
  1583. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1584. /**
  1585. * Gets a new Vector2 from current Vector2 floored values
  1586. * @returns a new Vector2
  1587. */
  1588. floor(): Vector2;
  1589. /**
  1590. * Gets a new Vector2 from current Vector2 floored values
  1591. * @returns a new Vector2
  1592. */
  1593. fract(): Vector2;
  1594. /**
  1595. * Gets the length of the vector
  1596. * @returns the vector length (float)
  1597. */
  1598. length(): number;
  1599. /**
  1600. * Gets the vector squared length
  1601. * @returns the vector squared length (float)
  1602. */
  1603. lengthSquared(): number;
  1604. /**
  1605. * Normalize the vector
  1606. * @returns the current updated Vector2
  1607. */
  1608. normalize(): Vector2;
  1609. /**
  1610. * Gets a new Vector2 copied from the Vector2
  1611. * @returns a new Vector2
  1612. */
  1613. clone(): Vector2;
  1614. /**
  1615. * Gets a new Vector2(0, 0)
  1616. * @returns a new Vector2
  1617. */
  1618. static Zero(): Vector2;
  1619. /**
  1620. * Gets a new Vector2(1, 1)
  1621. * @returns a new Vector2
  1622. */
  1623. static One(): Vector2;
  1624. /**
  1625. * Gets a new Vector2 set from the given index element of the given array
  1626. * @param array defines the data source
  1627. * @param offset defines the offset in the data source
  1628. * @returns a new Vector2
  1629. */
  1630. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1631. /**
  1632. * Sets "result" from the given index element of the given array
  1633. * @param array defines the data source
  1634. * @param offset defines the offset in the data source
  1635. * @param result defines the target vector
  1636. */
  1637. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1638. /**
  1639. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1640. * @param value1 defines 1st point of control
  1641. * @param value2 defines 2nd point of control
  1642. * @param value3 defines 3rd point of control
  1643. * @param value4 defines 4th point of control
  1644. * @param amount defines the interpolation factor
  1645. * @returns a new Vector2
  1646. */
  1647. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1648. /**
  1649. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  1650. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1651. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1652. * @param value defines the value to clamp
  1653. * @param min defines the lower limit
  1654. * @param max defines the upper limit
  1655. * @returns a new Vector2
  1656. */
  1657. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1658. /**
  1659. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1660. * @param value1 defines the 1st control point
  1661. * @param tangent1 defines the outgoing tangent
  1662. * @param value2 defines the 2nd control point
  1663. * @param tangent2 defines the incoming tangent
  1664. * @param amount defines the interpolation factor
  1665. * @returns a new Vector2
  1666. */
  1667. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1668. /**
  1669. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1670. * @param start defines the start vector
  1671. * @param end defines the end vector
  1672. * @param amount defines the interpolation factor
  1673. * @returns a new Vector2
  1674. */
  1675. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1676. /**
  1677. * Gets the dot product of the vector "left" and the vector "right"
  1678. * @param left defines first vector
  1679. * @param right defines second vector
  1680. * @returns the dot product (float)
  1681. */
  1682. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1683. /**
  1684. * Returns a new Vector2 equal to the normalized given vector
  1685. * @param vector defines the vector to normalize
  1686. * @returns a new Vector2
  1687. */
  1688. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1689. /**
  1690. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1691. * @param left defines 1st vector
  1692. * @param right defines 2nd vector
  1693. * @returns a new Vector2
  1694. */
  1695. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1696. /**
  1697. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1698. * @param left defines 1st vector
  1699. * @param right defines 2nd vector
  1700. * @returns a new Vector2
  1701. */
  1702. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1703. /**
  1704. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1705. * @param vector defines the vector to transform
  1706. * @param transformation defines the matrix to apply
  1707. * @returns a new Vector2
  1708. */
  1709. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1710. /**
  1711. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1712. * @param vector defines the vector to transform
  1713. * @param transformation defines the matrix to apply
  1714. * @param result defines the target vector
  1715. */
  1716. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1717. /**
  1718. * Determines if a given vector is included in a triangle
  1719. * @param p defines the vector to test
  1720. * @param p0 defines 1st triangle point
  1721. * @param p1 defines 2nd triangle point
  1722. * @param p2 defines 3rd triangle point
  1723. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1724. */
  1725. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1726. /**
  1727. * Gets the distance between the vectors "value1" and "value2"
  1728. * @param value1 defines first vector
  1729. * @param value2 defines second vector
  1730. * @returns the distance between vectors
  1731. */
  1732. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1733. /**
  1734. * Returns the squared distance between the vectors "value1" and "value2"
  1735. * @param value1 defines first vector
  1736. * @param value2 defines second vector
  1737. * @returns the squared distance between vectors
  1738. */
  1739. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1740. /**
  1741. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1742. * @param value1 defines first vector
  1743. * @param value2 defines second vector
  1744. * @returns a new Vector2
  1745. */
  1746. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1747. /**
  1748. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1749. * @param p defines the middle point
  1750. * @param segA defines one point of the segment
  1751. * @param segB defines the other point of the segment
  1752. * @returns the shortest distance
  1753. */
  1754. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1755. }
  1756. /**
  1757. * Classed used to store (x,y,z) vector representation
  1758. * A Vector3 is the main object used in 3D geometry
  1759. * It can represent etiher the coordinates of a point the space, either a direction
  1760. * Reminder: js uses a left handed forward facing system
  1761. */
  1762. export class Vector3 {
  1763. /**
  1764. * Defines the first coordinates (on X axis)
  1765. */
  1766. x: number;
  1767. /**
  1768. * Defines the second coordinates (on Y axis)
  1769. */
  1770. y: number;
  1771. /**
  1772. * Defines the third coordinates (on Z axis)
  1773. */
  1774. z: number;
  1775. private static _UpReadOnly;
  1776. private static _ZeroReadOnly;
  1777. /**
  1778. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1779. * @param x defines the first coordinates (on X axis)
  1780. * @param y defines the second coordinates (on Y axis)
  1781. * @param z defines the third coordinates (on Z axis)
  1782. */
  1783. constructor(
  1784. /**
  1785. * Defines the first coordinates (on X axis)
  1786. */
  1787. x?: number,
  1788. /**
  1789. * Defines the second coordinates (on Y axis)
  1790. */
  1791. y?: number,
  1792. /**
  1793. * Defines the third coordinates (on Z axis)
  1794. */
  1795. z?: number);
  1796. /**
  1797. * Creates a string representation of the Vector3
  1798. * @returns a string with the Vector3 coordinates.
  1799. */
  1800. toString(): string;
  1801. /**
  1802. * Gets the class name
  1803. * @returns the string "Vector3"
  1804. */
  1805. getClassName(): string;
  1806. /**
  1807. * Creates the Vector3 hash code
  1808. * @returns a number which tends to be unique between Vector3 instances
  1809. */
  1810. getHashCode(): number;
  1811. /**
  1812. * Creates an array containing three elements : the coordinates of the Vector3
  1813. * @returns a new array of numbers
  1814. */
  1815. asArray(): number[];
  1816. /**
  1817. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1818. * @param array defines the destination array
  1819. * @param index defines the offset in the destination array
  1820. * @returns the current Vector3
  1821. */
  1822. toArray(array: FloatArray, index?: number): Vector3;
  1823. /**
  1824. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1825. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1826. */
  1827. toQuaternion(): Quaternion;
  1828. /**
  1829. * Adds the given vector to the current Vector3
  1830. * @param otherVector defines the second operand
  1831. * @returns the current updated Vector3
  1832. */
  1833. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1834. /**
  1835. * Adds the given coordinates to the current Vector3
  1836. * @param x defines the x coordinate of the operand
  1837. * @param y defines the y coordinate of the operand
  1838. * @param z defines the z coordinate of the operand
  1839. * @returns the current updated Vector3
  1840. */
  1841. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1842. /**
  1843. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1844. * @param otherVector defines the second operand
  1845. * @returns the resulting Vector3
  1846. */
  1847. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1848. /**
  1849. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1850. * @param otherVector defines the second operand
  1851. * @param result defines the Vector3 object where to store the result
  1852. * @returns the current Vector3
  1853. */
  1854. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1855. /**
  1856. * Subtract the given vector from the current Vector3
  1857. * @param otherVector defines the second operand
  1858. * @returns the current updated Vector3
  1859. */
  1860. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1861. /**
  1862. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1863. * @param otherVector defines the second operand
  1864. * @returns the resulting Vector3
  1865. */
  1866. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1867. /**
  1868. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1869. * @param otherVector defines the second operand
  1870. * @param result defines the Vector3 object where to store the result
  1871. * @returns the current Vector3
  1872. */
  1873. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1874. /**
  1875. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1876. * @param x defines the x coordinate of the operand
  1877. * @param y defines the y coordinate of the operand
  1878. * @param z defines the z coordinate of the operand
  1879. * @returns the resulting Vector3
  1880. */
  1881. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1882. /**
  1883. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1884. * @param x defines the x coordinate of the operand
  1885. * @param y defines the y coordinate of the operand
  1886. * @param z defines the z coordinate of the operand
  1887. * @param result defines the Vector3 object where to store the result
  1888. * @returns the current Vector3
  1889. */
  1890. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1891. /**
  1892. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1893. * @returns a new Vector3
  1894. */
  1895. negate(): Vector3;
  1896. /**
  1897. * Multiplies the Vector3 coordinates by the float "scale"
  1898. * @param scale defines the multiplier factor
  1899. * @returns the current updated Vector3
  1900. */
  1901. scaleInPlace(scale: number): Vector3;
  1902. /**
  1903. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1904. * @param scale defines the multiplier factor
  1905. * @returns a new Vector3
  1906. */
  1907. scale(scale: number): Vector3;
  1908. /**
  1909. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1910. * @param scale defines the multiplier factor
  1911. * @param result defines the Vector3 object where to store the result
  1912. * @returns the current Vector3
  1913. */
  1914. scaleToRef(scale: number, result: Vector3): Vector3;
  1915. /**
  1916. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1917. * @param scale defines the scale factor
  1918. * @param result defines the Vector3 object where to store the result
  1919. * @returns the unmodified current Vector3
  1920. */
  1921. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1922. /**
  1923. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1924. * @param otherVector defines the second operand
  1925. * @returns true if both vectors are equals
  1926. */
  1927. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1928. /**
  1929. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1930. * @param otherVector defines the second operand
  1931. * @param epsilon defines the minimal distance to define values as equals
  1932. * @returns true if both vectors are distant less than epsilon
  1933. */
  1934. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1935. /**
  1936. * Returns true if the current Vector3 coordinates equals the given floats
  1937. * @param x defines the x coordinate of the operand
  1938. * @param y defines the y coordinate of the operand
  1939. * @param z defines the z coordinate of the operand
  1940. * @returns true if both vectors are equals
  1941. */
  1942. equalsToFloats(x: number, y: number, z: number): boolean;
  1943. /**
  1944. * Multiplies the current Vector3 coordinates by the given ones
  1945. * @param otherVector defines the second operand
  1946. * @returns the current updated Vector3
  1947. */
  1948. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1949. /**
  1950. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1951. * @param otherVector defines the second operand
  1952. * @returns the new Vector3
  1953. */
  1954. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1955. /**
  1956. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1957. * @param otherVector defines the second operand
  1958. * @param result defines the Vector3 object where to store the result
  1959. * @returns the current Vector3
  1960. */
  1961. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1962. /**
  1963. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1964. * @param x defines the x coordinate of the operand
  1965. * @param y defines the y coordinate of the operand
  1966. * @param z defines the z coordinate of the operand
  1967. * @returns the new Vector3
  1968. */
  1969. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1970. /**
  1971. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1972. * @param otherVector defines the second operand
  1973. * @returns the new Vector3
  1974. */
  1975. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1976. /**
  1977. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1978. * @param otherVector defines the second operand
  1979. * @param result defines the Vector3 object where to store the result
  1980. * @returns the current Vector3
  1981. */
  1982. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1983. /**
  1984. * Divides the current Vector3 coordinates by the given ones.
  1985. * @param otherVector defines the second operand
  1986. * @returns the current updated Vector3
  1987. */
  1988. divideInPlace(otherVector: Vector3): Vector3;
  1989. /**
  1990. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1991. * @param other defines the second operand
  1992. * @returns the current updated Vector3
  1993. */
  1994. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1995. /**
  1996. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1997. * @param other defines the second operand
  1998. * @returns the current updated Vector3
  1999. */
  2000. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2001. /**
  2002. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2003. * @param x defines the x coordinate of the operand
  2004. * @param y defines the y coordinate of the operand
  2005. * @param z defines the z coordinate of the operand
  2006. * @returns the current updated Vector3
  2007. */
  2008. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2009. /**
  2010. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2011. * @param x defines the x coordinate of the operand
  2012. * @param y defines the y coordinate of the operand
  2013. * @param z defines the z coordinate of the operand
  2014. * @returns the current updated Vector3
  2015. */
  2016. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2017. /**
  2018. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2019. * Check if is non uniform within a certain amount of decimal places to account for this
  2020. * @param epsilon the amount the values can differ
  2021. * @returns if the the vector is non uniform to a certain number of decimal places
  2022. */
  2023. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2024. /**
  2025. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2026. */
  2027. readonly isNonUniform: boolean;
  2028. /**
  2029. * Gets a new Vector3 from current Vector3 floored values
  2030. * @returns a new Vector3
  2031. */
  2032. floor(): Vector3;
  2033. /**
  2034. * Gets a new Vector3 from current Vector3 floored values
  2035. * @returns a new Vector3
  2036. */
  2037. fract(): Vector3;
  2038. /**
  2039. * Gets the length of the Vector3
  2040. * @returns the length of the Vector3
  2041. */
  2042. length(): number;
  2043. /**
  2044. * Gets the squared length of the Vector3
  2045. * @returns squared length of the Vector3
  2046. */
  2047. lengthSquared(): number;
  2048. /**
  2049. * Normalize the current Vector3.
  2050. * Please note that this is an in place operation.
  2051. * @returns the current updated Vector3
  2052. */
  2053. normalize(): Vector3;
  2054. /**
  2055. * Reorders the x y z properties of the vector in place
  2056. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2057. * @returns the current updated vector
  2058. */
  2059. reorderInPlace(order: string): this;
  2060. /**
  2061. * Rotates the vector around 0,0,0 by a quaternion
  2062. * @param quaternion the rotation quaternion
  2063. * @param result vector to store the result
  2064. * @returns the resulting vector
  2065. */
  2066. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2067. /**
  2068. * Rotates a vector around a given point
  2069. * @param quaternion the rotation quaternion
  2070. * @param point the point to rotate around
  2071. * @param result vector to store the result
  2072. * @returns the resulting vector
  2073. */
  2074. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2075. /**
  2076. * Normalize the current Vector3 with the given input length.
  2077. * Please note that this is an in place operation.
  2078. * @param len the length of the vector
  2079. * @returns the current updated Vector3
  2080. */
  2081. normalizeFromLength(len: number): Vector3;
  2082. /**
  2083. * Normalize the current Vector3 to a new vector
  2084. * @returns the new Vector3
  2085. */
  2086. normalizeToNew(): Vector3;
  2087. /**
  2088. * Normalize the current Vector3 to the reference
  2089. * @param reference define the Vector3 to update
  2090. * @returns the updated Vector3
  2091. */
  2092. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2093. /**
  2094. * Creates a new Vector3 copied from the current Vector3
  2095. * @returns the new Vector3
  2096. */
  2097. clone(): Vector3;
  2098. /**
  2099. * Copies the given vector coordinates to the current Vector3 ones
  2100. * @param source defines the source Vector3
  2101. * @returns the current updated Vector3
  2102. */
  2103. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2104. /**
  2105. * Copies the given floats to the current Vector3 coordinates
  2106. * @param x defines the x coordinate of the operand
  2107. * @param y defines the y coordinate of the operand
  2108. * @param z defines the z coordinate of the operand
  2109. * @returns the current updated Vector3
  2110. */
  2111. copyFromFloats(x: number, y: number, z: number): Vector3;
  2112. /**
  2113. * Copies the given floats to the current Vector3 coordinates
  2114. * @param x defines the x coordinate of the operand
  2115. * @param y defines the y coordinate of the operand
  2116. * @param z defines the z coordinate of the operand
  2117. * @returns the current updated Vector3
  2118. */
  2119. set(x: number, y: number, z: number): Vector3;
  2120. /**
  2121. * Copies the given float to the current Vector3 coordinates
  2122. * @param v defines the x, y and z coordinates of the operand
  2123. * @returns the current updated Vector3
  2124. */
  2125. setAll(v: number): Vector3;
  2126. /**
  2127. * Get the clip factor between two vectors
  2128. * @param vector0 defines the first operand
  2129. * @param vector1 defines the second operand
  2130. * @param axis defines the axis to use
  2131. * @param size defines the size along the axis
  2132. * @returns the clip factor
  2133. */
  2134. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2135. /**
  2136. * Get angle between two vectors
  2137. * @param vector0 angle between vector0 and vector1
  2138. * @param vector1 angle between vector0 and vector1
  2139. * @param normal direction of the normal
  2140. * @return the angle between vector0 and vector1
  2141. */
  2142. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2143. /**
  2144. * Returns a new Vector3 set from the index "offset" of the given array
  2145. * @param array defines the source array
  2146. * @param offset defines the offset in the source array
  2147. * @returns the new Vector3
  2148. */
  2149. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2150. /**
  2151. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2152. * This function is deprecated. Use FromArray instead
  2153. * @param array defines the source array
  2154. * @param offset defines the offset in the source array
  2155. * @returns the new Vector3
  2156. */
  2157. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2158. /**
  2159. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2160. * @param array defines the source array
  2161. * @param offset defines the offset in the source array
  2162. * @param result defines the Vector3 where to store the result
  2163. */
  2164. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2165. /**
  2166. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2167. * This function is deprecated. Use FromArrayToRef instead.
  2168. * @param array defines the source array
  2169. * @param offset defines the offset in the source array
  2170. * @param result defines the Vector3 where to store the result
  2171. */
  2172. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2173. /**
  2174. * Sets the given vector "result" with the given floats.
  2175. * @param x defines the x coordinate of the source
  2176. * @param y defines the y coordinate of the source
  2177. * @param z defines the z coordinate of the source
  2178. * @param result defines the Vector3 where to store the result
  2179. */
  2180. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2181. /**
  2182. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2183. * @returns a new empty Vector3
  2184. */
  2185. static Zero(): Vector3;
  2186. /**
  2187. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2188. * @returns a new unit Vector3
  2189. */
  2190. static One(): Vector3;
  2191. /**
  2192. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2193. * @returns a new up Vector3
  2194. */
  2195. static Up(): Vector3;
  2196. /**
  2197. * Gets a up Vector3 that must not be updated
  2198. */
  2199. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2200. /**
  2201. * Gets a zero Vector3 that must not be updated
  2202. */
  2203. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2204. /**
  2205. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2206. * @returns a new down Vector3
  2207. */
  2208. static Down(): Vector3;
  2209. /**
  2210. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2211. * @returns a new forward Vector3
  2212. */
  2213. static Forward(): Vector3;
  2214. /**
  2215. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2216. * @returns a new forward Vector3
  2217. */
  2218. static Backward(): Vector3;
  2219. /**
  2220. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2221. * @returns a new right Vector3
  2222. */
  2223. static Right(): Vector3;
  2224. /**
  2225. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2226. * @returns a new left Vector3
  2227. */
  2228. static Left(): Vector3;
  2229. /**
  2230. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2231. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2232. * @param vector defines the Vector3 to transform
  2233. * @param transformation defines the transformation matrix
  2234. * @returns the transformed Vector3
  2235. */
  2236. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2237. /**
  2238. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2239. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2240. * @param vector defines the Vector3 to transform
  2241. * @param transformation defines the transformation matrix
  2242. * @param result defines the Vector3 where to store the result
  2243. */
  2244. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2245. /**
  2246. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2247. * This method computes tranformed coordinates only, not transformed direction vectors
  2248. * @param x define the x coordinate of the source vector
  2249. * @param y define the y coordinate of the source vector
  2250. * @param z define the z coordinate of the source vector
  2251. * @param transformation defines the transformation matrix
  2252. * @param result defines the Vector3 where to store the result
  2253. */
  2254. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2255. /**
  2256. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2257. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2258. * @param vector defines the Vector3 to transform
  2259. * @param transformation defines the transformation matrix
  2260. * @returns the new Vector3
  2261. */
  2262. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2263. /**
  2264. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2265. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2266. * @param vector defines the Vector3 to transform
  2267. * @param transformation defines the transformation matrix
  2268. * @param result defines the Vector3 where to store the result
  2269. */
  2270. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2271. /**
  2272. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2273. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2274. * @param x define the x coordinate of the source vector
  2275. * @param y define the y coordinate of the source vector
  2276. * @param z define the z coordinate of the source vector
  2277. * @param transformation defines the transformation matrix
  2278. * @param result defines the Vector3 where to store the result
  2279. */
  2280. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2281. /**
  2282. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2283. * @param value1 defines the first control point
  2284. * @param value2 defines the second control point
  2285. * @param value3 defines the third control point
  2286. * @param value4 defines the fourth control point
  2287. * @param amount defines the amount on the spline to use
  2288. * @returns the new Vector3
  2289. */
  2290. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2291. /**
  2292. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2293. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2294. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2295. * @param value defines the current value
  2296. * @param min defines the lower range value
  2297. * @param max defines the upper range value
  2298. * @returns the new Vector3
  2299. */
  2300. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2301. /**
  2302. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2303. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2304. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2305. * @param value defines the current value
  2306. * @param min defines the lower range value
  2307. * @param max defines the upper range value
  2308. * @param result defines the Vector3 where to store the result
  2309. */
  2310. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2311. /**
  2312. * Checks if a given vector is inside a specific range
  2313. * @param v defines the vector to test
  2314. * @param min defines the minimum range
  2315. * @param max defines the maximum range
  2316. */
  2317. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2318. /**
  2319. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2320. * @param value1 defines the first control point
  2321. * @param tangent1 defines the first tangent vector
  2322. * @param value2 defines the second control point
  2323. * @param tangent2 defines the second tangent vector
  2324. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2325. * @returns the new Vector3
  2326. */
  2327. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2328. /**
  2329. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2330. * @param start defines the start value
  2331. * @param end defines the end value
  2332. * @param amount max defines amount between both (between 0 and 1)
  2333. * @returns the new Vector3
  2334. */
  2335. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2336. /**
  2337. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2338. * @param start defines the start value
  2339. * @param end defines the end value
  2340. * @param amount max defines amount between both (between 0 and 1)
  2341. * @param result defines the Vector3 where to store the result
  2342. */
  2343. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2344. /**
  2345. * Returns the dot product (float) between the vectors "left" and "right"
  2346. * @param left defines the left operand
  2347. * @param right defines the right operand
  2348. * @returns the dot product
  2349. */
  2350. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2351. /**
  2352. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2353. * The cross product is then orthogonal to both "left" and "right"
  2354. * @param left defines the left operand
  2355. * @param right defines the right operand
  2356. * @returns the cross product
  2357. */
  2358. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2359. /**
  2360. * Sets the given vector "result" with the cross product of "left" and "right"
  2361. * The cross product is then orthogonal to both "left" and "right"
  2362. * @param left defines the left operand
  2363. * @param right defines the right operand
  2364. * @param result defines the Vector3 where to store the result
  2365. */
  2366. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2367. /**
  2368. * Returns a new Vector3 as the normalization of the given vector
  2369. * @param vector defines the Vector3 to normalize
  2370. * @returns the new Vector3
  2371. */
  2372. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2373. /**
  2374. * Sets the given vector "result" with the normalization of the given first vector
  2375. * @param vector defines the Vector3 to normalize
  2376. * @param result defines the Vector3 where to store the result
  2377. */
  2378. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2379. /**
  2380. * Project a Vector3 onto screen space
  2381. * @param vector defines the Vector3 to project
  2382. * @param world defines the world matrix to use
  2383. * @param transform defines the transform (view x projection) matrix to use
  2384. * @param viewport defines the screen viewport to use
  2385. * @returns the new Vector3
  2386. */
  2387. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2388. /** @hidden */
  2389. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2390. /**
  2391. * Unproject from screen space to object space
  2392. * @param source defines the screen space Vector3 to use
  2393. * @param viewportWidth defines the current width of the viewport
  2394. * @param viewportHeight defines the current height of the viewport
  2395. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2396. * @param transform defines the transform (view x projection) matrix to use
  2397. * @returns the new Vector3
  2398. */
  2399. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2400. /**
  2401. * Unproject from screen space to object space
  2402. * @param source defines the screen space Vector3 to use
  2403. * @param viewportWidth defines the current width of the viewport
  2404. * @param viewportHeight defines the current height of the viewport
  2405. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2406. * @param view defines the view matrix to use
  2407. * @param projection defines the projection matrix to use
  2408. * @returns the new Vector3
  2409. */
  2410. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2411. /**
  2412. * Unproject from screen space to object space
  2413. * @param source defines the screen space Vector3 to use
  2414. * @param viewportWidth defines the current width of the viewport
  2415. * @param viewportHeight defines the current height of the viewport
  2416. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2417. * @param view defines the view matrix to use
  2418. * @param projection defines the projection matrix to use
  2419. * @param result defines the Vector3 where to store the result
  2420. */
  2421. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2422. /**
  2423. * Unproject from screen space to object space
  2424. * @param sourceX defines the screen space x coordinate to use
  2425. * @param sourceY defines the screen space y coordinate to use
  2426. * @param sourceZ defines the screen space z coordinate to use
  2427. * @param viewportWidth defines the current width of the viewport
  2428. * @param viewportHeight defines the current height of the viewport
  2429. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2430. * @param view defines the view matrix to use
  2431. * @param projection defines the projection matrix to use
  2432. * @param result defines the Vector3 where to store the result
  2433. */
  2434. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2435. /**
  2436. * Gets the minimal coordinate values between two Vector3
  2437. * @param left defines the first operand
  2438. * @param right defines the second operand
  2439. * @returns the new Vector3
  2440. */
  2441. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2442. /**
  2443. * Gets the maximal coordinate values between two Vector3
  2444. * @param left defines the first operand
  2445. * @param right defines the second operand
  2446. * @returns the new Vector3
  2447. */
  2448. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2449. /**
  2450. * Returns the distance between the vectors "value1" and "value2"
  2451. * @param value1 defines the first operand
  2452. * @param value2 defines the second operand
  2453. * @returns the distance
  2454. */
  2455. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2456. /**
  2457. * Returns the squared distance between the vectors "value1" and "value2"
  2458. * @param value1 defines the first operand
  2459. * @param value2 defines the second operand
  2460. * @returns the squared distance
  2461. */
  2462. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2463. /**
  2464. * Returns a new Vector3 located at the center between "value1" and "value2"
  2465. * @param value1 defines the first operand
  2466. * @param value2 defines the second operand
  2467. * @returns the new Vector3
  2468. */
  2469. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2470. /**
  2471. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2472. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2473. * to something in order to rotate it from its local system to the given target system
  2474. * Note: axis1, axis2 and axis3 are normalized during this operation
  2475. * @param axis1 defines the first axis
  2476. * @param axis2 defines the second axis
  2477. * @param axis3 defines the third axis
  2478. * @returns a new Vector3
  2479. */
  2480. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2481. /**
  2482. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  2483. * @param axis1 defines the first axis
  2484. * @param axis2 defines the second axis
  2485. * @param axis3 defines the third axis
  2486. * @param ref defines the Vector3 where to store the result
  2487. */
  2488. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  2489. }
  2490. /**
  2491. * Vector4 class created for EulerAngle class conversion to Quaternion
  2492. */
  2493. export class Vector4 {
  2494. /** x value of the vector */
  2495. x: number;
  2496. /** y value of the vector */
  2497. y: number;
  2498. /** z value of the vector */
  2499. z: number;
  2500. /** w value of the vector */
  2501. w: number;
  2502. /**
  2503. * Creates a Vector4 object from the given floats.
  2504. * @param x x value of the vector
  2505. * @param y y value of the vector
  2506. * @param z z value of the vector
  2507. * @param w w value of the vector
  2508. */
  2509. constructor(
  2510. /** x value of the vector */
  2511. x: number,
  2512. /** y value of the vector */
  2513. y: number,
  2514. /** z value of the vector */
  2515. z: number,
  2516. /** w value of the vector */
  2517. w: number);
  2518. /**
  2519. * Returns the string with the Vector4 coordinates.
  2520. * @returns a string containing all the vector values
  2521. */
  2522. toString(): string;
  2523. /**
  2524. * Returns the string "Vector4".
  2525. * @returns "Vector4"
  2526. */
  2527. getClassName(): string;
  2528. /**
  2529. * Returns the Vector4 hash code.
  2530. * @returns a unique hash code
  2531. */
  2532. getHashCode(): number;
  2533. /**
  2534. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  2535. * @returns the resulting array
  2536. */
  2537. asArray(): number[];
  2538. /**
  2539. * Populates the given array from the given index with the Vector4 coordinates.
  2540. * @param array array to populate
  2541. * @param index index of the array to start at (default: 0)
  2542. * @returns the Vector4.
  2543. */
  2544. toArray(array: FloatArray, index?: number): Vector4;
  2545. /**
  2546. * Adds the given vector to the current Vector4.
  2547. * @param otherVector the vector to add
  2548. * @returns the updated Vector4.
  2549. */
  2550. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2551. /**
  2552. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2553. * @param otherVector the vector to add
  2554. * @returns the resulting vector
  2555. */
  2556. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2557. /**
  2558. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2559. * @param otherVector the vector to add
  2560. * @param result the vector to store the result
  2561. * @returns the current Vector4.
  2562. */
  2563. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2564. /**
  2565. * Subtract in place the given vector from the current Vector4.
  2566. * @param otherVector the vector to subtract
  2567. * @returns the updated Vector4.
  2568. */
  2569. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2570. /**
  2571. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2572. * @param otherVector the vector to add
  2573. * @returns the new vector with the result
  2574. */
  2575. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2576. /**
  2577. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2578. * @param otherVector the vector to subtract
  2579. * @param result the vector to store the result
  2580. * @returns the current Vector4.
  2581. */
  2582. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2583. /**
  2584. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2585. */
  2586. /**
  2587. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2588. * @param x value to subtract
  2589. * @param y value to subtract
  2590. * @param z value to subtract
  2591. * @param w value to subtract
  2592. * @returns new vector containing the result
  2593. */
  2594. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2595. /**
  2596. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2597. * @param x value to subtract
  2598. * @param y value to subtract
  2599. * @param z value to subtract
  2600. * @param w value to subtract
  2601. * @param result the vector to store the result in
  2602. * @returns the current Vector4.
  2603. */
  2604. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2605. /**
  2606. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2607. * @returns a new vector with the negated values
  2608. */
  2609. negate(): Vector4;
  2610. /**
  2611. * Multiplies the current Vector4 coordinates by scale (float).
  2612. * @param scale the number to scale with
  2613. * @returns the updated Vector4.
  2614. */
  2615. scaleInPlace(scale: number): Vector4;
  2616. /**
  2617. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2618. * @param scale the number to scale with
  2619. * @returns a new vector with the result
  2620. */
  2621. scale(scale: number): Vector4;
  2622. /**
  2623. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2624. * @param scale the number to scale with
  2625. * @param result a vector to store the result in
  2626. * @returns the current Vector4.
  2627. */
  2628. scaleToRef(scale: number, result: Vector4): Vector4;
  2629. /**
  2630. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2631. * @param scale defines the scale factor
  2632. * @param result defines the Vector4 object where to store the result
  2633. * @returns the unmodified current Vector4
  2634. */
  2635. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2636. /**
  2637. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2638. * @param otherVector the vector to compare against
  2639. * @returns true if they are equal
  2640. */
  2641. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2642. /**
  2643. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2644. * @param otherVector vector to compare against
  2645. * @param epsilon (Default: very small number)
  2646. * @returns true if they are equal
  2647. */
  2648. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2649. /**
  2650. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2651. * @param x x value to compare against
  2652. * @param y y value to compare against
  2653. * @param z z value to compare against
  2654. * @param w w value to compare against
  2655. * @returns true if equal
  2656. */
  2657. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2658. /**
  2659. * Multiplies in place the current Vector4 by the given one.
  2660. * @param otherVector vector to multiple with
  2661. * @returns the updated Vector4.
  2662. */
  2663. multiplyInPlace(otherVector: Vector4): Vector4;
  2664. /**
  2665. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2666. * @param otherVector vector to multiple with
  2667. * @returns resulting new vector
  2668. */
  2669. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2670. /**
  2671. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2672. * @param otherVector vector to multiple with
  2673. * @param result vector to store the result
  2674. * @returns the current Vector4.
  2675. */
  2676. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2677. /**
  2678. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2679. * @param x x value multiply with
  2680. * @param y y value multiply with
  2681. * @param z z value multiply with
  2682. * @param w w value multiply with
  2683. * @returns resulting new vector
  2684. */
  2685. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2686. /**
  2687. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2688. * @param otherVector vector to devide with
  2689. * @returns resulting new vector
  2690. */
  2691. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2692. /**
  2693. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2694. * @param otherVector vector to devide with
  2695. * @param result vector to store the result
  2696. * @returns the current Vector4.
  2697. */
  2698. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2699. /**
  2700. * Divides the current Vector3 coordinates by the given ones.
  2701. * @param otherVector vector to devide with
  2702. * @returns the updated Vector3.
  2703. */
  2704. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2705. /**
  2706. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2707. * @param other defines the second operand
  2708. * @returns the current updated Vector4
  2709. */
  2710. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2711. /**
  2712. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2713. * @param other defines the second operand
  2714. * @returns the current updated Vector4
  2715. */
  2716. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2717. /**
  2718. * Gets a new Vector4 from current Vector4 floored values
  2719. * @returns a new Vector4
  2720. */
  2721. floor(): Vector4;
  2722. /**
  2723. * Gets a new Vector4 from current Vector3 floored values
  2724. * @returns a new Vector4
  2725. */
  2726. fract(): Vector4;
  2727. /**
  2728. * Returns the Vector4 length (float).
  2729. * @returns the length
  2730. */
  2731. length(): number;
  2732. /**
  2733. * Returns the Vector4 squared length (float).
  2734. * @returns the length squared
  2735. */
  2736. lengthSquared(): number;
  2737. /**
  2738. * Normalizes in place the Vector4.
  2739. * @returns the updated Vector4.
  2740. */
  2741. normalize(): Vector4;
  2742. /**
  2743. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2744. * @returns this converted to a new vector3
  2745. */
  2746. toVector3(): Vector3;
  2747. /**
  2748. * Returns a new Vector4 copied from the current one.
  2749. * @returns the new cloned vector
  2750. */
  2751. clone(): Vector4;
  2752. /**
  2753. * Updates the current Vector4 with the given one coordinates.
  2754. * @param source the source vector to copy from
  2755. * @returns the updated Vector4.
  2756. */
  2757. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2758. /**
  2759. * Updates the current Vector4 coordinates with the given floats.
  2760. * @param x float to copy from
  2761. * @param y float to copy from
  2762. * @param z float to copy from
  2763. * @param w float to copy from
  2764. * @returns the updated Vector4.
  2765. */
  2766. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2767. /**
  2768. * Updates the current Vector4 coordinates with the given floats.
  2769. * @param x float to set from
  2770. * @param y float to set from
  2771. * @param z float to set from
  2772. * @param w float to set from
  2773. * @returns the updated Vector4.
  2774. */
  2775. set(x: number, y: number, z: number, w: number): Vector4;
  2776. /**
  2777. * Copies the given float to the current Vector3 coordinates
  2778. * @param v defines the x, y, z and w coordinates of the operand
  2779. * @returns the current updated Vector3
  2780. */
  2781. setAll(v: number): Vector4;
  2782. /**
  2783. * Returns a new Vector4 set from the starting index of the given array.
  2784. * @param array the array to pull values from
  2785. * @param offset the offset into the array to start at
  2786. * @returns the new vector
  2787. */
  2788. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2789. /**
  2790. * Updates the given vector "result" from the starting index of the given array.
  2791. * @param array the array to pull values from
  2792. * @param offset the offset into the array to start at
  2793. * @param result the vector to store the result in
  2794. */
  2795. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2796. /**
  2797. * Updates the given vector "result" from the starting index of the given Float32Array.
  2798. * @param array the array to pull values from
  2799. * @param offset the offset into the array to start at
  2800. * @param result the vector to store the result in
  2801. */
  2802. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2803. /**
  2804. * Updates the given vector "result" coordinates from the given floats.
  2805. * @param x float to set from
  2806. * @param y float to set from
  2807. * @param z float to set from
  2808. * @param w float to set from
  2809. * @param result the vector to the floats in
  2810. */
  2811. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2812. /**
  2813. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2814. * @returns the new vector
  2815. */
  2816. static Zero(): Vector4;
  2817. /**
  2818. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2819. * @returns the new vector
  2820. */
  2821. static One(): Vector4;
  2822. /**
  2823. * Returns a new normalized Vector4 from the given one.
  2824. * @param vector the vector to normalize
  2825. * @returns the vector
  2826. */
  2827. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2828. /**
  2829. * Updates the given vector "result" from the normalization of the given one.
  2830. * @param vector the vector to normalize
  2831. * @param result the vector to store the result in
  2832. */
  2833. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2834. /**
  2835. * Returns a vector with the minimum values from the left and right vectors
  2836. * @param left left vector to minimize
  2837. * @param right right vector to minimize
  2838. * @returns a new vector with the minimum of the left and right vector values
  2839. */
  2840. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2841. /**
  2842. * Returns a vector with the maximum values from the left and right vectors
  2843. * @param left left vector to maximize
  2844. * @param right right vector to maximize
  2845. * @returns a new vector with the maximum of the left and right vector values
  2846. */
  2847. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2848. /**
  2849. * Returns the distance (float) between the vectors "value1" and "value2".
  2850. * @param value1 value to calulate the distance between
  2851. * @param value2 value to calulate the distance between
  2852. * @return the distance between the two vectors
  2853. */
  2854. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2855. /**
  2856. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2857. * @param value1 value to calulate the distance between
  2858. * @param value2 value to calulate the distance between
  2859. * @return the distance between the two vectors squared
  2860. */
  2861. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2862. /**
  2863. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2864. * @param value1 value to calulate the center between
  2865. * @param value2 value to calulate the center between
  2866. * @return the center between the two vectors
  2867. */
  2868. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2869. /**
  2870. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2871. * This methods computes transformed normalized direction vectors only.
  2872. * @param vector the vector to transform
  2873. * @param transformation the transformation matrix to apply
  2874. * @returns the new vector
  2875. */
  2876. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2877. /**
  2878. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2879. * This methods computes transformed normalized direction vectors only.
  2880. * @param vector the vector to transform
  2881. * @param transformation the transformation matrix to apply
  2882. * @param result the vector to store the result in
  2883. */
  2884. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2885. /**
  2886. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2887. * This methods computes transformed normalized direction vectors only.
  2888. * @param x value to transform
  2889. * @param y value to transform
  2890. * @param z value to transform
  2891. * @param w value to transform
  2892. * @param transformation the transformation matrix to apply
  2893. * @param result the vector to store the results in
  2894. */
  2895. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2896. /**
  2897. * Creates a new Vector4 from a Vector3
  2898. * @param source defines the source data
  2899. * @param w defines the 4th component (default is 0)
  2900. * @returns a new Vector4
  2901. */
  2902. static FromVector3(source: Vector3, w?: number): Vector4;
  2903. }
  2904. /**
  2905. * Class used to store quaternion data
  2906. * @see https://en.wikipedia.org/wiki/Quaternion
  2907. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2908. */
  2909. export class Quaternion {
  2910. /** defines the first component (0 by default) */
  2911. x: number;
  2912. /** defines the second component (0 by default) */
  2913. y: number;
  2914. /** defines the third component (0 by default) */
  2915. z: number;
  2916. /** defines the fourth component (1.0 by default) */
  2917. w: number;
  2918. /**
  2919. * Creates a new Quaternion from the given floats
  2920. * @param x defines the first component (0 by default)
  2921. * @param y defines the second component (0 by default)
  2922. * @param z defines the third component (0 by default)
  2923. * @param w defines the fourth component (1.0 by default)
  2924. */
  2925. constructor(
  2926. /** defines the first component (0 by default) */
  2927. x?: number,
  2928. /** defines the second component (0 by default) */
  2929. y?: number,
  2930. /** defines the third component (0 by default) */
  2931. z?: number,
  2932. /** defines the fourth component (1.0 by default) */
  2933. w?: number);
  2934. /**
  2935. * Gets a string representation for the current quaternion
  2936. * @returns a string with the Quaternion coordinates
  2937. */
  2938. toString(): string;
  2939. /**
  2940. * Gets the class name of the quaternion
  2941. * @returns the string "Quaternion"
  2942. */
  2943. getClassName(): string;
  2944. /**
  2945. * Gets a hash code for this quaternion
  2946. * @returns the quaternion hash code
  2947. */
  2948. getHashCode(): number;
  2949. /**
  2950. * Copy the quaternion to an array
  2951. * @returns a new array populated with 4 elements from the quaternion coordinates
  2952. */
  2953. asArray(): number[];
  2954. /**
  2955. * Check if two quaternions are equals
  2956. * @param otherQuaternion defines the second operand
  2957. * @return true if the current quaternion and the given one coordinates are strictly equals
  2958. */
  2959. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2960. /**
  2961. * Clone the current quaternion
  2962. * @returns a new quaternion copied from the current one
  2963. */
  2964. clone(): Quaternion;
  2965. /**
  2966. * Copy a quaternion to the current one
  2967. * @param other defines the other quaternion
  2968. * @returns the updated current quaternion
  2969. */
  2970. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2971. /**
  2972. * Updates the current quaternion with the given float coordinates
  2973. * @param x defines the x coordinate
  2974. * @param y defines the y coordinate
  2975. * @param z defines the z coordinate
  2976. * @param w defines the w coordinate
  2977. * @returns the updated current quaternion
  2978. */
  2979. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2980. /**
  2981. * Updates the current quaternion from the given float coordinates
  2982. * @param x defines the x coordinate
  2983. * @param y defines the y coordinate
  2984. * @param z defines the z coordinate
  2985. * @param w defines the w coordinate
  2986. * @returns the updated current quaternion
  2987. */
  2988. set(x: number, y: number, z: number, w: number): Quaternion;
  2989. /**
  2990. * Adds two quaternions
  2991. * @param other defines the second operand
  2992. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2993. */
  2994. add(other: DeepImmutable<Quaternion>): Quaternion;
  2995. /**
  2996. * Add a quaternion to the current one
  2997. * @param other defines the quaternion to add
  2998. * @returns the current quaternion
  2999. */
  3000. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3001. /**
  3002. * Subtract two quaternions
  3003. * @param other defines the second operand
  3004. * @returns a new quaternion as the subtraction result of the given one from the current one
  3005. */
  3006. subtract(other: Quaternion): Quaternion;
  3007. /**
  3008. * Multiplies the current quaternion by a scale factor
  3009. * @param value defines the scale factor
  3010. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3011. */
  3012. scale(value: number): Quaternion;
  3013. /**
  3014. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3015. * @param scale defines the scale factor
  3016. * @param result defines the Quaternion object where to store the result
  3017. * @returns the unmodified current quaternion
  3018. */
  3019. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3020. /**
  3021. * Multiplies in place the current quaternion by a scale factor
  3022. * @param value defines the scale factor
  3023. * @returns the current modified quaternion
  3024. */
  3025. scaleInPlace(value: number): Quaternion;
  3026. /**
  3027. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3028. * @param scale defines the scale factor
  3029. * @param result defines the Quaternion object where to store the result
  3030. * @returns the unmodified current quaternion
  3031. */
  3032. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3033. /**
  3034. * Multiplies two quaternions
  3035. * @param q1 defines the second operand
  3036. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3037. */
  3038. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3039. /**
  3040. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3041. * @param q1 defines the second operand
  3042. * @param result defines the target quaternion
  3043. * @returns the current quaternion
  3044. */
  3045. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3046. /**
  3047. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3048. * @param q1 defines the second operand
  3049. * @returns the currentupdated quaternion
  3050. */
  3051. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3052. /**
  3053. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3054. * @param ref defines the target quaternion
  3055. * @returns the current quaternion
  3056. */
  3057. conjugateToRef(ref: Quaternion): Quaternion;
  3058. /**
  3059. * Conjugates in place (1-q) the current quaternion
  3060. * @returns the current updated quaternion
  3061. */
  3062. conjugateInPlace(): Quaternion;
  3063. /**
  3064. * Conjugates in place (1-q) the current quaternion
  3065. * @returns a new quaternion
  3066. */
  3067. conjugate(): Quaternion;
  3068. /**
  3069. * Gets length of current quaternion
  3070. * @returns the quaternion length (float)
  3071. */
  3072. length(): number;
  3073. /**
  3074. * Normalize in place the current quaternion
  3075. * @returns the current updated quaternion
  3076. */
  3077. normalize(): Quaternion;
  3078. /**
  3079. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3080. * @param order is a reserved parameter and is ignore for now
  3081. * @returns a new Vector3 containing the Euler angles
  3082. */
  3083. toEulerAngles(order?: string): Vector3;
  3084. /**
  3085. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3086. * @param result defines the vector which will be filled with the Euler angles
  3087. * @param order is a reserved parameter and is ignore for now
  3088. * @returns the current unchanged quaternion
  3089. */
  3090. toEulerAnglesToRef(result: Vector3): Quaternion;
  3091. /**
  3092. * Updates the given rotation matrix with the current quaternion values
  3093. * @param result defines the target matrix
  3094. * @returns the current unchanged quaternion
  3095. */
  3096. toRotationMatrix(result: Matrix): Quaternion;
  3097. /**
  3098. * Updates the current quaternion from the given rotation matrix values
  3099. * @param matrix defines the source matrix
  3100. * @returns the current updated quaternion
  3101. */
  3102. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3103. /**
  3104. * Creates a new quaternion from a rotation matrix
  3105. * @param matrix defines the source matrix
  3106. * @returns a new quaternion created from the given rotation matrix values
  3107. */
  3108. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3109. /**
  3110. * Updates the given quaternion with the given rotation matrix values
  3111. * @param matrix defines the source matrix
  3112. * @param result defines the target quaternion
  3113. */
  3114. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3115. /**
  3116. * Returns the dot product (float) between the quaternions "left" and "right"
  3117. * @param left defines the left operand
  3118. * @param right defines the right operand
  3119. * @returns the dot product
  3120. */
  3121. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3122. /**
  3123. * Checks if the two quaternions are close to each other
  3124. * @param quat0 defines the first quaternion to check
  3125. * @param quat1 defines the second quaternion to check
  3126. * @returns true if the two quaternions are close to each other
  3127. */
  3128. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3129. /**
  3130. * Creates an empty quaternion
  3131. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3132. */
  3133. static Zero(): Quaternion;
  3134. /**
  3135. * Inverse a given quaternion
  3136. * @param q defines the source quaternion
  3137. * @returns a new quaternion as the inverted current quaternion
  3138. */
  3139. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3140. /**
  3141. * Inverse a given quaternion
  3142. * @param q defines the source quaternion
  3143. * @param result the quaternion the result will be stored in
  3144. * @returns the result quaternion
  3145. */
  3146. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3147. /**
  3148. * Creates an identity quaternion
  3149. * @returns the identity quaternion
  3150. */
  3151. static Identity(): Quaternion;
  3152. /**
  3153. * Gets a boolean indicating if the given quaternion is identity
  3154. * @param quaternion defines the quaternion to check
  3155. * @returns true if the quaternion is identity
  3156. */
  3157. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3158. /**
  3159. * Creates a quaternion from a rotation around an axis
  3160. * @param axis defines the axis to use
  3161. * @param angle defines the angle to use
  3162. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3163. */
  3164. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3165. /**
  3166. * Creates a rotation around an axis and stores it into the given quaternion
  3167. * @param axis defines the axis to use
  3168. * @param angle defines the angle to use
  3169. * @param result defines the target quaternion
  3170. * @returns the target quaternion
  3171. */
  3172. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3173. /**
  3174. * Creates a new quaternion from data stored into an array
  3175. * @param array defines the data source
  3176. * @param offset defines the offset in the source array where the data starts
  3177. * @returns a new quaternion
  3178. */
  3179. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3180. /**
  3181. * Create a quaternion from Euler rotation angles
  3182. * @param x Pitch
  3183. * @param y Yaw
  3184. * @param z Roll
  3185. * @returns the new Quaternion
  3186. */
  3187. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3188. /**
  3189. * Updates a quaternion from Euler rotation angles
  3190. * @param x Pitch
  3191. * @param y Yaw
  3192. * @param z Roll
  3193. * @param result the quaternion to store the result
  3194. * @returns the updated quaternion
  3195. */
  3196. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3197. /**
  3198. * Create a quaternion from Euler rotation vector
  3199. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3200. * @returns the new Quaternion
  3201. */
  3202. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3203. /**
  3204. * Updates a quaternion from Euler rotation vector
  3205. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3206. * @param result the quaternion to store the result
  3207. * @returns the updated quaternion
  3208. */
  3209. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3210. /**
  3211. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3212. * @param yaw defines the rotation around Y axis
  3213. * @param pitch defines the rotation around X axis
  3214. * @param roll defines the rotation around Z axis
  3215. * @returns the new quaternion
  3216. */
  3217. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3218. /**
  3219. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3220. * @param yaw defines the rotation around Y axis
  3221. * @param pitch defines the rotation around X axis
  3222. * @param roll defines the rotation around Z axis
  3223. * @param result defines the target quaternion
  3224. */
  3225. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3226. /**
  3227. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3228. * @param alpha defines the rotation around first axis
  3229. * @param beta defines the rotation around second axis
  3230. * @param gamma defines the rotation around third axis
  3231. * @returns the new quaternion
  3232. */
  3233. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3234. /**
  3235. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3236. * @param alpha defines the rotation around first axis
  3237. * @param beta defines the rotation around second axis
  3238. * @param gamma defines the rotation around third axis
  3239. * @param result defines the target quaternion
  3240. */
  3241. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3242. /**
  3243. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  3244. * @param axis1 defines the first axis
  3245. * @param axis2 defines the second axis
  3246. * @param axis3 defines the third axis
  3247. * @returns the new quaternion
  3248. */
  3249. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3250. /**
  3251. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  3252. * @param axis1 defines the first axis
  3253. * @param axis2 defines the second axis
  3254. * @param axis3 defines the third axis
  3255. * @param ref defines the target quaternion
  3256. */
  3257. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3258. /**
  3259. * Interpolates between two quaternions
  3260. * @param left defines first quaternion
  3261. * @param right defines second quaternion
  3262. * @param amount defines the gradient to use
  3263. * @returns the new interpolated quaternion
  3264. */
  3265. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3266. /**
  3267. * Interpolates between two quaternions and stores it into a target quaternion
  3268. * @param left defines first quaternion
  3269. * @param right defines second quaternion
  3270. * @param amount defines the gradient to use
  3271. * @param result defines the target quaternion
  3272. */
  3273. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3274. /**
  3275. * Interpolate between two quaternions using Hermite interpolation
  3276. * @param value1 defines first quaternion
  3277. * @param tangent1 defines the incoming tangent
  3278. * @param value2 defines second quaternion
  3279. * @param tangent2 defines the outgoing tangent
  3280. * @param amount defines the target quaternion
  3281. * @returns the new interpolated quaternion
  3282. */
  3283. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3284. }
  3285. /**
  3286. * Class used to store matrix data (4x4)
  3287. */
  3288. export class Matrix {
  3289. private static _updateFlagSeed;
  3290. private static _identityReadOnly;
  3291. private _isIdentity;
  3292. private _isIdentityDirty;
  3293. private _isIdentity3x2;
  3294. private _isIdentity3x2Dirty;
  3295. /**
  3296. * Gets the update flag of the matrix which is an unique number for the matrix.
  3297. * It will be incremented every time the matrix data change.
  3298. * You can use it to speed the comparison between two versions of the same matrix.
  3299. */
  3300. updateFlag: number;
  3301. private readonly _m;
  3302. /**
  3303. * Gets the internal data of the matrix
  3304. */
  3305. readonly m: DeepImmutable<Float32Array>;
  3306. /** @hidden */
  3307. _markAsUpdated(): void;
  3308. /** @hidden */
  3309. private _updateIdentityStatus;
  3310. /**
  3311. * Creates an empty matrix (filled with zeros)
  3312. */
  3313. constructor();
  3314. /**
  3315. * Check if the current matrix is identity
  3316. * @returns true is the matrix is the identity matrix
  3317. */
  3318. isIdentity(): boolean;
  3319. /**
  3320. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3321. * @returns true is the matrix is the identity matrix
  3322. */
  3323. isIdentityAs3x2(): boolean;
  3324. /**
  3325. * Gets the determinant of the matrix
  3326. * @returns the matrix determinant
  3327. */
  3328. determinant(): number;
  3329. /**
  3330. * Returns the matrix as a Float32Array
  3331. * @returns the matrix underlying array
  3332. */
  3333. toArray(): DeepImmutable<Float32Array>;
  3334. /**
  3335. * Returns the matrix as a Float32Array
  3336. * @returns the matrix underlying array.
  3337. */
  3338. asArray(): DeepImmutable<Float32Array>;
  3339. /**
  3340. * Inverts the current matrix in place
  3341. * @returns the current inverted matrix
  3342. */
  3343. invert(): Matrix;
  3344. /**
  3345. * Sets all the matrix elements to zero
  3346. * @returns the current matrix
  3347. */
  3348. reset(): Matrix;
  3349. /**
  3350. * Adds the current matrix with a second one
  3351. * @param other defines the matrix to add
  3352. * @returns a new matrix as the addition of the current matrix and the given one
  3353. */
  3354. add(other: DeepImmutable<Matrix>): Matrix;
  3355. /**
  3356. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3357. * @param other defines the matrix to add
  3358. * @param result defines the target matrix
  3359. * @returns the current matrix
  3360. */
  3361. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3362. /**
  3363. * Adds in place the given matrix to the current matrix
  3364. * @param other defines the second operand
  3365. * @returns the current updated matrix
  3366. */
  3367. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3368. /**
  3369. * Sets the given matrix to the current inverted Matrix
  3370. * @param other defines the target matrix
  3371. * @returns the unmodified current matrix
  3372. */
  3373. invertToRef(other: Matrix): Matrix;
  3374. /**
  3375. * add a value at the specified position in the current Matrix
  3376. * @param index the index of the value within the matrix. between 0 and 15.
  3377. * @param value the value to be added
  3378. * @returns the current updated matrix
  3379. */
  3380. addAtIndex(index: number, value: number): Matrix;
  3381. /**
  3382. * mutiply the specified position in the current Matrix by a value
  3383. * @param index the index of the value within the matrix. between 0 and 15.
  3384. * @param value the value to be added
  3385. * @returns the current updated matrix
  3386. */
  3387. multiplyAtIndex(index: number, value: number): Matrix;
  3388. /**
  3389. * Inserts the translation vector (using 3 floats) in the current matrix
  3390. * @param x defines the 1st component of the translation
  3391. * @param y defines the 2nd component of the translation
  3392. * @param z defines the 3rd component of the translation
  3393. * @returns the current updated matrix
  3394. */
  3395. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3396. /**
  3397. * Adds the translation vector (using 3 floats) in the current matrix
  3398. * @param x defines the 1st component of the translation
  3399. * @param y defines the 2nd component of the translation
  3400. * @param z defines the 3rd component of the translation
  3401. * @returns the current updated matrix
  3402. */
  3403. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3404. /**
  3405. * Inserts the translation vector in the current matrix
  3406. * @param vector3 defines the translation to insert
  3407. * @returns the current updated matrix
  3408. */
  3409. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3410. /**
  3411. * Gets the translation value of the current matrix
  3412. * @returns a new Vector3 as the extracted translation from the matrix
  3413. */
  3414. getTranslation(): Vector3;
  3415. /**
  3416. * Fill a Vector3 with the extracted translation from the matrix
  3417. * @param result defines the Vector3 where to store the translation
  3418. * @returns the current matrix
  3419. */
  3420. getTranslationToRef(result: Vector3): Matrix;
  3421. /**
  3422. * Remove rotation and scaling part from the matrix
  3423. * @returns the updated matrix
  3424. */
  3425. removeRotationAndScaling(): Matrix;
  3426. /**
  3427. * Multiply two matrices
  3428. * @param other defines the second operand
  3429. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3430. */
  3431. multiply(other: DeepImmutable<Matrix>): Matrix;
  3432. /**
  3433. * Copy the current matrix from the given one
  3434. * @param other defines the source matrix
  3435. * @returns the current updated matrix
  3436. */
  3437. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3438. /**
  3439. * Populates the given array from the starting index with the current matrix values
  3440. * @param array defines the target array
  3441. * @param offset defines the offset in the target array where to start storing values
  3442. * @returns the current matrix
  3443. */
  3444. copyToArray(array: Float32Array, offset?: number): Matrix;
  3445. /**
  3446. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3447. * @param other defines the second operand
  3448. * @param result defines the matrix where to store the multiplication
  3449. * @returns the current matrix
  3450. */
  3451. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3452. /**
  3453. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3454. * @param other defines the second operand
  3455. * @param result defines the array where to store the multiplication
  3456. * @param offset defines the offset in the target array where to start storing values
  3457. * @returns the current matrix
  3458. */
  3459. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3460. /**
  3461. * Check equality between this matrix and a second one
  3462. * @param value defines the second matrix to compare
  3463. * @returns true is the current matrix and the given one values are strictly equal
  3464. */
  3465. equals(value: DeepImmutable<Matrix>): boolean;
  3466. /**
  3467. * Clone the current matrix
  3468. * @returns a new matrix from the current matrix
  3469. */
  3470. clone(): Matrix;
  3471. /**
  3472. * Returns the name of the current matrix class
  3473. * @returns the string "Matrix"
  3474. */
  3475. getClassName(): string;
  3476. /**
  3477. * Gets the hash code of the current matrix
  3478. * @returns the hash code
  3479. */
  3480. getHashCode(): number;
  3481. /**
  3482. * Decomposes the current Matrix into a translation, rotation and scaling components
  3483. * @param scale defines the scale vector3 given as a reference to update
  3484. * @param rotation defines the rotation quaternion given as a reference to update
  3485. * @param translation defines the translation vector3 given as a reference to update
  3486. * @returns true if operation was successful
  3487. */
  3488. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3489. /**
  3490. * Gets specific row of the matrix
  3491. * @param index defines the number of the row to get
  3492. * @returns the index-th row of the current matrix as a new Vector4
  3493. */
  3494. getRow(index: number): Nullable<Vector4>;
  3495. /**
  3496. * Sets the index-th row of the current matrix to the vector4 values
  3497. * @param index defines the number of the row to set
  3498. * @param row defines the target vector4
  3499. * @returns the updated current matrix
  3500. */
  3501. setRow(index: number, row: Vector4): Matrix;
  3502. /**
  3503. * Compute the transpose of the matrix
  3504. * @returns the new transposed matrix
  3505. */
  3506. transpose(): Matrix;
  3507. /**
  3508. * Compute the transpose of the matrix and store it in a given matrix
  3509. * @param result defines the target matrix
  3510. * @returns the current matrix
  3511. */
  3512. transposeToRef(result: Matrix): Matrix;
  3513. /**
  3514. * Sets the index-th row of the current matrix with the given 4 x float values
  3515. * @param index defines the row index
  3516. * @param x defines the x component to set
  3517. * @param y defines the y component to set
  3518. * @param z defines the z component to set
  3519. * @param w defines the w component to set
  3520. * @returns the updated current matrix
  3521. */
  3522. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3523. /**
  3524. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3525. * @param scale defines the scale factor
  3526. * @returns a new matrix
  3527. */
  3528. scale(scale: number): Matrix;
  3529. /**
  3530. * Scale the current matrix values by a factor to a given result matrix
  3531. * @param scale defines the scale factor
  3532. * @param result defines the matrix to store the result
  3533. * @returns the current matrix
  3534. */
  3535. scaleToRef(scale: number, result: Matrix): Matrix;
  3536. /**
  3537. * Scale the current matrix values by a factor and add the result to a given matrix
  3538. * @param scale defines the scale factor
  3539. * @param result defines the Matrix to store the result
  3540. * @returns the current matrix
  3541. */
  3542. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3543. /**
  3544. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3545. * @param ref matrix to store the result
  3546. */
  3547. toNormalMatrix(ref: Matrix): void;
  3548. /**
  3549. * Gets only rotation part of the current matrix
  3550. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3551. */
  3552. getRotationMatrix(): Matrix;
  3553. /**
  3554. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3555. * @param result defines the target matrix to store data to
  3556. * @returns the current matrix
  3557. */
  3558. getRotationMatrixToRef(result: Matrix): Matrix;
  3559. /**
  3560. * Toggles model matrix from being right handed to left handed in place and vice versa
  3561. */
  3562. toggleModelMatrixHandInPlace(): void;
  3563. /**
  3564. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3565. */
  3566. toggleProjectionMatrixHandInPlace(): void;
  3567. /**
  3568. * Creates a matrix from an array
  3569. * @param array defines the source array
  3570. * @param offset defines an offset in the source array
  3571. * @returns a new Matrix set from the starting index of the given array
  3572. */
  3573. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3574. /**
  3575. * Copy the content of an array into a given matrix
  3576. * @param array defines the source array
  3577. * @param offset defines an offset in the source array
  3578. * @param result defines the target matrix
  3579. */
  3580. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3581. /**
  3582. * Stores an array into a matrix after having multiplied each component by a given factor
  3583. * @param array defines the source array
  3584. * @param offset defines the offset in the source array
  3585. * @param scale defines the scaling factor
  3586. * @param result defines the target matrix
  3587. */
  3588. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3589. /**
  3590. * Gets an identity matrix that must not be updated
  3591. */
  3592. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3593. /**
  3594. * Stores a list of values (16) inside a given matrix
  3595. * @param initialM11 defines 1st value of 1st row
  3596. * @param initialM12 defines 2nd value of 1st row
  3597. * @param initialM13 defines 3rd value of 1st row
  3598. * @param initialM14 defines 4th value of 1st row
  3599. * @param initialM21 defines 1st value of 2nd row
  3600. * @param initialM22 defines 2nd value of 2nd row
  3601. * @param initialM23 defines 3rd value of 2nd row
  3602. * @param initialM24 defines 4th value of 2nd row
  3603. * @param initialM31 defines 1st value of 3rd row
  3604. * @param initialM32 defines 2nd value of 3rd row
  3605. * @param initialM33 defines 3rd value of 3rd row
  3606. * @param initialM34 defines 4th value of 3rd row
  3607. * @param initialM41 defines 1st value of 4th row
  3608. * @param initialM42 defines 2nd value of 4th row
  3609. * @param initialM43 defines 3rd value of 4th row
  3610. * @param initialM44 defines 4th value of 4th row
  3611. * @param result defines the target matrix
  3612. */
  3613. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  3614. /**
  3615. * Creates new matrix from a list of values (16)
  3616. * @param initialM11 defines 1st value of 1st row
  3617. * @param initialM12 defines 2nd value of 1st row
  3618. * @param initialM13 defines 3rd value of 1st row
  3619. * @param initialM14 defines 4th value of 1st row
  3620. * @param initialM21 defines 1st value of 2nd row
  3621. * @param initialM22 defines 2nd value of 2nd row
  3622. * @param initialM23 defines 3rd value of 2nd row
  3623. * @param initialM24 defines 4th value of 2nd row
  3624. * @param initialM31 defines 1st value of 3rd row
  3625. * @param initialM32 defines 2nd value of 3rd row
  3626. * @param initialM33 defines 3rd value of 3rd row
  3627. * @param initialM34 defines 4th value of 3rd row
  3628. * @param initialM41 defines 1st value of 4th row
  3629. * @param initialM42 defines 2nd value of 4th row
  3630. * @param initialM43 defines 3rd value of 4th row
  3631. * @param initialM44 defines 4th value of 4th row
  3632. * @returns the new matrix
  3633. */
  3634. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  3635. /**
  3636. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3637. * @param scale defines the scale vector3
  3638. * @param rotation defines the rotation quaternion
  3639. * @param translation defines the translation vector3
  3640. * @returns a new matrix
  3641. */
  3642. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3643. /**
  3644. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3645. * @param scale defines the scale vector3
  3646. * @param rotation defines the rotation quaternion
  3647. * @param translation defines the translation vector3
  3648. * @param result defines the target matrix
  3649. */
  3650. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3651. /**
  3652. * Creates a new identity matrix
  3653. * @returns a new identity matrix
  3654. */
  3655. static Identity(): Matrix;
  3656. /**
  3657. * Creates a new identity matrix and stores the result in a given matrix
  3658. * @param result defines the target matrix
  3659. */
  3660. static IdentityToRef(result: Matrix): void;
  3661. /**
  3662. * Creates a new zero matrix
  3663. * @returns a new zero matrix
  3664. */
  3665. static Zero(): Matrix;
  3666. /**
  3667. * Creates a new rotation matrix for "angle" radians around the X axis
  3668. * @param angle defines the angle (in radians) to use
  3669. * @return the new matrix
  3670. */
  3671. static RotationX(angle: number): Matrix;
  3672. /**
  3673. * Creates a new matrix as the invert of a given matrix
  3674. * @param source defines the source matrix
  3675. * @returns the new matrix
  3676. */
  3677. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3678. /**
  3679. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3680. * @param angle defines the angle (in radians) to use
  3681. * @param result defines the target matrix
  3682. */
  3683. static RotationXToRef(angle: number, result: Matrix): void;
  3684. /**
  3685. * Creates a new rotation matrix for "angle" radians around the Y axis
  3686. * @param angle defines the angle (in radians) to use
  3687. * @return the new matrix
  3688. */
  3689. static RotationY(angle: number): Matrix;
  3690. /**
  3691. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3692. * @param angle defines the angle (in radians) to use
  3693. * @param result defines the target matrix
  3694. */
  3695. static RotationYToRef(angle: number, result: Matrix): void;
  3696. /**
  3697. * Creates a new rotation matrix for "angle" radians around the Z axis
  3698. * @param angle defines the angle (in radians) to use
  3699. * @return the new matrix
  3700. */
  3701. static RotationZ(angle: number): Matrix;
  3702. /**
  3703. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3704. * @param angle defines the angle (in radians) to use
  3705. * @param result defines the target matrix
  3706. */
  3707. static RotationZToRef(angle: number, result: Matrix): void;
  3708. /**
  3709. * Creates a new rotation matrix for "angle" radians around the given axis
  3710. * @param axis defines the axis to use
  3711. * @param angle defines the angle (in radians) to use
  3712. * @return the new matrix
  3713. */
  3714. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3715. /**
  3716. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3717. * @param axis defines the axis to use
  3718. * @param angle defines the angle (in radians) to use
  3719. * @param result defines the target matrix
  3720. */
  3721. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3722. /**
  3723. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3724. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3725. * @param from defines the vector to align
  3726. * @param to defines the vector to align to
  3727. * @param result defines the target matrix
  3728. */
  3729. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3730. /**
  3731. * Creates a rotation matrix
  3732. * @param yaw defines the yaw angle in radians (Y axis)
  3733. * @param pitch defines the pitch angle in radians (X axis)
  3734. * @param roll defines the roll angle in radians (X axis)
  3735. * @returns the new rotation matrix
  3736. */
  3737. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3738. /**
  3739. * Creates a rotation matrix and stores it in a given matrix
  3740. * @param yaw defines the yaw angle in radians (Y axis)
  3741. * @param pitch defines the pitch angle in radians (X axis)
  3742. * @param roll defines the roll angle in radians (X axis)
  3743. * @param result defines the target matrix
  3744. */
  3745. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3746. /**
  3747. * Creates a scaling matrix
  3748. * @param x defines the scale factor on X axis
  3749. * @param y defines the scale factor on Y axis
  3750. * @param z defines the scale factor on Z axis
  3751. * @returns the new matrix
  3752. */
  3753. static Scaling(x: number, y: number, z: number): Matrix;
  3754. /**
  3755. * Creates a scaling matrix and stores it in a given matrix
  3756. * @param x defines the scale factor on X axis
  3757. * @param y defines the scale factor on Y axis
  3758. * @param z defines the scale factor on Z axis
  3759. * @param result defines the target matrix
  3760. */
  3761. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3762. /**
  3763. * Creates a translation matrix
  3764. * @param x defines the translation on X axis
  3765. * @param y defines the translation on Y axis
  3766. * @param z defines the translationon Z axis
  3767. * @returns the new matrix
  3768. */
  3769. static Translation(x: number, y: number, z: number): Matrix;
  3770. /**
  3771. * Creates a translation matrix and stores it in a given matrix
  3772. * @param x defines the translation on X axis
  3773. * @param y defines the translation on Y axis
  3774. * @param z defines the translationon Z axis
  3775. * @param result defines the target matrix
  3776. */
  3777. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3778. /**
  3779. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3780. * @param startValue defines the start value
  3781. * @param endValue defines the end value
  3782. * @param gradient defines the gradient factor
  3783. * @returns the new matrix
  3784. */
  3785. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3786. /**
  3787. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3788. * @param startValue defines the start value
  3789. * @param endValue defines the end value
  3790. * @param gradient defines the gradient factor
  3791. * @param result defines the Matrix object where to store data
  3792. */
  3793. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3794. /**
  3795. * Builds a new matrix whose values are computed by:
  3796. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3797. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3798. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3799. * @param startValue defines the first matrix
  3800. * @param endValue defines the second matrix
  3801. * @param gradient defines the gradient between the two matrices
  3802. * @returns the new matrix
  3803. */
  3804. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3805. /**
  3806. * Update a matrix to values which are computed by:
  3807. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3808. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3809. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3810. * @param startValue defines the first matrix
  3811. * @param endValue defines the second matrix
  3812. * @param gradient defines the gradient between the two matrices
  3813. * @param result defines the target matrix
  3814. */
  3815. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3816. /**
  3817. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3818. * This function works in left handed mode
  3819. * @param eye defines the final position of the entity
  3820. * @param target defines where the entity should look at
  3821. * @param up defines the up vector for the entity
  3822. * @returns the new matrix
  3823. */
  3824. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3825. /**
  3826. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3827. * This function works in left handed mode
  3828. * @param eye defines the final position of the entity
  3829. * @param target defines where the entity should look at
  3830. * @param up defines the up vector for the entity
  3831. * @param result defines the target matrix
  3832. */
  3833. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3834. /**
  3835. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3836. * This function works in right handed mode
  3837. * @param eye defines the final position of the entity
  3838. * @param target defines where the entity should look at
  3839. * @param up defines the up vector for the entity
  3840. * @returns the new matrix
  3841. */
  3842. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3843. /**
  3844. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3845. * This function works in right handed mode
  3846. * @param eye defines the final position of the entity
  3847. * @param target defines where the entity should look at
  3848. * @param up defines the up vector for the entity
  3849. * @param result defines the target matrix
  3850. */
  3851. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3852. /**
  3853. * Create a left-handed orthographic projection matrix
  3854. * @param width defines the viewport width
  3855. * @param height defines the viewport height
  3856. * @param znear defines the near clip plane
  3857. * @param zfar defines the far clip plane
  3858. * @returns a new matrix as a left-handed orthographic projection matrix
  3859. */
  3860. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3861. /**
  3862. * Store a left-handed orthographic projection to a given matrix
  3863. * @param width defines the viewport width
  3864. * @param height defines the viewport height
  3865. * @param znear defines the near clip plane
  3866. * @param zfar defines the far clip plane
  3867. * @param result defines the target matrix
  3868. */
  3869. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3870. /**
  3871. * Create a left-handed orthographic projection matrix
  3872. * @param left defines the viewport left coordinate
  3873. * @param right defines the viewport right coordinate
  3874. * @param bottom defines the viewport bottom coordinate
  3875. * @param top defines the viewport top coordinate
  3876. * @param znear defines the near clip plane
  3877. * @param zfar defines the far clip plane
  3878. * @returns a new matrix as a left-handed orthographic projection matrix
  3879. */
  3880. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3881. /**
  3882. * Stores a left-handed orthographic projection into a given matrix
  3883. * @param left defines the viewport left coordinate
  3884. * @param right defines the viewport right coordinate
  3885. * @param bottom defines the viewport bottom coordinate
  3886. * @param top defines the viewport top coordinate
  3887. * @param znear defines the near clip plane
  3888. * @param zfar defines the far clip plane
  3889. * @param result defines the target matrix
  3890. */
  3891. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3892. /**
  3893. * Creates a right-handed orthographic projection matrix
  3894. * @param left defines the viewport left coordinate
  3895. * @param right defines the viewport right coordinate
  3896. * @param bottom defines the viewport bottom coordinate
  3897. * @param top defines the viewport top coordinate
  3898. * @param znear defines the near clip plane
  3899. * @param zfar defines the far clip plane
  3900. * @returns a new matrix as a right-handed orthographic projection matrix
  3901. */
  3902. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3903. /**
  3904. * Stores a right-handed orthographic projection into a given matrix
  3905. * @param left defines the viewport left coordinate
  3906. * @param right defines the viewport right coordinate
  3907. * @param bottom defines the viewport bottom coordinate
  3908. * @param top defines the viewport top coordinate
  3909. * @param znear defines the near clip plane
  3910. * @param zfar defines the far clip plane
  3911. * @param result defines the target matrix
  3912. */
  3913. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3914. /**
  3915. * Creates a left-handed perspective projection matrix
  3916. * @param width defines the viewport width
  3917. * @param height defines the viewport height
  3918. * @param znear defines the near clip plane
  3919. * @param zfar defines the far clip plane
  3920. * @returns a new matrix as a left-handed perspective projection matrix
  3921. */
  3922. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3923. /**
  3924. * Creates a left-handed perspective projection matrix
  3925. * @param fov defines the horizontal field of view
  3926. * @param aspect defines the aspect ratio
  3927. * @param znear defines the near clip plane
  3928. * @param zfar defines the far clip plane
  3929. * @returns a new matrix as a left-handed perspective projection matrix
  3930. */
  3931. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3932. /**
  3933. * Stores a left-handed perspective projection into a given matrix
  3934. * @param fov defines the horizontal field of view
  3935. * @param aspect defines the aspect ratio
  3936. * @param znear defines the near clip plane
  3937. * @param zfar defines the far clip plane
  3938. * @param result defines the target matrix
  3939. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3940. */
  3941. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3942. /**
  3943. * Creates a right-handed perspective projection matrix
  3944. * @param fov defines the horizontal field of view
  3945. * @param aspect defines the aspect ratio
  3946. * @param znear defines the near clip plane
  3947. * @param zfar defines the far clip plane
  3948. * @returns a new matrix as a right-handed perspective projection matrix
  3949. */
  3950. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3951. /**
  3952. * Stores a right-handed perspective projection into a given matrix
  3953. * @param fov defines the horizontal field of view
  3954. * @param aspect defines the aspect ratio
  3955. * @param znear defines the near clip plane
  3956. * @param zfar defines the far clip plane
  3957. * @param result defines the target matrix
  3958. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3959. */
  3960. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3961. /**
  3962. * Stores a perspective projection for WebVR info a given matrix
  3963. * @param fov defines the field of view
  3964. * @param znear defines the near clip plane
  3965. * @param zfar defines the far clip plane
  3966. * @param result defines the target matrix
  3967. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3968. */
  3969. static PerspectiveFovWebVRToRef(fov: {
  3970. upDegrees: number;
  3971. downDegrees: number;
  3972. leftDegrees: number;
  3973. rightDegrees: number;
  3974. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3975. /**
  3976. * Computes a complete transformation matrix
  3977. * @param viewport defines the viewport to use
  3978. * @param world defines the world matrix
  3979. * @param view defines the view matrix
  3980. * @param projection defines the projection matrix
  3981. * @param zmin defines the near clip plane
  3982. * @param zmax defines the far clip plane
  3983. * @returns the transformation matrix
  3984. */
  3985. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3986. /**
  3987. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3988. * @param matrix defines the matrix to use
  3989. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3990. */
  3991. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3992. /**
  3993. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3994. * @param matrix defines the matrix to use
  3995. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3996. */
  3997. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3998. /**
  3999. * Compute the transpose of a given matrix
  4000. * @param matrix defines the matrix to transpose
  4001. * @returns the new matrix
  4002. */
  4003. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4004. /**
  4005. * Compute the transpose of a matrix and store it in a target matrix
  4006. * @param matrix defines the matrix to transpose
  4007. * @param result defines the target matrix
  4008. */
  4009. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4010. /**
  4011. * Computes a reflection matrix from a plane
  4012. * @param plane defines the reflection plane
  4013. * @returns a new matrix
  4014. */
  4015. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4016. /**
  4017. * Computes a reflection matrix from a plane
  4018. * @param plane defines the reflection plane
  4019. * @param result defines the target matrix
  4020. */
  4021. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4022. /**
  4023. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4024. * @param xaxis defines the value of the 1st axis
  4025. * @param yaxis defines the value of the 2nd axis
  4026. * @param zaxis defines the value of the 3rd axis
  4027. * @param result defines the target matrix
  4028. */
  4029. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4030. /**
  4031. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4032. * @param quat defines the quaternion to use
  4033. * @param result defines the target matrix
  4034. */
  4035. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4036. }
  4037. /**
  4038. * @hidden
  4039. */
  4040. export class TmpVectors {
  4041. static Vector2: Vector2[];
  4042. static Vector3: Vector3[];
  4043. static Vector4: Vector4[];
  4044. static Quaternion: Quaternion[];
  4045. static Matrix: Matrix[];
  4046. }
  4047. }
  4048. declare module "babylonjs/Engines/constants" {
  4049. /** Defines the cross module used constants to avoid circular dependncies */
  4050. export class Constants {
  4051. /** Defines that alpha blending is disabled */
  4052. static readonly ALPHA_DISABLE: number;
  4053. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4054. static readonly ALPHA_ADD: number;
  4055. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4056. static readonly ALPHA_COMBINE: number;
  4057. /** Defines that alpha blending to DEST - SRC * DEST */
  4058. static readonly ALPHA_SUBTRACT: number;
  4059. /** Defines that alpha blending to SRC * DEST */
  4060. static readonly ALPHA_MULTIPLY: number;
  4061. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4062. static readonly ALPHA_MAXIMIZED: number;
  4063. /** Defines that alpha blending to SRC + DEST */
  4064. static readonly ALPHA_ONEONE: number;
  4065. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4066. static readonly ALPHA_PREMULTIPLIED: number;
  4067. /**
  4068. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4069. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4070. */
  4071. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4072. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4073. static readonly ALPHA_INTERPOLATE: number;
  4074. /**
  4075. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4076. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4077. */
  4078. static readonly ALPHA_SCREENMODE: number;
  4079. /** Defines that the ressource is not delayed*/
  4080. static readonly DELAYLOADSTATE_NONE: number;
  4081. /** Defines that the ressource was successfully delay loaded */
  4082. static readonly DELAYLOADSTATE_LOADED: number;
  4083. /** Defines that the ressource is currently delay loading */
  4084. static readonly DELAYLOADSTATE_LOADING: number;
  4085. /** Defines that the ressource is delayed and has not started loading */
  4086. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4087. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4088. static readonly NEVER: number;
  4089. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  4090. static readonly ALWAYS: number;
  4091. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4092. static readonly LESS: number;
  4093. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4094. static readonly EQUAL: number;
  4095. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  4096. static readonly LEQUAL: number;
  4097. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4098. static readonly GREATER: number;
  4099. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  4100. static readonly GEQUAL: number;
  4101. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  4102. static readonly NOTEQUAL: number;
  4103. /** Passed to stencilOperation to specify that stencil value must be kept */
  4104. static readonly KEEP: number;
  4105. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4106. static readonly REPLACE: number;
  4107. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4108. static readonly INCR: number;
  4109. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4110. static readonly DECR: number;
  4111. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4112. static readonly INVERT: number;
  4113. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4114. static readonly INCR_WRAP: number;
  4115. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4116. static readonly DECR_WRAP: number;
  4117. /** Texture is not repeating outside of 0..1 UVs */
  4118. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4119. /** Texture is repeating outside of 0..1 UVs */
  4120. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4121. /** Texture is repeating and mirrored */
  4122. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4123. /** ALPHA */
  4124. static readonly TEXTUREFORMAT_ALPHA: number;
  4125. /** LUMINANCE */
  4126. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4127. /** LUMINANCE_ALPHA */
  4128. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4129. /** RGB */
  4130. static readonly TEXTUREFORMAT_RGB: number;
  4131. /** RGBA */
  4132. static readonly TEXTUREFORMAT_RGBA: number;
  4133. /** RED */
  4134. static readonly TEXTUREFORMAT_RED: number;
  4135. /** RED (2nd reference) */
  4136. static readonly TEXTUREFORMAT_R: number;
  4137. /** RG */
  4138. static readonly TEXTUREFORMAT_RG: number;
  4139. /** RED_INTEGER */
  4140. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4141. /** RED_INTEGER (2nd reference) */
  4142. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4143. /** RG_INTEGER */
  4144. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4145. /** RGB_INTEGER */
  4146. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4147. /** RGBA_INTEGER */
  4148. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4149. /** UNSIGNED_BYTE */
  4150. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4151. /** UNSIGNED_BYTE (2nd reference) */
  4152. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4153. /** FLOAT */
  4154. static readonly TEXTURETYPE_FLOAT: number;
  4155. /** HALF_FLOAT */
  4156. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4157. /** BYTE */
  4158. static readonly TEXTURETYPE_BYTE: number;
  4159. /** SHORT */
  4160. static readonly TEXTURETYPE_SHORT: number;
  4161. /** UNSIGNED_SHORT */
  4162. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4163. /** INT */
  4164. static readonly TEXTURETYPE_INT: number;
  4165. /** UNSIGNED_INT */
  4166. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4167. /** UNSIGNED_SHORT_4_4_4_4 */
  4168. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4169. /** UNSIGNED_SHORT_5_5_5_1 */
  4170. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4171. /** UNSIGNED_SHORT_5_6_5 */
  4172. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4173. /** UNSIGNED_INT_2_10_10_10_REV */
  4174. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4175. /** UNSIGNED_INT_24_8 */
  4176. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4177. /** UNSIGNED_INT_10F_11F_11F_REV */
  4178. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4179. /** UNSIGNED_INT_5_9_9_9_REV */
  4180. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4181. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4182. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4183. /** nearest is mag = nearest and min = nearest and mip = linear */
  4184. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4185. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4186. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4187. /** Trilinear is mag = linear and min = linear and mip = linear */
  4188. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4189. /** nearest is mag = nearest and min = nearest and mip = linear */
  4190. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4191. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4192. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4193. /** Trilinear is mag = linear and min = linear and mip = linear */
  4194. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4195. /** mag = nearest and min = nearest and mip = nearest */
  4196. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4197. /** mag = nearest and min = linear and mip = nearest */
  4198. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4199. /** mag = nearest and min = linear and mip = linear */
  4200. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4201. /** mag = nearest and min = linear and mip = none */
  4202. static readonly TEXTURE_NEAREST_LINEAR: number;
  4203. /** mag = nearest and min = nearest and mip = none */
  4204. static readonly TEXTURE_NEAREST_NEAREST: number;
  4205. /** mag = linear and min = nearest and mip = nearest */
  4206. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4207. /** mag = linear and min = nearest and mip = linear */
  4208. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4209. /** mag = linear and min = linear and mip = none */
  4210. static readonly TEXTURE_LINEAR_LINEAR: number;
  4211. /** mag = linear and min = nearest and mip = none */
  4212. static readonly TEXTURE_LINEAR_NEAREST: number;
  4213. /** Explicit coordinates mode */
  4214. static readonly TEXTURE_EXPLICIT_MODE: number;
  4215. /** Spherical coordinates mode */
  4216. static readonly TEXTURE_SPHERICAL_MODE: number;
  4217. /** Planar coordinates mode */
  4218. static readonly TEXTURE_PLANAR_MODE: number;
  4219. /** Cubic coordinates mode */
  4220. static readonly TEXTURE_CUBIC_MODE: number;
  4221. /** Projection coordinates mode */
  4222. static readonly TEXTURE_PROJECTION_MODE: number;
  4223. /** Skybox coordinates mode */
  4224. static readonly TEXTURE_SKYBOX_MODE: number;
  4225. /** Inverse Cubic coordinates mode */
  4226. static readonly TEXTURE_INVCUBIC_MODE: number;
  4227. /** Equirectangular coordinates mode */
  4228. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4229. /** Equirectangular Fixed coordinates mode */
  4230. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4231. /** Equirectangular Fixed Mirrored coordinates mode */
  4232. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4233. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4234. static readonly SCALEMODE_FLOOR: number;
  4235. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4236. static readonly SCALEMODE_NEAREST: number;
  4237. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4238. static readonly SCALEMODE_CEILING: number;
  4239. /**
  4240. * The dirty texture flag value
  4241. */
  4242. static readonly MATERIAL_TextureDirtyFlag: number;
  4243. /**
  4244. * The dirty light flag value
  4245. */
  4246. static readonly MATERIAL_LightDirtyFlag: number;
  4247. /**
  4248. * The dirty fresnel flag value
  4249. */
  4250. static readonly MATERIAL_FresnelDirtyFlag: number;
  4251. /**
  4252. * The dirty attribute flag value
  4253. */
  4254. static readonly MATERIAL_AttributesDirtyFlag: number;
  4255. /**
  4256. * The dirty misc flag value
  4257. */
  4258. static readonly MATERIAL_MiscDirtyFlag: number;
  4259. /**
  4260. * The all dirty flag value
  4261. */
  4262. static readonly MATERIAL_AllDirtyFlag: number;
  4263. /**
  4264. * Returns the triangle fill mode
  4265. */
  4266. static readonly MATERIAL_TriangleFillMode: number;
  4267. /**
  4268. * Returns the wireframe mode
  4269. */
  4270. static readonly MATERIAL_WireFrameFillMode: number;
  4271. /**
  4272. * Returns the point fill mode
  4273. */
  4274. static readonly MATERIAL_PointFillMode: number;
  4275. /**
  4276. * Returns the point list draw mode
  4277. */
  4278. static readonly MATERIAL_PointListDrawMode: number;
  4279. /**
  4280. * Returns the line list draw mode
  4281. */
  4282. static readonly MATERIAL_LineListDrawMode: number;
  4283. /**
  4284. * Returns the line loop draw mode
  4285. */
  4286. static readonly MATERIAL_LineLoopDrawMode: number;
  4287. /**
  4288. * Returns the line strip draw mode
  4289. */
  4290. static readonly MATERIAL_LineStripDrawMode: number;
  4291. /**
  4292. * Returns the triangle strip draw mode
  4293. */
  4294. static readonly MATERIAL_TriangleStripDrawMode: number;
  4295. /**
  4296. * Returns the triangle fan draw mode
  4297. */
  4298. static readonly MATERIAL_TriangleFanDrawMode: number;
  4299. /**
  4300. * Stores the clock-wise side orientation
  4301. */
  4302. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4303. /**
  4304. * Stores the counter clock-wise side orientation
  4305. */
  4306. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4307. /**
  4308. * Nothing
  4309. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4310. */
  4311. static readonly ACTION_NothingTrigger: number;
  4312. /**
  4313. * On pick
  4314. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4315. */
  4316. static readonly ACTION_OnPickTrigger: number;
  4317. /**
  4318. * On left pick
  4319. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4320. */
  4321. static readonly ACTION_OnLeftPickTrigger: number;
  4322. /**
  4323. * On right pick
  4324. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4325. */
  4326. static readonly ACTION_OnRightPickTrigger: number;
  4327. /**
  4328. * On center pick
  4329. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4330. */
  4331. static readonly ACTION_OnCenterPickTrigger: number;
  4332. /**
  4333. * On pick down
  4334. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4335. */
  4336. static readonly ACTION_OnPickDownTrigger: number;
  4337. /**
  4338. * On double pick
  4339. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4340. */
  4341. static readonly ACTION_OnDoublePickTrigger: number;
  4342. /**
  4343. * On pick up
  4344. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4345. */
  4346. static readonly ACTION_OnPickUpTrigger: number;
  4347. /**
  4348. * On pick out.
  4349. * This trigger will only be raised if you also declared a OnPickDown
  4350. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4351. */
  4352. static readonly ACTION_OnPickOutTrigger: number;
  4353. /**
  4354. * On long press
  4355. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4356. */
  4357. static readonly ACTION_OnLongPressTrigger: number;
  4358. /**
  4359. * On pointer over
  4360. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4361. */
  4362. static readonly ACTION_OnPointerOverTrigger: number;
  4363. /**
  4364. * On pointer out
  4365. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4366. */
  4367. static readonly ACTION_OnPointerOutTrigger: number;
  4368. /**
  4369. * On every frame
  4370. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4371. */
  4372. static readonly ACTION_OnEveryFrameTrigger: number;
  4373. /**
  4374. * On intersection enter
  4375. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4376. */
  4377. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4378. /**
  4379. * On intersection exit
  4380. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4381. */
  4382. static readonly ACTION_OnIntersectionExitTrigger: number;
  4383. /**
  4384. * On key down
  4385. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4386. */
  4387. static readonly ACTION_OnKeyDownTrigger: number;
  4388. /**
  4389. * On key up
  4390. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4391. */
  4392. static readonly ACTION_OnKeyUpTrigger: number;
  4393. /**
  4394. * Billboard mode will only apply to Y axis
  4395. */
  4396. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4397. /**
  4398. * Billboard mode will apply to all axes
  4399. */
  4400. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4401. /**
  4402. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4403. */
  4404. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4405. /**
  4406. * Gets or sets base Assets URL
  4407. */
  4408. static PARTICLES_BaseAssetsUrl: string;
  4409. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4410. * Test order :
  4411. * Is the bounding sphere outside the frustum ?
  4412. * If not, are the bounding box vertices outside the frustum ?
  4413. * It not, then the cullable object is in the frustum.
  4414. */
  4415. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4416. /** Culling strategy : Bounding Sphere Only.
  4417. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4418. * It's also less accurate than the standard because some not visible objects can still be selected.
  4419. * Test : is the bounding sphere outside the frustum ?
  4420. * If not, then the cullable object is in the frustum.
  4421. */
  4422. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4423. /** Culling strategy : Optimistic Inclusion.
  4424. * This in an inclusion test first, then the standard exclusion test.
  4425. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4426. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  4427. * Anyway, it's as accurate as the standard strategy.
  4428. * Test :
  4429. * Is the cullable object bounding sphere center in the frustum ?
  4430. * If not, apply the default culling strategy.
  4431. */
  4432. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4433. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4434. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4435. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4436. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  4437. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4438. * Test :
  4439. * Is the cullable object bounding sphere center in the frustum ?
  4440. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4441. */
  4442. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4443. /**
  4444. * No logging while loading
  4445. */
  4446. static readonly SCENELOADER_NO_LOGGING: number;
  4447. /**
  4448. * Minimal logging while loading
  4449. */
  4450. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4451. /**
  4452. * Summary logging while loading
  4453. */
  4454. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4455. /**
  4456. * Detailled logging while loading
  4457. */
  4458. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4459. }
  4460. }
  4461. declare module "babylonjs/Engines/IPipelineContext" {
  4462. /**
  4463. * Class used to store and describe the pipeline context associated with an effect
  4464. */
  4465. export interface IPipelineContext {
  4466. /**
  4467. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  4468. */
  4469. isAsync: boolean;
  4470. /**
  4471. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  4472. */
  4473. isReady: boolean;
  4474. /** @hidden */
  4475. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  4476. }
  4477. }
  4478. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  4479. /** @hidden */
  4480. export interface IShaderProcessor {
  4481. attributeProcessor?: (attribute: string) => string;
  4482. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  4483. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  4484. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  4485. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  4486. lineProcessor?: (line: string, isFragment: boolean) => string;
  4487. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4488. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4489. }
  4490. }
  4491. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  4492. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  4493. /** @hidden */
  4494. export interface ProcessingOptions {
  4495. defines: string[];
  4496. indexParameters: any;
  4497. isFragment: boolean;
  4498. shouldUseHighPrecisionShader: boolean;
  4499. supportsUniformBuffers: boolean;
  4500. shadersRepository: string;
  4501. includesShadersStore: {
  4502. [key: string]: string;
  4503. };
  4504. processor?: IShaderProcessor;
  4505. version: string;
  4506. platformName: string;
  4507. lookForClosingBracketForUniformBuffer?: boolean;
  4508. }
  4509. }
  4510. declare module "babylonjs/Misc/stringTools" {
  4511. /**
  4512. * Helper to manipulate strings
  4513. */
  4514. export class StringTools {
  4515. /**
  4516. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  4517. * @param str Source string
  4518. * @param suffix Suffix to search for in the source string
  4519. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4520. */
  4521. static EndsWith(str: string, suffix: string): boolean;
  4522. /**
  4523. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  4524. * @param str Source string
  4525. * @param suffix Suffix to search for in the source string
  4526. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4527. */
  4528. static StartsWith(str: string, suffix: string): boolean;
  4529. }
  4530. }
  4531. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  4532. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4533. /** @hidden */
  4534. export class ShaderCodeNode {
  4535. line: string;
  4536. children: ShaderCodeNode[];
  4537. additionalDefineKey?: string;
  4538. additionalDefineValue?: string;
  4539. isValid(preprocessors: {
  4540. [key: string]: string;
  4541. }): boolean;
  4542. process(preprocessors: {
  4543. [key: string]: string;
  4544. }, options: ProcessingOptions): string;
  4545. }
  4546. }
  4547. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  4548. /** @hidden */
  4549. export class ShaderCodeCursor {
  4550. private _lines;
  4551. lineIndex: number;
  4552. readonly currentLine: string;
  4553. readonly canRead: boolean;
  4554. lines: string[];
  4555. }
  4556. }
  4557. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  4558. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4559. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4560. /** @hidden */
  4561. export class ShaderCodeConditionNode extends ShaderCodeNode {
  4562. process(preprocessors: {
  4563. [key: string]: string;
  4564. }, options: ProcessingOptions): string;
  4565. }
  4566. }
  4567. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  4568. /** @hidden */
  4569. export class ShaderDefineExpression {
  4570. isTrue(preprocessors: {
  4571. [key: string]: string;
  4572. }): boolean;
  4573. }
  4574. }
  4575. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  4576. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4577. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4578. /** @hidden */
  4579. export class ShaderCodeTestNode extends ShaderCodeNode {
  4580. testExpression: ShaderDefineExpression;
  4581. isValid(preprocessors: {
  4582. [key: string]: string;
  4583. }): boolean;
  4584. }
  4585. }
  4586. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  4587. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4588. /** @hidden */
  4589. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  4590. define: string;
  4591. not: boolean;
  4592. constructor(define: string, not?: boolean);
  4593. isTrue(preprocessors: {
  4594. [key: string]: string;
  4595. }): boolean;
  4596. }
  4597. }
  4598. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  4599. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4600. /** @hidden */
  4601. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  4602. leftOperand: ShaderDefineExpression;
  4603. rightOperand: ShaderDefineExpression;
  4604. isTrue(preprocessors: {
  4605. [key: string]: string;
  4606. }): boolean;
  4607. }
  4608. }
  4609. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  4610. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4611. /** @hidden */
  4612. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  4613. leftOperand: ShaderDefineExpression;
  4614. rightOperand: ShaderDefineExpression;
  4615. isTrue(preprocessors: {
  4616. [key: string]: string;
  4617. }): boolean;
  4618. }
  4619. }
  4620. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  4621. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4622. /** @hidden */
  4623. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  4624. define: string;
  4625. operand: string;
  4626. testValue: string;
  4627. constructor(define: string, operand: string, testValue: string);
  4628. isTrue(preprocessors: {
  4629. [key: string]: string;
  4630. }): boolean;
  4631. }
  4632. }
  4633. declare module "babylonjs/Misc/loadFileError" {
  4634. import { WebRequest } from "babylonjs/Misc/webRequest";
  4635. /**
  4636. * @ignore
  4637. * Application error to support additional information when loading a file
  4638. */
  4639. export class LoadFileError extends Error {
  4640. /** defines the optional web request */
  4641. request?: WebRequest | undefined;
  4642. private static _setPrototypeOf;
  4643. /**
  4644. * Creates a new LoadFileError
  4645. * @param message defines the message of the error
  4646. * @param request defines the optional web request
  4647. */
  4648. constructor(message: string,
  4649. /** defines the optional web request */
  4650. request?: WebRequest | undefined);
  4651. }
  4652. }
  4653. declare module "babylonjs/Offline/IOfflineProvider" {
  4654. /**
  4655. * Class used to enable access to offline support
  4656. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4657. */
  4658. export interface IOfflineProvider {
  4659. /**
  4660. * Gets a boolean indicating if scene must be saved in the database
  4661. */
  4662. enableSceneOffline: boolean;
  4663. /**
  4664. * Gets a boolean indicating if textures must be saved in the database
  4665. */
  4666. enableTexturesOffline: boolean;
  4667. /**
  4668. * Open the offline support and make it available
  4669. * @param successCallback defines the callback to call on success
  4670. * @param errorCallback defines the callback to call on error
  4671. */
  4672. open(successCallback: () => void, errorCallback: () => void): void;
  4673. /**
  4674. * Loads an image from the offline support
  4675. * @param url defines the url to load from
  4676. * @param image defines the target DOM image
  4677. */
  4678. loadImage(url: string, image: HTMLImageElement): void;
  4679. /**
  4680. * Loads a file from offline support
  4681. * @param url defines the URL to load from
  4682. * @param sceneLoaded defines a callback to call on success
  4683. * @param progressCallBack defines a callback to call when progress changed
  4684. * @param errorCallback defines a callback to call on error
  4685. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4686. */
  4687. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4688. }
  4689. }
  4690. declare module "babylonjs/Misc/filesInputStore" {
  4691. /**
  4692. * Class used to help managing file picking and drag'n'drop
  4693. * File Storage
  4694. */
  4695. export class FilesInputStore {
  4696. /**
  4697. * List of files ready to be loaded
  4698. */
  4699. static FilesToLoad: {
  4700. [key: string]: File;
  4701. };
  4702. }
  4703. }
  4704. declare module "babylonjs/Misc/retryStrategy" {
  4705. import { WebRequest } from "babylonjs/Misc/webRequest";
  4706. /**
  4707. * Class used to define a retry strategy when error happens while loading assets
  4708. */
  4709. export class RetryStrategy {
  4710. /**
  4711. * Function used to defines an exponential back off strategy
  4712. * @param maxRetries defines the maximum number of retries (3 by default)
  4713. * @param baseInterval defines the interval between retries
  4714. * @returns the strategy function to use
  4715. */
  4716. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  4717. }
  4718. }
  4719. declare module "babylonjs/Misc/fileTools" {
  4720. import { WebRequest } from "babylonjs/Misc/webRequest";
  4721. import { Nullable } from "babylonjs/types";
  4722. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  4723. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  4724. /**
  4725. * @hidden
  4726. */
  4727. export class FileTools {
  4728. /**
  4729. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  4730. */
  4731. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  4732. /**
  4733. * Gets or sets the base URL to use to load assets
  4734. */
  4735. static BaseUrl: string;
  4736. /**
  4737. * Default behaviour for cors in the application.
  4738. * It can be a string if the expected behavior is identical in the entire app.
  4739. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  4740. */
  4741. static CorsBehavior: string | ((url: string | string[]) => string);
  4742. /**
  4743. * Gets or sets a function used to pre-process url before using them to load assets
  4744. */
  4745. static PreprocessUrl: (url: string) => string;
  4746. /**
  4747. * Removes unwanted characters from an url
  4748. * @param url defines the url to clean
  4749. * @returns the cleaned url
  4750. */
  4751. private static _CleanUrl;
  4752. /**
  4753. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  4754. * @param url define the url we are trying
  4755. * @param element define the dom element where to configure the cors policy
  4756. */
  4757. static SetCorsBehavior(url: string | string[], element: {
  4758. crossOrigin: string | null;
  4759. }): void;
  4760. /**
  4761. * Loads an image as an HTMLImageElement.
  4762. * @param input url string, ArrayBuffer, or Blob to load
  4763. * @param onLoad callback called when the image successfully loads
  4764. * @param onError callback called when the image fails to load
  4765. * @param offlineProvider offline provider for caching
  4766. * @returns the HTMLImageElement of the loaded image
  4767. */
  4768. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  4769. /**
  4770. * Loads a file
  4771. * @param fileToLoad defines the file to load
  4772. * @param callback defines the callback to call when data is loaded
  4773. * @param progressCallBack defines the callback to call during loading process
  4774. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  4775. * @returns a file request object
  4776. */
  4777. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  4778. /**
  4779. * Loads a file
  4780. * @param url url string, ArrayBuffer, or Blob to load
  4781. * @param onSuccess callback called when the file successfully loads
  4782. * @param onProgress callback called while file is loading (if the server supports this mode)
  4783. * @param offlineProvider defines the offline provider for caching
  4784. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  4785. * @param onError callback called when the file fails to load
  4786. * @returns a file request object
  4787. */
  4788. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  4789. /**
  4790. * Checks if the loaded document was accessed via `file:`-Protocol.
  4791. * @returns boolean
  4792. */
  4793. static IsFileURL(): boolean;
  4794. }
  4795. }
  4796. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  4797. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4798. /** @hidden */
  4799. export class ShaderProcessor {
  4800. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  4801. private static _ProcessPrecision;
  4802. private static _ExtractOperation;
  4803. private static _BuildSubExpression;
  4804. private static _BuildExpression;
  4805. private static _MoveCursorWithinIf;
  4806. private static _MoveCursor;
  4807. private static _EvaluatePreProcessors;
  4808. private static _PreparePreProcessors;
  4809. private static _ProcessShaderConversion;
  4810. private static _ProcessIncludes;
  4811. }
  4812. }
  4813. declare module "babylonjs/Maths/math.color" {
  4814. import { DeepImmutable, FloatArray } from "babylonjs/types";
  4815. /**
  4816. * Class used to hold a RBG color
  4817. */
  4818. export class Color3 {
  4819. /**
  4820. * Defines the red component (between 0 and 1, default is 0)
  4821. */
  4822. r: number;
  4823. /**
  4824. * Defines the green component (between 0 and 1, default is 0)
  4825. */
  4826. g: number;
  4827. /**
  4828. * Defines the blue component (between 0 and 1, default is 0)
  4829. */
  4830. b: number;
  4831. /**
  4832. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  4833. * @param r defines the red component (between 0 and 1, default is 0)
  4834. * @param g defines the green component (between 0 and 1, default is 0)
  4835. * @param b defines the blue component (between 0 and 1, default is 0)
  4836. */
  4837. constructor(
  4838. /**
  4839. * Defines the red component (between 0 and 1, default is 0)
  4840. */
  4841. r?: number,
  4842. /**
  4843. * Defines the green component (between 0 and 1, default is 0)
  4844. */
  4845. g?: number,
  4846. /**
  4847. * Defines the blue component (between 0 and 1, default is 0)
  4848. */
  4849. b?: number);
  4850. /**
  4851. * Creates a string with the Color3 current values
  4852. * @returns the string representation of the Color3 object
  4853. */
  4854. toString(): string;
  4855. /**
  4856. * Returns the string "Color3"
  4857. * @returns "Color3"
  4858. */
  4859. getClassName(): string;
  4860. /**
  4861. * Compute the Color3 hash code
  4862. * @returns an unique number that can be used to hash Color3 objects
  4863. */
  4864. getHashCode(): number;
  4865. /**
  4866. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  4867. * @param array defines the array where to store the r,g,b components
  4868. * @param index defines an optional index in the target array to define where to start storing values
  4869. * @returns the current Color3 object
  4870. */
  4871. toArray(array: FloatArray, index?: number): Color3;
  4872. /**
  4873. * Returns a new Color4 object from the current Color3 and the given alpha
  4874. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  4875. * @returns a new Color4 object
  4876. */
  4877. toColor4(alpha?: number): Color4;
  4878. /**
  4879. * Returns a new array populated with 3 numeric elements : red, green and blue values
  4880. * @returns the new array
  4881. */
  4882. asArray(): number[];
  4883. /**
  4884. * Returns the luminance value
  4885. * @returns a float value
  4886. */
  4887. toLuminance(): number;
  4888. /**
  4889. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  4890. * @param otherColor defines the second operand
  4891. * @returns the new Color3 object
  4892. */
  4893. multiply(otherColor: DeepImmutable<Color3>): Color3;
  4894. /**
  4895. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  4896. * @param otherColor defines the second operand
  4897. * @param result defines the Color3 object where to store the result
  4898. * @returns the current Color3
  4899. */
  4900. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4901. /**
  4902. * Determines equality between Color3 objects
  4903. * @param otherColor defines the second operand
  4904. * @returns true if the rgb values are equal to the given ones
  4905. */
  4906. equals(otherColor: DeepImmutable<Color3>): boolean;
  4907. /**
  4908. * Determines equality between the current Color3 object and a set of r,b,g values
  4909. * @param r defines the red component to check
  4910. * @param g defines the green component to check
  4911. * @param b defines the blue component to check
  4912. * @returns true if the rgb values are equal to the given ones
  4913. */
  4914. equalsFloats(r: number, g: number, b: number): boolean;
  4915. /**
  4916. * Multiplies in place each rgb value by scale
  4917. * @param scale defines the scaling factor
  4918. * @returns the updated Color3
  4919. */
  4920. scale(scale: number): Color3;
  4921. /**
  4922. * Multiplies the rgb values by scale and stores the result into "result"
  4923. * @param scale defines the scaling factor
  4924. * @param result defines the Color3 object where to store the result
  4925. * @returns the unmodified current Color3
  4926. */
  4927. scaleToRef(scale: number, result: Color3): Color3;
  4928. /**
  4929. * Scale the current Color3 values by a factor and add the result to a given Color3
  4930. * @param scale defines the scale factor
  4931. * @param result defines color to store the result into
  4932. * @returns the unmodified current Color3
  4933. */
  4934. scaleAndAddToRef(scale: number, result: Color3): Color3;
  4935. /**
  4936. * Clamps the rgb values by the min and max values and stores the result into "result"
  4937. * @param min defines minimum clamping value (default is 0)
  4938. * @param max defines maximum clamping value (default is 1)
  4939. * @param result defines color to store the result into
  4940. * @returns the original Color3
  4941. */
  4942. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  4943. /**
  4944. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  4945. * @param otherColor defines the second operand
  4946. * @returns the new Color3
  4947. */
  4948. add(otherColor: DeepImmutable<Color3>): Color3;
  4949. /**
  4950. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  4951. * @param otherColor defines the second operand
  4952. * @param result defines Color3 object to store the result into
  4953. * @returns the unmodified current Color3
  4954. */
  4955. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4956. /**
  4957. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  4958. * @param otherColor defines the second operand
  4959. * @returns the new Color3
  4960. */
  4961. subtract(otherColor: DeepImmutable<Color3>): Color3;
  4962. /**
  4963. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  4964. * @param otherColor defines the second operand
  4965. * @param result defines Color3 object to store the result into
  4966. * @returns the unmodified current Color3
  4967. */
  4968. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4969. /**
  4970. * Copy the current object
  4971. * @returns a new Color3 copied the current one
  4972. */
  4973. clone(): Color3;
  4974. /**
  4975. * Copies the rgb values from the source in the current Color3
  4976. * @param source defines the source Color3 object
  4977. * @returns the updated Color3 object
  4978. */
  4979. copyFrom(source: DeepImmutable<Color3>): Color3;
  4980. /**
  4981. * Updates the Color3 rgb values from the given floats
  4982. * @param r defines the red component to read from
  4983. * @param g defines the green component to read from
  4984. * @param b defines the blue component to read from
  4985. * @returns the current Color3 object
  4986. */
  4987. copyFromFloats(r: number, g: number, b: number): Color3;
  4988. /**
  4989. * Updates the Color3 rgb values from the given floats
  4990. * @param r defines the red component to read from
  4991. * @param g defines the green component to read from
  4992. * @param b defines the blue component to read from
  4993. * @returns the current Color3 object
  4994. */
  4995. set(r: number, g: number, b: number): Color3;
  4996. /**
  4997. * Compute the Color3 hexadecimal code as a string
  4998. * @returns a string containing the hexadecimal representation of the Color3 object
  4999. */
  5000. toHexString(): string;
  5001. /**
  5002. * Computes a new Color3 converted from the current one to linear space
  5003. * @returns a new Color3 object
  5004. */
  5005. toLinearSpace(): Color3;
  5006. /**
  5007. * Converts current color in rgb space to HSV values
  5008. * @returns a new color3 representing the HSV values
  5009. */
  5010. toHSV(): Color3;
  5011. /**
  5012. * Converts current color in rgb space to HSV values
  5013. * @param result defines the Color3 where to store the HSV values
  5014. */
  5015. toHSVToRef(result: Color3): void;
  5016. /**
  5017. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5018. * @param convertedColor defines the Color3 object where to store the linear space version
  5019. * @returns the unmodified Color3
  5020. */
  5021. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5022. /**
  5023. * Computes a new Color3 converted from the current one to gamma space
  5024. * @returns a new Color3 object
  5025. */
  5026. toGammaSpace(): Color3;
  5027. /**
  5028. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5029. * @param convertedColor defines the Color3 object where to store the gamma space version
  5030. * @returns the unmodified Color3
  5031. */
  5032. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5033. private static _BlackReadOnly;
  5034. /**
  5035. * Convert Hue, saturation and value to a Color3 (RGB)
  5036. * @param hue defines the hue
  5037. * @param saturation defines the saturation
  5038. * @param value defines the value
  5039. * @param result defines the Color3 where to store the RGB values
  5040. */
  5041. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5042. /**
  5043. * Creates a new Color3 from the string containing valid hexadecimal values
  5044. * @param hex defines a string containing valid hexadecimal values
  5045. * @returns a new Color3 object
  5046. */
  5047. static FromHexString(hex: string): Color3;
  5048. /**
  5049. * Creates a new Color3 from the starting index of the given array
  5050. * @param array defines the source array
  5051. * @param offset defines an offset in the source array
  5052. * @returns a new Color3 object
  5053. */
  5054. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5055. /**
  5056. * Creates a new Color3 from integer values (< 256)
  5057. * @param r defines the red component to read from (value between 0 and 255)
  5058. * @param g defines the green component to read from (value between 0 and 255)
  5059. * @param b defines the blue component to read from (value between 0 and 255)
  5060. * @returns a new Color3 object
  5061. */
  5062. static FromInts(r: number, g: number, b: number): Color3;
  5063. /**
  5064. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5065. * @param start defines the start Color3 value
  5066. * @param end defines the end Color3 value
  5067. * @param amount defines the gradient value between start and end
  5068. * @returns a new Color3 object
  5069. */
  5070. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5071. /**
  5072. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5073. * @param left defines the start value
  5074. * @param right defines the end value
  5075. * @param amount defines the gradient factor
  5076. * @param result defines the Color3 object where to store the result
  5077. */
  5078. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5079. /**
  5080. * Returns a Color3 value containing a red color
  5081. * @returns a new Color3 object
  5082. */
  5083. static Red(): Color3;
  5084. /**
  5085. * Returns a Color3 value containing a green color
  5086. * @returns a new Color3 object
  5087. */
  5088. static Green(): Color3;
  5089. /**
  5090. * Returns a Color3 value containing a blue color
  5091. * @returns a new Color3 object
  5092. */
  5093. static Blue(): Color3;
  5094. /**
  5095. * Returns a Color3 value containing a black color
  5096. * @returns a new Color3 object
  5097. */
  5098. static Black(): Color3;
  5099. /**
  5100. * Gets a Color3 value containing a black color that must not be updated
  5101. */
  5102. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5103. /**
  5104. * Returns a Color3 value containing a white color
  5105. * @returns a new Color3 object
  5106. */
  5107. static White(): Color3;
  5108. /**
  5109. * Returns a Color3 value containing a purple color
  5110. * @returns a new Color3 object
  5111. */
  5112. static Purple(): Color3;
  5113. /**
  5114. * Returns a Color3 value containing a magenta color
  5115. * @returns a new Color3 object
  5116. */
  5117. static Magenta(): Color3;
  5118. /**
  5119. * Returns a Color3 value containing a yellow color
  5120. * @returns a new Color3 object
  5121. */
  5122. static Yellow(): Color3;
  5123. /**
  5124. * Returns a Color3 value containing a gray color
  5125. * @returns a new Color3 object
  5126. */
  5127. static Gray(): Color3;
  5128. /**
  5129. * Returns a Color3 value containing a teal color
  5130. * @returns a new Color3 object
  5131. */
  5132. static Teal(): Color3;
  5133. /**
  5134. * Returns a Color3 value containing a random color
  5135. * @returns a new Color3 object
  5136. */
  5137. static Random(): Color3;
  5138. }
  5139. /**
  5140. * Class used to hold a RBGA color
  5141. */
  5142. export class Color4 {
  5143. /**
  5144. * Defines the red component (between 0 and 1, default is 0)
  5145. */
  5146. r: number;
  5147. /**
  5148. * Defines the green component (between 0 and 1, default is 0)
  5149. */
  5150. g: number;
  5151. /**
  5152. * Defines the blue component (between 0 and 1, default is 0)
  5153. */
  5154. b: number;
  5155. /**
  5156. * Defines the alpha component (between 0 and 1, default is 1)
  5157. */
  5158. a: number;
  5159. /**
  5160. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5161. * @param r defines the red component (between 0 and 1, default is 0)
  5162. * @param g defines the green component (between 0 and 1, default is 0)
  5163. * @param b defines the blue component (between 0 and 1, default is 0)
  5164. * @param a defines the alpha component (between 0 and 1, default is 1)
  5165. */
  5166. constructor(
  5167. /**
  5168. * Defines the red component (between 0 and 1, default is 0)
  5169. */
  5170. r?: number,
  5171. /**
  5172. * Defines the green component (between 0 and 1, default is 0)
  5173. */
  5174. g?: number,
  5175. /**
  5176. * Defines the blue component (between 0 and 1, default is 0)
  5177. */
  5178. b?: number,
  5179. /**
  5180. * Defines the alpha component (between 0 and 1, default is 1)
  5181. */
  5182. a?: number);
  5183. /**
  5184. * Adds in place the given Color4 values to the current Color4 object
  5185. * @param right defines the second operand
  5186. * @returns the current updated Color4 object
  5187. */
  5188. addInPlace(right: DeepImmutable<Color4>): Color4;
  5189. /**
  5190. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5191. * @returns the new array
  5192. */
  5193. asArray(): number[];
  5194. /**
  5195. * Stores from the starting index in the given array the Color4 successive values
  5196. * @param array defines the array where to store the r,g,b components
  5197. * @param index defines an optional index in the target array to define where to start storing values
  5198. * @returns the current Color4 object
  5199. */
  5200. toArray(array: number[], index?: number): Color4;
  5201. /**
  5202. * Determines equality between Color4 objects
  5203. * @param otherColor defines the second operand
  5204. * @returns true if the rgba values are equal to the given ones
  5205. */
  5206. equals(otherColor: DeepImmutable<Color4>): boolean;
  5207. /**
  5208. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5209. * @param right defines the second operand
  5210. * @returns a new Color4 object
  5211. */
  5212. add(right: DeepImmutable<Color4>): Color4;
  5213. /**
  5214. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5215. * @param right defines the second operand
  5216. * @returns a new Color4 object
  5217. */
  5218. subtract(right: DeepImmutable<Color4>): Color4;
  5219. /**
  5220. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5221. * @param right defines the second operand
  5222. * @param result defines the Color4 object where to store the result
  5223. * @returns the current Color4 object
  5224. */
  5225. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5226. /**
  5227. * Creates a new Color4 with the current Color4 values multiplied by scale
  5228. * @param scale defines the scaling factor to apply
  5229. * @returns a new Color4 object
  5230. */
  5231. scale(scale: number): Color4;
  5232. /**
  5233. * Multiplies the current Color4 values by scale and stores the result in "result"
  5234. * @param scale defines the scaling factor to apply
  5235. * @param result defines the Color4 object where to store the result
  5236. * @returns the current unmodified Color4
  5237. */
  5238. scaleToRef(scale: number, result: Color4): Color4;
  5239. /**
  5240. * Scale the current Color4 values by a factor and add the result to a given Color4
  5241. * @param scale defines the scale factor
  5242. * @param result defines the Color4 object where to store the result
  5243. * @returns the unmodified current Color4
  5244. */
  5245. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5246. /**
  5247. * Clamps the rgb values by the min and max values and stores the result into "result"
  5248. * @param min defines minimum clamping value (default is 0)
  5249. * @param max defines maximum clamping value (default is 1)
  5250. * @param result defines color to store the result into.
  5251. * @returns the cuurent Color4
  5252. */
  5253. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5254. /**
  5255. * Multipy an Color4 value by another and return a new Color4 object
  5256. * @param color defines the Color4 value to multiply by
  5257. * @returns a new Color4 object
  5258. */
  5259. multiply(color: Color4): Color4;
  5260. /**
  5261. * Multipy a Color4 value by another and push the result in a reference value
  5262. * @param color defines the Color4 value to multiply by
  5263. * @param result defines the Color4 to fill the result in
  5264. * @returns the result Color4
  5265. */
  5266. multiplyToRef(color: Color4, result: Color4): Color4;
  5267. /**
  5268. * Creates a string with the Color4 current values
  5269. * @returns the string representation of the Color4 object
  5270. */
  5271. toString(): string;
  5272. /**
  5273. * Returns the string "Color4"
  5274. * @returns "Color4"
  5275. */
  5276. getClassName(): string;
  5277. /**
  5278. * Compute the Color4 hash code
  5279. * @returns an unique number that can be used to hash Color4 objects
  5280. */
  5281. getHashCode(): number;
  5282. /**
  5283. * Creates a new Color4 copied from the current one
  5284. * @returns a new Color4 object
  5285. */
  5286. clone(): Color4;
  5287. /**
  5288. * Copies the given Color4 values into the current one
  5289. * @param source defines the source Color4 object
  5290. * @returns the current updated Color4 object
  5291. */
  5292. copyFrom(source: Color4): Color4;
  5293. /**
  5294. * Copies the given float values into the current one
  5295. * @param r defines the red component to read from
  5296. * @param g defines the green component to read from
  5297. * @param b defines the blue component to read from
  5298. * @param a defines the alpha component to read from
  5299. * @returns the current updated Color4 object
  5300. */
  5301. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5302. /**
  5303. * Copies the given float values into the current one
  5304. * @param r defines the red component to read from
  5305. * @param g defines the green component to read from
  5306. * @param b defines the blue component to read from
  5307. * @param a defines the alpha component to read from
  5308. * @returns the current updated Color4 object
  5309. */
  5310. set(r: number, g: number, b: number, a: number): Color4;
  5311. /**
  5312. * Compute the Color4 hexadecimal code as a string
  5313. * @returns a string containing the hexadecimal representation of the Color4 object
  5314. */
  5315. toHexString(): string;
  5316. /**
  5317. * Computes a new Color4 converted from the current one to linear space
  5318. * @returns a new Color4 object
  5319. */
  5320. toLinearSpace(): Color4;
  5321. /**
  5322. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5323. * @param convertedColor defines the Color4 object where to store the linear space version
  5324. * @returns the unmodified Color4
  5325. */
  5326. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5327. /**
  5328. * Computes a new Color4 converted from the current one to gamma space
  5329. * @returns a new Color4 object
  5330. */
  5331. toGammaSpace(): Color4;
  5332. /**
  5333. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5334. * @param convertedColor defines the Color4 object where to store the gamma space version
  5335. * @returns the unmodified Color4
  5336. */
  5337. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5338. /**
  5339. * Creates a new Color4 from the string containing valid hexadecimal values
  5340. * @param hex defines a string containing valid hexadecimal values
  5341. * @returns a new Color4 object
  5342. */
  5343. static FromHexString(hex: string): Color4;
  5344. /**
  5345. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5346. * @param left defines the start value
  5347. * @param right defines the end value
  5348. * @param amount defines the gradient factor
  5349. * @returns a new Color4 object
  5350. */
  5351. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5352. /**
  5353. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5354. * @param left defines the start value
  5355. * @param right defines the end value
  5356. * @param amount defines the gradient factor
  5357. * @param result defines the Color4 object where to store data
  5358. */
  5359. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5360. /**
  5361. * Creates a new Color4 from a Color3 and an alpha value
  5362. * @param color3 defines the source Color3 to read from
  5363. * @param alpha defines the alpha component (1.0 by default)
  5364. * @returns a new Color4 object
  5365. */
  5366. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5367. /**
  5368. * Creates a new Color4 from the starting index element of the given array
  5369. * @param array defines the source array to read from
  5370. * @param offset defines the offset in the source array
  5371. * @returns a new Color4 object
  5372. */
  5373. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5374. /**
  5375. * Creates a new Color3 from integer values (< 256)
  5376. * @param r defines the red component to read from (value between 0 and 255)
  5377. * @param g defines the green component to read from (value between 0 and 255)
  5378. * @param b defines the blue component to read from (value between 0 and 255)
  5379. * @param a defines the alpha component to read from (value between 0 and 255)
  5380. * @returns a new Color3 object
  5381. */
  5382. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5383. /**
  5384. * Check the content of a given array and convert it to an array containing RGBA data
  5385. * If the original array was already containing count * 4 values then it is returned directly
  5386. * @param colors defines the array to check
  5387. * @param count defines the number of RGBA data to expect
  5388. * @returns an array containing count * 4 values (RGBA)
  5389. */
  5390. static CheckColors4(colors: number[], count: number): number[];
  5391. }
  5392. /**
  5393. * @hidden
  5394. */
  5395. export class TmpColors {
  5396. static Color3: Color3[];
  5397. static Color4: Color4[];
  5398. }
  5399. }
  5400. declare module "babylonjs/Maths/sphericalPolynomial" {
  5401. import { Vector3 } from "babylonjs/Maths/math.vector";
  5402. import { Color3 } from "babylonjs/Maths/math.color";
  5403. /**
  5404. * Class representing spherical harmonics coefficients to the 3rd degree
  5405. */
  5406. export class SphericalHarmonics {
  5407. /**
  5408. * Defines whether or not the harmonics have been prescaled for rendering.
  5409. */
  5410. preScaled: boolean;
  5411. /**
  5412. * The l0,0 coefficients of the spherical harmonics
  5413. */
  5414. l00: Vector3;
  5415. /**
  5416. * The l1,-1 coefficients of the spherical harmonics
  5417. */
  5418. l1_1: Vector3;
  5419. /**
  5420. * The l1,0 coefficients of the spherical harmonics
  5421. */
  5422. l10: Vector3;
  5423. /**
  5424. * The l1,1 coefficients of the spherical harmonics
  5425. */
  5426. l11: Vector3;
  5427. /**
  5428. * The l2,-2 coefficients of the spherical harmonics
  5429. */
  5430. l2_2: Vector3;
  5431. /**
  5432. * The l2,-1 coefficients of the spherical harmonics
  5433. */
  5434. l2_1: Vector3;
  5435. /**
  5436. * The l2,0 coefficients of the spherical harmonics
  5437. */
  5438. l20: Vector3;
  5439. /**
  5440. * The l2,1 coefficients of the spherical harmonics
  5441. */
  5442. l21: Vector3;
  5443. /**
  5444. * The l2,2 coefficients of the spherical harmonics
  5445. */
  5446. l22: Vector3;
  5447. /**
  5448. * Adds a light to the spherical harmonics
  5449. * @param direction the direction of the light
  5450. * @param color the color of the light
  5451. * @param deltaSolidAngle the delta solid angle of the light
  5452. */
  5453. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5454. /**
  5455. * Scales the spherical harmonics by the given amount
  5456. * @param scale the amount to scale
  5457. */
  5458. scaleInPlace(scale: number): void;
  5459. /**
  5460. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5461. *
  5462. * ```
  5463. * E_lm = A_l * L_lm
  5464. * ```
  5465. *
  5466. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5467. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5468. * the scaling factors are given in equation 9.
  5469. */
  5470. convertIncidentRadianceToIrradiance(): void;
  5471. /**
  5472. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5473. *
  5474. * ```
  5475. * L = (1/pi) * E * rho
  5476. * ```
  5477. *
  5478. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5479. */
  5480. convertIrradianceToLambertianRadiance(): void;
  5481. /**
  5482. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5483. * required operations at run time.
  5484. *
  5485. * This is simply done by scaling back the SH with Ylm constants parameter.
  5486. * The trigonometric part being applied by the shader at run time.
  5487. */
  5488. preScaleForRendering(): void;
  5489. /**
  5490. * Constructs a spherical harmonics from an array.
  5491. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5492. * @returns the spherical harmonics
  5493. */
  5494. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5495. /**
  5496. * Gets the spherical harmonics from polynomial
  5497. * @param polynomial the spherical polynomial
  5498. * @returns the spherical harmonics
  5499. */
  5500. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5501. }
  5502. /**
  5503. * Class representing spherical polynomial coefficients to the 3rd degree
  5504. */
  5505. export class SphericalPolynomial {
  5506. private _harmonics;
  5507. /**
  5508. * The spherical harmonics used to create the polynomials.
  5509. */
  5510. readonly preScaledHarmonics: SphericalHarmonics;
  5511. /**
  5512. * The x coefficients of the spherical polynomial
  5513. */
  5514. x: Vector3;
  5515. /**
  5516. * The y coefficients of the spherical polynomial
  5517. */
  5518. y: Vector3;
  5519. /**
  5520. * The z coefficients of the spherical polynomial
  5521. */
  5522. z: Vector3;
  5523. /**
  5524. * The xx coefficients of the spherical polynomial
  5525. */
  5526. xx: Vector3;
  5527. /**
  5528. * The yy coefficients of the spherical polynomial
  5529. */
  5530. yy: Vector3;
  5531. /**
  5532. * The zz coefficients of the spherical polynomial
  5533. */
  5534. zz: Vector3;
  5535. /**
  5536. * The xy coefficients of the spherical polynomial
  5537. */
  5538. xy: Vector3;
  5539. /**
  5540. * The yz coefficients of the spherical polynomial
  5541. */
  5542. yz: Vector3;
  5543. /**
  5544. * The zx coefficients of the spherical polynomial
  5545. */
  5546. zx: Vector3;
  5547. /**
  5548. * Adds an ambient color to the spherical polynomial
  5549. * @param color the color to add
  5550. */
  5551. addAmbient(color: Color3): void;
  5552. /**
  5553. * Scales the spherical polynomial by the given amount
  5554. * @param scale the amount to scale
  5555. */
  5556. scaleInPlace(scale: number): void;
  5557. /**
  5558. * Gets the spherical polynomial from harmonics
  5559. * @param harmonics the spherical harmonics
  5560. * @returns the spherical polynomial
  5561. */
  5562. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5563. /**
  5564. * Constructs a spherical polynomial from an array.
  5565. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5566. * @returns the spherical polynomial
  5567. */
  5568. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5569. }
  5570. }
  5571. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  5572. /**
  5573. * Define options used to create a render target texture
  5574. */
  5575. export class RenderTargetCreationOptions {
  5576. /**
  5577. * Specifies is mipmaps must be generated
  5578. */
  5579. generateMipMaps?: boolean;
  5580. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5581. generateDepthBuffer?: boolean;
  5582. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5583. generateStencilBuffer?: boolean;
  5584. /** Defines texture type (int by default) */
  5585. type?: number;
  5586. /** Defines sampling mode (trilinear by default) */
  5587. samplingMode?: number;
  5588. /** Defines format (RGBA by default) */
  5589. format?: number;
  5590. }
  5591. }
  5592. declare module "babylonjs/States/alphaCullingState" {
  5593. /**
  5594. * @hidden
  5595. **/
  5596. export class _AlphaState {
  5597. private _isAlphaBlendDirty;
  5598. private _isBlendFunctionParametersDirty;
  5599. private _isBlendEquationParametersDirty;
  5600. private _isBlendConstantsDirty;
  5601. private _alphaBlend;
  5602. private _blendFunctionParameters;
  5603. private _blendEquationParameters;
  5604. private _blendConstants;
  5605. /**
  5606. * Initializes the state.
  5607. */
  5608. constructor();
  5609. readonly isDirty: boolean;
  5610. alphaBlend: boolean;
  5611. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  5612. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  5613. setAlphaEquationParameters(rgb: number, alpha: number): void;
  5614. reset(): void;
  5615. apply(gl: WebGLRenderingContext): void;
  5616. }
  5617. }
  5618. declare module "babylonjs/States/depthCullingState" {
  5619. import { Nullable } from "babylonjs/types";
  5620. /**
  5621. * @hidden
  5622. **/
  5623. export class _DepthCullingState {
  5624. private _isDepthTestDirty;
  5625. private _isDepthMaskDirty;
  5626. private _isDepthFuncDirty;
  5627. private _isCullFaceDirty;
  5628. private _isCullDirty;
  5629. private _isZOffsetDirty;
  5630. private _isFrontFaceDirty;
  5631. private _depthTest;
  5632. private _depthMask;
  5633. private _depthFunc;
  5634. private _cull;
  5635. private _cullFace;
  5636. private _zOffset;
  5637. private _frontFace;
  5638. /**
  5639. * Initializes the state.
  5640. */
  5641. constructor();
  5642. readonly isDirty: boolean;
  5643. zOffset: number;
  5644. cullFace: Nullable<number>;
  5645. cull: Nullable<boolean>;
  5646. depthFunc: Nullable<number>;
  5647. depthMask: boolean;
  5648. depthTest: boolean;
  5649. frontFace: Nullable<number>;
  5650. reset(): void;
  5651. apply(gl: WebGLRenderingContext): void;
  5652. }
  5653. }
  5654. declare module "babylonjs/States/stencilState" {
  5655. /**
  5656. * @hidden
  5657. **/
  5658. export class _StencilState {
  5659. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  5660. static readonly ALWAYS: number;
  5661. /** Passed to stencilOperation to specify that stencil value must be kept */
  5662. static readonly KEEP: number;
  5663. /** Passed to stencilOperation to specify that stencil value must be replaced */
  5664. static readonly REPLACE: number;
  5665. private _isStencilTestDirty;
  5666. private _isStencilMaskDirty;
  5667. private _isStencilFuncDirty;
  5668. private _isStencilOpDirty;
  5669. private _stencilTest;
  5670. private _stencilMask;
  5671. private _stencilFunc;
  5672. private _stencilFuncRef;
  5673. private _stencilFuncMask;
  5674. private _stencilOpStencilFail;
  5675. private _stencilOpDepthFail;
  5676. private _stencilOpStencilDepthPass;
  5677. readonly isDirty: boolean;
  5678. stencilFunc: number;
  5679. stencilFuncRef: number;
  5680. stencilFuncMask: number;
  5681. stencilOpStencilFail: number;
  5682. stencilOpDepthFail: number;
  5683. stencilOpStencilDepthPass: number;
  5684. stencilMask: number;
  5685. stencilTest: boolean;
  5686. constructor();
  5687. reset(): void;
  5688. apply(gl: WebGLRenderingContext): void;
  5689. }
  5690. }
  5691. declare module "babylonjs/States/index" {
  5692. export * from "babylonjs/States/alphaCullingState";
  5693. export * from "babylonjs/States/depthCullingState";
  5694. export * from "babylonjs/States/stencilState";
  5695. }
  5696. declare module "babylonjs/Instrumentation/timeToken" {
  5697. import { Nullable } from "babylonjs/types";
  5698. /**
  5699. * @hidden
  5700. **/
  5701. export class _TimeToken {
  5702. _startTimeQuery: Nullable<WebGLQuery>;
  5703. _endTimeQuery: Nullable<WebGLQuery>;
  5704. _timeElapsedQuery: Nullable<WebGLQuery>;
  5705. _timeElapsedQueryEnded: boolean;
  5706. }
  5707. }
  5708. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5709. /**
  5710. * Class used to evalaute queries containing `and` and `or` operators
  5711. */
  5712. export class AndOrNotEvaluator {
  5713. /**
  5714. * Evaluate a query
  5715. * @param query defines the query to evaluate
  5716. * @param evaluateCallback defines the callback used to filter result
  5717. * @returns true if the query matches
  5718. */
  5719. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5720. private static _HandleParenthesisContent;
  5721. private static _SimplifyNegation;
  5722. }
  5723. }
  5724. declare module "babylonjs/Misc/tags" {
  5725. /**
  5726. * Class used to store custom tags
  5727. */
  5728. export class Tags {
  5729. /**
  5730. * Adds support for tags on the given object
  5731. * @param obj defines the object to use
  5732. */
  5733. static EnableFor(obj: any): void;
  5734. /**
  5735. * Removes tags support
  5736. * @param obj defines the object to use
  5737. */
  5738. static DisableFor(obj: any): void;
  5739. /**
  5740. * Gets a boolean indicating if the given object has tags
  5741. * @param obj defines the object to use
  5742. * @returns a boolean
  5743. */
  5744. static HasTags(obj: any): boolean;
  5745. /**
  5746. * Gets the tags available on a given object
  5747. * @param obj defines the object to use
  5748. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5749. * @returns the tags
  5750. */
  5751. static GetTags(obj: any, asString?: boolean): any;
  5752. /**
  5753. * Adds tags to an object
  5754. * @param obj defines the object to use
  5755. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5756. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5757. */
  5758. static AddTagsTo(obj: any, tagsString: string): void;
  5759. /**
  5760. * @hidden
  5761. */
  5762. static _AddTagTo(obj: any, tag: string): void;
  5763. /**
  5764. * Removes specific tags from a specific object
  5765. * @param obj defines the object to use
  5766. * @param tagsString defines the tags to remove
  5767. */
  5768. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5769. /**
  5770. * @hidden
  5771. */
  5772. static _RemoveTagFrom(obj: any, tag: string): void;
  5773. /**
  5774. * Defines if tags hosted on an object match a given query
  5775. * @param obj defines the object to use
  5776. * @param tagsQuery defines the tag query
  5777. * @returns a boolean
  5778. */
  5779. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5780. }
  5781. }
  5782. declare module "babylonjs/Maths/math.path" {
  5783. import { DeepImmutable, Nullable } from "babylonjs/types";
  5784. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  5785. /**
  5786. * Defines potential orientation for back face culling
  5787. */
  5788. export enum Orientation {
  5789. /**
  5790. * Clockwise
  5791. */
  5792. CW = 0,
  5793. /** Counter clockwise */
  5794. CCW = 1
  5795. }
  5796. /** Class used to represent a Bezier curve */
  5797. export class BezierCurve {
  5798. /**
  5799. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5800. * @param t defines the time
  5801. * @param x1 defines the left coordinate on X axis
  5802. * @param y1 defines the left coordinate on Y axis
  5803. * @param x2 defines the right coordinate on X axis
  5804. * @param y2 defines the right coordinate on Y axis
  5805. * @returns the interpolated value
  5806. */
  5807. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5808. }
  5809. /**
  5810. * Defines angle representation
  5811. */
  5812. export class Angle {
  5813. private _radians;
  5814. /**
  5815. * Creates an Angle object of "radians" radians (float).
  5816. * @param radians the angle in radians
  5817. */
  5818. constructor(radians: number);
  5819. /**
  5820. * Get value in degrees
  5821. * @returns the Angle value in degrees (float)
  5822. */
  5823. degrees(): number;
  5824. /**
  5825. * Get value in radians
  5826. * @returns the Angle value in radians (float)
  5827. */
  5828. radians(): number;
  5829. /**
  5830. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  5831. * @param a defines first vector
  5832. * @param b defines second vector
  5833. * @returns a new Angle
  5834. */
  5835. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5836. /**
  5837. * Gets a new Angle object from the given float in radians
  5838. * @param radians defines the angle value in radians
  5839. * @returns a new Angle
  5840. */
  5841. static FromRadians(radians: number): Angle;
  5842. /**
  5843. * Gets a new Angle object from the given float in degrees
  5844. * @param degrees defines the angle value in degrees
  5845. * @returns a new Angle
  5846. */
  5847. static FromDegrees(degrees: number): Angle;
  5848. }
  5849. /**
  5850. * This represents an arc in a 2d space.
  5851. */
  5852. export class Arc2 {
  5853. /** Defines the start point of the arc */
  5854. startPoint: Vector2;
  5855. /** Defines the mid point of the arc */
  5856. midPoint: Vector2;
  5857. /** Defines the end point of the arc */
  5858. endPoint: Vector2;
  5859. /**
  5860. * Defines the center point of the arc.
  5861. */
  5862. centerPoint: Vector2;
  5863. /**
  5864. * Defines the radius of the arc.
  5865. */
  5866. radius: number;
  5867. /**
  5868. * Defines the angle of the arc (from mid point to end point).
  5869. */
  5870. angle: Angle;
  5871. /**
  5872. * Defines the start angle of the arc (from start point to middle point).
  5873. */
  5874. startAngle: Angle;
  5875. /**
  5876. * Defines the orientation of the arc (clock wise/counter clock wise).
  5877. */
  5878. orientation: Orientation;
  5879. /**
  5880. * Creates an Arc object from the three given points : start, middle and end.
  5881. * @param startPoint Defines the start point of the arc
  5882. * @param midPoint Defines the midlle point of the arc
  5883. * @param endPoint Defines the end point of the arc
  5884. */
  5885. constructor(
  5886. /** Defines the start point of the arc */
  5887. startPoint: Vector2,
  5888. /** Defines the mid point of the arc */
  5889. midPoint: Vector2,
  5890. /** Defines the end point of the arc */
  5891. endPoint: Vector2);
  5892. }
  5893. /**
  5894. * Represents a 2D path made up of multiple 2D points
  5895. */
  5896. export class Path2 {
  5897. private _points;
  5898. private _length;
  5899. /**
  5900. * If the path start and end point are the same
  5901. */
  5902. closed: boolean;
  5903. /**
  5904. * Creates a Path2 object from the starting 2D coordinates x and y.
  5905. * @param x the starting points x value
  5906. * @param y the starting points y value
  5907. */
  5908. constructor(x: number, y: number);
  5909. /**
  5910. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5911. * @param x the added points x value
  5912. * @param y the added points y value
  5913. * @returns the updated Path2.
  5914. */
  5915. addLineTo(x: number, y: number): Path2;
  5916. /**
  5917. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  5918. * @param midX middle point x value
  5919. * @param midY middle point y value
  5920. * @param endX end point x value
  5921. * @param endY end point y value
  5922. * @param numberOfSegments (default: 36)
  5923. * @returns the updated Path2.
  5924. */
  5925. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5926. /**
  5927. * Closes the Path2.
  5928. * @returns the Path2.
  5929. */
  5930. close(): Path2;
  5931. /**
  5932. * Gets the sum of the distance between each sequential point in the path
  5933. * @returns the Path2 total length (float).
  5934. */
  5935. length(): number;
  5936. /**
  5937. * Gets the points which construct the path
  5938. * @returns the Path2 internal array of points.
  5939. */
  5940. getPoints(): Vector2[];
  5941. /**
  5942. * Retreives the point at the distance aways from the starting point
  5943. * @param normalizedLengthPosition the length along the path to retreive the point from
  5944. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5945. */
  5946. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5947. /**
  5948. * Creates a new path starting from an x and y position
  5949. * @param x starting x value
  5950. * @param y starting y value
  5951. * @returns a new Path2 starting at the coordinates (x, y).
  5952. */
  5953. static StartingAt(x: number, y: number): Path2;
  5954. }
  5955. /**
  5956. * Represents a 3D path made up of multiple 3D points
  5957. */
  5958. export class Path3D {
  5959. /**
  5960. * an array of Vector3, the curve axis of the Path3D
  5961. */
  5962. path: Vector3[];
  5963. private _curve;
  5964. private _distances;
  5965. private _tangents;
  5966. private _normals;
  5967. private _binormals;
  5968. private _raw;
  5969. /**
  5970. * new Path3D(path, normal, raw)
  5971. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5972. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5973. * @param path an array of Vector3, the curve axis of the Path3D
  5974. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5975. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5976. */
  5977. constructor(
  5978. /**
  5979. * an array of Vector3, the curve axis of the Path3D
  5980. */
  5981. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  5982. /**
  5983. * Returns the Path3D array of successive Vector3 designing its curve.
  5984. * @returns the Path3D array of successive Vector3 designing its curve.
  5985. */
  5986. getCurve(): Vector3[];
  5987. /**
  5988. * Returns an array populated with tangent vectors on each Path3D curve point.
  5989. * @returns an array populated with tangent vectors on each Path3D curve point.
  5990. */
  5991. getTangents(): Vector3[];
  5992. /**
  5993. * Returns an array populated with normal vectors on each Path3D curve point.
  5994. * @returns an array populated with normal vectors on each Path3D curve point.
  5995. */
  5996. getNormals(): Vector3[];
  5997. /**
  5998. * Returns an array populated with binormal vectors on each Path3D curve point.
  5999. * @returns an array populated with binormal vectors on each Path3D curve point.
  6000. */
  6001. getBinormals(): Vector3[];
  6002. /**
  6003. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  6004. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  6005. */
  6006. getDistances(): number[];
  6007. /**
  6008. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  6009. * @param path path which all values are copied into the curves points
  6010. * @param firstNormal which should be projected onto the curve
  6011. * @returns the same object updated.
  6012. */
  6013. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  6014. private _compute;
  6015. private _getFirstNonNullVector;
  6016. private _getLastNonNullVector;
  6017. private _normalVector;
  6018. }
  6019. /**
  6020. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6021. * A Curve3 is designed from a series of successive Vector3.
  6022. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  6023. */
  6024. export class Curve3 {
  6025. private _points;
  6026. private _length;
  6027. /**
  6028. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  6029. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  6030. * @param v1 (Vector3) the control point
  6031. * @param v2 (Vector3) the end point of the Quadratic Bezier
  6032. * @param nbPoints (integer) the wanted number of points in the curve
  6033. * @returns the created Curve3
  6034. */
  6035. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6036. /**
  6037. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  6038. * @param v0 (Vector3) the origin point of the Cubic Bezier
  6039. * @param v1 (Vector3) the first control point
  6040. * @param v2 (Vector3) the second control point
  6041. * @param v3 (Vector3) the end point of the Cubic Bezier
  6042. * @param nbPoints (integer) the wanted number of points in the curve
  6043. * @returns the created Curve3
  6044. */
  6045. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6046. /**
  6047. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  6048. * @param p1 (Vector3) the origin point of the Hermite Spline
  6049. * @param t1 (Vector3) the tangent vector at the origin point
  6050. * @param p2 (Vector3) the end point of the Hermite Spline
  6051. * @param t2 (Vector3) the tangent vector at the end point
  6052. * @param nbPoints (integer) the wanted number of points in the curve
  6053. * @returns the created Curve3
  6054. */
  6055. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6056. /**
  6057. * Returns a Curve3 object along a CatmullRom Spline curve :
  6058. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  6059. * @param nbPoints (integer) the wanted number of points between each curve control points
  6060. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  6061. * @returns the created Curve3
  6062. */
  6063. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  6064. /**
  6065. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6066. * A Curve3 is designed from a series of successive Vector3.
  6067. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  6068. * @param points points which make up the curve
  6069. */
  6070. constructor(points: Vector3[]);
  6071. /**
  6072. * @returns the Curve3 stored array of successive Vector3
  6073. */
  6074. getPoints(): Vector3[];
  6075. /**
  6076. * @returns the computed length (float) of the curve.
  6077. */
  6078. length(): number;
  6079. /**
  6080. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  6081. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  6082. * curveA and curveB keep unchanged.
  6083. * @param curve the curve to continue from this curve
  6084. * @returns the newly constructed curve
  6085. */
  6086. continue(curve: DeepImmutable<Curve3>): Curve3;
  6087. private _computeLength;
  6088. }
  6089. }
  6090. declare module "babylonjs/Animations/easing" {
  6091. /**
  6092. * This represents the main contract an easing function should follow.
  6093. * Easing functions are used throughout the animation system.
  6094. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6095. */
  6096. export interface IEasingFunction {
  6097. /**
  6098. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6099. * of the easing function.
  6100. * The link below provides some of the most common examples of easing functions.
  6101. * @see https://easings.net/
  6102. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6103. * @returns the corresponding value on the curve defined by the easing function
  6104. */
  6105. ease(gradient: number): number;
  6106. }
  6107. /**
  6108. * Base class used for every default easing function.
  6109. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6110. */
  6111. export class EasingFunction implements IEasingFunction {
  6112. /**
  6113. * Interpolation follows the mathematical formula associated with the easing function.
  6114. */
  6115. static readonly EASINGMODE_EASEIN: number;
  6116. /**
  6117. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6118. */
  6119. static readonly EASINGMODE_EASEOUT: number;
  6120. /**
  6121. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6122. */
  6123. static readonly EASINGMODE_EASEINOUT: number;
  6124. private _easingMode;
  6125. /**
  6126. * Sets the easing mode of the current function.
  6127. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6128. */
  6129. setEasingMode(easingMode: number): void;
  6130. /**
  6131. * Gets the current easing mode.
  6132. * @returns the easing mode
  6133. */
  6134. getEasingMode(): number;
  6135. /**
  6136. * @hidden
  6137. */
  6138. easeInCore(gradient: number): number;
  6139. /**
  6140. * Given an input gradient between 0 and 1, this returns the corresponding value
  6141. * of the easing function.
  6142. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6143. * @returns the corresponding value on the curve defined by the easing function
  6144. */
  6145. ease(gradient: number): number;
  6146. }
  6147. /**
  6148. * Easing function with a circle shape (see link below).
  6149. * @see https://easings.net/#easeInCirc
  6150. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6151. */
  6152. export class CircleEase extends EasingFunction implements IEasingFunction {
  6153. /** @hidden */
  6154. easeInCore(gradient: number): number;
  6155. }
  6156. /**
  6157. * Easing function with a ease back shape (see link below).
  6158. * @see https://easings.net/#easeInBack
  6159. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6160. */
  6161. export class BackEase extends EasingFunction implements IEasingFunction {
  6162. /** Defines the amplitude of the function */
  6163. amplitude: number;
  6164. /**
  6165. * Instantiates a back ease easing
  6166. * @see https://easings.net/#easeInBack
  6167. * @param amplitude Defines the amplitude of the function
  6168. */
  6169. constructor(
  6170. /** Defines the amplitude of the function */
  6171. amplitude?: number);
  6172. /** @hidden */
  6173. easeInCore(gradient: number): number;
  6174. }
  6175. /**
  6176. * Easing function with a bouncing shape (see link below).
  6177. * @see https://easings.net/#easeInBounce
  6178. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6179. */
  6180. export class BounceEase extends EasingFunction implements IEasingFunction {
  6181. /** Defines the number of bounces */
  6182. bounces: number;
  6183. /** Defines the amplitude of the bounce */
  6184. bounciness: number;
  6185. /**
  6186. * Instantiates a bounce easing
  6187. * @see https://easings.net/#easeInBounce
  6188. * @param bounces Defines the number of bounces
  6189. * @param bounciness Defines the amplitude of the bounce
  6190. */
  6191. constructor(
  6192. /** Defines the number of bounces */
  6193. bounces?: number,
  6194. /** Defines the amplitude of the bounce */
  6195. bounciness?: number);
  6196. /** @hidden */
  6197. easeInCore(gradient: number): number;
  6198. }
  6199. /**
  6200. * Easing function with a power of 3 shape (see link below).
  6201. * @see https://easings.net/#easeInCubic
  6202. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6203. */
  6204. export class CubicEase extends EasingFunction implements IEasingFunction {
  6205. /** @hidden */
  6206. easeInCore(gradient: number): number;
  6207. }
  6208. /**
  6209. * Easing function with an elastic shape (see link below).
  6210. * @see https://easings.net/#easeInElastic
  6211. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6212. */
  6213. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6214. /** Defines the number of oscillations*/
  6215. oscillations: number;
  6216. /** Defines the amplitude of the oscillations*/
  6217. springiness: number;
  6218. /**
  6219. * Instantiates an elastic easing function
  6220. * @see https://easings.net/#easeInElastic
  6221. * @param oscillations Defines the number of oscillations
  6222. * @param springiness Defines the amplitude of the oscillations
  6223. */
  6224. constructor(
  6225. /** Defines the number of oscillations*/
  6226. oscillations?: number,
  6227. /** Defines the amplitude of the oscillations*/
  6228. springiness?: number);
  6229. /** @hidden */
  6230. easeInCore(gradient: number): number;
  6231. }
  6232. /**
  6233. * Easing function with an exponential shape (see link below).
  6234. * @see https://easings.net/#easeInExpo
  6235. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6236. */
  6237. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6238. /** Defines the exponent of the function */
  6239. exponent: number;
  6240. /**
  6241. * Instantiates an exponential easing function
  6242. * @see https://easings.net/#easeInExpo
  6243. * @param exponent Defines the exponent of the function
  6244. */
  6245. constructor(
  6246. /** Defines the exponent of the function */
  6247. exponent?: number);
  6248. /** @hidden */
  6249. easeInCore(gradient: number): number;
  6250. }
  6251. /**
  6252. * Easing function with a power shape (see link below).
  6253. * @see https://easings.net/#easeInQuad
  6254. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6255. */
  6256. export class PowerEase extends EasingFunction implements IEasingFunction {
  6257. /** Defines the power of the function */
  6258. power: number;
  6259. /**
  6260. * Instantiates an power base easing function
  6261. * @see https://easings.net/#easeInQuad
  6262. * @param power Defines the power of the function
  6263. */
  6264. constructor(
  6265. /** Defines the power of the function */
  6266. power?: number);
  6267. /** @hidden */
  6268. easeInCore(gradient: number): number;
  6269. }
  6270. /**
  6271. * Easing function with a power of 2 shape (see link below).
  6272. * @see https://easings.net/#easeInQuad
  6273. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6274. */
  6275. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6276. /** @hidden */
  6277. easeInCore(gradient: number): number;
  6278. }
  6279. /**
  6280. * Easing function with a power of 4 shape (see link below).
  6281. * @see https://easings.net/#easeInQuart
  6282. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6283. */
  6284. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6285. /** @hidden */
  6286. easeInCore(gradient: number): number;
  6287. }
  6288. /**
  6289. * Easing function with a power of 5 shape (see link below).
  6290. * @see https://easings.net/#easeInQuint
  6291. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6292. */
  6293. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6294. /** @hidden */
  6295. easeInCore(gradient: number): number;
  6296. }
  6297. /**
  6298. * Easing function with a sin shape (see link below).
  6299. * @see https://easings.net/#easeInSine
  6300. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6301. */
  6302. export class SineEase extends EasingFunction implements IEasingFunction {
  6303. /** @hidden */
  6304. easeInCore(gradient: number): number;
  6305. }
  6306. /**
  6307. * Easing function with a bezier shape (see link below).
  6308. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6309. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6310. */
  6311. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6312. /** Defines the x component of the start tangent in the bezier curve */
  6313. x1: number;
  6314. /** Defines the y component of the start tangent in the bezier curve */
  6315. y1: number;
  6316. /** Defines the x component of the end tangent in the bezier curve */
  6317. x2: number;
  6318. /** Defines the y component of the end tangent in the bezier curve */
  6319. y2: number;
  6320. /**
  6321. * Instantiates a bezier function
  6322. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6323. * @param x1 Defines the x component of the start tangent in the bezier curve
  6324. * @param y1 Defines the y component of the start tangent in the bezier curve
  6325. * @param x2 Defines the x component of the end tangent in the bezier curve
  6326. * @param y2 Defines the y component of the end tangent in the bezier curve
  6327. */
  6328. constructor(
  6329. /** Defines the x component of the start tangent in the bezier curve */
  6330. x1?: number,
  6331. /** Defines the y component of the start tangent in the bezier curve */
  6332. y1?: number,
  6333. /** Defines the x component of the end tangent in the bezier curve */
  6334. x2?: number,
  6335. /** Defines the y component of the end tangent in the bezier curve */
  6336. y2?: number);
  6337. /** @hidden */
  6338. easeInCore(gradient: number): number;
  6339. }
  6340. }
  6341. declare module "babylonjs/Animations/animationKey" {
  6342. /**
  6343. * Defines an interface which represents an animation key frame
  6344. */
  6345. export interface IAnimationKey {
  6346. /**
  6347. * Frame of the key frame
  6348. */
  6349. frame: number;
  6350. /**
  6351. * Value at the specifies key frame
  6352. */
  6353. value: any;
  6354. /**
  6355. * The input tangent for the cubic hermite spline
  6356. */
  6357. inTangent?: any;
  6358. /**
  6359. * The output tangent for the cubic hermite spline
  6360. */
  6361. outTangent?: any;
  6362. /**
  6363. * The animation interpolation type
  6364. */
  6365. interpolation?: AnimationKeyInterpolation;
  6366. }
  6367. /**
  6368. * Enum for the animation key frame interpolation type
  6369. */
  6370. export enum AnimationKeyInterpolation {
  6371. /**
  6372. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6373. */
  6374. STEP = 1
  6375. }
  6376. }
  6377. declare module "babylonjs/Animations/animationRange" {
  6378. /**
  6379. * Represents the range of an animation
  6380. */
  6381. export class AnimationRange {
  6382. /**The name of the animation range**/
  6383. name: string;
  6384. /**The starting frame of the animation */
  6385. from: number;
  6386. /**The ending frame of the animation*/
  6387. to: number;
  6388. /**
  6389. * Initializes the range of an animation
  6390. * @param name The name of the animation range
  6391. * @param from The starting frame of the animation
  6392. * @param to The ending frame of the animation
  6393. */
  6394. constructor(
  6395. /**The name of the animation range**/
  6396. name: string,
  6397. /**The starting frame of the animation */
  6398. from: number,
  6399. /**The ending frame of the animation*/
  6400. to: number);
  6401. /**
  6402. * Makes a copy of the animation range
  6403. * @returns A copy of the animation range
  6404. */
  6405. clone(): AnimationRange;
  6406. }
  6407. }
  6408. declare module "babylonjs/Animations/animationEvent" {
  6409. /**
  6410. * Composed of a frame, and an action function
  6411. */
  6412. export class AnimationEvent {
  6413. /** The frame for which the event is triggered **/
  6414. frame: number;
  6415. /** The event to perform when triggered **/
  6416. action: (currentFrame: number) => void;
  6417. /** Specifies if the event should be triggered only once**/
  6418. onlyOnce?: boolean | undefined;
  6419. /**
  6420. * Specifies if the animation event is done
  6421. */
  6422. isDone: boolean;
  6423. /**
  6424. * Initializes the animation event
  6425. * @param frame The frame for which the event is triggered
  6426. * @param action The event to perform when triggered
  6427. * @param onlyOnce Specifies if the event should be triggered only once
  6428. */
  6429. constructor(
  6430. /** The frame for which the event is triggered **/
  6431. frame: number,
  6432. /** The event to perform when triggered **/
  6433. action: (currentFrame: number) => void,
  6434. /** Specifies if the event should be triggered only once**/
  6435. onlyOnce?: boolean | undefined);
  6436. /** @hidden */
  6437. _clone(): AnimationEvent;
  6438. }
  6439. }
  6440. declare module "babylonjs/Behaviors/behavior" {
  6441. import { Nullable } from "babylonjs/types";
  6442. /**
  6443. * Interface used to define a behavior
  6444. */
  6445. export interface Behavior<T> {
  6446. /** gets or sets behavior's name */
  6447. name: string;
  6448. /**
  6449. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6450. */
  6451. init(): void;
  6452. /**
  6453. * Called when the behavior is attached to a target
  6454. * @param target defines the target where the behavior is attached to
  6455. */
  6456. attach(target: T): void;
  6457. /**
  6458. * Called when the behavior is detached from its target
  6459. */
  6460. detach(): void;
  6461. }
  6462. /**
  6463. * Interface implemented by classes supporting behaviors
  6464. */
  6465. export interface IBehaviorAware<T> {
  6466. /**
  6467. * Attach a behavior
  6468. * @param behavior defines the behavior to attach
  6469. * @returns the current host
  6470. */
  6471. addBehavior(behavior: Behavior<T>): T;
  6472. /**
  6473. * Remove a behavior from the current object
  6474. * @param behavior defines the behavior to detach
  6475. * @returns the current host
  6476. */
  6477. removeBehavior(behavior: Behavior<T>): T;
  6478. /**
  6479. * Gets a behavior using its name to search
  6480. * @param name defines the name to search
  6481. * @returns the behavior or null if not found
  6482. */
  6483. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6484. }
  6485. }
  6486. declare module "babylonjs/Misc/smartArray" {
  6487. /**
  6488. * Defines an array and its length.
  6489. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6490. */
  6491. export interface ISmartArrayLike<T> {
  6492. /**
  6493. * The data of the array.
  6494. */
  6495. data: Array<T>;
  6496. /**
  6497. * The active length of the array.
  6498. */
  6499. length: number;
  6500. }
  6501. /**
  6502. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6503. */
  6504. export class SmartArray<T> implements ISmartArrayLike<T> {
  6505. /**
  6506. * The full set of data from the array.
  6507. */
  6508. data: Array<T>;
  6509. /**
  6510. * The active length of the array.
  6511. */
  6512. length: number;
  6513. protected _id: number;
  6514. /**
  6515. * Instantiates a Smart Array.
  6516. * @param capacity defines the default capacity of the array.
  6517. */
  6518. constructor(capacity: number);
  6519. /**
  6520. * Pushes a value at the end of the active data.
  6521. * @param value defines the object to push in the array.
  6522. */
  6523. push(value: T): void;
  6524. /**
  6525. * Iterates over the active data and apply the lambda to them.
  6526. * @param func defines the action to apply on each value.
  6527. */
  6528. forEach(func: (content: T) => void): void;
  6529. /**
  6530. * Sorts the full sets of data.
  6531. * @param compareFn defines the comparison function to apply.
  6532. */
  6533. sort(compareFn: (a: T, b: T) => number): void;
  6534. /**
  6535. * Resets the active data to an empty array.
  6536. */
  6537. reset(): void;
  6538. /**
  6539. * Releases all the data from the array as well as the array.
  6540. */
  6541. dispose(): void;
  6542. /**
  6543. * Concats the active data with a given array.
  6544. * @param array defines the data to concatenate with.
  6545. */
  6546. concat(array: any): void;
  6547. /**
  6548. * Returns the position of a value in the active data.
  6549. * @param value defines the value to find the index for
  6550. * @returns the index if found in the active data otherwise -1
  6551. */
  6552. indexOf(value: T): number;
  6553. /**
  6554. * Returns whether an element is part of the active data.
  6555. * @param value defines the value to look for
  6556. * @returns true if found in the active data otherwise false
  6557. */
  6558. contains(value: T): boolean;
  6559. private static _GlobalId;
  6560. }
  6561. /**
  6562. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6563. * The data in this array can only be present once
  6564. */
  6565. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6566. private _duplicateId;
  6567. /**
  6568. * Pushes a value at the end of the active data.
  6569. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6570. * @param value defines the object to push in the array.
  6571. */
  6572. push(value: T): void;
  6573. /**
  6574. * Pushes a value at the end of the active data.
  6575. * If the data is already present, it won t be added again
  6576. * @param value defines the object to push in the array.
  6577. * @returns true if added false if it was already present
  6578. */
  6579. pushNoDuplicate(value: T): boolean;
  6580. /**
  6581. * Resets the active data to an empty array.
  6582. */
  6583. reset(): void;
  6584. /**
  6585. * Concats the active data with a given array.
  6586. * This ensures no dupplicate will be present in the result.
  6587. * @param array defines the data to concatenate with.
  6588. */
  6589. concatWithNoDuplicate(array: any): void;
  6590. }
  6591. }
  6592. declare module "babylonjs/Cameras/cameraInputsManager" {
  6593. import { Nullable } from "babylonjs/types";
  6594. import { Camera } from "babylonjs/Cameras/camera";
  6595. /**
  6596. * @ignore
  6597. * This is a list of all the different input types that are available in the application.
  6598. * Fo instance: ArcRotateCameraGamepadInput...
  6599. */
  6600. export var CameraInputTypes: {};
  6601. /**
  6602. * This is the contract to implement in order to create a new input class.
  6603. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6604. */
  6605. export interface ICameraInput<TCamera extends Camera> {
  6606. /**
  6607. * Defines the camera the input is attached to.
  6608. */
  6609. camera: Nullable<TCamera>;
  6610. /**
  6611. * Gets the class name of the current intput.
  6612. * @returns the class name
  6613. */
  6614. getClassName(): string;
  6615. /**
  6616. * Get the friendly name associated with the input class.
  6617. * @returns the input friendly name
  6618. */
  6619. getSimpleName(): string;
  6620. /**
  6621. * Attach the input controls to a specific dom element to get the input from.
  6622. * @param element Defines the element the controls should be listened from
  6623. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6624. */
  6625. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6626. /**
  6627. * Detach the current controls from the specified dom element.
  6628. * @param element Defines the element to stop listening the inputs from
  6629. */
  6630. detachControl(element: Nullable<HTMLElement>): void;
  6631. /**
  6632. * Update the current camera state depending on the inputs that have been used this frame.
  6633. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6634. */
  6635. checkInputs?: () => void;
  6636. }
  6637. /**
  6638. * Represents a map of input types to input instance or input index to input instance.
  6639. */
  6640. export interface CameraInputsMap<TCamera extends Camera> {
  6641. /**
  6642. * Accessor to the input by input type.
  6643. */
  6644. [name: string]: ICameraInput<TCamera>;
  6645. /**
  6646. * Accessor to the input by input index.
  6647. */
  6648. [idx: number]: ICameraInput<TCamera>;
  6649. }
  6650. /**
  6651. * This represents the input manager used within a camera.
  6652. * It helps dealing with all the different kind of input attached to a camera.
  6653. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6654. */
  6655. export class CameraInputsManager<TCamera extends Camera> {
  6656. /**
  6657. * Defines the list of inputs attahed to the camera.
  6658. */
  6659. attached: CameraInputsMap<TCamera>;
  6660. /**
  6661. * Defines the dom element the camera is collecting inputs from.
  6662. * This is null if the controls have not been attached.
  6663. */
  6664. attachedElement: Nullable<HTMLElement>;
  6665. /**
  6666. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6667. */
  6668. noPreventDefault: boolean;
  6669. /**
  6670. * Defined the camera the input manager belongs to.
  6671. */
  6672. camera: TCamera;
  6673. /**
  6674. * Update the current camera state depending on the inputs that have been used this frame.
  6675. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6676. */
  6677. checkInputs: () => void;
  6678. /**
  6679. * Instantiate a new Camera Input Manager.
  6680. * @param camera Defines the camera the input manager blongs to
  6681. */
  6682. constructor(camera: TCamera);
  6683. /**
  6684. * Add an input method to a camera
  6685. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6686. * @param input camera input method
  6687. */
  6688. add(input: ICameraInput<TCamera>): void;
  6689. /**
  6690. * Remove a specific input method from a camera
  6691. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6692. * @param inputToRemove camera input method
  6693. */
  6694. remove(inputToRemove: ICameraInput<TCamera>): void;
  6695. /**
  6696. * Remove a specific input type from a camera
  6697. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6698. * @param inputType the type of the input to remove
  6699. */
  6700. removeByType(inputType: string): void;
  6701. private _addCheckInputs;
  6702. /**
  6703. * Attach the input controls to the currently attached dom element to listen the events from.
  6704. * @param input Defines the input to attach
  6705. */
  6706. attachInput(input: ICameraInput<TCamera>): void;
  6707. /**
  6708. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6709. * @param element Defines the dom element to collect the events from
  6710. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6711. */
  6712. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6713. /**
  6714. * Detach the current manager inputs controls from a specific dom element.
  6715. * @param element Defines the dom element to collect the events from
  6716. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6717. */
  6718. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6719. /**
  6720. * Rebuild the dynamic inputCheck function from the current list of
  6721. * defined inputs in the manager.
  6722. */
  6723. rebuildInputCheck(): void;
  6724. /**
  6725. * Remove all attached input methods from a camera
  6726. */
  6727. clear(): void;
  6728. /**
  6729. * Serialize the current input manager attached to a camera.
  6730. * This ensures than once parsed,
  6731. * the input associated to the camera will be identical to the current ones
  6732. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6733. */
  6734. serialize(serializedCamera: any): void;
  6735. /**
  6736. * Parses an input manager serialized JSON to restore the previous list of inputs
  6737. * and states associated to a camera.
  6738. * @param parsedCamera Defines the JSON to parse
  6739. */
  6740. parse(parsedCamera: any): void;
  6741. }
  6742. }
  6743. declare module "babylonjs/Collisions/intersectionInfo" {
  6744. import { Nullable } from "babylonjs/types";
  6745. /**
  6746. * @hidden
  6747. */
  6748. export class IntersectionInfo {
  6749. bu: Nullable<number>;
  6750. bv: Nullable<number>;
  6751. distance: number;
  6752. faceId: number;
  6753. subMeshId: number;
  6754. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6755. }
  6756. }
  6757. declare module "babylonjs/Maths/math.plane" {
  6758. import { DeepImmutable } from "babylonjs/types";
  6759. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6760. /**
  6761. * Represens a plane by the equation ax + by + cz + d = 0
  6762. */
  6763. export class Plane {
  6764. private static _TmpMatrix;
  6765. /**
  6766. * Normal of the plane (a,b,c)
  6767. */
  6768. normal: Vector3;
  6769. /**
  6770. * d component of the plane
  6771. */
  6772. d: number;
  6773. /**
  6774. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6775. * @param a a component of the plane
  6776. * @param b b component of the plane
  6777. * @param c c component of the plane
  6778. * @param d d component of the plane
  6779. */
  6780. constructor(a: number, b: number, c: number, d: number);
  6781. /**
  6782. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6783. */
  6784. asArray(): number[];
  6785. /**
  6786. * @returns a new plane copied from the current Plane.
  6787. */
  6788. clone(): Plane;
  6789. /**
  6790. * @returns the string "Plane".
  6791. */
  6792. getClassName(): string;
  6793. /**
  6794. * @returns the Plane hash code.
  6795. */
  6796. getHashCode(): number;
  6797. /**
  6798. * Normalize the current Plane in place.
  6799. * @returns the updated Plane.
  6800. */
  6801. normalize(): Plane;
  6802. /**
  6803. * Applies a transformation the plane and returns the result
  6804. * @param transformation the transformation matrix to be applied to the plane
  6805. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6806. */
  6807. transform(transformation: DeepImmutable<Matrix>): Plane;
  6808. /**
  6809. * Calcualtte the dot product between the point and the plane normal
  6810. * @param point point to calculate the dot product with
  6811. * @returns the dot product (float) of the point coordinates and the plane normal.
  6812. */
  6813. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6814. /**
  6815. * Updates the current Plane from the plane defined by the three given points.
  6816. * @param point1 one of the points used to contruct the plane
  6817. * @param point2 one of the points used to contruct the plane
  6818. * @param point3 one of the points used to contruct the plane
  6819. * @returns the updated Plane.
  6820. */
  6821. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6822. /**
  6823. * Checks if the plane is facing a given direction
  6824. * @param direction the direction to check if the plane is facing
  6825. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6826. * @returns True is the vector "direction" is the same side than the plane normal.
  6827. */
  6828. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6829. /**
  6830. * Calculates the distance to a point
  6831. * @param point point to calculate distance to
  6832. * @returns the signed distance (float) from the given point to the Plane.
  6833. */
  6834. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6835. /**
  6836. * Creates a plane from an array
  6837. * @param array the array to create a plane from
  6838. * @returns a new Plane from the given array.
  6839. */
  6840. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6841. /**
  6842. * Creates a plane from three points
  6843. * @param point1 point used to create the plane
  6844. * @param point2 point used to create the plane
  6845. * @param point3 point used to create the plane
  6846. * @returns a new Plane defined by the three given points.
  6847. */
  6848. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6849. /**
  6850. * Creates a plane from an origin point and a normal
  6851. * @param origin origin of the plane to be constructed
  6852. * @param normal normal of the plane to be constructed
  6853. * @returns a new Plane the normal vector to this plane at the given origin point.
  6854. * Note : the vector "normal" is updated because normalized.
  6855. */
  6856. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6857. /**
  6858. * Calculates the distance from a plane and a point
  6859. * @param origin origin of the plane to be constructed
  6860. * @param normal normal of the plane to be constructed
  6861. * @param point point to calculate distance to
  6862. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6863. */
  6864. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6865. }
  6866. }
  6867. declare module "babylonjs/Culling/boundingSphere" {
  6868. import { DeepImmutable } from "babylonjs/types";
  6869. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6870. import { Plane } from "babylonjs/Maths/math.plane";
  6871. /**
  6872. * Class used to store bounding sphere information
  6873. */
  6874. export class BoundingSphere {
  6875. /**
  6876. * Gets the center of the bounding sphere in local space
  6877. */
  6878. readonly center: Vector3;
  6879. /**
  6880. * Radius of the bounding sphere in local space
  6881. */
  6882. radius: number;
  6883. /**
  6884. * Gets the center of the bounding sphere in world space
  6885. */
  6886. readonly centerWorld: Vector3;
  6887. /**
  6888. * Radius of the bounding sphere in world space
  6889. */
  6890. radiusWorld: number;
  6891. /**
  6892. * Gets the minimum vector in local space
  6893. */
  6894. readonly minimum: Vector3;
  6895. /**
  6896. * Gets the maximum vector in local space
  6897. */
  6898. readonly maximum: Vector3;
  6899. private _worldMatrix;
  6900. private static readonly TmpVector3;
  6901. /**
  6902. * Creates a new bounding sphere
  6903. * @param min defines the minimum vector (in local space)
  6904. * @param max defines the maximum vector (in local space)
  6905. * @param worldMatrix defines the new world matrix
  6906. */
  6907. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6908. /**
  6909. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6910. * @param min defines the new minimum vector (in local space)
  6911. * @param max defines the new maximum vector (in local space)
  6912. * @param worldMatrix defines the new world matrix
  6913. */
  6914. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6915. /**
  6916. * Scale the current bounding sphere by applying a scale factor
  6917. * @param factor defines the scale factor to apply
  6918. * @returns the current bounding box
  6919. */
  6920. scale(factor: number): BoundingSphere;
  6921. /**
  6922. * Gets the world matrix of the bounding box
  6923. * @returns a matrix
  6924. */
  6925. getWorldMatrix(): DeepImmutable<Matrix>;
  6926. /** @hidden */
  6927. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6928. /**
  6929. * Tests if the bounding sphere is intersecting the frustum planes
  6930. * @param frustumPlanes defines the frustum planes to test
  6931. * @returns true if there is an intersection
  6932. */
  6933. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6934. /**
  6935. * Tests if the bounding sphere center is in between the frustum planes.
  6936. * Used for optimistic fast inclusion.
  6937. * @param frustumPlanes defines the frustum planes to test
  6938. * @returns true if the sphere center is in between the frustum planes
  6939. */
  6940. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6941. /**
  6942. * Tests if a point is inside the bounding sphere
  6943. * @param point defines the point to test
  6944. * @returns true if the point is inside the bounding sphere
  6945. */
  6946. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6947. /**
  6948. * Checks if two sphere intersct
  6949. * @param sphere0 sphere 0
  6950. * @param sphere1 sphere 1
  6951. * @returns true if the speres intersect
  6952. */
  6953. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6954. }
  6955. }
  6956. declare module "babylonjs/Culling/boundingBox" {
  6957. import { DeepImmutable } from "babylonjs/types";
  6958. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6959. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6960. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6961. import { Plane } from "babylonjs/Maths/math.plane";
  6962. /**
  6963. * Class used to store bounding box information
  6964. */
  6965. export class BoundingBox implements ICullable {
  6966. /**
  6967. * Gets the 8 vectors representing the bounding box in local space
  6968. */
  6969. readonly vectors: Vector3[];
  6970. /**
  6971. * Gets the center of the bounding box in local space
  6972. */
  6973. readonly center: Vector3;
  6974. /**
  6975. * Gets the center of the bounding box in world space
  6976. */
  6977. readonly centerWorld: Vector3;
  6978. /**
  6979. * Gets the extend size in local space
  6980. */
  6981. readonly extendSize: Vector3;
  6982. /**
  6983. * Gets the extend size in world space
  6984. */
  6985. readonly extendSizeWorld: Vector3;
  6986. /**
  6987. * Gets the OBB (object bounding box) directions
  6988. */
  6989. readonly directions: Vector3[];
  6990. /**
  6991. * Gets the 8 vectors representing the bounding box in world space
  6992. */
  6993. readonly vectorsWorld: Vector3[];
  6994. /**
  6995. * Gets the minimum vector in world space
  6996. */
  6997. readonly minimumWorld: Vector3;
  6998. /**
  6999. * Gets the maximum vector in world space
  7000. */
  7001. readonly maximumWorld: Vector3;
  7002. /**
  7003. * Gets the minimum vector in local space
  7004. */
  7005. readonly minimum: Vector3;
  7006. /**
  7007. * Gets the maximum vector in local space
  7008. */
  7009. readonly maximum: Vector3;
  7010. private _worldMatrix;
  7011. private static readonly TmpVector3;
  7012. /**
  7013. * @hidden
  7014. */
  7015. _tag: number;
  7016. /**
  7017. * Creates a new bounding box
  7018. * @param min defines the minimum vector (in local space)
  7019. * @param max defines the maximum vector (in local space)
  7020. * @param worldMatrix defines the new world matrix
  7021. */
  7022. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7023. /**
  7024. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7025. * @param min defines the new minimum vector (in local space)
  7026. * @param max defines the new maximum vector (in local space)
  7027. * @param worldMatrix defines the new world matrix
  7028. */
  7029. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7030. /**
  7031. * Scale the current bounding box by applying a scale factor
  7032. * @param factor defines the scale factor to apply
  7033. * @returns the current bounding box
  7034. */
  7035. scale(factor: number): BoundingBox;
  7036. /**
  7037. * Gets the world matrix of the bounding box
  7038. * @returns a matrix
  7039. */
  7040. getWorldMatrix(): DeepImmutable<Matrix>;
  7041. /** @hidden */
  7042. _update(world: DeepImmutable<Matrix>): void;
  7043. /**
  7044. * Tests if the bounding box is intersecting the frustum planes
  7045. * @param frustumPlanes defines the frustum planes to test
  7046. * @returns true if there is an intersection
  7047. */
  7048. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7049. /**
  7050. * Tests if the bounding box is entirely inside the frustum planes
  7051. * @param frustumPlanes defines the frustum planes to test
  7052. * @returns true if there is an inclusion
  7053. */
  7054. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7055. /**
  7056. * Tests if a point is inside the bounding box
  7057. * @param point defines the point to test
  7058. * @returns true if the point is inside the bounding box
  7059. */
  7060. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7061. /**
  7062. * Tests if the bounding box intersects with a bounding sphere
  7063. * @param sphere defines the sphere to test
  7064. * @returns true if there is an intersection
  7065. */
  7066. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7067. /**
  7068. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7069. * @param min defines the min vector to use
  7070. * @param max defines the max vector to use
  7071. * @returns true if there is an intersection
  7072. */
  7073. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7074. /**
  7075. * Tests if two bounding boxes are intersections
  7076. * @param box0 defines the first box to test
  7077. * @param box1 defines the second box to test
  7078. * @returns true if there is an intersection
  7079. */
  7080. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7081. /**
  7082. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7083. * @param minPoint defines the minimum vector of the bounding box
  7084. * @param maxPoint defines the maximum vector of the bounding box
  7085. * @param sphereCenter defines the sphere center
  7086. * @param sphereRadius defines the sphere radius
  7087. * @returns true if there is an intersection
  7088. */
  7089. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7090. /**
  7091. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7092. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7093. * @param frustumPlanes defines the frustum planes to test
  7094. * @return true if there is an inclusion
  7095. */
  7096. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7097. /**
  7098. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7099. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7100. * @param frustumPlanes defines the frustum planes to test
  7101. * @return true if there is an intersection
  7102. */
  7103. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7104. }
  7105. }
  7106. declare module "babylonjs/Collisions/collider" {
  7107. import { Nullable, IndicesArray } from "babylonjs/types";
  7108. import { Vector3 } from "babylonjs/Maths/math.vector";
  7109. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7110. import { Plane } from "babylonjs/Maths/math.plane";
  7111. /** @hidden */
  7112. export class Collider {
  7113. /** Define if a collision was found */
  7114. collisionFound: boolean;
  7115. /**
  7116. * Define last intersection point in local space
  7117. */
  7118. intersectionPoint: Vector3;
  7119. /**
  7120. * Define last collided mesh
  7121. */
  7122. collidedMesh: Nullable<AbstractMesh>;
  7123. private _collisionPoint;
  7124. private _planeIntersectionPoint;
  7125. private _tempVector;
  7126. private _tempVector2;
  7127. private _tempVector3;
  7128. private _tempVector4;
  7129. private _edge;
  7130. private _baseToVertex;
  7131. private _destinationPoint;
  7132. private _slidePlaneNormal;
  7133. private _displacementVector;
  7134. /** @hidden */
  7135. _radius: Vector3;
  7136. /** @hidden */
  7137. _retry: number;
  7138. private _velocity;
  7139. private _basePoint;
  7140. private _epsilon;
  7141. /** @hidden */
  7142. _velocityWorldLength: number;
  7143. /** @hidden */
  7144. _basePointWorld: Vector3;
  7145. private _velocityWorld;
  7146. private _normalizedVelocity;
  7147. /** @hidden */
  7148. _initialVelocity: Vector3;
  7149. /** @hidden */
  7150. _initialPosition: Vector3;
  7151. private _nearestDistance;
  7152. private _collisionMask;
  7153. collisionMask: number;
  7154. /**
  7155. * Gets the plane normal used to compute the sliding response (in local space)
  7156. */
  7157. readonly slidePlaneNormal: Vector3;
  7158. /** @hidden */
  7159. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7160. /** @hidden */
  7161. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7162. /** @hidden */
  7163. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7164. /** @hidden */
  7165. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7166. /** @hidden */
  7167. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7168. /** @hidden */
  7169. _getResponse(pos: Vector3, vel: Vector3): void;
  7170. }
  7171. }
  7172. declare module "babylonjs/Culling/boundingInfo" {
  7173. import { DeepImmutable } from "babylonjs/types";
  7174. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7175. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7176. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7177. import { Plane } from "babylonjs/Maths/math.plane";
  7178. import { Collider } from "babylonjs/Collisions/collider";
  7179. /**
  7180. * Interface for cullable objects
  7181. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7182. */
  7183. export interface ICullable {
  7184. /**
  7185. * Checks if the object or part of the object is in the frustum
  7186. * @param frustumPlanes Camera near/planes
  7187. * @returns true if the object is in frustum otherwise false
  7188. */
  7189. isInFrustum(frustumPlanes: Plane[]): boolean;
  7190. /**
  7191. * Checks if a cullable object (mesh...) is in the camera frustum
  7192. * Unlike isInFrustum this cheks the full bounding box
  7193. * @param frustumPlanes Camera near/planes
  7194. * @returns true if the object is in frustum otherwise false
  7195. */
  7196. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7197. }
  7198. /**
  7199. * Info for a bounding data of a mesh
  7200. */
  7201. export class BoundingInfo implements ICullable {
  7202. /**
  7203. * Bounding box for the mesh
  7204. */
  7205. readonly boundingBox: BoundingBox;
  7206. /**
  7207. * Bounding sphere for the mesh
  7208. */
  7209. readonly boundingSphere: BoundingSphere;
  7210. private _isLocked;
  7211. private static readonly TmpVector3;
  7212. /**
  7213. * Constructs bounding info
  7214. * @param minimum min vector of the bounding box/sphere
  7215. * @param maximum max vector of the bounding box/sphere
  7216. * @param worldMatrix defines the new world matrix
  7217. */
  7218. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7219. /**
  7220. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7221. * @param min defines the new minimum vector (in local space)
  7222. * @param max defines the new maximum vector (in local space)
  7223. * @param worldMatrix defines the new world matrix
  7224. */
  7225. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7226. /**
  7227. * min vector of the bounding box/sphere
  7228. */
  7229. readonly minimum: Vector3;
  7230. /**
  7231. * max vector of the bounding box/sphere
  7232. */
  7233. readonly maximum: Vector3;
  7234. /**
  7235. * If the info is locked and won't be updated to avoid perf overhead
  7236. */
  7237. isLocked: boolean;
  7238. /**
  7239. * Updates the bounding sphere and box
  7240. * @param world world matrix to be used to update
  7241. */
  7242. update(world: DeepImmutable<Matrix>): void;
  7243. /**
  7244. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7245. * @param center New center of the bounding info
  7246. * @param extend New extend of the bounding info
  7247. * @returns the current bounding info
  7248. */
  7249. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7250. /**
  7251. * Scale the current bounding info by applying a scale factor
  7252. * @param factor defines the scale factor to apply
  7253. * @returns the current bounding info
  7254. */
  7255. scale(factor: number): BoundingInfo;
  7256. /**
  7257. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7258. * @param frustumPlanes defines the frustum to test
  7259. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7260. * @returns true if the bounding info is in the frustum planes
  7261. */
  7262. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7263. /**
  7264. * Gets the world distance between the min and max points of the bounding box
  7265. */
  7266. readonly diagonalLength: number;
  7267. /**
  7268. * Checks if a cullable object (mesh...) is in the camera frustum
  7269. * Unlike isInFrustum this cheks the full bounding box
  7270. * @param frustumPlanes Camera near/planes
  7271. * @returns true if the object is in frustum otherwise false
  7272. */
  7273. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7274. /** @hidden */
  7275. _checkCollision(collider: Collider): boolean;
  7276. /**
  7277. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7278. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7279. * @param point the point to check intersection with
  7280. * @returns if the point intersects
  7281. */
  7282. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7283. /**
  7284. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7285. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7286. * @param boundingInfo the bounding info to check intersection with
  7287. * @param precise if the intersection should be done using OBB
  7288. * @returns if the bounding info intersects
  7289. */
  7290. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7291. }
  7292. }
  7293. declare module "babylonjs/Maths/math.functions" {
  7294. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7295. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7296. /**
  7297. * Extracts minimum and maximum values from a list of indexed positions
  7298. * @param positions defines the positions to use
  7299. * @param indices defines the indices to the positions
  7300. * @param indexStart defines the start index
  7301. * @param indexCount defines the end index
  7302. * @param bias defines bias value to add to the result
  7303. * @return minimum and maximum values
  7304. */
  7305. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7306. minimum: Vector3;
  7307. maximum: Vector3;
  7308. };
  7309. /**
  7310. * Extracts minimum and maximum values from a list of positions
  7311. * @param positions defines the positions to use
  7312. * @param start defines the start index in the positions array
  7313. * @param count defines the number of positions to handle
  7314. * @param bias defines bias value to add to the result
  7315. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7316. * @return minimum and maximum values
  7317. */
  7318. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7319. minimum: Vector3;
  7320. maximum: Vector3;
  7321. };
  7322. }
  7323. declare module "babylonjs/Misc/iInspectable" {
  7324. /**
  7325. * Enum that determines the text-wrapping mode to use.
  7326. */
  7327. export enum InspectableType {
  7328. /**
  7329. * Checkbox for booleans
  7330. */
  7331. Checkbox = 0,
  7332. /**
  7333. * Sliders for numbers
  7334. */
  7335. Slider = 1,
  7336. /**
  7337. * Vector3
  7338. */
  7339. Vector3 = 2,
  7340. /**
  7341. * Quaternions
  7342. */
  7343. Quaternion = 3,
  7344. /**
  7345. * Color3
  7346. */
  7347. Color3 = 4,
  7348. /**
  7349. * String
  7350. */
  7351. String = 5
  7352. }
  7353. /**
  7354. * Interface used to define custom inspectable properties.
  7355. * This interface is used by the inspector to display custom property grids
  7356. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7357. */
  7358. export interface IInspectable {
  7359. /**
  7360. * Gets the label to display
  7361. */
  7362. label: string;
  7363. /**
  7364. * Gets the name of the property to edit
  7365. */
  7366. propertyName: string;
  7367. /**
  7368. * Gets the type of the editor to use
  7369. */
  7370. type: InspectableType;
  7371. /**
  7372. * Gets the minimum value of the property when using in "slider" mode
  7373. */
  7374. min?: number;
  7375. /**
  7376. * Gets the maximum value of the property when using in "slider" mode
  7377. */
  7378. max?: number;
  7379. /**
  7380. * Gets the setp to use when using in "slider" mode
  7381. */
  7382. step?: number;
  7383. }
  7384. }
  7385. declare module "babylonjs/Misc/timingTools" {
  7386. /**
  7387. * Class used to provide helper for timing
  7388. */
  7389. export class TimingTools {
  7390. /**
  7391. * Polyfill for setImmediate
  7392. * @param action defines the action to execute after the current execution block
  7393. */
  7394. static SetImmediate(action: () => void): void;
  7395. }
  7396. }
  7397. declare module "babylonjs/Misc/instantiationTools" {
  7398. /**
  7399. * Class used to enable instatition of objects by class name
  7400. */
  7401. export class InstantiationTools {
  7402. /**
  7403. * Use this object to register external classes like custom textures or material
  7404. * to allow the laoders to instantiate them
  7405. */
  7406. static RegisteredExternalClasses: {
  7407. [key: string]: Object;
  7408. };
  7409. /**
  7410. * Tries to instantiate a new object from a given class name
  7411. * @param className defines the class name to instantiate
  7412. * @returns the new object or null if the system was not able to do the instantiation
  7413. */
  7414. static Instantiate(className: string): any;
  7415. }
  7416. }
  7417. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  7418. import { Nullable } from "babylonjs/types";
  7419. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7420. /**
  7421. * This represents the required contract to create a new type of texture loader.
  7422. */
  7423. export interface IInternalTextureLoader {
  7424. /**
  7425. * Defines wether the loader supports cascade loading the different faces.
  7426. */
  7427. supportCascades: boolean;
  7428. /**
  7429. * This returns if the loader support the current file information.
  7430. * @param extension defines the file extension of the file being loaded
  7431. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7432. * @param fallback defines the fallback internal texture if any
  7433. * @param isBase64 defines whether the texture is encoded as a base64
  7434. * @param isBuffer defines whether the texture data are stored as a buffer
  7435. * @returns true if the loader can load the specified file
  7436. */
  7437. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7438. /**
  7439. * Transform the url before loading if required.
  7440. * @param rootUrl the url of the texture
  7441. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7442. * @returns the transformed texture
  7443. */
  7444. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7445. /**
  7446. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7447. * @param rootUrl the url of the texture
  7448. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7449. * @returns the fallback texture
  7450. */
  7451. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7452. /**
  7453. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7454. * @param data contains the texture data
  7455. * @param texture defines the BabylonJS internal texture
  7456. * @param createPolynomials will be true if polynomials have been requested
  7457. * @param onLoad defines the callback to trigger once the texture is ready
  7458. * @param onError defines the callback to trigger in case of error
  7459. */
  7460. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7461. /**
  7462. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7463. * @param data contains the texture data
  7464. * @param texture defines the BabylonJS internal texture
  7465. * @param callback defines the method to call once ready to upload
  7466. */
  7467. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7468. }
  7469. }
  7470. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7471. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7472. import { Nullable } from "babylonjs/types";
  7473. import { Scene } from "babylonjs/scene";
  7474. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7475. module "babylonjs/Engines/engine" {
  7476. interface Engine {
  7477. /**
  7478. * Creates a depth stencil cube texture.
  7479. * This is only available in WebGL 2.
  7480. * @param size The size of face edge in the cube texture.
  7481. * @param options The options defining the cube texture.
  7482. * @returns The cube texture
  7483. */
  7484. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7485. /**
  7486. * Creates a cube texture
  7487. * @param rootUrl defines the url where the files to load is located
  7488. * @param scene defines the current scene
  7489. * @param files defines the list of files to load (1 per face)
  7490. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7491. * @param onLoad defines an optional callback raised when the texture is loaded
  7492. * @param onError defines an optional callback raised if there is an issue to load the texture
  7493. * @param format defines the format of the data
  7494. * @param forcedExtension defines the extension to use to pick the right loader
  7495. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7496. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7497. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7498. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7499. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7500. * @returns the cube texture as an InternalTexture
  7501. */
  7502. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  7503. /**
  7504. * Creates a cube texture
  7505. * @param rootUrl defines the url where the files to load is located
  7506. * @param scene defines the current scene
  7507. * @param files defines the list of files to load (1 per face)
  7508. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7509. * @param onLoad defines an optional callback raised when the texture is loaded
  7510. * @param onError defines an optional callback raised if there is an issue to load the texture
  7511. * @param format defines the format of the data
  7512. * @param forcedExtension defines the extension to use to pick the right loader
  7513. * @returns the cube texture as an InternalTexture
  7514. */
  7515. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7516. /**
  7517. * Creates a cube texture
  7518. * @param rootUrl defines the url where the files to load is located
  7519. * @param scene defines the current scene
  7520. * @param files defines the list of files to load (1 per face)
  7521. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7522. * @param onLoad defines an optional callback raised when the texture is loaded
  7523. * @param onError defines an optional callback raised if there is an issue to load the texture
  7524. * @param format defines the format of the data
  7525. * @param forcedExtension defines the extension to use to pick the right loader
  7526. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7527. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7528. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7529. * @returns the cube texture as an InternalTexture
  7530. */
  7531. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7532. /** @hidden */
  7533. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7534. /** @hidden */
  7535. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7536. /** @hidden */
  7537. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7538. /** @hidden */
  7539. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7540. }
  7541. }
  7542. }
  7543. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7544. import { Nullable } from "babylonjs/types";
  7545. import { Scene } from "babylonjs/scene";
  7546. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7547. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7548. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7549. /**
  7550. * Class for creating a cube texture
  7551. */
  7552. export class CubeTexture extends BaseTexture {
  7553. private _delayedOnLoad;
  7554. /**
  7555. * The url of the texture
  7556. */
  7557. url: string;
  7558. /**
  7559. * Gets or sets the center of the bounding box associated with the cube texture.
  7560. * It must define where the camera used to render the texture was set
  7561. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7562. */
  7563. boundingBoxPosition: Vector3;
  7564. private _boundingBoxSize;
  7565. /**
  7566. * Gets or sets the size of the bounding box associated with the cube texture
  7567. * When defined, the cubemap will switch to local mode
  7568. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7569. * @example https://www.babylonjs-playground.com/#RNASML
  7570. */
  7571. /**
  7572. * Returns the bounding box size
  7573. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7574. */
  7575. boundingBoxSize: Vector3;
  7576. protected _rotationY: number;
  7577. /**
  7578. * Sets texture matrix rotation angle around Y axis in radians.
  7579. */
  7580. /**
  7581. * Gets texture matrix rotation angle around Y axis radians.
  7582. */
  7583. rotationY: number;
  7584. /**
  7585. * Are mip maps generated for this texture or not.
  7586. */
  7587. readonly noMipmap: boolean;
  7588. private _noMipmap;
  7589. private _files;
  7590. private _extensions;
  7591. private _textureMatrix;
  7592. private _format;
  7593. private _createPolynomials;
  7594. /** @hidden */
  7595. _prefiltered: boolean;
  7596. /**
  7597. * Creates a cube texture from an array of image urls
  7598. * @param files defines an array of image urls
  7599. * @param scene defines the hosting scene
  7600. * @param noMipmap specifies if mip maps are not used
  7601. * @returns a cube texture
  7602. */
  7603. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7604. /**
  7605. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7606. * @param url defines the url of the prefiltered texture
  7607. * @param scene defines the scene the texture is attached to
  7608. * @param forcedExtension defines the extension of the file if different from the url
  7609. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7610. * @return the prefiltered texture
  7611. */
  7612. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7613. /**
  7614. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7615. * as prefiltered data.
  7616. * @param rootUrl defines the url of the texture or the root name of the six images
  7617. * @param scene defines the scene the texture is attached to
  7618. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7619. * @param noMipmap defines if mipmaps should be created or not
  7620. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7621. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7622. * @param onError defines a callback triggered in case of error during load
  7623. * @param format defines the internal format to use for the texture once loaded
  7624. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7625. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7626. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7627. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7628. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7629. * @return the cube texture
  7630. */
  7631. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7632. /**
  7633. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7634. */
  7635. readonly isPrefiltered: boolean;
  7636. /**
  7637. * Get the current class name of the texture useful for serialization or dynamic coding.
  7638. * @returns "CubeTexture"
  7639. */
  7640. getClassName(): string;
  7641. /**
  7642. * Update the url (and optional buffer) of this texture if url was null during construction.
  7643. * @param url the url of the texture
  7644. * @param forcedExtension defines the extension to use
  7645. * @param onLoad callback called when the texture is loaded (defaults to null)
  7646. */
  7647. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7648. /**
  7649. * Delays loading of the cube texture
  7650. * @param forcedExtension defines the extension to use
  7651. */
  7652. delayLoad(forcedExtension?: string): void;
  7653. /**
  7654. * Returns the reflection texture matrix
  7655. * @returns the reflection texture matrix
  7656. */
  7657. getReflectionTextureMatrix(): Matrix;
  7658. /**
  7659. * Sets the reflection texture matrix
  7660. * @param value Reflection texture matrix
  7661. */
  7662. setReflectionTextureMatrix(value: Matrix): void;
  7663. /**
  7664. * Parses text to create a cube texture
  7665. * @param parsedTexture define the serialized text to read from
  7666. * @param scene defines the hosting scene
  7667. * @param rootUrl defines the root url of the cube texture
  7668. * @returns a cube texture
  7669. */
  7670. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7671. /**
  7672. * Makes a clone, or deep copy, of the cube texture
  7673. * @returns a new cube texture
  7674. */
  7675. clone(): CubeTexture;
  7676. }
  7677. }
  7678. declare module "babylonjs/Materials/materialDefines" {
  7679. /**
  7680. * Manages the defines for the Material
  7681. */
  7682. export class MaterialDefines {
  7683. /** @hidden */
  7684. protected _keys: string[];
  7685. private _isDirty;
  7686. /** @hidden */
  7687. _renderId: number;
  7688. /** @hidden */
  7689. _areLightsDirty: boolean;
  7690. /** @hidden */
  7691. _areLightsDisposed: boolean;
  7692. /** @hidden */
  7693. _areAttributesDirty: boolean;
  7694. /** @hidden */
  7695. _areTexturesDirty: boolean;
  7696. /** @hidden */
  7697. _areFresnelDirty: boolean;
  7698. /** @hidden */
  7699. _areMiscDirty: boolean;
  7700. /** @hidden */
  7701. _areImageProcessingDirty: boolean;
  7702. /** @hidden */
  7703. _normals: boolean;
  7704. /** @hidden */
  7705. _uvs: boolean;
  7706. /** @hidden */
  7707. _needNormals: boolean;
  7708. /** @hidden */
  7709. _needUVs: boolean;
  7710. [id: string]: any;
  7711. /**
  7712. * Specifies if the material needs to be re-calculated
  7713. */
  7714. readonly isDirty: boolean;
  7715. /**
  7716. * Marks the material to indicate that it has been re-calculated
  7717. */
  7718. markAsProcessed(): void;
  7719. /**
  7720. * Marks the material to indicate that it needs to be re-calculated
  7721. */
  7722. markAsUnprocessed(): void;
  7723. /**
  7724. * Marks the material to indicate all of its defines need to be re-calculated
  7725. */
  7726. markAllAsDirty(): void;
  7727. /**
  7728. * Marks the material to indicate that image processing needs to be re-calculated
  7729. */
  7730. markAsImageProcessingDirty(): void;
  7731. /**
  7732. * Marks the material to indicate the lights need to be re-calculated
  7733. * @param disposed Defines whether the light is dirty due to dispose or not
  7734. */
  7735. markAsLightDirty(disposed?: boolean): void;
  7736. /**
  7737. * Marks the attribute state as changed
  7738. */
  7739. markAsAttributesDirty(): void;
  7740. /**
  7741. * Marks the texture state as changed
  7742. */
  7743. markAsTexturesDirty(): void;
  7744. /**
  7745. * Marks the fresnel state as changed
  7746. */
  7747. markAsFresnelDirty(): void;
  7748. /**
  7749. * Marks the misc state as changed
  7750. */
  7751. markAsMiscDirty(): void;
  7752. /**
  7753. * Rebuilds the material defines
  7754. */
  7755. rebuild(): void;
  7756. /**
  7757. * Specifies if two material defines are equal
  7758. * @param other - A material define instance to compare to
  7759. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7760. */
  7761. isEqual(other: MaterialDefines): boolean;
  7762. /**
  7763. * Clones this instance's defines to another instance
  7764. * @param other - material defines to clone values to
  7765. */
  7766. cloneTo(other: MaterialDefines): void;
  7767. /**
  7768. * Resets the material define values
  7769. */
  7770. reset(): void;
  7771. /**
  7772. * Converts the material define values to a string
  7773. * @returns - String of material define information
  7774. */
  7775. toString(): string;
  7776. }
  7777. }
  7778. declare module "babylonjs/Materials/colorCurves" {
  7779. import { Effect } from "babylonjs/Materials/effect";
  7780. /**
  7781. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7782. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7783. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  7784. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7785. */
  7786. export class ColorCurves {
  7787. private _dirty;
  7788. private _tempColor;
  7789. private _globalCurve;
  7790. private _highlightsCurve;
  7791. private _midtonesCurve;
  7792. private _shadowsCurve;
  7793. private _positiveCurve;
  7794. private _negativeCurve;
  7795. private _globalHue;
  7796. private _globalDensity;
  7797. private _globalSaturation;
  7798. private _globalExposure;
  7799. /**
  7800. * Gets the global Hue value.
  7801. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7802. */
  7803. /**
  7804. * Sets the global Hue value.
  7805. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7806. */
  7807. globalHue: number;
  7808. /**
  7809. * Gets the global Density value.
  7810. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7811. * Values less than zero provide a filter of opposite hue.
  7812. */
  7813. /**
  7814. * Sets the global Density value.
  7815. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7816. * Values less than zero provide a filter of opposite hue.
  7817. */
  7818. globalDensity: number;
  7819. /**
  7820. * Gets the global Saturation value.
  7821. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7822. */
  7823. /**
  7824. * Sets the global Saturation value.
  7825. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7826. */
  7827. globalSaturation: number;
  7828. /**
  7829. * Gets the global Exposure value.
  7830. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7831. */
  7832. /**
  7833. * Sets the global Exposure value.
  7834. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7835. */
  7836. globalExposure: number;
  7837. private _highlightsHue;
  7838. private _highlightsDensity;
  7839. private _highlightsSaturation;
  7840. private _highlightsExposure;
  7841. /**
  7842. * Gets the highlights Hue value.
  7843. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7844. */
  7845. /**
  7846. * Sets the highlights Hue value.
  7847. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7848. */
  7849. highlightsHue: number;
  7850. /**
  7851. * Gets the highlights Density value.
  7852. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7853. * Values less than zero provide a filter of opposite hue.
  7854. */
  7855. /**
  7856. * Sets the highlights Density value.
  7857. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7858. * Values less than zero provide a filter of opposite hue.
  7859. */
  7860. highlightsDensity: number;
  7861. /**
  7862. * Gets the highlights Saturation value.
  7863. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7864. */
  7865. /**
  7866. * Sets the highlights Saturation value.
  7867. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7868. */
  7869. highlightsSaturation: number;
  7870. /**
  7871. * Gets the highlights Exposure value.
  7872. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7873. */
  7874. /**
  7875. * Sets the highlights Exposure value.
  7876. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7877. */
  7878. highlightsExposure: number;
  7879. private _midtonesHue;
  7880. private _midtonesDensity;
  7881. private _midtonesSaturation;
  7882. private _midtonesExposure;
  7883. /**
  7884. * Gets the midtones Hue value.
  7885. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7886. */
  7887. /**
  7888. * Sets the midtones Hue value.
  7889. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7890. */
  7891. midtonesHue: number;
  7892. /**
  7893. * Gets the midtones Density value.
  7894. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7895. * Values less than zero provide a filter of opposite hue.
  7896. */
  7897. /**
  7898. * Sets the midtones Density value.
  7899. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7900. * Values less than zero provide a filter of opposite hue.
  7901. */
  7902. midtonesDensity: number;
  7903. /**
  7904. * Gets the midtones Saturation value.
  7905. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7906. */
  7907. /**
  7908. * Sets the midtones Saturation value.
  7909. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7910. */
  7911. midtonesSaturation: number;
  7912. /**
  7913. * Gets the midtones Exposure value.
  7914. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7915. */
  7916. /**
  7917. * Sets the midtones Exposure value.
  7918. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7919. */
  7920. midtonesExposure: number;
  7921. private _shadowsHue;
  7922. private _shadowsDensity;
  7923. private _shadowsSaturation;
  7924. private _shadowsExposure;
  7925. /**
  7926. * Gets the shadows Hue value.
  7927. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7928. */
  7929. /**
  7930. * Sets the shadows Hue value.
  7931. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7932. */
  7933. shadowsHue: number;
  7934. /**
  7935. * Gets the shadows Density value.
  7936. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7937. * Values less than zero provide a filter of opposite hue.
  7938. */
  7939. /**
  7940. * Sets the shadows Density value.
  7941. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7942. * Values less than zero provide a filter of opposite hue.
  7943. */
  7944. shadowsDensity: number;
  7945. /**
  7946. * Gets the shadows Saturation value.
  7947. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7948. */
  7949. /**
  7950. * Sets the shadows Saturation value.
  7951. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7952. */
  7953. shadowsSaturation: number;
  7954. /**
  7955. * Gets the shadows Exposure value.
  7956. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7957. */
  7958. /**
  7959. * Sets the shadows Exposure value.
  7960. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7961. */
  7962. shadowsExposure: number;
  7963. /**
  7964. * Returns the class name
  7965. * @returns The class name
  7966. */
  7967. getClassName(): string;
  7968. /**
  7969. * Binds the color curves to the shader.
  7970. * @param colorCurves The color curve to bind
  7971. * @param effect The effect to bind to
  7972. * @param positiveUniform The positive uniform shader parameter
  7973. * @param neutralUniform The neutral uniform shader parameter
  7974. * @param negativeUniform The negative uniform shader parameter
  7975. */
  7976. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7977. /**
  7978. * Prepare the list of uniforms associated with the ColorCurves effects.
  7979. * @param uniformsList The list of uniforms used in the effect
  7980. */
  7981. static PrepareUniforms(uniformsList: string[]): void;
  7982. /**
  7983. * Returns color grading data based on a hue, density, saturation and exposure value.
  7984. * @param filterHue The hue of the color filter.
  7985. * @param filterDensity The density of the color filter.
  7986. * @param saturation The saturation.
  7987. * @param exposure The exposure.
  7988. * @param result The result data container.
  7989. */
  7990. private getColorGradingDataToRef;
  7991. /**
  7992. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  7993. * @param value The input slider value in range [-100,100].
  7994. * @returns Adjusted value.
  7995. */
  7996. private static applyColorGradingSliderNonlinear;
  7997. /**
  7998. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  7999. * @param hue The hue (H) input.
  8000. * @param saturation The saturation (S) input.
  8001. * @param brightness The brightness (B) input.
  8002. * @result An RGBA color represented as Vector4.
  8003. */
  8004. private static fromHSBToRef;
  8005. /**
  8006. * Returns a value clamped between min and max
  8007. * @param value The value to clamp
  8008. * @param min The minimum of value
  8009. * @param max The maximum of value
  8010. * @returns The clamped value.
  8011. */
  8012. private static clamp;
  8013. /**
  8014. * Clones the current color curve instance.
  8015. * @return The cloned curves
  8016. */
  8017. clone(): ColorCurves;
  8018. /**
  8019. * Serializes the current color curve instance to a json representation.
  8020. * @return a JSON representation
  8021. */
  8022. serialize(): any;
  8023. /**
  8024. * Parses the color curve from a json representation.
  8025. * @param source the JSON source to parse
  8026. * @return The parsed curves
  8027. */
  8028. static Parse(source: any): ColorCurves;
  8029. }
  8030. }
  8031. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8032. import { Observable } from "babylonjs/Misc/observable";
  8033. import { Nullable } from "babylonjs/types";
  8034. import { Color4 } from "babylonjs/Maths/math.color";
  8035. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8036. import { Effect } from "babylonjs/Materials/effect";
  8037. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8038. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8039. /**
  8040. * Interface to follow in your material defines to integrate easily the
  8041. * Image proccessing functions.
  8042. * @hidden
  8043. */
  8044. export interface IImageProcessingConfigurationDefines {
  8045. IMAGEPROCESSING: boolean;
  8046. VIGNETTE: boolean;
  8047. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8048. VIGNETTEBLENDMODEOPAQUE: boolean;
  8049. TONEMAPPING: boolean;
  8050. TONEMAPPING_ACES: boolean;
  8051. CONTRAST: boolean;
  8052. EXPOSURE: boolean;
  8053. COLORCURVES: boolean;
  8054. COLORGRADING: boolean;
  8055. COLORGRADING3D: boolean;
  8056. SAMPLER3DGREENDEPTH: boolean;
  8057. SAMPLER3DBGRMAP: boolean;
  8058. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8059. }
  8060. /**
  8061. * @hidden
  8062. */
  8063. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8064. IMAGEPROCESSING: boolean;
  8065. VIGNETTE: boolean;
  8066. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8067. VIGNETTEBLENDMODEOPAQUE: boolean;
  8068. TONEMAPPING: boolean;
  8069. TONEMAPPING_ACES: boolean;
  8070. CONTRAST: boolean;
  8071. COLORCURVES: boolean;
  8072. COLORGRADING: boolean;
  8073. COLORGRADING3D: boolean;
  8074. SAMPLER3DGREENDEPTH: boolean;
  8075. SAMPLER3DBGRMAP: boolean;
  8076. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8077. EXPOSURE: boolean;
  8078. constructor();
  8079. }
  8080. /**
  8081. * This groups together the common properties used for image processing either in direct forward pass
  8082. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8083. * or not.
  8084. */
  8085. export class ImageProcessingConfiguration {
  8086. /**
  8087. * Default tone mapping applied in BabylonJS.
  8088. */
  8089. static readonly TONEMAPPING_STANDARD: number;
  8090. /**
  8091. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8092. * to other engines rendering to increase portability.
  8093. */
  8094. static readonly TONEMAPPING_ACES: number;
  8095. /**
  8096. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8097. */
  8098. colorCurves: Nullable<ColorCurves>;
  8099. private _colorCurvesEnabled;
  8100. /**
  8101. * Gets wether the color curves effect is enabled.
  8102. */
  8103. /**
  8104. * Sets wether the color curves effect is enabled.
  8105. */
  8106. colorCurvesEnabled: boolean;
  8107. private _colorGradingTexture;
  8108. /**
  8109. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8110. */
  8111. /**
  8112. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8113. */
  8114. colorGradingTexture: Nullable<BaseTexture>;
  8115. private _colorGradingEnabled;
  8116. /**
  8117. * Gets wether the color grading effect is enabled.
  8118. */
  8119. /**
  8120. * Sets wether the color grading effect is enabled.
  8121. */
  8122. colorGradingEnabled: boolean;
  8123. private _colorGradingWithGreenDepth;
  8124. /**
  8125. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8126. */
  8127. /**
  8128. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8129. */
  8130. colorGradingWithGreenDepth: boolean;
  8131. private _colorGradingBGR;
  8132. /**
  8133. * Gets wether the color grading texture contains BGR values.
  8134. */
  8135. /**
  8136. * Sets wether the color grading texture contains BGR values.
  8137. */
  8138. colorGradingBGR: boolean;
  8139. /** @hidden */
  8140. _exposure: number;
  8141. /**
  8142. * Gets the Exposure used in the effect.
  8143. */
  8144. /**
  8145. * Sets the Exposure used in the effect.
  8146. */
  8147. exposure: number;
  8148. private _toneMappingEnabled;
  8149. /**
  8150. * Gets wether the tone mapping effect is enabled.
  8151. */
  8152. /**
  8153. * Sets wether the tone mapping effect is enabled.
  8154. */
  8155. toneMappingEnabled: boolean;
  8156. private _toneMappingType;
  8157. /**
  8158. * Gets the type of tone mapping effect.
  8159. */
  8160. /**
  8161. * Sets the type of tone mapping effect used in BabylonJS.
  8162. */
  8163. toneMappingType: number;
  8164. protected _contrast: number;
  8165. /**
  8166. * Gets the contrast used in the effect.
  8167. */
  8168. /**
  8169. * Sets the contrast used in the effect.
  8170. */
  8171. contrast: number;
  8172. /**
  8173. * Vignette stretch size.
  8174. */
  8175. vignetteStretch: number;
  8176. /**
  8177. * Vignette centre X Offset.
  8178. */
  8179. vignetteCentreX: number;
  8180. /**
  8181. * Vignette centre Y Offset.
  8182. */
  8183. vignetteCentreY: number;
  8184. /**
  8185. * Vignette weight or intensity of the vignette effect.
  8186. */
  8187. vignetteWeight: number;
  8188. /**
  8189. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8190. * if vignetteEnabled is set to true.
  8191. */
  8192. vignetteColor: Color4;
  8193. /**
  8194. * Camera field of view used by the Vignette effect.
  8195. */
  8196. vignetteCameraFov: number;
  8197. private _vignetteBlendMode;
  8198. /**
  8199. * Gets the vignette blend mode allowing different kind of effect.
  8200. */
  8201. /**
  8202. * Sets the vignette blend mode allowing different kind of effect.
  8203. */
  8204. vignetteBlendMode: number;
  8205. private _vignetteEnabled;
  8206. /**
  8207. * Gets wether the vignette effect is enabled.
  8208. */
  8209. /**
  8210. * Sets wether the vignette effect is enabled.
  8211. */
  8212. vignetteEnabled: boolean;
  8213. private _applyByPostProcess;
  8214. /**
  8215. * Gets wether the image processing is applied through a post process or not.
  8216. */
  8217. /**
  8218. * Sets wether the image processing is applied through a post process or not.
  8219. */
  8220. applyByPostProcess: boolean;
  8221. private _isEnabled;
  8222. /**
  8223. * Gets wether the image processing is enabled or not.
  8224. */
  8225. /**
  8226. * Sets wether the image processing is enabled or not.
  8227. */
  8228. isEnabled: boolean;
  8229. /**
  8230. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8231. */
  8232. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8233. /**
  8234. * Method called each time the image processing information changes requires to recompile the effect.
  8235. */
  8236. protected _updateParameters(): void;
  8237. /**
  8238. * Gets the current class name.
  8239. * @return "ImageProcessingConfiguration"
  8240. */
  8241. getClassName(): string;
  8242. /**
  8243. * Prepare the list of uniforms associated with the Image Processing effects.
  8244. * @param uniforms The list of uniforms used in the effect
  8245. * @param defines the list of defines currently in use
  8246. */
  8247. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8248. /**
  8249. * Prepare the list of samplers associated with the Image Processing effects.
  8250. * @param samplersList The list of uniforms used in the effect
  8251. * @param defines the list of defines currently in use
  8252. */
  8253. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8254. /**
  8255. * Prepare the list of defines associated to the shader.
  8256. * @param defines the list of defines to complete
  8257. * @param forPostProcess Define if we are currently in post process mode or not
  8258. */
  8259. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8260. /**
  8261. * Returns true if all the image processing information are ready.
  8262. * @returns True if ready, otherwise, false
  8263. */
  8264. isReady(): boolean;
  8265. /**
  8266. * Binds the image processing to the shader.
  8267. * @param effect The effect to bind to
  8268. * @param aspectRatio Define the current aspect ratio of the effect
  8269. */
  8270. bind(effect: Effect, aspectRatio?: number): void;
  8271. /**
  8272. * Clones the current image processing instance.
  8273. * @return The cloned image processing
  8274. */
  8275. clone(): ImageProcessingConfiguration;
  8276. /**
  8277. * Serializes the current image processing instance to a json representation.
  8278. * @return a JSON representation
  8279. */
  8280. serialize(): any;
  8281. /**
  8282. * Parses the image processing from a json representation.
  8283. * @param source the JSON source to parse
  8284. * @return The parsed image processing
  8285. */
  8286. static Parse(source: any): ImageProcessingConfiguration;
  8287. private static _VIGNETTEMODE_MULTIPLY;
  8288. private static _VIGNETTEMODE_OPAQUE;
  8289. /**
  8290. * Used to apply the vignette as a mix with the pixel color.
  8291. */
  8292. static readonly VIGNETTEMODE_MULTIPLY: number;
  8293. /**
  8294. * Used to apply the vignette as a replacement of the pixel color.
  8295. */
  8296. static readonly VIGNETTEMODE_OPAQUE: number;
  8297. }
  8298. }
  8299. declare module "babylonjs/Shaders/postprocess.vertex" {
  8300. /** @hidden */
  8301. export var postprocessVertexShader: {
  8302. name: string;
  8303. shader: string;
  8304. };
  8305. }
  8306. declare module "babylonjs/Maths/math.axis" {
  8307. import { Vector3 } from "babylonjs/Maths/math.vector";
  8308. /** Defines supported spaces */
  8309. export enum Space {
  8310. /** Local (object) space */
  8311. LOCAL = 0,
  8312. /** World space */
  8313. WORLD = 1,
  8314. /** Bone space */
  8315. BONE = 2
  8316. }
  8317. /** Defines the 3 main axes */
  8318. export class Axis {
  8319. /** X axis */
  8320. static X: Vector3;
  8321. /** Y axis */
  8322. static Y: Vector3;
  8323. /** Z axis */
  8324. static Z: Vector3;
  8325. }
  8326. }
  8327. declare module "babylonjs/Cameras/targetCamera" {
  8328. import { Nullable } from "babylonjs/types";
  8329. import { Camera } from "babylonjs/Cameras/camera";
  8330. import { Scene } from "babylonjs/scene";
  8331. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8332. /**
  8333. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8334. * This is the base of the follow, arc rotate cameras and Free camera
  8335. * @see http://doc.babylonjs.com/features/cameras
  8336. */
  8337. export class TargetCamera extends Camera {
  8338. private static _RigCamTransformMatrix;
  8339. private static _TargetTransformMatrix;
  8340. private static _TargetFocalPoint;
  8341. /**
  8342. * Define the current direction the camera is moving to
  8343. */
  8344. cameraDirection: Vector3;
  8345. /**
  8346. * Define the current rotation the camera is rotating to
  8347. */
  8348. cameraRotation: Vector2;
  8349. /**
  8350. * When set, the up vector of the camera will be updated by the rotation of the camera
  8351. */
  8352. updateUpVectorFromRotation: boolean;
  8353. private _tmpQuaternion;
  8354. /**
  8355. * Define the current rotation of the camera
  8356. */
  8357. rotation: Vector3;
  8358. /**
  8359. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8360. */
  8361. rotationQuaternion: Quaternion;
  8362. /**
  8363. * Define the current speed of the camera
  8364. */
  8365. speed: number;
  8366. /**
  8367. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8368. * around all axis.
  8369. */
  8370. noRotationConstraint: boolean;
  8371. /**
  8372. * Define the current target of the camera as an object or a position.
  8373. */
  8374. lockedTarget: any;
  8375. /** @hidden */
  8376. _currentTarget: Vector3;
  8377. /** @hidden */
  8378. _initialFocalDistance: number;
  8379. /** @hidden */
  8380. _viewMatrix: Matrix;
  8381. /** @hidden */
  8382. _camMatrix: Matrix;
  8383. /** @hidden */
  8384. _cameraTransformMatrix: Matrix;
  8385. /** @hidden */
  8386. _cameraRotationMatrix: Matrix;
  8387. /** @hidden */
  8388. _referencePoint: Vector3;
  8389. /** @hidden */
  8390. _transformedReferencePoint: Vector3;
  8391. protected _globalCurrentTarget: Vector3;
  8392. protected _globalCurrentUpVector: Vector3;
  8393. /** @hidden */
  8394. _reset: () => void;
  8395. private _defaultUp;
  8396. /**
  8397. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8398. * This is the base of the follow, arc rotate cameras and Free camera
  8399. * @see http://doc.babylonjs.com/features/cameras
  8400. * @param name Defines the name of the camera in the scene
  8401. * @param position Defines the start position of the camera in the scene
  8402. * @param scene Defines the scene the camera belongs to
  8403. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8404. */
  8405. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8406. /**
  8407. * Gets the position in front of the camera at a given distance.
  8408. * @param distance The distance from the camera we want the position to be
  8409. * @returns the position
  8410. */
  8411. getFrontPosition(distance: number): Vector3;
  8412. /** @hidden */
  8413. _getLockedTargetPosition(): Nullable<Vector3>;
  8414. private _storedPosition;
  8415. private _storedRotation;
  8416. private _storedRotationQuaternion;
  8417. /**
  8418. * Store current camera state of the camera (fov, position, rotation, etc..)
  8419. * @returns the camera
  8420. */
  8421. storeState(): Camera;
  8422. /**
  8423. * Restored camera state. You must call storeState() first
  8424. * @returns whether it was successful or not
  8425. * @hidden
  8426. */
  8427. _restoreStateValues(): boolean;
  8428. /** @hidden */
  8429. _initCache(): void;
  8430. /** @hidden */
  8431. _updateCache(ignoreParentClass?: boolean): void;
  8432. /** @hidden */
  8433. _isSynchronizedViewMatrix(): boolean;
  8434. /** @hidden */
  8435. _computeLocalCameraSpeed(): number;
  8436. /**
  8437. * Defines the target the camera should look at.
  8438. * @param target Defines the new target as a Vector or a mesh
  8439. */
  8440. setTarget(target: Vector3): void;
  8441. /**
  8442. * Return the current target position of the camera. This value is expressed in local space.
  8443. * @returns the target position
  8444. */
  8445. getTarget(): Vector3;
  8446. /** @hidden */
  8447. _decideIfNeedsToMove(): boolean;
  8448. /** @hidden */
  8449. _updatePosition(): void;
  8450. /** @hidden */
  8451. _checkInputs(): void;
  8452. protected _updateCameraRotationMatrix(): void;
  8453. /**
  8454. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  8455. * @returns the current camera
  8456. */
  8457. private _rotateUpVectorWithCameraRotationMatrix;
  8458. private _cachedRotationZ;
  8459. private _cachedQuaternionRotationZ;
  8460. /** @hidden */
  8461. _getViewMatrix(): Matrix;
  8462. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8463. /**
  8464. * @hidden
  8465. */
  8466. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8467. /**
  8468. * @hidden
  8469. */
  8470. _updateRigCameras(): void;
  8471. private _getRigCamPositionAndTarget;
  8472. /**
  8473. * Gets the current object class name.
  8474. * @return the class name
  8475. */
  8476. getClassName(): string;
  8477. }
  8478. }
  8479. declare module "babylonjs/Events/keyboardEvents" {
  8480. /**
  8481. * Gather the list of keyboard event types as constants.
  8482. */
  8483. export class KeyboardEventTypes {
  8484. /**
  8485. * The keydown event is fired when a key becomes active (pressed).
  8486. */
  8487. static readonly KEYDOWN: number;
  8488. /**
  8489. * The keyup event is fired when a key has been released.
  8490. */
  8491. static readonly KEYUP: number;
  8492. }
  8493. /**
  8494. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8495. */
  8496. export class KeyboardInfo {
  8497. /**
  8498. * Defines the type of event (KeyboardEventTypes)
  8499. */
  8500. type: number;
  8501. /**
  8502. * Defines the related dom event
  8503. */
  8504. event: KeyboardEvent;
  8505. /**
  8506. * Instantiates a new keyboard info.
  8507. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8508. * @param type Defines the type of event (KeyboardEventTypes)
  8509. * @param event Defines the related dom event
  8510. */
  8511. constructor(
  8512. /**
  8513. * Defines the type of event (KeyboardEventTypes)
  8514. */
  8515. type: number,
  8516. /**
  8517. * Defines the related dom event
  8518. */
  8519. event: KeyboardEvent);
  8520. }
  8521. /**
  8522. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8523. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8524. */
  8525. export class KeyboardInfoPre extends KeyboardInfo {
  8526. /**
  8527. * Defines the type of event (KeyboardEventTypes)
  8528. */
  8529. type: number;
  8530. /**
  8531. * Defines the related dom event
  8532. */
  8533. event: KeyboardEvent;
  8534. /**
  8535. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8536. */
  8537. skipOnPointerObservable: boolean;
  8538. /**
  8539. * Instantiates a new keyboard pre info.
  8540. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8541. * @param type Defines the type of event (KeyboardEventTypes)
  8542. * @param event Defines the related dom event
  8543. */
  8544. constructor(
  8545. /**
  8546. * Defines the type of event (KeyboardEventTypes)
  8547. */
  8548. type: number,
  8549. /**
  8550. * Defines the related dom event
  8551. */
  8552. event: KeyboardEvent);
  8553. }
  8554. }
  8555. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8556. import { Nullable } from "babylonjs/types";
  8557. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8558. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8559. /**
  8560. * Manage the keyboard inputs to control the movement of a free camera.
  8561. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8562. */
  8563. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8564. /**
  8565. * Defines the camera the input is attached to.
  8566. */
  8567. camera: FreeCamera;
  8568. /**
  8569. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8570. */
  8571. keysUp: number[];
  8572. /**
  8573. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8574. */
  8575. keysDown: number[];
  8576. /**
  8577. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8578. */
  8579. keysLeft: number[];
  8580. /**
  8581. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8582. */
  8583. keysRight: number[];
  8584. private _keys;
  8585. private _onCanvasBlurObserver;
  8586. private _onKeyboardObserver;
  8587. private _engine;
  8588. private _scene;
  8589. /**
  8590. * Attach the input controls to a specific dom element to get the input from.
  8591. * @param element Defines the element the controls should be listened from
  8592. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8593. */
  8594. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8595. /**
  8596. * Detach the current controls from the specified dom element.
  8597. * @param element Defines the element to stop listening the inputs from
  8598. */
  8599. detachControl(element: Nullable<HTMLElement>): void;
  8600. /**
  8601. * Update the current camera state depending on the inputs that have been used this frame.
  8602. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8603. */
  8604. checkInputs(): void;
  8605. /**
  8606. * Gets the class name of the current intput.
  8607. * @returns the class name
  8608. */
  8609. getClassName(): string;
  8610. /** @hidden */
  8611. _onLostFocus(): void;
  8612. /**
  8613. * Get the friendly name associated with the input class.
  8614. * @returns the input friendly name
  8615. */
  8616. getSimpleName(): string;
  8617. }
  8618. }
  8619. declare module "babylonjs/Lights/shadowLight" {
  8620. import { Camera } from "babylonjs/Cameras/camera";
  8621. import { Scene } from "babylonjs/scene";
  8622. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8623. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8624. import { Light } from "babylonjs/Lights/light";
  8625. /**
  8626. * Interface describing all the common properties and methods a shadow light needs to implement.
  8627. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8628. * as well as binding the different shadow properties to the effects.
  8629. */
  8630. export interface IShadowLight extends Light {
  8631. /**
  8632. * The light id in the scene (used in scene.findLighById for instance)
  8633. */
  8634. id: string;
  8635. /**
  8636. * The position the shdow will be casted from.
  8637. */
  8638. position: Vector3;
  8639. /**
  8640. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8641. */
  8642. direction: Vector3;
  8643. /**
  8644. * The transformed position. Position of the light in world space taking parenting in account.
  8645. */
  8646. transformedPosition: Vector3;
  8647. /**
  8648. * The transformed direction. Direction of the light in world space taking parenting in account.
  8649. */
  8650. transformedDirection: Vector3;
  8651. /**
  8652. * The friendly name of the light in the scene.
  8653. */
  8654. name: string;
  8655. /**
  8656. * Defines the shadow projection clipping minimum z value.
  8657. */
  8658. shadowMinZ: number;
  8659. /**
  8660. * Defines the shadow projection clipping maximum z value.
  8661. */
  8662. shadowMaxZ: number;
  8663. /**
  8664. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8665. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8666. */
  8667. computeTransformedInformation(): boolean;
  8668. /**
  8669. * Gets the scene the light belongs to.
  8670. * @returns The scene
  8671. */
  8672. getScene(): Scene;
  8673. /**
  8674. * Callback defining a custom Projection Matrix Builder.
  8675. * This can be used to override the default projection matrix computation.
  8676. */
  8677. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8678. /**
  8679. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8680. * @param matrix The materix to updated with the projection information
  8681. * @param viewMatrix The transform matrix of the light
  8682. * @param renderList The list of mesh to render in the map
  8683. * @returns The current light
  8684. */
  8685. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8686. /**
  8687. * Gets the current depth scale used in ESM.
  8688. * @returns The scale
  8689. */
  8690. getDepthScale(): number;
  8691. /**
  8692. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8693. * @returns true if a cube texture needs to be use
  8694. */
  8695. needCube(): boolean;
  8696. /**
  8697. * Detects if the projection matrix requires to be recomputed this frame.
  8698. * @returns true if it requires to be recomputed otherwise, false.
  8699. */
  8700. needProjectionMatrixCompute(): boolean;
  8701. /**
  8702. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8703. */
  8704. forceProjectionMatrixCompute(): void;
  8705. /**
  8706. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8707. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8708. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8709. */
  8710. getShadowDirection(faceIndex?: number): Vector3;
  8711. /**
  8712. * Gets the minZ used for shadow according to both the scene and the light.
  8713. * @param activeCamera The camera we are returning the min for
  8714. * @returns the depth min z
  8715. */
  8716. getDepthMinZ(activeCamera: Camera): number;
  8717. /**
  8718. * Gets the maxZ used for shadow according to both the scene and the light.
  8719. * @param activeCamera The camera we are returning the max for
  8720. * @returns the depth max z
  8721. */
  8722. getDepthMaxZ(activeCamera: Camera): number;
  8723. }
  8724. /**
  8725. * Base implementation IShadowLight
  8726. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8727. */
  8728. export abstract class ShadowLight extends Light implements IShadowLight {
  8729. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8730. protected _position: Vector3;
  8731. protected _setPosition(value: Vector3): void;
  8732. /**
  8733. * Sets the position the shadow will be casted from. Also use as the light position for both
  8734. * point and spot lights.
  8735. */
  8736. /**
  8737. * Sets the position the shadow will be casted from. Also use as the light position for both
  8738. * point and spot lights.
  8739. */
  8740. position: Vector3;
  8741. protected _direction: Vector3;
  8742. protected _setDirection(value: Vector3): void;
  8743. /**
  8744. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8745. * Also use as the light direction on spot and directional lights.
  8746. */
  8747. /**
  8748. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8749. * Also use as the light direction on spot and directional lights.
  8750. */
  8751. direction: Vector3;
  8752. private _shadowMinZ;
  8753. /**
  8754. * Gets the shadow projection clipping minimum z value.
  8755. */
  8756. /**
  8757. * Sets the shadow projection clipping minimum z value.
  8758. */
  8759. shadowMinZ: number;
  8760. private _shadowMaxZ;
  8761. /**
  8762. * Sets the shadow projection clipping maximum z value.
  8763. */
  8764. /**
  8765. * Gets the shadow projection clipping maximum z value.
  8766. */
  8767. shadowMaxZ: number;
  8768. /**
  8769. * Callback defining a custom Projection Matrix Builder.
  8770. * This can be used to override the default projection matrix computation.
  8771. */
  8772. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8773. /**
  8774. * The transformed position. Position of the light in world space taking parenting in account.
  8775. */
  8776. transformedPosition: Vector3;
  8777. /**
  8778. * The transformed direction. Direction of the light in world space taking parenting in account.
  8779. */
  8780. transformedDirection: Vector3;
  8781. private _needProjectionMatrixCompute;
  8782. /**
  8783. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8784. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8785. */
  8786. computeTransformedInformation(): boolean;
  8787. /**
  8788. * Return the depth scale used for the shadow map.
  8789. * @returns the depth scale.
  8790. */
  8791. getDepthScale(): number;
  8792. /**
  8793. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8794. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8795. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8796. */
  8797. getShadowDirection(faceIndex?: number): Vector3;
  8798. /**
  8799. * Returns the ShadowLight absolute position in the World.
  8800. * @returns the position vector in world space
  8801. */
  8802. getAbsolutePosition(): Vector3;
  8803. /**
  8804. * Sets the ShadowLight direction toward the passed target.
  8805. * @param target The point to target in local space
  8806. * @returns the updated ShadowLight direction
  8807. */
  8808. setDirectionToTarget(target: Vector3): Vector3;
  8809. /**
  8810. * Returns the light rotation in euler definition.
  8811. * @returns the x y z rotation in local space.
  8812. */
  8813. getRotation(): Vector3;
  8814. /**
  8815. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8816. * @returns true if a cube texture needs to be use
  8817. */
  8818. needCube(): boolean;
  8819. /**
  8820. * Detects if the projection matrix requires to be recomputed this frame.
  8821. * @returns true if it requires to be recomputed otherwise, false.
  8822. */
  8823. needProjectionMatrixCompute(): boolean;
  8824. /**
  8825. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8826. */
  8827. forceProjectionMatrixCompute(): void;
  8828. /** @hidden */
  8829. _initCache(): void;
  8830. /** @hidden */
  8831. _isSynchronized(): boolean;
  8832. /**
  8833. * Computes the world matrix of the node
  8834. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8835. * @returns the world matrix
  8836. */
  8837. computeWorldMatrix(force?: boolean): Matrix;
  8838. /**
  8839. * Gets the minZ used for shadow according to both the scene and the light.
  8840. * @param activeCamera The camera we are returning the min for
  8841. * @returns the depth min z
  8842. */
  8843. getDepthMinZ(activeCamera: Camera): number;
  8844. /**
  8845. * Gets the maxZ used for shadow according to both the scene and the light.
  8846. * @param activeCamera The camera we are returning the max for
  8847. * @returns the depth max z
  8848. */
  8849. getDepthMaxZ(activeCamera: Camera): number;
  8850. /**
  8851. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8852. * @param matrix The materix to updated with the projection information
  8853. * @param viewMatrix The transform matrix of the light
  8854. * @param renderList The list of mesh to render in the map
  8855. * @returns The current light
  8856. */
  8857. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8858. }
  8859. }
  8860. declare module "babylonjs/Materials/materialHelper" {
  8861. import { Nullable } from "babylonjs/types";
  8862. import { Scene } from "babylonjs/scene";
  8863. import { Engine } from "babylonjs/Engines/engine";
  8864. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8865. import { Light } from "babylonjs/Lights/light";
  8866. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  8867. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  8868. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8869. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8870. /**
  8871. * "Static Class" containing the most commonly used helper while dealing with material for
  8872. * rendering purpose.
  8873. *
  8874. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8875. *
  8876. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8877. */
  8878. export class MaterialHelper {
  8879. /**
  8880. * Bind the current view position to an effect.
  8881. * @param effect The effect to be bound
  8882. * @param scene The scene the eyes position is used from
  8883. */
  8884. static BindEyePosition(effect: Effect, scene: Scene): void;
  8885. /**
  8886. * Helps preparing the defines values about the UVs in used in the effect.
  8887. * UVs are shared as much as we can accross channels in the shaders.
  8888. * @param texture The texture we are preparing the UVs for
  8889. * @param defines The defines to update
  8890. * @param key The channel key "diffuse", "specular"... used in the shader
  8891. */
  8892. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8893. /**
  8894. * Binds a texture matrix value to its corrsponding uniform
  8895. * @param texture The texture to bind the matrix for
  8896. * @param uniformBuffer The uniform buffer receivin the data
  8897. * @param key The channel key "diffuse", "specular"... used in the shader
  8898. */
  8899. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8900. /**
  8901. * Gets the current status of the fog (should it be enabled?)
  8902. * @param mesh defines the mesh to evaluate for fog support
  8903. * @param scene defines the hosting scene
  8904. * @returns true if fog must be enabled
  8905. */
  8906. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8907. /**
  8908. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8909. * @param mesh defines the current mesh
  8910. * @param scene defines the current scene
  8911. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8912. * @param pointsCloud defines if point cloud rendering has to be turned on
  8913. * @param fogEnabled defines if fog has to be turned on
  8914. * @param alphaTest defines if alpha testing has to be turned on
  8915. * @param defines defines the current list of defines
  8916. */
  8917. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8918. /**
  8919. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8920. * @param scene defines the current scene
  8921. * @param engine defines the current engine
  8922. * @param defines specifies the list of active defines
  8923. * @param useInstances defines if instances have to be turned on
  8924. * @param useClipPlane defines if clip plane have to be turned on
  8925. */
  8926. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8927. /**
  8928. * Prepares the defines for bones
  8929. * @param mesh The mesh containing the geometry data we will draw
  8930. * @param defines The defines to update
  8931. */
  8932. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8933. /**
  8934. * Prepares the defines for morph targets
  8935. * @param mesh The mesh containing the geometry data we will draw
  8936. * @param defines The defines to update
  8937. */
  8938. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8939. /**
  8940. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8941. * @param mesh The mesh containing the geometry data we will draw
  8942. * @param defines The defines to update
  8943. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8944. * @param useBones Precise whether bones should be used or not (override mesh info)
  8945. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8946. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8947. * @returns false if defines are considered not dirty and have not been checked
  8948. */
  8949. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8950. /**
  8951. * Prepares the defines related to multiview
  8952. * @param scene The scene we are intending to draw
  8953. * @param defines The defines to update
  8954. */
  8955. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8956. /**
  8957. * Prepares the defines related to the light information passed in parameter
  8958. * @param scene The scene we are intending to draw
  8959. * @param mesh The mesh the effect is compiling for
  8960. * @param light The light the effect is compiling for
  8961. * @param lightIndex The index of the light
  8962. * @param defines The defines to update
  8963. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8964. * @param state Defines the current state regarding what is needed (normals, etc...)
  8965. */
  8966. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  8967. needNormals: boolean;
  8968. needRebuild: boolean;
  8969. shadowEnabled: boolean;
  8970. specularEnabled: boolean;
  8971. lightmapMode: boolean;
  8972. }): void;
  8973. /**
  8974. * Prepares the defines related to the light information passed in parameter
  8975. * @param scene The scene we are intending to draw
  8976. * @param mesh The mesh the effect is compiling for
  8977. * @param defines The defines to update
  8978. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8979. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8980. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8981. * @returns true if normals will be required for the rest of the effect
  8982. */
  8983. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8984. /**
  8985. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  8986. * @param lightIndex defines the light index
  8987. * @param uniformsList The uniform list
  8988. * @param samplersList The sampler list
  8989. * @param projectedLightTexture defines if projected texture must be used
  8990. * @param uniformBuffersList defines an optional list of uniform buffers
  8991. */
  8992. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  8993. /**
  8994. * Prepares the uniforms and samplers list to be used in the effect
  8995. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  8996. * @param samplersList The sampler list
  8997. * @param defines The defines helping in the list generation
  8998. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  8999. */
  9000. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9001. /**
  9002. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9003. * @param defines The defines to update while falling back
  9004. * @param fallbacks The authorized effect fallbacks
  9005. * @param maxSimultaneousLights The maximum number of lights allowed
  9006. * @param rank the current rank of the Effect
  9007. * @returns The newly affected rank
  9008. */
  9009. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9010. private static _TmpMorphInfluencers;
  9011. /**
  9012. * Prepares the list of attributes required for morph targets according to the effect defines.
  9013. * @param attribs The current list of supported attribs
  9014. * @param mesh The mesh to prepare the morph targets attributes for
  9015. * @param influencers The number of influencers
  9016. */
  9017. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9018. /**
  9019. * Prepares the list of attributes required for morph targets according to the effect defines.
  9020. * @param attribs The current list of supported attribs
  9021. * @param mesh The mesh to prepare the morph targets attributes for
  9022. * @param defines The current Defines of the effect
  9023. */
  9024. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9025. /**
  9026. * Prepares the list of attributes required for bones according to the effect defines.
  9027. * @param attribs The current list of supported attribs
  9028. * @param mesh The mesh to prepare the bones attributes for
  9029. * @param defines The current Defines of the effect
  9030. * @param fallbacks The current efffect fallback strategy
  9031. */
  9032. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9033. /**
  9034. * Check and prepare the list of attributes required for instances according to the effect defines.
  9035. * @param attribs The current list of supported attribs
  9036. * @param defines The current MaterialDefines of the effect
  9037. */
  9038. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9039. /**
  9040. * Add the list of attributes required for instances to the attribs array.
  9041. * @param attribs The current list of supported attribs
  9042. */
  9043. static PushAttributesForInstances(attribs: string[]): void;
  9044. /**
  9045. * Binds the light shadow information to the effect for the given mesh.
  9046. * @param light The light containing the generator
  9047. * @param scene The scene the lights belongs to
  9048. * @param mesh The mesh we are binding the information to render
  9049. * @param lightIndex The light index in the effect used to render the mesh
  9050. * @param effect The effect we are binding the data to
  9051. */
  9052. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9053. /**
  9054. * Binds the light information to the effect.
  9055. * @param light The light containing the generator
  9056. * @param effect The effect we are binding the data to
  9057. * @param lightIndex The light index in the effect used to render
  9058. */
  9059. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9060. /**
  9061. * Binds the lights information from the scene to the effect for the given mesh.
  9062. * @param light Light to bind
  9063. * @param lightIndex Light index
  9064. * @param scene The scene where the light belongs to
  9065. * @param mesh The mesh we are binding the information to render
  9066. * @param effect The effect we are binding the data to
  9067. * @param useSpecular Defines if specular is supported
  9068. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9069. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9070. */
  9071. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9072. /**
  9073. * Binds the lights information from the scene to the effect for the given mesh.
  9074. * @param scene The scene the lights belongs to
  9075. * @param mesh The mesh we are binding the information to render
  9076. * @param effect The effect we are binding the data to
  9077. * @param defines The generated defines for the effect
  9078. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9079. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9080. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9081. */
  9082. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9083. private static _tempFogColor;
  9084. /**
  9085. * Binds the fog information from the scene to the effect for the given mesh.
  9086. * @param scene The scene the lights belongs to
  9087. * @param mesh The mesh we are binding the information to render
  9088. * @param effect The effect we are binding the data to
  9089. * @param linearSpace Defines if the fog effect is applied in linear space
  9090. */
  9091. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9092. /**
  9093. * Binds the bones information from the mesh to the effect.
  9094. * @param mesh The mesh we are binding the information to render
  9095. * @param effect The effect we are binding the data to
  9096. */
  9097. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9098. /**
  9099. * Binds the morph targets information from the mesh to the effect.
  9100. * @param abstractMesh The mesh we are binding the information to render
  9101. * @param effect The effect we are binding the data to
  9102. */
  9103. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9104. /**
  9105. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9106. * @param defines The generated defines used in the effect
  9107. * @param effect The effect we are binding the data to
  9108. * @param scene The scene we are willing to render with logarithmic scale for
  9109. */
  9110. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9111. /**
  9112. * Binds the clip plane information from the scene to the effect.
  9113. * @param scene The scene the clip plane information are extracted from
  9114. * @param effect The effect we are binding the data to
  9115. */
  9116. static BindClipPlane(effect: Effect, scene: Scene): void;
  9117. }
  9118. }
  9119. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9120. /** @hidden */
  9121. export var packingFunctions: {
  9122. name: string;
  9123. shader: string;
  9124. };
  9125. }
  9126. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9127. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9128. /** @hidden */
  9129. export var shadowMapPixelShader: {
  9130. name: string;
  9131. shader: string;
  9132. };
  9133. }
  9134. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9135. /** @hidden */
  9136. export var bonesDeclaration: {
  9137. name: string;
  9138. shader: string;
  9139. };
  9140. }
  9141. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9142. /** @hidden */
  9143. export var morphTargetsVertexGlobalDeclaration: {
  9144. name: string;
  9145. shader: string;
  9146. };
  9147. }
  9148. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9149. /** @hidden */
  9150. export var morphTargetsVertexDeclaration: {
  9151. name: string;
  9152. shader: string;
  9153. };
  9154. }
  9155. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9156. /** @hidden */
  9157. export var instancesDeclaration: {
  9158. name: string;
  9159. shader: string;
  9160. };
  9161. }
  9162. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9163. /** @hidden */
  9164. export var helperFunctions: {
  9165. name: string;
  9166. shader: string;
  9167. };
  9168. }
  9169. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9170. /** @hidden */
  9171. export var morphTargetsVertex: {
  9172. name: string;
  9173. shader: string;
  9174. };
  9175. }
  9176. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9177. /** @hidden */
  9178. export var instancesVertex: {
  9179. name: string;
  9180. shader: string;
  9181. };
  9182. }
  9183. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9184. /** @hidden */
  9185. export var bonesVertex: {
  9186. name: string;
  9187. shader: string;
  9188. };
  9189. }
  9190. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9191. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9192. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9193. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9194. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9195. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9196. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9197. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9198. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9199. /** @hidden */
  9200. export var shadowMapVertexShader: {
  9201. name: string;
  9202. shader: string;
  9203. };
  9204. }
  9205. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9206. /** @hidden */
  9207. export var depthBoxBlurPixelShader: {
  9208. name: string;
  9209. shader: string;
  9210. };
  9211. }
  9212. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9213. import { Nullable } from "babylonjs/types";
  9214. import { Scene } from "babylonjs/scene";
  9215. import { Matrix } from "babylonjs/Maths/math.vector";
  9216. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9217. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9218. import { Mesh } from "babylonjs/Meshes/mesh";
  9219. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9220. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9221. import { Effect } from "babylonjs/Materials/effect";
  9222. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9223. import "babylonjs/Shaders/shadowMap.fragment";
  9224. import "babylonjs/Shaders/shadowMap.vertex";
  9225. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9226. import { Observable } from "babylonjs/Misc/observable";
  9227. /**
  9228. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9229. */
  9230. export interface ICustomShaderOptions {
  9231. /**
  9232. * Gets or sets the custom shader name to use
  9233. */
  9234. shaderName: string;
  9235. /**
  9236. * The list of attribute names used in the shader
  9237. */
  9238. attributes?: string[];
  9239. /**
  9240. * The list of unifrom names used in the shader
  9241. */
  9242. uniforms?: string[];
  9243. /**
  9244. * The list of sampler names used in the shader
  9245. */
  9246. samplers?: string[];
  9247. /**
  9248. * The list of defines used in the shader
  9249. */
  9250. defines?: string[];
  9251. }
  9252. /**
  9253. * Interface to implement to create a shadow generator compatible with BJS.
  9254. */
  9255. export interface IShadowGenerator {
  9256. /**
  9257. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9258. * @returns The render target texture if present otherwise, null
  9259. */
  9260. getShadowMap(): Nullable<RenderTargetTexture>;
  9261. /**
  9262. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9263. * @returns The render target texture if the shadow map is present otherwise, null
  9264. */
  9265. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9266. /**
  9267. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9268. * @param subMesh The submesh we want to render in the shadow map
  9269. * @param useInstances Defines wether will draw in the map using instances
  9270. * @returns true if ready otherwise, false
  9271. */
  9272. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9273. /**
  9274. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9275. * @param defines Defines of the material we want to update
  9276. * @param lightIndex Index of the light in the enabled light list of the material
  9277. */
  9278. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9279. /**
  9280. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9281. * defined in the generator but impacting the effect).
  9282. * It implies the unifroms available on the materials are the standard BJS ones.
  9283. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9284. * @param effect The effect we are binfing the information for
  9285. */
  9286. bindShadowLight(lightIndex: string, effect: Effect): void;
  9287. /**
  9288. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9289. * (eq to shadow prjection matrix * light transform matrix)
  9290. * @returns The transform matrix used to create the shadow map
  9291. */
  9292. getTransformMatrix(): Matrix;
  9293. /**
  9294. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9295. * Cube and 2D textures for instance.
  9296. */
  9297. recreateShadowMap(): void;
  9298. /**
  9299. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9300. * @param onCompiled Callback triggered at the and of the effects compilation
  9301. * @param options Sets of optional options forcing the compilation with different modes
  9302. */
  9303. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9304. useInstances: boolean;
  9305. }>): void;
  9306. /**
  9307. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9308. * @param options Sets of optional options forcing the compilation with different modes
  9309. * @returns A promise that resolves when the compilation completes
  9310. */
  9311. forceCompilationAsync(options?: Partial<{
  9312. useInstances: boolean;
  9313. }>): Promise<void>;
  9314. /**
  9315. * Serializes the shadow generator setup to a json object.
  9316. * @returns The serialized JSON object
  9317. */
  9318. serialize(): any;
  9319. /**
  9320. * Disposes the Shadow map and related Textures and effects.
  9321. */
  9322. dispose(): void;
  9323. }
  9324. /**
  9325. * Default implementation IShadowGenerator.
  9326. * This is the main object responsible of generating shadows in the framework.
  9327. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9328. */
  9329. export class ShadowGenerator implements IShadowGenerator {
  9330. /**
  9331. * Shadow generator mode None: no filtering applied.
  9332. */
  9333. static readonly FILTER_NONE: number;
  9334. /**
  9335. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9336. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9337. */
  9338. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9339. /**
  9340. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9341. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9342. */
  9343. static readonly FILTER_POISSONSAMPLING: number;
  9344. /**
  9345. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9346. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9347. */
  9348. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9349. /**
  9350. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9351. * edge artifacts on steep falloff.
  9352. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9353. */
  9354. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9355. /**
  9356. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9357. * edge artifacts on steep falloff.
  9358. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9359. */
  9360. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9361. /**
  9362. * Shadow generator mode PCF: Percentage Closer Filtering
  9363. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9364. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9365. */
  9366. static readonly FILTER_PCF: number;
  9367. /**
  9368. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9369. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9370. * Contact Hardening
  9371. */
  9372. static readonly FILTER_PCSS: number;
  9373. /**
  9374. * Reserved for PCF and PCSS
  9375. * Highest Quality.
  9376. *
  9377. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9378. *
  9379. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9380. */
  9381. static readonly QUALITY_HIGH: number;
  9382. /**
  9383. * Reserved for PCF and PCSS
  9384. * Good tradeoff for quality/perf cross devices
  9385. *
  9386. * Execute PCF on a 3*3 kernel.
  9387. *
  9388. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9389. */
  9390. static readonly QUALITY_MEDIUM: number;
  9391. /**
  9392. * Reserved for PCF and PCSS
  9393. * The lowest quality but the fastest.
  9394. *
  9395. * Execute PCF on a 1*1 kernel.
  9396. *
  9397. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9398. */
  9399. static readonly QUALITY_LOW: number;
  9400. /** Gets or sets the custom shader name to use */
  9401. customShaderOptions: ICustomShaderOptions;
  9402. /**
  9403. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9404. */
  9405. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9406. /**
  9407. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9408. */
  9409. onAfterShadowMapRenderObservable: Observable<Effect>;
  9410. /**
  9411. * Observable triggered before a mesh is rendered in the shadow map.
  9412. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9413. */
  9414. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9415. /**
  9416. * Observable triggered after a mesh is rendered in the shadow map.
  9417. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9418. */
  9419. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9420. private _bias;
  9421. /**
  9422. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9423. */
  9424. /**
  9425. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9426. */
  9427. bias: number;
  9428. private _normalBias;
  9429. /**
  9430. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9431. */
  9432. /**
  9433. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9434. */
  9435. normalBias: number;
  9436. private _blurBoxOffset;
  9437. /**
  9438. * Gets the blur box offset: offset applied during the blur pass.
  9439. * Only useful if useKernelBlur = false
  9440. */
  9441. /**
  9442. * Sets the blur box offset: offset applied during the blur pass.
  9443. * Only useful if useKernelBlur = false
  9444. */
  9445. blurBoxOffset: number;
  9446. private _blurScale;
  9447. /**
  9448. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9449. * 2 means half of the size.
  9450. */
  9451. /**
  9452. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9453. * 2 means half of the size.
  9454. */
  9455. blurScale: number;
  9456. private _blurKernel;
  9457. /**
  9458. * Gets the blur kernel: kernel size of the blur pass.
  9459. * Only useful if useKernelBlur = true
  9460. */
  9461. /**
  9462. * Sets the blur kernel: kernel size of the blur pass.
  9463. * Only useful if useKernelBlur = true
  9464. */
  9465. blurKernel: number;
  9466. private _useKernelBlur;
  9467. /**
  9468. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9469. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9470. */
  9471. /**
  9472. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9473. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9474. */
  9475. useKernelBlur: boolean;
  9476. private _depthScale;
  9477. /**
  9478. * Gets the depth scale used in ESM mode.
  9479. */
  9480. /**
  9481. * Sets the depth scale used in ESM mode.
  9482. * This can override the scale stored on the light.
  9483. */
  9484. depthScale: number;
  9485. private _filter;
  9486. /**
  9487. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9488. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9489. */
  9490. /**
  9491. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9492. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9493. */
  9494. filter: number;
  9495. /**
  9496. * Gets if the current filter is set to Poisson Sampling.
  9497. */
  9498. /**
  9499. * Sets the current filter to Poisson Sampling.
  9500. */
  9501. usePoissonSampling: boolean;
  9502. /**
  9503. * Gets if the current filter is set to ESM.
  9504. */
  9505. /**
  9506. * Sets the current filter is to ESM.
  9507. */
  9508. useExponentialShadowMap: boolean;
  9509. /**
  9510. * Gets if the current filter is set to filtered ESM.
  9511. */
  9512. /**
  9513. * Gets if the current filter is set to filtered ESM.
  9514. */
  9515. useBlurExponentialShadowMap: boolean;
  9516. /**
  9517. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9518. * exponential to prevent steep falloff artifacts).
  9519. */
  9520. /**
  9521. * Sets the current filter to "close ESM" (using the inverse of the
  9522. * exponential to prevent steep falloff artifacts).
  9523. */
  9524. useCloseExponentialShadowMap: boolean;
  9525. /**
  9526. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9527. * exponential to prevent steep falloff artifacts).
  9528. */
  9529. /**
  9530. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9531. * exponential to prevent steep falloff artifacts).
  9532. */
  9533. useBlurCloseExponentialShadowMap: boolean;
  9534. /**
  9535. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9536. */
  9537. /**
  9538. * Sets the current filter to "PCF" (percentage closer filtering).
  9539. */
  9540. usePercentageCloserFiltering: boolean;
  9541. private _filteringQuality;
  9542. /**
  9543. * Gets the PCF or PCSS Quality.
  9544. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9545. */
  9546. /**
  9547. * Sets the PCF or PCSS Quality.
  9548. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9549. */
  9550. filteringQuality: number;
  9551. /**
  9552. * Gets if the current filter is set to "PCSS" (contact hardening).
  9553. */
  9554. /**
  9555. * Sets the current filter to "PCSS" (contact hardening).
  9556. */
  9557. useContactHardeningShadow: boolean;
  9558. private _contactHardeningLightSizeUVRatio;
  9559. /**
  9560. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9561. * Using a ratio helps keeping shape stability independently of the map size.
  9562. *
  9563. * It does not account for the light projection as it was having too much
  9564. * instability during the light setup or during light position changes.
  9565. *
  9566. * Only valid if useContactHardeningShadow is true.
  9567. */
  9568. /**
  9569. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9570. * Using a ratio helps keeping shape stability independently of the map size.
  9571. *
  9572. * It does not account for the light projection as it was having too much
  9573. * instability during the light setup or during light position changes.
  9574. *
  9575. * Only valid if useContactHardeningShadow is true.
  9576. */
  9577. contactHardeningLightSizeUVRatio: number;
  9578. private _darkness;
  9579. /** Gets or sets the actual darkness of a shadow */
  9580. darkness: number;
  9581. /**
  9582. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9583. * 0 means strongest and 1 would means no shadow.
  9584. * @returns the darkness.
  9585. */
  9586. getDarkness(): number;
  9587. /**
  9588. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9589. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9590. * @returns the shadow generator allowing fluent coding.
  9591. */
  9592. setDarkness(darkness: number): ShadowGenerator;
  9593. private _transparencyShadow;
  9594. /** Gets or sets the ability to have transparent shadow */
  9595. transparencyShadow: boolean;
  9596. /**
  9597. * Sets the ability to have transparent shadow (boolean).
  9598. * @param transparent True if transparent else False
  9599. * @returns the shadow generator allowing fluent coding
  9600. */
  9601. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9602. private _shadowMap;
  9603. private _shadowMap2;
  9604. /**
  9605. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9606. * @returns The render target texture if present otherwise, null
  9607. */
  9608. getShadowMap(): Nullable<RenderTargetTexture>;
  9609. /**
  9610. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9611. * @returns The render target texture if the shadow map is present otherwise, null
  9612. */
  9613. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9614. /**
  9615. * Gets the class name of that object
  9616. * @returns "ShadowGenerator"
  9617. */
  9618. getClassName(): string;
  9619. /**
  9620. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9621. * @param mesh Mesh to add
  9622. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9623. * @returns the Shadow Generator itself
  9624. */
  9625. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9626. /**
  9627. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9628. * @param mesh Mesh to remove
  9629. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9630. * @returns the Shadow Generator itself
  9631. */
  9632. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9633. /**
  9634. * Controls the extent to which the shadows fade out at the edge of the frustum
  9635. * Used only by directionals and spots
  9636. */
  9637. frustumEdgeFalloff: number;
  9638. private _light;
  9639. /**
  9640. * Returns the associated light object.
  9641. * @returns the light generating the shadow
  9642. */
  9643. getLight(): IShadowLight;
  9644. /**
  9645. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9646. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9647. * It might on the other hand introduce peter panning.
  9648. */
  9649. forceBackFacesOnly: boolean;
  9650. private _scene;
  9651. private _lightDirection;
  9652. private _effect;
  9653. private _viewMatrix;
  9654. private _projectionMatrix;
  9655. private _transformMatrix;
  9656. private _cachedPosition;
  9657. private _cachedDirection;
  9658. private _cachedDefines;
  9659. private _currentRenderID;
  9660. private _boxBlurPostprocess;
  9661. private _kernelBlurXPostprocess;
  9662. private _kernelBlurYPostprocess;
  9663. private _blurPostProcesses;
  9664. private _mapSize;
  9665. private _currentFaceIndex;
  9666. private _currentFaceIndexCache;
  9667. private _textureType;
  9668. private _defaultTextureMatrix;
  9669. /** @hidden */
  9670. static _SceneComponentInitialization: (scene: Scene) => void;
  9671. /**
  9672. * Creates a ShadowGenerator object.
  9673. * A ShadowGenerator is the required tool to use the shadows.
  9674. * Each light casting shadows needs to use its own ShadowGenerator.
  9675. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9676. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9677. * @param light The light object generating the shadows.
  9678. * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  9679. */
  9680. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9681. private _initializeGenerator;
  9682. private _initializeShadowMap;
  9683. private _initializeBlurRTTAndPostProcesses;
  9684. private _renderForShadowMap;
  9685. private _renderSubMeshForShadowMap;
  9686. private _applyFilterValues;
  9687. /**
  9688. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9689. * @param onCompiled Callback triggered at the and of the effects compilation
  9690. * @param options Sets of optional options forcing the compilation with different modes
  9691. */
  9692. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9693. useInstances: boolean;
  9694. }>): void;
  9695. /**
  9696. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9697. * @param options Sets of optional options forcing the compilation with different modes
  9698. * @returns A promise that resolves when the compilation completes
  9699. */
  9700. forceCompilationAsync(options?: Partial<{
  9701. useInstances: boolean;
  9702. }>): Promise<void>;
  9703. /**
  9704. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9705. * @param subMesh The submesh we want to render in the shadow map
  9706. * @param useInstances Defines wether will draw in the map using instances
  9707. * @returns true if ready otherwise, false
  9708. */
  9709. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9710. /**
  9711. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9712. * @param defines Defines of the material we want to update
  9713. * @param lightIndex Index of the light in the enabled light list of the material
  9714. */
  9715. prepareDefines(defines: any, lightIndex: number): void;
  9716. /**
  9717. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9718. * defined in the generator but impacting the effect).
  9719. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9720. * @param effect The effect we are binfing the information for
  9721. */
  9722. bindShadowLight(lightIndex: string, effect: Effect): void;
  9723. /**
  9724. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9725. * (eq to shadow prjection matrix * light transform matrix)
  9726. * @returns The transform matrix used to create the shadow map
  9727. */
  9728. getTransformMatrix(): Matrix;
  9729. /**
  9730. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9731. * Cube and 2D textures for instance.
  9732. */
  9733. recreateShadowMap(): void;
  9734. private _disposeBlurPostProcesses;
  9735. private _disposeRTTandPostProcesses;
  9736. /**
  9737. * Disposes the ShadowGenerator.
  9738. * Returns nothing.
  9739. */
  9740. dispose(): void;
  9741. /**
  9742. * Serializes the shadow generator setup to a json object.
  9743. * @returns The serialized JSON object
  9744. */
  9745. serialize(): any;
  9746. /**
  9747. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9748. * @param parsedShadowGenerator The JSON object to parse
  9749. * @param scene The scene to create the shadow map for
  9750. * @returns The parsed shadow generator
  9751. */
  9752. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9753. }
  9754. }
  9755. declare module "babylonjs/Lights/light" {
  9756. import { Nullable } from "babylonjs/types";
  9757. import { Scene } from "babylonjs/scene";
  9758. import { Vector3 } from "babylonjs/Maths/math.vector";
  9759. import { Color3 } from "babylonjs/Maths/math.color";
  9760. import { Node } from "babylonjs/node";
  9761. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9762. import { Effect } from "babylonjs/Materials/effect";
  9763. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9764. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9765. /**
  9766. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9767. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9768. * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.
  9769. */
  9770. export abstract class Light extends Node {
  9771. /**
  9772. * Falloff Default: light is falling off following the material specification:
  9773. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9774. */
  9775. static readonly FALLOFF_DEFAULT: number;
  9776. /**
  9777. * Falloff Physical: light is falling off following the inverse squared distance law.
  9778. */
  9779. static readonly FALLOFF_PHYSICAL: number;
  9780. /**
  9781. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9782. * to enhance interoperability with other engines.
  9783. */
  9784. static readonly FALLOFF_GLTF: number;
  9785. /**
  9786. * Falloff Standard: light is falling off like in the standard material
  9787. * to enhance interoperability with other materials.
  9788. */
  9789. static readonly FALLOFF_STANDARD: number;
  9790. /**
  9791. * If every light affecting the material is in this lightmapMode,
  9792. * material.lightmapTexture adds or multiplies
  9793. * (depends on material.useLightmapAsShadowmap)
  9794. * after every other light calculations.
  9795. */
  9796. static readonly LIGHTMAP_DEFAULT: number;
  9797. /**
  9798. * material.lightmapTexture as only diffuse lighting from this light
  9799. * adds only specular lighting from this light
  9800. * adds dynamic shadows
  9801. */
  9802. static readonly LIGHTMAP_SPECULAR: number;
  9803. /**
  9804. * material.lightmapTexture as only lighting
  9805. * no light calculation from this light
  9806. * only adds dynamic shadows from this light
  9807. */
  9808. static readonly LIGHTMAP_SHADOWSONLY: number;
  9809. /**
  9810. * Each light type uses the default quantity according to its type:
  9811. * point/spot lights use luminous intensity
  9812. * directional lights use illuminance
  9813. */
  9814. static readonly INTENSITYMODE_AUTOMATIC: number;
  9815. /**
  9816. * lumen (lm)
  9817. */
  9818. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9819. /**
  9820. * candela (lm/sr)
  9821. */
  9822. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9823. /**
  9824. * lux (lm/m^2)
  9825. */
  9826. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9827. /**
  9828. * nit (cd/m^2)
  9829. */
  9830. static readonly INTENSITYMODE_LUMINANCE: number;
  9831. /**
  9832. * Light type const id of the point light.
  9833. */
  9834. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9835. /**
  9836. * Light type const id of the directional light.
  9837. */
  9838. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9839. /**
  9840. * Light type const id of the spot light.
  9841. */
  9842. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9843. /**
  9844. * Light type const id of the hemispheric light.
  9845. */
  9846. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9847. /**
  9848. * Diffuse gives the basic color to an object.
  9849. */
  9850. diffuse: Color3;
  9851. /**
  9852. * Specular produces a highlight color on an object.
  9853. * Note: This is note affecting PBR materials.
  9854. */
  9855. specular: Color3;
  9856. /**
  9857. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9858. * falling off base on range or angle.
  9859. * This can be set to any values in Light.FALLOFF_x.
  9860. *
  9861. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9862. * other types of materials.
  9863. */
  9864. falloffType: number;
  9865. /**
  9866. * Strength of the light.
  9867. * Note: By default it is define in the framework own unit.
  9868. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9869. */
  9870. intensity: number;
  9871. private _range;
  9872. protected _inverseSquaredRange: number;
  9873. /**
  9874. * Defines how far from the source the light is impacting in scene units.
  9875. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9876. */
  9877. /**
  9878. * Defines how far from the source the light is impacting in scene units.
  9879. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9880. */
  9881. range: number;
  9882. /**
  9883. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9884. * of light.
  9885. */
  9886. private _photometricScale;
  9887. private _intensityMode;
  9888. /**
  9889. * Gets the photometric scale used to interpret the intensity.
  9890. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9891. */
  9892. /**
  9893. * Sets the photometric scale used to interpret the intensity.
  9894. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9895. */
  9896. intensityMode: number;
  9897. private _radius;
  9898. /**
  9899. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9900. */
  9901. /**
  9902. * sets the light radius used by PBR Materials to simulate soft area lights.
  9903. */
  9904. radius: number;
  9905. private _renderPriority;
  9906. /**
  9907. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9908. * exceeding the number allowed of the materials.
  9909. */
  9910. renderPriority: number;
  9911. private _shadowEnabled;
  9912. /**
  9913. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9914. * the current shadow generator.
  9915. */
  9916. /**
  9917. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9918. * the current shadow generator.
  9919. */
  9920. shadowEnabled: boolean;
  9921. private _includedOnlyMeshes;
  9922. /**
  9923. * Gets the only meshes impacted by this light.
  9924. */
  9925. /**
  9926. * Sets the only meshes impacted by this light.
  9927. */
  9928. includedOnlyMeshes: AbstractMesh[];
  9929. private _excludedMeshes;
  9930. /**
  9931. * Gets the meshes not impacted by this light.
  9932. */
  9933. /**
  9934. * Sets the meshes not impacted by this light.
  9935. */
  9936. excludedMeshes: AbstractMesh[];
  9937. private _excludeWithLayerMask;
  9938. /**
  9939. * Gets the layer id use to find what meshes are not impacted by the light.
  9940. * Inactive if 0
  9941. */
  9942. /**
  9943. * Sets the layer id use to find what meshes are not impacted by the light.
  9944. * Inactive if 0
  9945. */
  9946. excludeWithLayerMask: number;
  9947. private _includeOnlyWithLayerMask;
  9948. /**
  9949. * Gets the layer id use to find what meshes are impacted by the light.
  9950. * Inactive if 0
  9951. */
  9952. /**
  9953. * Sets the layer id use to find what meshes are impacted by the light.
  9954. * Inactive if 0
  9955. */
  9956. includeOnlyWithLayerMask: number;
  9957. private _lightmapMode;
  9958. /**
  9959. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9960. */
  9961. /**
  9962. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9963. */
  9964. lightmapMode: number;
  9965. /**
  9966. * Shadow generator associted to the light.
  9967. * @hidden Internal use only.
  9968. */
  9969. _shadowGenerator: Nullable<IShadowGenerator>;
  9970. /**
  9971. * @hidden Internal use only.
  9972. */
  9973. _excludedMeshesIds: string[];
  9974. /**
  9975. * @hidden Internal use only.
  9976. */
  9977. _includedOnlyMeshesIds: string[];
  9978. /**
  9979. * The current light unifom buffer.
  9980. * @hidden Internal use only.
  9981. */
  9982. _uniformBuffer: UniformBuffer;
  9983. /**
  9984. * Creates a Light object in the scene.
  9985. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9986. * @param name The firendly name of the light
  9987. * @param scene The scene the light belongs too
  9988. */
  9989. constructor(name: string, scene: Scene);
  9990. protected abstract _buildUniformLayout(): void;
  9991. /**
  9992. * Sets the passed Effect "effect" with the Light information.
  9993. * @param effect The effect to update
  9994. * @param lightIndex The index of the light in the effect to update
  9995. * @returns The light
  9996. */
  9997. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9998. /**
  9999. * Returns the string "Light".
  10000. * @returns the class name
  10001. */
  10002. getClassName(): string;
  10003. /** @hidden */
  10004. readonly _isLight: boolean;
  10005. /**
  10006. * Converts the light information to a readable string for debug purpose.
  10007. * @param fullDetails Supports for multiple levels of logging within scene loading
  10008. * @returns the human readable light info
  10009. */
  10010. toString(fullDetails?: boolean): string;
  10011. /** @hidden */
  10012. protected _syncParentEnabledState(): void;
  10013. /**
  10014. * Set the enabled state of this node.
  10015. * @param value - the new enabled state
  10016. */
  10017. setEnabled(value: boolean): void;
  10018. /**
  10019. * Returns the Light associated shadow generator if any.
  10020. * @return the associated shadow generator.
  10021. */
  10022. getShadowGenerator(): Nullable<IShadowGenerator>;
  10023. /**
  10024. * Returns a Vector3, the absolute light position in the World.
  10025. * @returns the world space position of the light
  10026. */
  10027. getAbsolutePosition(): Vector3;
  10028. /**
  10029. * Specifies if the light will affect the passed mesh.
  10030. * @param mesh The mesh to test against the light
  10031. * @return true the mesh is affected otherwise, false.
  10032. */
  10033. canAffectMesh(mesh: AbstractMesh): boolean;
  10034. /**
  10035. * Sort function to order lights for rendering.
  10036. * @param a First Light object to compare to second.
  10037. * @param b Second Light object to compare first.
  10038. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10039. */
  10040. static CompareLightsPriority(a: Light, b: Light): number;
  10041. /**
  10042. * Releases resources associated with this node.
  10043. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10044. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10045. */
  10046. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10047. /**
  10048. * Returns the light type ID (integer).
  10049. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10050. */
  10051. getTypeID(): number;
  10052. /**
  10053. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10054. * @returns the scaled intensity in intensity mode unit
  10055. */
  10056. getScaledIntensity(): number;
  10057. /**
  10058. * Returns a new Light object, named "name", from the current one.
  10059. * @param name The name of the cloned light
  10060. * @returns the new created light
  10061. */
  10062. clone(name: string): Nullable<Light>;
  10063. /**
  10064. * Serializes the current light into a Serialization object.
  10065. * @returns the serialized object.
  10066. */
  10067. serialize(): any;
  10068. /**
  10069. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10070. * This new light is named "name" and added to the passed scene.
  10071. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10072. * @param name The friendly name of the light
  10073. * @param scene The scene the new light will belong to
  10074. * @returns the constructor function
  10075. */
  10076. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10077. /**
  10078. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10079. * @param parsedLight The JSON representation of the light
  10080. * @param scene The scene to create the parsed light in
  10081. * @returns the created light after parsing
  10082. */
  10083. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10084. private _hookArrayForExcluded;
  10085. private _hookArrayForIncludedOnly;
  10086. private _resyncMeshes;
  10087. /**
  10088. * Forces the meshes to update their light related information in their rendering used effects
  10089. * @hidden Internal Use Only
  10090. */
  10091. _markMeshesAsLightDirty(): void;
  10092. /**
  10093. * Recomputes the cached photometric scale if needed.
  10094. */
  10095. private _computePhotometricScale;
  10096. /**
  10097. * Returns the Photometric Scale according to the light type and intensity mode.
  10098. */
  10099. private _getPhotometricScale;
  10100. /**
  10101. * Reorder the light in the scene according to their defined priority.
  10102. * @hidden Internal Use Only
  10103. */
  10104. _reorderLightsInScene(): void;
  10105. /**
  10106. * Prepares the list of defines specific to the light type.
  10107. * @param defines the list of defines
  10108. * @param lightIndex defines the index of the light for the effect
  10109. */
  10110. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10111. }
  10112. }
  10113. declare module "babylonjs/Actions/action" {
  10114. import { Observable } from "babylonjs/Misc/observable";
  10115. import { Condition } from "babylonjs/Actions/condition";
  10116. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10117. import { ActionManager } from "babylonjs/Actions/actionManager";
  10118. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10119. /**
  10120. * Interface used to define Action
  10121. */
  10122. export interface IAction {
  10123. /**
  10124. * Trigger for the action
  10125. */
  10126. trigger: number;
  10127. /** Options of the trigger */
  10128. triggerOptions: any;
  10129. /**
  10130. * Gets the trigger parameters
  10131. * @returns the trigger parameters
  10132. */
  10133. getTriggerParameter(): any;
  10134. /**
  10135. * Internal only - executes current action event
  10136. * @hidden
  10137. */
  10138. _executeCurrent(evt?: ActionEvent): void;
  10139. /**
  10140. * Serialize placeholder for child classes
  10141. * @param parent of child
  10142. * @returns the serialized object
  10143. */
  10144. serialize(parent: any): any;
  10145. /**
  10146. * Internal only
  10147. * @hidden
  10148. */
  10149. _prepare(): void;
  10150. /**
  10151. * Internal only - manager for action
  10152. * @hidden
  10153. */
  10154. _actionManager: AbstractActionManager;
  10155. /**
  10156. * Adds action to chain of actions, may be a DoNothingAction
  10157. * @param action defines the next action to execute
  10158. * @returns The action passed in
  10159. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10160. */
  10161. then(action: IAction): IAction;
  10162. }
  10163. /**
  10164. * The action to be carried out following a trigger
  10165. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10166. */
  10167. export class Action implements IAction {
  10168. /** the trigger, with or without parameters, for the action */
  10169. triggerOptions: any;
  10170. /**
  10171. * Trigger for the action
  10172. */
  10173. trigger: number;
  10174. /**
  10175. * Internal only - manager for action
  10176. * @hidden
  10177. */
  10178. _actionManager: ActionManager;
  10179. private _nextActiveAction;
  10180. private _child;
  10181. private _condition?;
  10182. private _triggerParameter;
  10183. /**
  10184. * An event triggered prior to action being executed.
  10185. */
  10186. onBeforeExecuteObservable: Observable<Action>;
  10187. /**
  10188. * Creates a new Action
  10189. * @param triggerOptions the trigger, with or without parameters, for the action
  10190. * @param condition an optional determinant of action
  10191. */
  10192. constructor(
  10193. /** the trigger, with or without parameters, for the action */
  10194. triggerOptions: any, condition?: Condition);
  10195. /**
  10196. * Internal only
  10197. * @hidden
  10198. */
  10199. _prepare(): void;
  10200. /**
  10201. * Gets the trigger parameters
  10202. * @returns the trigger parameters
  10203. */
  10204. getTriggerParameter(): any;
  10205. /**
  10206. * Internal only - executes current action event
  10207. * @hidden
  10208. */
  10209. _executeCurrent(evt?: ActionEvent): void;
  10210. /**
  10211. * Execute placeholder for child classes
  10212. * @param evt optional action event
  10213. */
  10214. execute(evt?: ActionEvent): void;
  10215. /**
  10216. * Skips to next active action
  10217. */
  10218. skipToNextActiveAction(): void;
  10219. /**
  10220. * Adds action to chain of actions, may be a DoNothingAction
  10221. * @param action defines the next action to execute
  10222. * @returns The action passed in
  10223. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10224. */
  10225. then(action: Action): Action;
  10226. /**
  10227. * Internal only
  10228. * @hidden
  10229. */
  10230. _getProperty(propertyPath: string): string;
  10231. /**
  10232. * Internal only
  10233. * @hidden
  10234. */
  10235. _getEffectiveTarget(target: any, propertyPath: string): any;
  10236. /**
  10237. * Serialize placeholder for child classes
  10238. * @param parent of child
  10239. * @returns the serialized object
  10240. */
  10241. serialize(parent: any): any;
  10242. /**
  10243. * Internal only called by serialize
  10244. * @hidden
  10245. */
  10246. protected _serialize(serializedAction: any, parent?: any): any;
  10247. /**
  10248. * Internal only
  10249. * @hidden
  10250. */
  10251. static _SerializeValueAsString: (value: any) => string;
  10252. /**
  10253. * Internal only
  10254. * @hidden
  10255. */
  10256. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10257. name: string;
  10258. targetType: string;
  10259. value: string;
  10260. };
  10261. }
  10262. }
  10263. declare module "babylonjs/Actions/condition" {
  10264. import { ActionManager } from "babylonjs/Actions/actionManager";
  10265. /**
  10266. * A Condition applied to an Action
  10267. */
  10268. export class Condition {
  10269. /**
  10270. * Internal only - manager for action
  10271. * @hidden
  10272. */
  10273. _actionManager: ActionManager;
  10274. /**
  10275. * Internal only
  10276. * @hidden
  10277. */
  10278. _evaluationId: number;
  10279. /**
  10280. * Internal only
  10281. * @hidden
  10282. */
  10283. _currentResult: boolean;
  10284. /**
  10285. * Creates a new Condition
  10286. * @param actionManager the manager of the action the condition is applied to
  10287. */
  10288. constructor(actionManager: ActionManager);
  10289. /**
  10290. * Check if the current condition is valid
  10291. * @returns a boolean
  10292. */
  10293. isValid(): boolean;
  10294. /**
  10295. * Internal only
  10296. * @hidden
  10297. */
  10298. _getProperty(propertyPath: string): string;
  10299. /**
  10300. * Internal only
  10301. * @hidden
  10302. */
  10303. _getEffectiveTarget(target: any, propertyPath: string): any;
  10304. /**
  10305. * Serialize placeholder for child classes
  10306. * @returns the serialized object
  10307. */
  10308. serialize(): any;
  10309. /**
  10310. * Internal only
  10311. * @hidden
  10312. */
  10313. protected _serialize(serializedCondition: any): any;
  10314. }
  10315. /**
  10316. * Defines specific conditional operators as extensions of Condition
  10317. */
  10318. export class ValueCondition extends Condition {
  10319. /** path to specify the property of the target the conditional operator uses */
  10320. propertyPath: string;
  10321. /** the value compared by the conditional operator against the current value of the property */
  10322. value: any;
  10323. /** the conditional operator, default ValueCondition.IsEqual */
  10324. operator: number;
  10325. /**
  10326. * Internal only
  10327. * @hidden
  10328. */
  10329. private static _IsEqual;
  10330. /**
  10331. * Internal only
  10332. * @hidden
  10333. */
  10334. private static _IsDifferent;
  10335. /**
  10336. * Internal only
  10337. * @hidden
  10338. */
  10339. private static _IsGreater;
  10340. /**
  10341. * Internal only
  10342. * @hidden
  10343. */
  10344. private static _IsLesser;
  10345. /**
  10346. * returns the number for IsEqual
  10347. */
  10348. static readonly IsEqual: number;
  10349. /**
  10350. * Returns the number for IsDifferent
  10351. */
  10352. static readonly IsDifferent: number;
  10353. /**
  10354. * Returns the number for IsGreater
  10355. */
  10356. static readonly IsGreater: number;
  10357. /**
  10358. * Returns the number for IsLesser
  10359. */
  10360. static readonly IsLesser: number;
  10361. /**
  10362. * Internal only The action manager for the condition
  10363. * @hidden
  10364. */
  10365. _actionManager: ActionManager;
  10366. /**
  10367. * Internal only
  10368. * @hidden
  10369. */
  10370. private _target;
  10371. /**
  10372. * Internal only
  10373. * @hidden
  10374. */
  10375. private _effectiveTarget;
  10376. /**
  10377. * Internal only
  10378. * @hidden
  10379. */
  10380. private _property;
  10381. /**
  10382. * Creates a new ValueCondition
  10383. * @param actionManager manager for the action the condition applies to
  10384. * @param target for the action
  10385. * @param propertyPath path to specify the property of the target the conditional operator uses
  10386. * @param value the value compared by the conditional operator against the current value of the property
  10387. * @param operator the conditional operator, default ValueCondition.IsEqual
  10388. */
  10389. constructor(actionManager: ActionManager, target: any,
  10390. /** path to specify the property of the target the conditional operator uses */
  10391. propertyPath: string,
  10392. /** the value compared by the conditional operator against the current value of the property */
  10393. value: any,
  10394. /** the conditional operator, default ValueCondition.IsEqual */
  10395. operator?: number);
  10396. /**
  10397. * Compares the given value with the property value for the specified conditional operator
  10398. * @returns the result of the comparison
  10399. */
  10400. isValid(): boolean;
  10401. /**
  10402. * Serialize the ValueCondition into a JSON compatible object
  10403. * @returns serialization object
  10404. */
  10405. serialize(): any;
  10406. /**
  10407. * Gets the name of the conditional operator for the ValueCondition
  10408. * @param operator the conditional operator
  10409. * @returns the name
  10410. */
  10411. static GetOperatorName(operator: number): string;
  10412. }
  10413. /**
  10414. * Defines a predicate condition as an extension of Condition
  10415. */
  10416. export class PredicateCondition extends Condition {
  10417. /** defines the predicate function used to validate the condition */
  10418. predicate: () => boolean;
  10419. /**
  10420. * Internal only - manager for action
  10421. * @hidden
  10422. */
  10423. _actionManager: ActionManager;
  10424. /**
  10425. * Creates a new PredicateCondition
  10426. * @param actionManager manager for the action the condition applies to
  10427. * @param predicate defines the predicate function used to validate the condition
  10428. */
  10429. constructor(actionManager: ActionManager,
  10430. /** defines the predicate function used to validate the condition */
  10431. predicate: () => boolean);
  10432. /**
  10433. * @returns the validity of the predicate condition
  10434. */
  10435. isValid(): boolean;
  10436. }
  10437. /**
  10438. * Defines a state condition as an extension of Condition
  10439. */
  10440. export class StateCondition extends Condition {
  10441. /** Value to compare with target state */
  10442. value: string;
  10443. /**
  10444. * Internal only - manager for action
  10445. * @hidden
  10446. */
  10447. _actionManager: ActionManager;
  10448. /**
  10449. * Internal only
  10450. * @hidden
  10451. */
  10452. private _target;
  10453. /**
  10454. * Creates a new StateCondition
  10455. * @param actionManager manager for the action the condition applies to
  10456. * @param target of the condition
  10457. * @param value to compare with target state
  10458. */
  10459. constructor(actionManager: ActionManager, target: any,
  10460. /** Value to compare with target state */
  10461. value: string);
  10462. /**
  10463. * Gets a boolean indicating if the current condition is met
  10464. * @returns the validity of the state
  10465. */
  10466. isValid(): boolean;
  10467. /**
  10468. * Serialize the StateCondition into a JSON compatible object
  10469. * @returns serialization object
  10470. */
  10471. serialize(): any;
  10472. }
  10473. }
  10474. declare module "babylonjs/Actions/directActions" {
  10475. import { Action } from "babylonjs/Actions/action";
  10476. import { Condition } from "babylonjs/Actions/condition";
  10477. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10478. /**
  10479. * This defines an action responsible to toggle a boolean once triggered.
  10480. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10481. */
  10482. export class SwitchBooleanAction extends Action {
  10483. /**
  10484. * The path to the boolean property in the target object
  10485. */
  10486. propertyPath: string;
  10487. private _target;
  10488. private _effectiveTarget;
  10489. private _property;
  10490. /**
  10491. * Instantiate the action
  10492. * @param triggerOptions defines the trigger options
  10493. * @param target defines the object containing the boolean
  10494. * @param propertyPath defines the path to the boolean property in the target object
  10495. * @param condition defines the trigger related conditions
  10496. */
  10497. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10498. /** @hidden */
  10499. _prepare(): void;
  10500. /**
  10501. * Execute the action toggle the boolean value.
  10502. */
  10503. execute(): void;
  10504. /**
  10505. * Serializes the actions and its related information.
  10506. * @param parent defines the object to serialize in
  10507. * @returns the serialized object
  10508. */
  10509. serialize(parent: any): any;
  10510. }
  10511. /**
  10512. * This defines an action responsible to set a the state field of the target
  10513. * to a desired value once triggered.
  10514. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10515. */
  10516. export class SetStateAction extends Action {
  10517. /**
  10518. * The value to store in the state field.
  10519. */
  10520. value: string;
  10521. private _target;
  10522. /**
  10523. * Instantiate the action
  10524. * @param triggerOptions defines the trigger options
  10525. * @param target defines the object containing the state property
  10526. * @param value defines the value to store in the state field
  10527. * @param condition defines the trigger related conditions
  10528. */
  10529. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10530. /**
  10531. * Execute the action and store the value on the target state property.
  10532. */
  10533. execute(): void;
  10534. /**
  10535. * Serializes the actions and its related information.
  10536. * @param parent defines the object to serialize in
  10537. * @returns the serialized object
  10538. */
  10539. serialize(parent: any): any;
  10540. }
  10541. /**
  10542. * This defines an action responsible to set a property of the target
  10543. * to a desired value once triggered.
  10544. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10545. */
  10546. export class SetValueAction extends Action {
  10547. /**
  10548. * The path of the property to set in the target.
  10549. */
  10550. propertyPath: string;
  10551. /**
  10552. * The value to set in the property
  10553. */
  10554. value: any;
  10555. private _target;
  10556. private _effectiveTarget;
  10557. private _property;
  10558. /**
  10559. * Instantiate the action
  10560. * @param triggerOptions defines the trigger options
  10561. * @param target defines the object containing the property
  10562. * @param propertyPath defines the path of the property to set in the target
  10563. * @param value defines the value to set in the property
  10564. * @param condition defines the trigger related conditions
  10565. */
  10566. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10567. /** @hidden */
  10568. _prepare(): void;
  10569. /**
  10570. * Execute the action and set the targetted property to the desired value.
  10571. */
  10572. execute(): void;
  10573. /**
  10574. * Serializes the actions and its related information.
  10575. * @param parent defines the object to serialize in
  10576. * @returns the serialized object
  10577. */
  10578. serialize(parent: any): any;
  10579. }
  10580. /**
  10581. * This defines an action responsible to increment the target value
  10582. * to a desired value once triggered.
  10583. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10584. */
  10585. export class IncrementValueAction extends Action {
  10586. /**
  10587. * The path of the property to increment in the target.
  10588. */
  10589. propertyPath: string;
  10590. /**
  10591. * The value we should increment the property by.
  10592. */
  10593. value: any;
  10594. private _target;
  10595. private _effectiveTarget;
  10596. private _property;
  10597. /**
  10598. * Instantiate the action
  10599. * @param triggerOptions defines the trigger options
  10600. * @param target defines the object containing the property
  10601. * @param propertyPath defines the path of the property to increment in the target
  10602. * @param value defines the value value we should increment the property by
  10603. * @param condition defines the trigger related conditions
  10604. */
  10605. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10606. /** @hidden */
  10607. _prepare(): void;
  10608. /**
  10609. * Execute the action and increment the target of the value amount.
  10610. */
  10611. execute(): void;
  10612. /**
  10613. * Serializes the actions and its related information.
  10614. * @param parent defines the object to serialize in
  10615. * @returns the serialized object
  10616. */
  10617. serialize(parent: any): any;
  10618. }
  10619. /**
  10620. * This defines an action responsible to start an animation once triggered.
  10621. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10622. */
  10623. export class PlayAnimationAction extends Action {
  10624. /**
  10625. * Where the animation should start (animation frame)
  10626. */
  10627. from: number;
  10628. /**
  10629. * Where the animation should stop (animation frame)
  10630. */
  10631. to: number;
  10632. /**
  10633. * Define if the animation should loop or stop after the first play.
  10634. */
  10635. loop?: boolean;
  10636. private _target;
  10637. /**
  10638. * Instantiate the action
  10639. * @param triggerOptions defines the trigger options
  10640. * @param target defines the target animation or animation name
  10641. * @param from defines from where the animation should start (animation frame)
  10642. * @param end defines where the animation should stop (animation frame)
  10643. * @param loop defines if the animation should loop or stop after the first play
  10644. * @param condition defines the trigger related conditions
  10645. */
  10646. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10647. /** @hidden */
  10648. _prepare(): void;
  10649. /**
  10650. * Execute the action and play the animation.
  10651. */
  10652. execute(): void;
  10653. /**
  10654. * Serializes the actions and its related information.
  10655. * @param parent defines the object to serialize in
  10656. * @returns the serialized object
  10657. */
  10658. serialize(parent: any): any;
  10659. }
  10660. /**
  10661. * This defines an action responsible to stop an animation once triggered.
  10662. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10663. */
  10664. export class StopAnimationAction extends Action {
  10665. private _target;
  10666. /**
  10667. * Instantiate the action
  10668. * @param triggerOptions defines the trigger options
  10669. * @param target defines the target animation or animation name
  10670. * @param condition defines the trigger related conditions
  10671. */
  10672. constructor(triggerOptions: any, target: any, condition?: Condition);
  10673. /** @hidden */
  10674. _prepare(): void;
  10675. /**
  10676. * Execute the action and stop the animation.
  10677. */
  10678. execute(): void;
  10679. /**
  10680. * Serializes the actions and its related information.
  10681. * @param parent defines the object to serialize in
  10682. * @returns the serialized object
  10683. */
  10684. serialize(parent: any): any;
  10685. }
  10686. /**
  10687. * This defines an action responsible that does nothing once triggered.
  10688. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10689. */
  10690. export class DoNothingAction extends Action {
  10691. /**
  10692. * Instantiate the action
  10693. * @param triggerOptions defines the trigger options
  10694. * @param condition defines the trigger related conditions
  10695. */
  10696. constructor(triggerOptions?: any, condition?: Condition);
  10697. /**
  10698. * Execute the action and do nothing.
  10699. */
  10700. execute(): void;
  10701. /**
  10702. * Serializes the actions and its related information.
  10703. * @param parent defines the object to serialize in
  10704. * @returns the serialized object
  10705. */
  10706. serialize(parent: any): any;
  10707. }
  10708. /**
  10709. * This defines an action responsible to trigger several actions once triggered.
  10710. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10711. */
  10712. export class CombineAction extends Action {
  10713. /**
  10714. * The list of aggregated animations to run.
  10715. */
  10716. children: Action[];
  10717. /**
  10718. * Instantiate the action
  10719. * @param triggerOptions defines the trigger options
  10720. * @param children defines the list of aggregated animations to run
  10721. * @param condition defines the trigger related conditions
  10722. */
  10723. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10724. /** @hidden */
  10725. _prepare(): void;
  10726. /**
  10727. * Execute the action and executes all the aggregated actions.
  10728. */
  10729. execute(evt: ActionEvent): void;
  10730. /**
  10731. * Serializes the actions and its related information.
  10732. * @param parent defines the object to serialize in
  10733. * @returns the serialized object
  10734. */
  10735. serialize(parent: any): any;
  10736. }
  10737. /**
  10738. * This defines an action responsible to run code (external event) once triggered.
  10739. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10740. */
  10741. export class ExecuteCodeAction extends Action {
  10742. /**
  10743. * The callback function to run.
  10744. */
  10745. func: (evt: ActionEvent) => void;
  10746. /**
  10747. * Instantiate the action
  10748. * @param triggerOptions defines the trigger options
  10749. * @param func defines the callback function to run
  10750. * @param condition defines the trigger related conditions
  10751. */
  10752. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10753. /**
  10754. * Execute the action and run the attached code.
  10755. */
  10756. execute(evt: ActionEvent): void;
  10757. }
  10758. /**
  10759. * This defines an action responsible to set the parent property of the target once triggered.
  10760. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10761. */
  10762. export class SetParentAction extends Action {
  10763. private _parent;
  10764. private _target;
  10765. /**
  10766. * Instantiate the action
  10767. * @param triggerOptions defines the trigger options
  10768. * @param target defines the target containing the parent property
  10769. * @param parent defines from where the animation should start (animation frame)
  10770. * @param condition defines the trigger related conditions
  10771. */
  10772. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10773. /** @hidden */
  10774. _prepare(): void;
  10775. /**
  10776. * Execute the action and set the parent property.
  10777. */
  10778. execute(): void;
  10779. /**
  10780. * Serializes the actions and its related information.
  10781. * @param parent defines the object to serialize in
  10782. * @returns the serialized object
  10783. */
  10784. serialize(parent: any): any;
  10785. }
  10786. }
  10787. declare module "babylonjs/Actions/actionManager" {
  10788. import { Nullable } from "babylonjs/types";
  10789. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10790. import { Scene } from "babylonjs/scene";
  10791. import { IAction } from "babylonjs/Actions/action";
  10792. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10793. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10794. /**
  10795. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10796. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10797. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10798. */
  10799. export class ActionManager extends AbstractActionManager {
  10800. /**
  10801. * Nothing
  10802. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10803. */
  10804. static readonly NothingTrigger: number;
  10805. /**
  10806. * On pick
  10807. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10808. */
  10809. static readonly OnPickTrigger: number;
  10810. /**
  10811. * On left pick
  10812. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10813. */
  10814. static readonly OnLeftPickTrigger: number;
  10815. /**
  10816. * On right pick
  10817. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10818. */
  10819. static readonly OnRightPickTrigger: number;
  10820. /**
  10821. * On center pick
  10822. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10823. */
  10824. static readonly OnCenterPickTrigger: number;
  10825. /**
  10826. * On pick down
  10827. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10828. */
  10829. static readonly OnPickDownTrigger: number;
  10830. /**
  10831. * On double pick
  10832. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10833. */
  10834. static readonly OnDoublePickTrigger: number;
  10835. /**
  10836. * On pick up
  10837. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10838. */
  10839. static readonly OnPickUpTrigger: number;
  10840. /**
  10841. * On pick out.
  10842. * This trigger will only be raised if you also declared a OnPickDown
  10843. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10844. */
  10845. static readonly OnPickOutTrigger: number;
  10846. /**
  10847. * On long press
  10848. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10849. */
  10850. static readonly OnLongPressTrigger: number;
  10851. /**
  10852. * On pointer over
  10853. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10854. */
  10855. static readonly OnPointerOverTrigger: number;
  10856. /**
  10857. * On pointer out
  10858. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10859. */
  10860. static readonly OnPointerOutTrigger: number;
  10861. /**
  10862. * On every frame
  10863. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10864. */
  10865. static readonly OnEveryFrameTrigger: number;
  10866. /**
  10867. * On intersection enter
  10868. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10869. */
  10870. static readonly OnIntersectionEnterTrigger: number;
  10871. /**
  10872. * On intersection exit
  10873. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10874. */
  10875. static readonly OnIntersectionExitTrigger: number;
  10876. /**
  10877. * On key down
  10878. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10879. */
  10880. static readonly OnKeyDownTrigger: number;
  10881. /**
  10882. * On key up
  10883. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10884. */
  10885. static readonly OnKeyUpTrigger: number;
  10886. private _scene;
  10887. /**
  10888. * Creates a new action manager
  10889. * @param scene defines the hosting scene
  10890. */
  10891. constructor(scene: Scene);
  10892. /**
  10893. * Releases all associated resources
  10894. */
  10895. dispose(): void;
  10896. /**
  10897. * Gets hosting scene
  10898. * @returns the hosting scene
  10899. */
  10900. getScene(): Scene;
  10901. /**
  10902. * Does this action manager handles actions of any of the given triggers
  10903. * @param triggers defines the triggers to be tested
  10904. * @return a boolean indicating whether one (or more) of the triggers is handled
  10905. */
  10906. hasSpecificTriggers(triggers: number[]): boolean;
  10907. /**
  10908. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10909. * speed.
  10910. * @param triggerA defines the trigger to be tested
  10911. * @param triggerB defines the trigger to be tested
  10912. * @return a boolean indicating whether one (or more) of the triggers is handled
  10913. */
  10914. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10915. /**
  10916. * Does this action manager handles actions of a given trigger
  10917. * @param trigger defines the trigger to be tested
  10918. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10919. * @return whether the trigger is handled
  10920. */
  10921. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10922. /**
  10923. * Does this action manager has pointer triggers
  10924. */
  10925. readonly hasPointerTriggers: boolean;
  10926. /**
  10927. * Does this action manager has pick triggers
  10928. */
  10929. readonly hasPickTriggers: boolean;
  10930. /**
  10931. * Registers an action to this action manager
  10932. * @param action defines the action to be registered
  10933. * @return the action amended (prepared) after registration
  10934. */
  10935. registerAction(action: IAction): Nullable<IAction>;
  10936. /**
  10937. * Unregisters an action to this action manager
  10938. * @param action defines the action to be unregistered
  10939. * @return a boolean indicating whether the action has been unregistered
  10940. */
  10941. unregisterAction(action: IAction): Boolean;
  10942. /**
  10943. * Process a specific trigger
  10944. * @param trigger defines the trigger to process
  10945. * @param evt defines the event details to be processed
  10946. */
  10947. processTrigger(trigger: number, evt?: IActionEvent): void;
  10948. /** @hidden */
  10949. _getEffectiveTarget(target: any, propertyPath: string): any;
  10950. /** @hidden */
  10951. _getProperty(propertyPath: string): string;
  10952. /**
  10953. * Serialize this manager to a JSON object
  10954. * @param name defines the property name to store this manager
  10955. * @returns a JSON representation of this manager
  10956. */
  10957. serialize(name: string): any;
  10958. /**
  10959. * Creates a new ActionManager from a JSON data
  10960. * @param parsedActions defines the JSON data to read from
  10961. * @param object defines the hosting mesh
  10962. * @param scene defines the hosting scene
  10963. */
  10964. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10965. /**
  10966. * Get a trigger name by index
  10967. * @param trigger defines the trigger index
  10968. * @returns a trigger name
  10969. */
  10970. static GetTriggerName(trigger: number): string;
  10971. }
  10972. }
  10973. declare module "babylonjs/Culling/ray" {
  10974. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10975. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10976. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10977. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10978. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10979. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10980. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10981. import { Plane } from "babylonjs/Maths/math.plane";
  10982. /**
  10983. * Class representing a ray with position and direction
  10984. */
  10985. export class Ray {
  10986. /** origin point */
  10987. origin: Vector3;
  10988. /** direction */
  10989. direction: Vector3;
  10990. /** length of the ray */
  10991. length: number;
  10992. private static readonly TmpVector3;
  10993. private _tmpRay;
  10994. /**
  10995. * Creates a new ray
  10996. * @param origin origin point
  10997. * @param direction direction
  10998. * @param length length of the ray
  10999. */
  11000. constructor(
  11001. /** origin point */
  11002. origin: Vector3,
  11003. /** direction */
  11004. direction: Vector3,
  11005. /** length of the ray */
  11006. length?: number);
  11007. /**
  11008. * Checks if the ray intersects a box
  11009. * @param minimum bound of the box
  11010. * @param maximum bound of the box
  11011. * @param intersectionTreshold extra extend to be added to the box in all direction
  11012. * @returns if the box was hit
  11013. */
  11014. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11015. /**
  11016. * Checks if the ray intersects a box
  11017. * @param box the bounding box to check
  11018. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11019. * @returns if the box was hit
  11020. */
  11021. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11022. /**
  11023. * If the ray hits a sphere
  11024. * @param sphere the bounding sphere to check
  11025. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11026. * @returns true if it hits the sphere
  11027. */
  11028. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11029. /**
  11030. * If the ray hits a triange
  11031. * @param vertex0 triangle vertex
  11032. * @param vertex1 triangle vertex
  11033. * @param vertex2 triangle vertex
  11034. * @returns intersection information if hit
  11035. */
  11036. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11037. /**
  11038. * Checks if ray intersects a plane
  11039. * @param plane the plane to check
  11040. * @returns the distance away it was hit
  11041. */
  11042. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11043. /**
  11044. * Calculate the intercept of a ray on a given axis
  11045. * @param axis to check 'x' | 'y' | 'z'
  11046. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11047. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11048. */
  11049. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11050. /**
  11051. * Checks if ray intersects a mesh
  11052. * @param mesh the mesh to check
  11053. * @param fastCheck if only the bounding box should checked
  11054. * @returns picking info of the intersecton
  11055. */
  11056. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11057. /**
  11058. * Checks if ray intersects a mesh
  11059. * @param meshes the meshes to check
  11060. * @param fastCheck if only the bounding box should checked
  11061. * @param results array to store result in
  11062. * @returns Array of picking infos
  11063. */
  11064. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11065. private _comparePickingInfo;
  11066. private static smallnum;
  11067. private static rayl;
  11068. /**
  11069. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11070. * @param sega the first point of the segment to test the intersection against
  11071. * @param segb the second point of the segment to test the intersection against
  11072. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11073. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11074. */
  11075. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11076. /**
  11077. * Update the ray from viewport position
  11078. * @param x position
  11079. * @param y y position
  11080. * @param viewportWidth viewport width
  11081. * @param viewportHeight viewport height
  11082. * @param world world matrix
  11083. * @param view view matrix
  11084. * @param projection projection matrix
  11085. * @returns this ray updated
  11086. */
  11087. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11088. /**
  11089. * Creates a ray with origin and direction of 0,0,0
  11090. * @returns the new ray
  11091. */
  11092. static Zero(): Ray;
  11093. /**
  11094. * Creates a new ray from screen space and viewport
  11095. * @param x position
  11096. * @param y y position
  11097. * @param viewportWidth viewport width
  11098. * @param viewportHeight viewport height
  11099. * @param world world matrix
  11100. * @param view view matrix
  11101. * @param projection projection matrix
  11102. * @returns new ray
  11103. */
  11104. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11105. /**
  11106. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  11107. * transformed to the given world matrix.
  11108. * @param origin The origin point
  11109. * @param end The end point
  11110. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11111. * @returns the new ray
  11112. */
  11113. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11114. /**
  11115. * Transforms a ray by a matrix
  11116. * @param ray ray to transform
  11117. * @param matrix matrix to apply
  11118. * @returns the resulting new ray
  11119. */
  11120. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11121. /**
  11122. * Transforms a ray by a matrix
  11123. * @param ray ray to transform
  11124. * @param matrix matrix to apply
  11125. * @param result ray to store result in
  11126. */
  11127. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11128. /**
  11129. * Unproject a ray from screen space to object space
  11130. * @param sourceX defines the screen space x coordinate to use
  11131. * @param sourceY defines the screen space y coordinate to use
  11132. * @param viewportWidth defines the current width of the viewport
  11133. * @param viewportHeight defines the current height of the viewport
  11134. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11135. * @param view defines the view matrix to use
  11136. * @param projection defines the projection matrix to use
  11137. */
  11138. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11139. }
  11140. /**
  11141. * Type used to define predicate used to select faces when a mesh intersection is detected
  11142. */
  11143. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11144. module "babylonjs/scene" {
  11145. interface Scene {
  11146. /** @hidden */
  11147. _tempPickingRay: Nullable<Ray>;
  11148. /** @hidden */
  11149. _cachedRayForTransform: Ray;
  11150. /** @hidden */
  11151. _pickWithRayInverseMatrix: Matrix;
  11152. /** @hidden */
  11153. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11154. /** @hidden */
  11155. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11156. }
  11157. }
  11158. }
  11159. declare module "babylonjs/sceneComponent" {
  11160. import { Scene } from "babylonjs/scene";
  11161. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11162. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11163. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11164. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11165. import { Nullable } from "babylonjs/types";
  11166. import { Camera } from "babylonjs/Cameras/camera";
  11167. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11168. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11169. import { AbstractScene } from "babylonjs/abstractScene";
  11170. /**
  11171. * Groups all the scene component constants in one place to ease maintenance.
  11172. * @hidden
  11173. */
  11174. export class SceneComponentConstants {
  11175. static readonly NAME_EFFECTLAYER: string;
  11176. static readonly NAME_LAYER: string;
  11177. static readonly NAME_LENSFLARESYSTEM: string;
  11178. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11179. static readonly NAME_PARTICLESYSTEM: string;
  11180. static readonly NAME_GAMEPAD: string;
  11181. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11182. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11183. static readonly NAME_DEPTHRENDERER: string;
  11184. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11185. static readonly NAME_SPRITE: string;
  11186. static readonly NAME_OUTLINERENDERER: string;
  11187. static readonly NAME_PROCEDURALTEXTURE: string;
  11188. static readonly NAME_SHADOWGENERATOR: string;
  11189. static readonly NAME_OCTREE: string;
  11190. static readonly NAME_PHYSICSENGINE: string;
  11191. static readonly NAME_AUDIO: string;
  11192. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11193. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11194. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11195. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11196. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11197. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11198. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11199. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11200. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11201. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11202. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11203. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11204. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11205. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11206. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11207. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11208. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11209. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11210. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11211. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11212. static readonly STEP_AFTERRENDER_AUDIO: number;
  11213. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11214. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11215. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11216. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11217. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11218. static readonly STEP_POINTERMOVE_SPRITE: number;
  11219. static readonly STEP_POINTERDOWN_SPRITE: number;
  11220. static readonly STEP_POINTERUP_SPRITE: number;
  11221. }
  11222. /**
  11223. * This represents a scene component.
  11224. *
  11225. * This is used to decouple the dependency the scene is having on the different workloads like
  11226. * layers, post processes...
  11227. */
  11228. export interface ISceneComponent {
  11229. /**
  11230. * The name of the component. Each component must have a unique name.
  11231. */
  11232. name: string;
  11233. /**
  11234. * The scene the component belongs to.
  11235. */
  11236. scene: Scene;
  11237. /**
  11238. * Register the component to one instance of a scene.
  11239. */
  11240. register(): void;
  11241. /**
  11242. * Rebuilds the elements related to this component in case of
  11243. * context lost for instance.
  11244. */
  11245. rebuild(): void;
  11246. /**
  11247. * Disposes the component and the associated ressources.
  11248. */
  11249. dispose(): void;
  11250. }
  11251. /**
  11252. * This represents a SERIALIZABLE scene component.
  11253. *
  11254. * This extends Scene Component to add Serialization methods on top.
  11255. */
  11256. export interface ISceneSerializableComponent extends ISceneComponent {
  11257. /**
  11258. * Adds all the elements from the container to the scene
  11259. * @param container the container holding the elements
  11260. */
  11261. addFromContainer(container: AbstractScene): void;
  11262. /**
  11263. * Removes all the elements in the container from the scene
  11264. * @param container contains the elements to remove
  11265. * @param dispose if the removed element should be disposed (default: false)
  11266. */
  11267. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11268. /**
  11269. * Serializes the component data to the specified json object
  11270. * @param serializationObject The object to serialize to
  11271. */
  11272. serialize(serializationObject: any): void;
  11273. }
  11274. /**
  11275. * Strong typing of a Mesh related stage step action
  11276. */
  11277. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11278. /**
  11279. * Strong typing of a Evaluate Sub Mesh related stage step action
  11280. */
  11281. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11282. /**
  11283. * Strong typing of a Active Mesh related stage step action
  11284. */
  11285. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11286. /**
  11287. * Strong typing of a Camera related stage step action
  11288. */
  11289. export type CameraStageAction = (camera: Camera) => void;
  11290. /**
  11291. * Strong typing of a Camera Frame buffer related stage step action
  11292. */
  11293. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11294. /**
  11295. * Strong typing of a Render Target related stage step action
  11296. */
  11297. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11298. /**
  11299. * Strong typing of a RenderingGroup related stage step action
  11300. */
  11301. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11302. /**
  11303. * Strong typing of a Mesh Render related stage step action
  11304. */
  11305. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11306. /**
  11307. * Strong typing of a simple stage step action
  11308. */
  11309. export type SimpleStageAction = () => void;
  11310. /**
  11311. * Strong typing of a render target action.
  11312. */
  11313. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11314. /**
  11315. * Strong typing of a pointer move action.
  11316. */
  11317. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11318. /**
  11319. * Strong typing of a pointer up/down action.
  11320. */
  11321. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11322. /**
  11323. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11324. * @hidden
  11325. */
  11326. export class Stage<T extends Function> extends Array<{
  11327. index: number;
  11328. component: ISceneComponent;
  11329. action: T;
  11330. }> {
  11331. /**
  11332. * Hide ctor from the rest of the world.
  11333. * @param items The items to add.
  11334. */
  11335. private constructor();
  11336. /**
  11337. * Creates a new Stage.
  11338. * @returns A new instance of a Stage
  11339. */
  11340. static Create<T extends Function>(): Stage<T>;
  11341. /**
  11342. * Registers a step in an ordered way in the targeted stage.
  11343. * @param index Defines the position to register the step in
  11344. * @param component Defines the component attached to the step
  11345. * @param action Defines the action to launch during the step
  11346. */
  11347. registerStep(index: number, component: ISceneComponent, action: T): void;
  11348. /**
  11349. * Clears all the steps from the stage.
  11350. */
  11351. clear(): void;
  11352. }
  11353. }
  11354. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11355. import { Nullable } from "babylonjs/types";
  11356. import { Observable } from "babylonjs/Misc/observable";
  11357. import { Scene } from "babylonjs/scene";
  11358. import { Sprite } from "babylonjs/Sprites/sprite";
  11359. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11360. import { Ray } from "babylonjs/Culling/ray";
  11361. import { Camera } from "babylonjs/Cameras/camera";
  11362. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11363. import { ISceneComponent } from "babylonjs/sceneComponent";
  11364. module "babylonjs/scene" {
  11365. interface Scene {
  11366. /** @hidden */
  11367. _pointerOverSprite: Nullable<Sprite>;
  11368. /** @hidden */
  11369. _pickedDownSprite: Nullable<Sprite>;
  11370. /** @hidden */
  11371. _tempSpritePickingRay: Nullable<Ray>;
  11372. /**
  11373. * All of the sprite managers added to this scene
  11374. * @see http://doc.babylonjs.com/babylon101/sprites
  11375. */
  11376. spriteManagers: Array<ISpriteManager>;
  11377. /**
  11378. * An event triggered when sprites rendering is about to start
  11379. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11380. */
  11381. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11382. /**
  11383. * An event triggered when sprites rendering is done
  11384. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11385. */
  11386. onAfterSpritesRenderingObservable: Observable<Scene>;
  11387. /** @hidden */
  11388. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11389. /** Launch a ray to try to pick a sprite in the scene
  11390. * @param x position on screen
  11391. * @param y position on screen
  11392. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11393. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11394. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11395. * @returns a PickingInfo
  11396. */
  11397. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11398. /** Use the given ray to pick a sprite in the scene
  11399. * @param ray The ray (in world space) to use to pick meshes
  11400. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11401. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11402. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11403. * @returns a PickingInfo
  11404. */
  11405. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11406. /** @hidden */
  11407. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11408. /** Launch a ray to try to pick sprites in the scene
  11409. * @param x position on screen
  11410. * @param y position on screen
  11411. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11412. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11413. * @returns a PickingInfo array
  11414. */
  11415. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11416. /** Use the given ray to pick sprites in the scene
  11417. * @param ray The ray (in world space) to use to pick meshes
  11418. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11419. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11420. * @returns a PickingInfo array
  11421. */
  11422. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11423. /**
  11424. * Force the sprite under the pointer
  11425. * @param sprite defines the sprite to use
  11426. */
  11427. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11428. /**
  11429. * Gets the sprite under the pointer
  11430. * @returns a Sprite or null if no sprite is under the pointer
  11431. */
  11432. getPointerOverSprite(): Nullable<Sprite>;
  11433. }
  11434. }
  11435. /**
  11436. * Defines the sprite scene component responsible to manage sprites
  11437. * in a given scene.
  11438. */
  11439. export class SpriteSceneComponent implements ISceneComponent {
  11440. /**
  11441. * The component name helpfull to identify the component in the list of scene components.
  11442. */
  11443. readonly name: string;
  11444. /**
  11445. * The scene the component belongs to.
  11446. */
  11447. scene: Scene;
  11448. /** @hidden */
  11449. private _spritePredicate;
  11450. /**
  11451. * Creates a new instance of the component for the given scene
  11452. * @param scene Defines the scene to register the component in
  11453. */
  11454. constructor(scene: Scene);
  11455. /**
  11456. * Registers the component in a given scene
  11457. */
  11458. register(): void;
  11459. /**
  11460. * Rebuilds the elements related to this component in case of
  11461. * context lost for instance.
  11462. */
  11463. rebuild(): void;
  11464. /**
  11465. * Disposes the component and the associated ressources.
  11466. */
  11467. dispose(): void;
  11468. private _pickSpriteButKeepRay;
  11469. private _pointerMove;
  11470. private _pointerDown;
  11471. private _pointerUp;
  11472. }
  11473. }
  11474. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11475. /** @hidden */
  11476. export var fogFragmentDeclaration: {
  11477. name: string;
  11478. shader: string;
  11479. };
  11480. }
  11481. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11482. /** @hidden */
  11483. export var fogFragment: {
  11484. name: string;
  11485. shader: string;
  11486. };
  11487. }
  11488. declare module "babylonjs/Shaders/sprites.fragment" {
  11489. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11490. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11491. /** @hidden */
  11492. export var spritesPixelShader: {
  11493. name: string;
  11494. shader: string;
  11495. };
  11496. }
  11497. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11498. /** @hidden */
  11499. export var fogVertexDeclaration: {
  11500. name: string;
  11501. shader: string;
  11502. };
  11503. }
  11504. declare module "babylonjs/Shaders/sprites.vertex" {
  11505. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11506. /** @hidden */
  11507. export var spritesVertexShader: {
  11508. name: string;
  11509. shader: string;
  11510. };
  11511. }
  11512. declare module "babylonjs/Sprites/spriteManager" {
  11513. import { IDisposable, Scene } from "babylonjs/scene";
  11514. import { Nullable } from "babylonjs/types";
  11515. import { Observable } from "babylonjs/Misc/observable";
  11516. import { Sprite } from "babylonjs/Sprites/sprite";
  11517. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11518. import { Camera } from "babylonjs/Cameras/camera";
  11519. import { Texture } from "babylonjs/Materials/Textures/texture";
  11520. import "babylonjs/Shaders/sprites.fragment";
  11521. import "babylonjs/Shaders/sprites.vertex";
  11522. import { Ray } from "babylonjs/Culling/ray";
  11523. /**
  11524. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11525. */
  11526. export interface ISpriteManager extends IDisposable {
  11527. /**
  11528. * Restricts the camera to viewing objects with the same layerMask.
  11529. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11530. */
  11531. layerMask: number;
  11532. /**
  11533. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11534. */
  11535. isPickable: boolean;
  11536. /**
  11537. * Specifies the rendering group id for this mesh (0 by default)
  11538. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11539. */
  11540. renderingGroupId: number;
  11541. /**
  11542. * Defines the list of sprites managed by the manager.
  11543. */
  11544. sprites: Array<Sprite>;
  11545. /**
  11546. * Tests the intersection of a sprite with a specific ray.
  11547. * @param ray The ray we are sending to test the collision
  11548. * @param camera The camera space we are sending rays in
  11549. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11550. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11551. * @returns picking info or null.
  11552. */
  11553. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11554. /**
  11555. * Intersects the sprites with a ray
  11556. * @param ray defines the ray to intersect with
  11557. * @param camera defines the current active camera
  11558. * @param predicate defines a predicate used to select candidate sprites
  11559. * @returns null if no hit or a PickingInfo array
  11560. */
  11561. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11562. /**
  11563. * Renders the list of sprites on screen.
  11564. */
  11565. render(): void;
  11566. }
  11567. /**
  11568. * Class used to manage multiple sprites on the same spritesheet
  11569. * @see http://doc.babylonjs.com/babylon101/sprites
  11570. */
  11571. export class SpriteManager implements ISpriteManager {
  11572. /** defines the manager's name */
  11573. name: string;
  11574. /** Gets the list of sprites */
  11575. sprites: Sprite[];
  11576. /** Gets or sets the rendering group id (0 by default) */
  11577. renderingGroupId: number;
  11578. /** Gets or sets camera layer mask */
  11579. layerMask: number;
  11580. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11581. fogEnabled: boolean;
  11582. /** Gets or sets a boolean indicating if the sprites are pickable */
  11583. isPickable: boolean;
  11584. /** Defines the default width of a cell in the spritesheet */
  11585. cellWidth: number;
  11586. /** Defines the default height of a cell in the spritesheet */
  11587. cellHeight: number;
  11588. /** Associative array from JSON sprite data file */
  11589. private _cellData;
  11590. /** Array of sprite names from JSON sprite data file */
  11591. private _spriteMap;
  11592. /** True when packed cell data from JSON file is ready*/
  11593. private _packedAndReady;
  11594. /**
  11595. * An event triggered when the manager is disposed.
  11596. */
  11597. onDisposeObservable: Observable<SpriteManager>;
  11598. private _onDisposeObserver;
  11599. /**
  11600. * Callback called when the manager is disposed
  11601. */
  11602. onDispose: () => void;
  11603. private _capacity;
  11604. private _fromPacked;
  11605. private _spriteTexture;
  11606. private _epsilon;
  11607. private _scene;
  11608. private _vertexData;
  11609. private _buffer;
  11610. private _vertexBuffers;
  11611. private _indexBuffer;
  11612. private _effectBase;
  11613. private _effectFog;
  11614. /**
  11615. * Gets or sets the spritesheet texture
  11616. */
  11617. texture: Texture;
  11618. /**
  11619. * Creates a new sprite manager
  11620. * @param name defines the manager's name
  11621. * @param imgUrl defines the sprite sheet url
  11622. * @param capacity defines the maximum allowed number of sprites
  11623. * @param cellSize defines the size of a sprite cell
  11624. * @param scene defines the hosting scene
  11625. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11626. * @param samplingMode defines the smapling mode to use with spritesheet
  11627. * @param fromPacked set to false; do not alter
  11628. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11629. */
  11630. constructor(
  11631. /** defines the manager's name */
  11632. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11633. private _makePacked;
  11634. private _appendSpriteVertex;
  11635. /**
  11636. * Intersects the sprites with a ray
  11637. * @param ray defines the ray to intersect with
  11638. * @param camera defines the current active camera
  11639. * @param predicate defines a predicate used to select candidate sprites
  11640. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11641. * @returns null if no hit or a PickingInfo
  11642. */
  11643. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11644. /**
  11645. * Intersects the sprites with a ray
  11646. * @param ray defines the ray to intersect with
  11647. * @param camera defines the current active camera
  11648. * @param predicate defines a predicate used to select candidate sprites
  11649. * @returns null if no hit or a PickingInfo array
  11650. */
  11651. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11652. /**
  11653. * Render all child sprites
  11654. */
  11655. render(): void;
  11656. /**
  11657. * Release associated resources
  11658. */
  11659. dispose(): void;
  11660. }
  11661. }
  11662. declare module "babylonjs/Sprites/sprite" {
  11663. import { Vector3 } from "babylonjs/Maths/math.vector";
  11664. import { Nullable } from "babylonjs/types";
  11665. import { ActionManager } from "babylonjs/Actions/actionManager";
  11666. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11667. import { Color4 } from "babylonjs/Maths/math.color";
  11668. /**
  11669. * Class used to represent a sprite
  11670. * @see http://doc.babylonjs.com/babylon101/sprites
  11671. */
  11672. export class Sprite {
  11673. /** defines the name */
  11674. name: string;
  11675. /** Gets or sets the current world position */
  11676. position: Vector3;
  11677. /** Gets or sets the main color */
  11678. color: Color4;
  11679. /** Gets or sets the width */
  11680. width: number;
  11681. /** Gets or sets the height */
  11682. height: number;
  11683. /** Gets or sets rotation angle */
  11684. angle: number;
  11685. /** Gets or sets the cell index in the sprite sheet */
  11686. cellIndex: number;
  11687. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11688. cellRef: string;
  11689. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11690. invertU: number;
  11691. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11692. invertV: number;
  11693. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11694. disposeWhenFinishedAnimating: boolean;
  11695. /** Gets the list of attached animations */
  11696. animations: Animation[];
  11697. /** Gets or sets a boolean indicating if the sprite can be picked */
  11698. isPickable: boolean;
  11699. /**
  11700. * Gets or sets the associated action manager
  11701. */
  11702. actionManager: Nullable<ActionManager>;
  11703. private _animationStarted;
  11704. private _loopAnimation;
  11705. private _fromIndex;
  11706. private _toIndex;
  11707. private _delay;
  11708. private _direction;
  11709. private _manager;
  11710. private _time;
  11711. private _onAnimationEnd;
  11712. /**
  11713. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11714. */
  11715. isVisible: boolean;
  11716. /**
  11717. * Gets or sets the sprite size
  11718. */
  11719. size: number;
  11720. /**
  11721. * Creates a new Sprite
  11722. * @param name defines the name
  11723. * @param manager defines the manager
  11724. */
  11725. constructor(
  11726. /** defines the name */
  11727. name: string, manager: ISpriteManager);
  11728. /**
  11729. * Starts an animation
  11730. * @param from defines the initial key
  11731. * @param to defines the end key
  11732. * @param loop defines if the animation must loop
  11733. * @param delay defines the start delay (in ms)
  11734. * @param onAnimationEnd defines a callback to call when animation ends
  11735. */
  11736. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11737. /** Stops current animation (if any) */
  11738. stopAnimation(): void;
  11739. /** @hidden */
  11740. _animate(deltaTime: number): void;
  11741. /** Release associated resources */
  11742. dispose(): void;
  11743. }
  11744. }
  11745. declare module "babylonjs/Collisions/pickingInfo" {
  11746. import { Nullable } from "babylonjs/types";
  11747. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11748. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11749. import { Sprite } from "babylonjs/Sprites/sprite";
  11750. import { Ray } from "babylonjs/Culling/ray";
  11751. /**
  11752. * Information about the result of picking within a scene
  11753. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11754. */
  11755. export class PickingInfo {
  11756. /** @hidden */
  11757. _pickingUnavailable: boolean;
  11758. /**
  11759. * If the pick collided with an object
  11760. */
  11761. hit: boolean;
  11762. /**
  11763. * Distance away where the pick collided
  11764. */
  11765. distance: number;
  11766. /**
  11767. * The location of pick collision
  11768. */
  11769. pickedPoint: Nullable<Vector3>;
  11770. /**
  11771. * The mesh corresponding the the pick collision
  11772. */
  11773. pickedMesh: Nullable<AbstractMesh>;
  11774. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11775. bu: number;
  11776. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11777. bv: number;
  11778. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11779. faceId: number;
  11780. /** Id of the the submesh that was picked */
  11781. subMeshId: number;
  11782. /** If a sprite was picked, this will be the sprite the pick collided with */
  11783. pickedSprite: Nullable<Sprite>;
  11784. /**
  11785. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11786. */
  11787. originMesh: Nullable<AbstractMesh>;
  11788. /**
  11789. * The ray that was used to perform the picking.
  11790. */
  11791. ray: Nullable<Ray>;
  11792. /**
  11793. * Gets the normal correspodning to the face the pick collided with
  11794. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11795. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11796. * @returns The normal correspodning to the face the pick collided with
  11797. */
  11798. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11799. /**
  11800. * Gets the texture coordinates of where the pick occured
  11801. * @returns the vector containing the coordnates of the texture
  11802. */
  11803. getTextureCoordinates(): Nullable<Vector2>;
  11804. }
  11805. }
  11806. declare module "babylonjs/Events/pointerEvents" {
  11807. import { Nullable } from "babylonjs/types";
  11808. import { Vector2 } from "babylonjs/Maths/math.vector";
  11809. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11810. import { Ray } from "babylonjs/Culling/ray";
  11811. /**
  11812. * Gather the list of pointer event types as constants.
  11813. */
  11814. export class PointerEventTypes {
  11815. /**
  11816. * The pointerdown event is fired when a pointer becomes active. For mouse, it is fired when the device transitions from no buttons depressed to at least one button depressed. For touch, it is fired when physical contact is made with the digitizer. For pen, it is fired when the stylus makes physical contact with the digitizer.
  11817. */
  11818. static readonly POINTERDOWN: number;
  11819. /**
  11820. * The pointerup event is fired when a pointer is no longer active.
  11821. */
  11822. static readonly POINTERUP: number;
  11823. /**
  11824. * The pointermove event is fired when a pointer changes coordinates.
  11825. */
  11826. static readonly POINTERMOVE: number;
  11827. /**
  11828. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11829. */
  11830. static readonly POINTERWHEEL: number;
  11831. /**
  11832. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11833. */
  11834. static readonly POINTERPICK: number;
  11835. /**
  11836. * The pointertap event is fired when a the object has been touched and released without drag.
  11837. */
  11838. static readonly POINTERTAP: number;
  11839. /**
  11840. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11841. */
  11842. static readonly POINTERDOUBLETAP: number;
  11843. }
  11844. /**
  11845. * Base class of pointer info types.
  11846. */
  11847. export class PointerInfoBase {
  11848. /**
  11849. * Defines the type of event (PointerEventTypes)
  11850. */
  11851. type: number;
  11852. /**
  11853. * Defines the related dom event
  11854. */
  11855. event: PointerEvent | MouseWheelEvent;
  11856. /**
  11857. * Instantiates the base class of pointers info.
  11858. * @param type Defines the type of event (PointerEventTypes)
  11859. * @param event Defines the related dom event
  11860. */
  11861. constructor(
  11862. /**
  11863. * Defines the type of event (PointerEventTypes)
  11864. */
  11865. type: number,
  11866. /**
  11867. * Defines the related dom event
  11868. */
  11869. event: PointerEvent | MouseWheelEvent);
  11870. }
  11871. /**
  11872. * This class is used to store pointer related info for the onPrePointerObservable event.
  11873. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11874. */
  11875. export class PointerInfoPre extends PointerInfoBase {
  11876. /**
  11877. * Ray from a pointer if availible (eg. 6dof controller)
  11878. */
  11879. ray: Nullable<Ray>;
  11880. /**
  11881. * Defines the local position of the pointer on the canvas.
  11882. */
  11883. localPosition: Vector2;
  11884. /**
  11885. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11886. */
  11887. skipOnPointerObservable: boolean;
  11888. /**
  11889. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11890. * @param type Defines the type of event (PointerEventTypes)
  11891. * @param event Defines the related dom event
  11892. * @param localX Defines the local x coordinates of the pointer when the event occured
  11893. * @param localY Defines the local y coordinates of the pointer when the event occured
  11894. */
  11895. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11896. }
  11897. /**
  11898. * This type contains all the data related to a pointer event in Babylon.js.
  11899. * The event member is an instance of PointerEvent for all types except PointerWheel and is of type MouseWheelEvent when type equals PointerWheel. The different event types can be found in the PointerEventTypes class.
  11900. */
  11901. export class PointerInfo extends PointerInfoBase {
  11902. /**
  11903. * Defines the picking info associated to the info (if any)\
  11904. */
  11905. pickInfo: Nullable<PickingInfo>;
  11906. /**
  11907. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11908. * @param type Defines the type of event (PointerEventTypes)
  11909. * @param event Defines the related dom event
  11910. * @param pickInfo Defines the picking info associated to the info (if any)\
  11911. */
  11912. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11913. /**
  11914. * Defines the picking info associated to the info (if any)\
  11915. */
  11916. pickInfo: Nullable<PickingInfo>);
  11917. }
  11918. /**
  11919. * Data relating to a touch event on the screen.
  11920. */
  11921. export interface PointerTouch {
  11922. /**
  11923. * X coordinate of touch.
  11924. */
  11925. x: number;
  11926. /**
  11927. * Y coordinate of touch.
  11928. */
  11929. y: number;
  11930. /**
  11931. * Id of touch. Unique for each finger.
  11932. */
  11933. pointerId: number;
  11934. /**
  11935. * Event type passed from DOM.
  11936. */
  11937. type: any;
  11938. }
  11939. }
  11940. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  11941. import { Observable } from "babylonjs/Misc/observable";
  11942. import { Nullable } from "babylonjs/types";
  11943. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  11944. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  11945. /**
  11946. * Manage the mouse inputs to control the movement of a free camera.
  11947. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11948. */
  11949. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11950. /**
  11951. * Define if touch is enabled in the mouse input
  11952. */
  11953. touchEnabled: boolean;
  11954. /**
  11955. * Defines the camera the input is attached to.
  11956. */
  11957. camera: FreeCamera;
  11958. /**
  11959. * Defines the buttons associated with the input to handle camera move.
  11960. */
  11961. buttons: number[];
  11962. /**
  11963. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11964. */
  11965. angularSensibility: number;
  11966. private _pointerInput;
  11967. private _onMouseMove;
  11968. private _observer;
  11969. private previousPosition;
  11970. /**
  11971. * Observable for when a pointer move event occurs containing the move offset
  11972. */
  11973. onPointerMovedObservable: Observable<{
  11974. offsetX: number;
  11975. offsetY: number;
  11976. }>;
  11977. /**
  11978. * @hidden
  11979. * If the camera should be rotated automatically based on pointer movement
  11980. */
  11981. _allowCameraRotation: boolean;
  11982. /**
  11983. * Manage the mouse inputs to control the movement of a free camera.
  11984. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11985. * @param touchEnabled Defines if touch is enabled or not
  11986. */
  11987. constructor(
  11988. /**
  11989. * Define if touch is enabled in the mouse input
  11990. */
  11991. touchEnabled?: boolean);
  11992. /**
  11993. * Attach the input controls to a specific dom element to get the input from.
  11994. * @param element Defines the element the controls should be listened from
  11995. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11996. */
  11997. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11998. /**
  11999. * Called on JS contextmenu event.
  12000. * Override this method to provide functionality.
  12001. */
  12002. protected onContextMenu(evt: PointerEvent): void;
  12003. /**
  12004. * Detach the current controls from the specified dom element.
  12005. * @param element Defines the element to stop listening the inputs from
  12006. */
  12007. detachControl(element: Nullable<HTMLElement>): void;
  12008. /**
  12009. * Gets the class name of the current intput.
  12010. * @returns the class name
  12011. */
  12012. getClassName(): string;
  12013. /**
  12014. * Get the friendly name associated with the input class.
  12015. * @returns the input friendly name
  12016. */
  12017. getSimpleName(): string;
  12018. }
  12019. }
  12020. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12021. import { Nullable } from "babylonjs/types";
  12022. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12023. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12024. /**
  12025. * Manage the touch inputs to control the movement of a free camera.
  12026. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12027. */
  12028. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12029. /**
  12030. * Defines the camera the input is attached to.
  12031. */
  12032. camera: FreeCamera;
  12033. /**
  12034. * Defines the touch sensibility for rotation.
  12035. * The higher the faster.
  12036. */
  12037. touchAngularSensibility: number;
  12038. /**
  12039. * Defines the touch sensibility for move.
  12040. * The higher the faster.
  12041. */
  12042. touchMoveSensibility: number;
  12043. private _offsetX;
  12044. private _offsetY;
  12045. private _pointerPressed;
  12046. private _pointerInput;
  12047. private _observer;
  12048. private _onLostFocus;
  12049. /**
  12050. * Attach the input controls to a specific dom element to get the input from.
  12051. * @param element Defines the element the controls should be listened from
  12052. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12053. */
  12054. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12055. /**
  12056. * Detach the current controls from the specified dom element.
  12057. * @param element Defines the element to stop listening the inputs from
  12058. */
  12059. detachControl(element: Nullable<HTMLElement>): void;
  12060. /**
  12061. * Update the current camera state depending on the inputs that have been used this frame.
  12062. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12063. */
  12064. checkInputs(): void;
  12065. /**
  12066. * Gets the class name of the current intput.
  12067. * @returns the class name
  12068. */
  12069. getClassName(): string;
  12070. /**
  12071. * Get the friendly name associated with the input class.
  12072. * @returns the input friendly name
  12073. */
  12074. getSimpleName(): string;
  12075. }
  12076. }
  12077. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12078. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12079. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12080. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12081. import { Nullable } from "babylonjs/types";
  12082. /**
  12083. * Default Inputs manager for the FreeCamera.
  12084. * It groups all the default supported inputs for ease of use.
  12085. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12086. */
  12087. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12088. /**
  12089. * @hidden
  12090. */
  12091. _mouseInput: Nullable<FreeCameraMouseInput>;
  12092. /**
  12093. * Instantiates a new FreeCameraInputsManager.
  12094. * @param camera Defines the camera the inputs belong to
  12095. */
  12096. constructor(camera: FreeCamera);
  12097. /**
  12098. * Add keyboard input support to the input manager.
  12099. * @returns the current input manager
  12100. */
  12101. addKeyboard(): FreeCameraInputsManager;
  12102. /**
  12103. * Add mouse input support to the input manager.
  12104. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12105. * @returns the current input manager
  12106. */
  12107. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12108. /**
  12109. * Removes the mouse input support from the manager
  12110. * @returns the current input manager
  12111. */
  12112. removeMouse(): FreeCameraInputsManager;
  12113. /**
  12114. * Add touch input support to the input manager.
  12115. * @returns the current input manager
  12116. */
  12117. addTouch(): FreeCameraInputsManager;
  12118. /**
  12119. * Remove all attached input methods from a camera
  12120. */
  12121. clear(): void;
  12122. }
  12123. }
  12124. declare module "babylonjs/Cameras/freeCamera" {
  12125. import { Vector3 } from "babylonjs/Maths/math.vector";
  12126. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12127. import { Scene } from "babylonjs/scene";
  12128. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12129. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12130. /**
  12131. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12132. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12133. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12134. */
  12135. export class FreeCamera extends TargetCamera {
  12136. /**
  12137. * Define the collision ellipsoid of the camera.
  12138. * This is helpful to simulate a camera body like the player body around the camera
  12139. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12140. */
  12141. ellipsoid: Vector3;
  12142. /**
  12143. * Define an offset for the position of the ellipsoid around the camera.
  12144. * This can be helpful to determine the center of the body near the gravity center of the body
  12145. * instead of its head.
  12146. */
  12147. ellipsoidOffset: Vector3;
  12148. /**
  12149. * Enable or disable collisions of the camera with the rest of the scene objects.
  12150. */
  12151. checkCollisions: boolean;
  12152. /**
  12153. * Enable or disable gravity on the camera.
  12154. */
  12155. applyGravity: boolean;
  12156. /**
  12157. * Define the input manager associated to the camera.
  12158. */
  12159. inputs: FreeCameraInputsManager;
  12160. /**
  12161. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12162. * Higher values reduce sensitivity.
  12163. */
  12164. /**
  12165. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12166. * Higher values reduce sensitivity.
  12167. */
  12168. angularSensibility: number;
  12169. /**
  12170. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12171. */
  12172. keysUp: number[];
  12173. /**
  12174. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12175. */
  12176. keysDown: number[];
  12177. /**
  12178. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12179. */
  12180. keysLeft: number[];
  12181. /**
  12182. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12183. */
  12184. keysRight: number[];
  12185. /**
  12186. * Event raised when the camera collide with a mesh in the scene.
  12187. */
  12188. onCollide: (collidedMesh: AbstractMesh) => void;
  12189. private _collider;
  12190. private _needMoveForGravity;
  12191. private _oldPosition;
  12192. private _diffPosition;
  12193. private _newPosition;
  12194. /** @hidden */
  12195. _localDirection: Vector3;
  12196. /** @hidden */
  12197. _transformedDirection: Vector3;
  12198. /**
  12199. * Instantiates a Free Camera.
  12200. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12201. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12202. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12203. * @param name Define the name of the camera in the scene
  12204. * @param position Define the start position of the camera in the scene
  12205. * @param scene Define the scene the camera belongs to
  12206. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12207. */
  12208. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12209. /**
  12210. * Attached controls to the current camera.
  12211. * @param element Defines the element the controls should be listened from
  12212. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12213. */
  12214. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12215. /**
  12216. * Detach the current controls from the camera.
  12217. * The camera will stop reacting to inputs.
  12218. * @param element Defines the element to stop listening the inputs from
  12219. */
  12220. detachControl(element: HTMLElement): void;
  12221. private _collisionMask;
  12222. /**
  12223. * Define a collision mask to limit the list of object the camera can collide with
  12224. */
  12225. collisionMask: number;
  12226. /** @hidden */
  12227. _collideWithWorld(displacement: Vector3): void;
  12228. private _onCollisionPositionChange;
  12229. /** @hidden */
  12230. _checkInputs(): void;
  12231. /** @hidden */
  12232. _decideIfNeedsToMove(): boolean;
  12233. /** @hidden */
  12234. _updatePosition(): void;
  12235. /**
  12236. * Destroy the camera and release the current resources hold by it.
  12237. */
  12238. dispose(): void;
  12239. /**
  12240. * Gets the current object class name.
  12241. * @return the class name
  12242. */
  12243. getClassName(): string;
  12244. }
  12245. }
  12246. declare module "babylonjs/Gamepads/gamepad" {
  12247. import { Observable } from "babylonjs/Misc/observable";
  12248. /**
  12249. * Represents a gamepad control stick position
  12250. */
  12251. export class StickValues {
  12252. /**
  12253. * The x component of the control stick
  12254. */
  12255. x: number;
  12256. /**
  12257. * The y component of the control stick
  12258. */
  12259. y: number;
  12260. /**
  12261. * Initializes the gamepad x and y control stick values
  12262. * @param x The x component of the gamepad control stick value
  12263. * @param y The y component of the gamepad control stick value
  12264. */
  12265. constructor(
  12266. /**
  12267. * The x component of the control stick
  12268. */
  12269. x: number,
  12270. /**
  12271. * The y component of the control stick
  12272. */
  12273. y: number);
  12274. }
  12275. /**
  12276. * An interface which manages callbacks for gamepad button changes
  12277. */
  12278. export interface GamepadButtonChanges {
  12279. /**
  12280. * Called when a gamepad has been changed
  12281. */
  12282. changed: boolean;
  12283. /**
  12284. * Called when a gamepad press event has been triggered
  12285. */
  12286. pressChanged: boolean;
  12287. /**
  12288. * Called when a touch event has been triggered
  12289. */
  12290. touchChanged: boolean;
  12291. /**
  12292. * Called when a value has changed
  12293. */
  12294. valueChanged: boolean;
  12295. }
  12296. /**
  12297. * Represents a gamepad
  12298. */
  12299. export class Gamepad {
  12300. /**
  12301. * The id of the gamepad
  12302. */
  12303. id: string;
  12304. /**
  12305. * The index of the gamepad
  12306. */
  12307. index: number;
  12308. /**
  12309. * The browser gamepad
  12310. */
  12311. browserGamepad: any;
  12312. /**
  12313. * Specifies what type of gamepad this represents
  12314. */
  12315. type: number;
  12316. private _leftStick;
  12317. private _rightStick;
  12318. /** @hidden */
  12319. _isConnected: boolean;
  12320. private _leftStickAxisX;
  12321. private _leftStickAxisY;
  12322. private _rightStickAxisX;
  12323. private _rightStickAxisY;
  12324. /**
  12325. * Triggered when the left control stick has been changed
  12326. */
  12327. private _onleftstickchanged;
  12328. /**
  12329. * Triggered when the right control stick has been changed
  12330. */
  12331. private _onrightstickchanged;
  12332. /**
  12333. * Represents a gamepad controller
  12334. */
  12335. static GAMEPAD: number;
  12336. /**
  12337. * Represents a generic controller
  12338. */
  12339. static GENERIC: number;
  12340. /**
  12341. * Represents an XBox controller
  12342. */
  12343. static XBOX: number;
  12344. /**
  12345. * Represents a pose-enabled controller
  12346. */
  12347. static POSE_ENABLED: number;
  12348. /**
  12349. * Represents an Dual Shock controller
  12350. */
  12351. static DUALSHOCK: number;
  12352. /**
  12353. * Specifies whether the left control stick should be Y-inverted
  12354. */
  12355. protected _invertLeftStickY: boolean;
  12356. /**
  12357. * Specifies if the gamepad has been connected
  12358. */
  12359. readonly isConnected: boolean;
  12360. /**
  12361. * Initializes the gamepad
  12362. * @param id The id of the gamepad
  12363. * @param index The index of the gamepad
  12364. * @param browserGamepad The browser gamepad
  12365. * @param leftStickX The x component of the left joystick
  12366. * @param leftStickY The y component of the left joystick
  12367. * @param rightStickX The x component of the right joystick
  12368. * @param rightStickY The y component of the right joystick
  12369. */
  12370. constructor(
  12371. /**
  12372. * The id of the gamepad
  12373. */
  12374. id: string,
  12375. /**
  12376. * The index of the gamepad
  12377. */
  12378. index: number,
  12379. /**
  12380. * The browser gamepad
  12381. */
  12382. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12383. /**
  12384. * Callback triggered when the left joystick has changed
  12385. * @param callback
  12386. */
  12387. onleftstickchanged(callback: (values: StickValues) => void): void;
  12388. /**
  12389. * Callback triggered when the right joystick has changed
  12390. * @param callback
  12391. */
  12392. onrightstickchanged(callback: (values: StickValues) => void): void;
  12393. /**
  12394. * Gets the left joystick
  12395. */
  12396. /**
  12397. * Sets the left joystick values
  12398. */
  12399. leftStick: StickValues;
  12400. /**
  12401. * Gets the right joystick
  12402. */
  12403. /**
  12404. * Sets the right joystick value
  12405. */
  12406. rightStick: StickValues;
  12407. /**
  12408. * Updates the gamepad joystick positions
  12409. */
  12410. update(): void;
  12411. /**
  12412. * Disposes the gamepad
  12413. */
  12414. dispose(): void;
  12415. }
  12416. /**
  12417. * Represents a generic gamepad
  12418. */
  12419. export class GenericPad extends Gamepad {
  12420. private _buttons;
  12421. private _onbuttondown;
  12422. private _onbuttonup;
  12423. /**
  12424. * Observable triggered when a button has been pressed
  12425. */
  12426. onButtonDownObservable: Observable<number>;
  12427. /**
  12428. * Observable triggered when a button has been released
  12429. */
  12430. onButtonUpObservable: Observable<number>;
  12431. /**
  12432. * Callback triggered when a button has been pressed
  12433. * @param callback Called when a button has been pressed
  12434. */
  12435. onbuttondown(callback: (buttonPressed: number) => void): void;
  12436. /**
  12437. * Callback triggered when a button has been released
  12438. * @param callback Called when a button has been released
  12439. */
  12440. onbuttonup(callback: (buttonReleased: number) => void): void;
  12441. /**
  12442. * Initializes the generic gamepad
  12443. * @param id The id of the generic gamepad
  12444. * @param index The index of the generic gamepad
  12445. * @param browserGamepad The browser gamepad
  12446. */
  12447. constructor(id: string, index: number, browserGamepad: any);
  12448. private _setButtonValue;
  12449. /**
  12450. * Updates the generic gamepad
  12451. */
  12452. update(): void;
  12453. /**
  12454. * Disposes the generic gamepad
  12455. */
  12456. dispose(): void;
  12457. }
  12458. }
  12459. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12460. import { Nullable } from "babylonjs/types";
  12461. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12462. import { Scene } from "babylonjs/scene";
  12463. module "babylonjs/Engines/engine" {
  12464. interface Engine {
  12465. /**
  12466. * Creates a raw texture
  12467. * @param data defines the data to store in the texture
  12468. * @param width defines the width of the texture
  12469. * @param height defines the height of the texture
  12470. * @param format defines the format of the data
  12471. * @param generateMipMaps defines if the engine should generate the mip levels
  12472. * @param invertY defines if data must be stored with Y axis inverted
  12473. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12474. * @param compression defines the compression used (null by default)
  12475. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12476. * @returns the raw texture inside an InternalTexture
  12477. */
  12478. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12479. /**
  12480. * Update a raw texture
  12481. * @param texture defines the texture to update
  12482. * @param data defines the data to store in the texture
  12483. * @param format defines the format of the data
  12484. * @param invertY defines if data must be stored with Y axis inverted
  12485. */
  12486. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12487. /**
  12488. * Update a raw texture
  12489. * @param texture defines the texture to update
  12490. * @param data defines the data to store in the texture
  12491. * @param format defines the format of the data
  12492. * @param invertY defines if data must be stored with Y axis inverted
  12493. * @param compression defines the compression used (null by default)
  12494. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12495. */
  12496. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12497. /**
  12498. * Creates a new raw cube texture
  12499. * @param data defines the array of data to use to create each face
  12500. * @param size defines the size of the textures
  12501. * @param format defines the format of the data
  12502. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12503. * @param generateMipMaps defines if the engine should generate the mip levels
  12504. * @param invertY defines if data must be stored with Y axis inverted
  12505. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12506. * @param compression defines the compression used (null by default)
  12507. * @returns the cube texture as an InternalTexture
  12508. */
  12509. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12510. /**
  12511. * Update a raw cube texture
  12512. * @param texture defines the texture to udpdate
  12513. * @param data defines the data to store
  12514. * @param format defines the data format
  12515. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12516. * @param invertY defines if data must be stored with Y axis inverted
  12517. */
  12518. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12519. /**
  12520. * Update a raw cube texture
  12521. * @param texture defines the texture to udpdate
  12522. * @param data defines the data to store
  12523. * @param format defines the data format
  12524. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12525. * @param invertY defines if data must be stored with Y axis inverted
  12526. * @param compression defines the compression used (null by default)
  12527. */
  12528. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12529. /**
  12530. * Update a raw cube texture
  12531. * @param texture defines the texture to udpdate
  12532. * @param data defines the data to store
  12533. * @param format defines the data format
  12534. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12535. * @param invertY defines if data must be stored with Y axis inverted
  12536. * @param compression defines the compression used (null by default)
  12537. * @param level defines which level of the texture to update
  12538. */
  12539. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12540. /**
  12541. * Creates a new raw cube texture from a specified url
  12542. * @param url defines the url where the data is located
  12543. * @param scene defines the current scene
  12544. * @param size defines the size of the textures
  12545. * @param format defines the format of the data
  12546. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12547. * @param noMipmap defines if the engine should avoid generating the mip levels
  12548. * @param callback defines a callback used to extract texture data from loaded data
  12549. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12550. * @param onLoad defines a callback called when texture is loaded
  12551. * @param onError defines a callback called if there is an error
  12552. * @returns the cube texture as an InternalTexture
  12553. */
  12554. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  12555. /**
  12556. * Creates a new raw cube texture from a specified url
  12557. * @param url defines the url where the data is located
  12558. * @param scene defines the current scene
  12559. * @param size defines the size of the textures
  12560. * @param format defines the format of the data
  12561. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12562. * @param noMipmap defines if the engine should avoid generating the mip levels
  12563. * @param callback defines a callback used to extract texture data from loaded data
  12564. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12565. * @param onLoad defines a callback called when texture is loaded
  12566. * @param onError defines a callback called if there is an error
  12567. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12568. * @param invertY defines if data must be stored with Y axis inverted
  12569. * @returns the cube texture as an InternalTexture
  12570. */
  12571. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  12572. /**
  12573. * Creates a new raw 3D texture
  12574. * @param data defines the data used to create the texture
  12575. * @param width defines the width of the texture
  12576. * @param height defines the height of the texture
  12577. * @param depth defines the depth of the texture
  12578. * @param format defines the format of the texture
  12579. * @param generateMipMaps defines if the engine must generate mip levels
  12580. * @param invertY defines if data must be stored with Y axis inverted
  12581. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12582. * @param compression defines the compressed used (can be null)
  12583. * @param textureType defines the compressed used (can be null)
  12584. * @returns a new raw 3D texture (stored in an InternalTexture)
  12585. */
  12586. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12587. /**
  12588. * Update a raw 3D texture
  12589. * @param texture defines the texture to update
  12590. * @param data defines the data to store
  12591. * @param format defines the data format
  12592. * @param invertY defines if data must be stored with Y axis inverted
  12593. */
  12594. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12595. /**
  12596. * Update a raw 3D texture
  12597. * @param texture defines the texture to update
  12598. * @param data defines the data to store
  12599. * @param format defines the data format
  12600. * @param invertY defines if data must be stored with Y axis inverted
  12601. * @param compression defines the used compression (can be null)
  12602. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12603. */
  12604. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12605. }
  12606. }
  12607. }
  12608. declare module "babylonjs/Materials/Textures/rawTexture" {
  12609. import { Scene } from "babylonjs/scene";
  12610. import { Texture } from "babylonjs/Materials/Textures/texture";
  12611. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12612. /**
  12613. * Raw texture can help creating a texture directly from an array of data.
  12614. * This can be super useful if you either get the data from an uncompressed source or
  12615. * if you wish to create your texture pixel by pixel.
  12616. */
  12617. export class RawTexture extends Texture {
  12618. /**
  12619. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12620. */
  12621. format: number;
  12622. private _engine;
  12623. /**
  12624. * Instantiates a new RawTexture.
  12625. * Raw texture can help creating a texture directly from an array of data.
  12626. * This can be super useful if you either get the data from an uncompressed source or
  12627. * if you wish to create your texture pixel by pixel.
  12628. * @param data define the array of data to use to create the texture
  12629. * @param width define the width of the texture
  12630. * @param height define the height of the texture
  12631. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12632. * @param scene define the scene the texture belongs to
  12633. * @param generateMipMaps define whether mip maps should be generated or not
  12634. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12635. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12636. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12637. */
  12638. constructor(data: ArrayBufferView, width: number, height: number,
  12639. /**
  12640. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12641. */
  12642. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12643. /**
  12644. * Updates the texture underlying data.
  12645. * @param data Define the new data of the texture
  12646. */
  12647. update(data: ArrayBufferView): void;
  12648. /**
  12649. * Creates a luminance texture from some data.
  12650. * @param data Define the texture data
  12651. * @param width Define the width of the texture
  12652. * @param height Define the height of the texture
  12653. * @param scene Define the scene the texture belongs to
  12654. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12655. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12656. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12657. * @returns the luminance texture
  12658. */
  12659. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12660. /**
  12661. * Creates a luminance alpha texture from some data.
  12662. * @param data Define the texture data
  12663. * @param width Define the width of the texture
  12664. * @param height Define the height of the texture
  12665. * @param scene Define the scene the texture belongs to
  12666. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12667. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12668. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12669. * @returns the luminance alpha texture
  12670. */
  12671. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12672. /**
  12673. * Creates an alpha texture from some data.
  12674. * @param data Define the texture data
  12675. * @param width Define the width of the texture
  12676. * @param height Define the height of the texture
  12677. * @param scene Define the scene the texture belongs to
  12678. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12679. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12680. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12681. * @returns the alpha texture
  12682. */
  12683. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12684. /**
  12685. * Creates a RGB texture from some data.
  12686. * @param data Define the texture data
  12687. * @param width Define the width of the texture
  12688. * @param height Define the height of the texture
  12689. * @param scene Define the scene the texture belongs to
  12690. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12691. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12692. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12693. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12694. * @returns the RGB alpha texture
  12695. */
  12696. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12697. /**
  12698. * Creates a RGBA texture from some data.
  12699. * @param data Define the texture data
  12700. * @param width Define the width of the texture
  12701. * @param height Define the height of the texture
  12702. * @param scene Define the scene the texture belongs to
  12703. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12704. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12705. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12706. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12707. * @returns the RGBA texture
  12708. */
  12709. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12710. /**
  12711. * Creates a R texture from some data.
  12712. * @param data Define the texture data
  12713. * @param width Define the width of the texture
  12714. * @param height Define the height of the texture
  12715. * @param scene Define the scene the texture belongs to
  12716. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12717. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12718. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12719. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12720. * @returns the R texture
  12721. */
  12722. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12723. }
  12724. }
  12725. declare module "babylonjs/Maths/math.size" {
  12726. /**
  12727. * Interface for the size containing width and height
  12728. */
  12729. export interface ISize {
  12730. /**
  12731. * Width
  12732. */
  12733. width: number;
  12734. /**
  12735. * Heighht
  12736. */
  12737. height: number;
  12738. }
  12739. /**
  12740. * Size containing widht and height
  12741. */
  12742. export class Size implements ISize {
  12743. /**
  12744. * Width
  12745. */
  12746. width: number;
  12747. /**
  12748. * Height
  12749. */
  12750. height: number;
  12751. /**
  12752. * Creates a Size object from the given width and height (floats).
  12753. * @param width width of the new size
  12754. * @param height height of the new size
  12755. */
  12756. constructor(width: number, height: number);
  12757. /**
  12758. * Returns a string with the Size width and height
  12759. * @returns a string with the Size width and height
  12760. */
  12761. toString(): string;
  12762. /**
  12763. * "Size"
  12764. * @returns the string "Size"
  12765. */
  12766. getClassName(): string;
  12767. /**
  12768. * Returns the Size hash code.
  12769. * @returns a hash code for a unique width and height
  12770. */
  12771. getHashCode(): number;
  12772. /**
  12773. * Updates the current size from the given one.
  12774. * @param src the given size
  12775. */
  12776. copyFrom(src: Size): void;
  12777. /**
  12778. * Updates in place the current Size from the given floats.
  12779. * @param width width of the new size
  12780. * @param height height of the new size
  12781. * @returns the updated Size.
  12782. */
  12783. copyFromFloats(width: number, height: number): Size;
  12784. /**
  12785. * Updates in place the current Size from the given floats.
  12786. * @param width width to set
  12787. * @param height height to set
  12788. * @returns the updated Size.
  12789. */
  12790. set(width: number, height: number): Size;
  12791. /**
  12792. * Multiplies the width and height by numbers
  12793. * @param w factor to multiple the width by
  12794. * @param h factor to multiple the height by
  12795. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12796. */
  12797. multiplyByFloats(w: number, h: number): Size;
  12798. /**
  12799. * Clones the size
  12800. * @returns a new Size copied from the given one.
  12801. */
  12802. clone(): Size;
  12803. /**
  12804. * True if the current Size and the given one width and height are strictly equal.
  12805. * @param other the other size to compare against
  12806. * @returns True if the current Size and the given one width and height are strictly equal.
  12807. */
  12808. equals(other: Size): boolean;
  12809. /**
  12810. * The surface of the Size : width * height (float).
  12811. */
  12812. readonly surface: number;
  12813. /**
  12814. * Create a new size of zero
  12815. * @returns a new Size set to (0.0, 0.0)
  12816. */
  12817. static Zero(): Size;
  12818. /**
  12819. * Sums the width and height of two sizes
  12820. * @param otherSize size to add to this size
  12821. * @returns a new Size set as the addition result of the current Size and the given one.
  12822. */
  12823. add(otherSize: Size): Size;
  12824. /**
  12825. * Subtracts the width and height of two
  12826. * @param otherSize size to subtract to this size
  12827. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12828. */
  12829. subtract(otherSize: Size): Size;
  12830. /**
  12831. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12832. * @param start starting size to lerp between
  12833. * @param end end size to lerp between
  12834. * @param amount amount to lerp between the start and end values
  12835. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12836. */
  12837. static Lerp(start: Size, end: Size, amount: number): Size;
  12838. }
  12839. }
  12840. declare module "babylonjs/Animations/runtimeAnimation" {
  12841. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  12842. import { Animatable } from "babylonjs/Animations/animatable";
  12843. import { Scene } from "babylonjs/scene";
  12844. /**
  12845. * Defines a runtime animation
  12846. */
  12847. export class RuntimeAnimation {
  12848. private _events;
  12849. /**
  12850. * The current frame of the runtime animation
  12851. */
  12852. private _currentFrame;
  12853. /**
  12854. * The animation used by the runtime animation
  12855. */
  12856. private _animation;
  12857. /**
  12858. * The target of the runtime animation
  12859. */
  12860. private _target;
  12861. /**
  12862. * The initiating animatable
  12863. */
  12864. private _host;
  12865. /**
  12866. * The original value of the runtime animation
  12867. */
  12868. private _originalValue;
  12869. /**
  12870. * The original blend value of the runtime animation
  12871. */
  12872. private _originalBlendValue;
  12873. /**
  12874. * The offsets cache of the runtime animation
  12875. */
  12876. private _offsetsCache;
  12877. /**
  12878. * The high limits cache of the runtime animation
  12879. */
  12880. private _highLimitsCache;
  12881. /**
  12882. * Specifies if the runtime animation has been stopped
  12883. */
  12884. private _stopped;
  12885. /**
  12886. * The blending factor of the runtime animation
  12887. */
  12888. private _blendingFactor;
  12889. /**
  12890. * The BabylonJS scene
  12891. */
  12892. private _scene;
  12893. /**
  12894. * The current value of the runtime animation
  12895. */
  12896. private _currentValue;
  12897. /** @hidden */
  12898. _animationState: _IAnimationState;
  12899. /**
  12900. * The active target of the runtime animation
  12901. */
  12902. private _activeTargets;
  12903. private _currentActiveTarget;
  12904. private _directTarget;
  12905. /**
  12906. * The target path of the runtime animation
  12907. */
  12908. private _targetPath;
  12909. /**
  12910. * The weight of the runtime animation
  12911. */
  12912. private _weight;
  12913. /**
  12914. * The ratio offset of the runtime animation
  12915. */
  12916. private _ratioOffset;
  12917. /**
  12918. * The previous delay of the runtime animation
  12919. */
  12920. private _previousDelay;
  12921. /**
  12922. * The previous ratio of the runtime animation
  12923. */
  12924. private _previousRatio;
  12925. private _enableBlending;
  12926. private _keys;
  12927. private _minFrame;
  12928. private _maxFrame;
  12929. private _minValue;
  12930. private _maxValue;
  12931. private _targetIsArray;
  12932. /**
  12933. * Gets the current frame of the runtime animation
  12934. */
  12935. readonly currentFrame: number;
  12936. /**
  12937. * Gets the weight of the runtime animation
  12938. */
  12939. readonly weight: number;
  12940. /**
  12941. * Gets the current value of the runtime animation
  12942. */
  12943. readonly currentValue: any;
  12944. /**
  12945. * Gets the target path of the runtime animation
  12946. */
  12947. readonly targetPath: string;
  12948. /**
  12949. * Gets the actual target of the runtime animation
  12950. */
  12951. readonly target: any;
  12952. /** @hidden */
  12953. _onLoop: () => void;
  12954. /**
  12955. * Create a new RuntimeAnimation object
  12956. * @param target defines the target of the animation
  12957. * @param animation defines the source animation object
  12958. * @param scene defines the hosting scene
  12959. * @param host defines the initiating Animatable
  12960. */
  12961. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12962. private _preparePath;
  12963. /**
  12964. * Gets the animation from the runtime animation
  12965. */
  12966. readonly animation: Animation;
  12967. /**
  12968. * Resets the runtime animation to the beginning
  12969. * @param restoreOriginal defines whether to restore the target property to the original value
  12970. */
  12971. reset(restoreOriginal?: boolean): void;
  12972. /**
  12973. * Specifies if the runtime animation is stopped
  12974. * @returns Boolean specifying if the runtime animation is stopped
  12975. */
  12976. isStopped(): boolean;
  12977. /**
  12978. * Disposes of the runtime animation
  12979. */
  12980. dispose(): void;
  12981. /**
  12982. * Apply the interpolated value to the target
  12983. * @param currentValue defines the value computed by the animation
  12984. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12985. */
  12986. setValue(currentValue: any, weight: number): void;
  12987. private _getOriginalValues;
  12988. private _setValue;
  12989. /**
  12990. * Gets the loop pmode of the runtime animation
  12991. * @returns Loop Mode
  12992. */
  12993. private _getCorrectLoopMode;
  12994. /**
  12995. * Move the current animation to a given frame
  12996. * @param frame defines the frame to move to
  12997. */
  12998. goToFrame(frame: number): void;
  12999. /**
  13000. * @hidden Internal use only
  13001. */
  13002. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13003. /**
  13004. * Execute the current animation
  13005. * @param delay defines the delay to add to the current frame
  13006. * @param from defines the lower bound of the animation range
  13007. * @param to defines the upper bound of the animation range
  13008. * @param loop defines if the current animation must loop
  13009. * @param speedRatio defines the current speed ratio
  13010. * @param weight defines the weight of the animation (default is -1 so no weight)
  13011. * @param onLoop optional callback called when animation loops
  13012. * @returns a boolean indicating if the animation is running
  13013. */
  13014. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13015. }
  13016. }
  13017. declare module "babylonjs/Animations/animatable" {
  13018. import { Animation } from "babylonjs/Animations/animation";
  13019. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13020. import { Nullable } from "babylonjs/types";
  13021. import { Observable } from "babylonjs/Misc/observable";
  13022. import { Scene } from "babylonjs/scene";
  13023. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13024. import { Node } from "babylonjs/node";
  13025. /**
  13026. * Class used to store an actual running animation
  13027. */
  13028. export class Animatable {
  13029. /** defines the target object */
  13030. target: any;
  13031. /** defines the starting frame number (default is 0) */
  13032. fromFrame: number;
  13033. /** defines the ending frame number (default is 100) */
  13034. toFrame: number;
  13035. /** defines if the animation must loop (default is false) */
  13036. loopAnimation: boolean;
  13037. /** defines a callback to call when animation ends if it is not looping */
  13038. onAnimationEnd?: (() => void) | null | undefined;
  13039. /** defines a callback to call when animation loops */
  13040. onAnimationLoop?: (() => void) | null | undefined;
  13041. private _localDelayOffset;
  13042. private _pausedDelay;
  13043. private _runtimeAnimations;
  13044. private _paused;
  13045. private _scene;
  13046. private _speedRatio;
  13047. private _weight;
  13048. private _syncRoot;
  13049. /**
  13050. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13051. * This will only apply for non looping animation (default is true)
  13052. */
  13053. disposeOnEnd: boolean;
  13054. /**
  13055. * Gets a boolean indicating if the animation has started
  13056. */
  13057. animationStarted: boolean;
  13058. /**
  13059. * Observer raised when the animation ends
  13060. */
  13061. onAnimationEndObservable: Observable<Animatable>;
  13062. /**
  13063. * Observer raised when the animation loops
  13064. */
  13065. onAnimationLoopObservable: Observable<Animatable>;
  13066. /**
  13067. * Gets the root Animatable used to synchronize and normalize animations
  13068. */
  13069. readonly syncRoot: Nullable<Animatable>;
  13070. /**
  13071. * Gets the current frame of the first RuntimeAnimation
  13072. * Used to synchronize Animatables
  13073. */
  13074. readonly masterFrame: number;
  13075. /**
  13076. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13077. */
  13078. weight: number;
  13079. /**
  13080. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13081. */
  13082. speedRatio: number;
  13083. /**
  13084. * Creates a new Animatable
  13085. * @param scene defines the hosting scene
  13086. * @param target defines the target object
  13087. * @param fromFrame defines the starting frame number (default is 0)
  13088. * @param toFrame defines the ending frame number (default is 100)
  13089. * @param loopAnimation defines if the animation must loop (default is false)
  13090. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13091. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13092. * @param animations defines a group of animation to add to the new Animatable
  13093. * @param onAnimationLoop defines a callback to call when animation loops
  13094. */
  13095. constructor(scene: Scene,
  13096. /** defines the target object */
  13097. target: any,
  13098. /** defines the starting frame number (default is 0) */
  13099. fromFrame?: number,
  13100. /** defines the ending frame number (default is 100) */
  13101. toFrame?: number,
  13102. /** defines if the animation must loop (default is false) */
  13103. loopAnimation?: boolean, speedRatio?: number,
  13104. /** defines a callback to call when animation ends if it is not looping */
  13105. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13106. /** defines a callback to call when animation loops */
  13107. onAnimationLoop?: (() => void) | null | undefined);
  13108. /**
  13109. * Synchronize and normalize current Animatable with a source Animatable
  13110. * This is useful when using animation weights and when animations are not of the same length
  13111. * @param root defines the root Animatable to synchronize with
  13112. * @returns the current Animatable
  13113. */
  13114. syncWith(root: Animatable): Animatable;
  13115. /**
  13116. * Gets the list of runtime animations
  13117. * @returns an array of RuntimeAnimation
  13118. */
  13119. getAnimations(): RuntimeAnimation[];
  13120. /**
  13121. * Adds more animations to the current animatable
  13122. * @param target defines the target of the animations
  13123. * @param animations defines the new animations to add
  13124. */
  13125. appendAnimations(target: any, animations: Animation[]): void;
  13126. /**
  13127. * Gets the source animation for a specific property
  13128. * @param property defines the propertyu to look for
  13129. * @returns null or the source animation for the given property
  13130. */
  13131. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13132. /**
  13133. * Gets the runtime animation for a specific property
  13134. * @param property defines the propertyu to look for
  13135. * @returns null or the runtime animation for the given property
  13136. */
  13137. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13138. /**
  13139. * Resets the animatable to its original state
  13140. */
  13141. reset(): void;
  13142. /**
  13143. * Allows the animatable to blend with current running animations
  13144. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13145. * @param blendingSpeed defines the blending speed to use
  13146. */
  13147. enableBlending(blendingSpeed: number): void;
  13148. /**
  13149. * Disable animation blending
  13150. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13151. */
  13152. disableBlending(): void;
  13153. /**
  13154. * Jump directly to a given frame
  13155. * @param frame defines the frame to jump to
  13156. */
  13157. goToFrame(frame: number): void;
  13158. /**
  13159. * Pause the animation
  13160. */
  13161. pause(): void;
  13162. /**
  13163. * Restart the animation
  13164. */
  13165. restart(): void;
  13166. private _raiseOnAnimationEnd;
  13167. /**
  13168. * Stop and delete the current animation
  13169. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13170. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  13171. */
  13172. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13173. /**
  13174. * Wait asynchronously for the animation to end
  13175. * @returns a promise which will be fullfilled when the animation ends
  13176. */
  13177. waitAsync(): Promise<Animatable>;
  13178. /** @hidden */
  13179. _animate(delay: number): boolean;
  13180. }
  13181. module "babylonjs/scene" {
  13182. interface Scene {
  13183. /** @hidden */
  13184. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13185. /** @hidden */
  13186. _processLateAnimationBindingsForMatrices(holder: {
  13187. totalWeight: number;
  13188. animations: RuntimeAnimation[];
  13189. originalValue: Matrix;
  13190. }): any;
  13191. /** @hidden */
  13192. _processLateAnimationBindingsForQuaternions(holder: {
  13193. totalWeight: number;
  13194. animations: RuntimeAnimation[];
  13195. originalValue: Quaternion;
  13196. }, refQuaternion: Quaternion): Quaternion;
  13197. /** @hidden */
  13198. _processLateAnimationBindings(): void;
  13199. /**
  13200. * Will start the animation sequence of a given target
  13201. * @param target defines the target
  13202. * @param from defines from which frame should animation start
  13203. * @param to defines until which frame should animation run.
  13204. * @param weight defines the weight to apply to the animation (1.0 by default)
  13205. * @param loop defines if the animation loops
  13206. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13207. * @param onAnimationEnd defines the function to be executed when the animation ends
  13208. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13209. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13210. * @param onAnimationLoop defines the callback to call when an animation loops
  13211. * @returns the animatable object created for this animation
  13212. */
  13213. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13214. /**
  13215. * Will start the animation sequence of a given target
  13216. * @param target defines the target
  13217. * @param from defines from which frame should animation start
  13218. * @param to defines until which frame should animation run.
  13219. * @param loop defines if the animation loops
  13220. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13221. * @param onAnimationEnd defines the function to be executed when the animation ends
  13222. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13223. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13224. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13225. * @param onAnimationLoop defines the callback to call when an animation loops
  13226. * @returns the animatable object created for this animation
  13227. */
  13228. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13229. /**
  13230. * Will start the animation sequence of a given target and its hierarchy
  13231. * @param target defines the target
  13232. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  13233. * @param from defines from which frame should animation start
  13234. * @param to defines until which frame should animation run.
  13235. * @param loop defines if the animation loops
  13236. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13237. * @param onAnimationEnd defines the function to be executed when the animation ends
  13238. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13239. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13240. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13241. * @param onAnimationLoop defines the callback to call when an animation loops
  13242. * @returns the list of created animatables
  13243. */
  13244. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable[];
  13245. /**
  13246. * Begin a new animation on a given node
  13247. * @param target defines the target where the animation will take place
  13248. * @param animations defines the list of animations to start
  13249. * @param from defines the initial value
  13250. * @param to defines the final value
  13251. * @param loop defines if you want animation to loop (off by default)
  13252. * @param speedRatio defines the speed ratio to apply to all animations
  13253. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13254. * @param onAnimationLoop defines the callback to call when an animation loops
  13255. * @returns the list of created animatables
  13256. */
  13257. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13258. /**
  13259. * Begin a new animation on a given node and its hierarchy
  13260. * @param target defines the root node where the animation will take place
  13261. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  13262. * @param animations defines the list of animations to start
  13263. * @param from defines the initial value
  13264. * @param to defines the final value
  13265. * @param loop defines if you want animation to loop (off by default)
  13266. * @param speedRatio defines the speed ratio to apply to all animations
  13267. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13268. * @param onAnimationLoop defines the callback to call when an animation loops
  13269. * @returns the list of animatables created for all nodes
  13270. */
  13271. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13272. /**
  13273. * Gets the animatable associated with a specific target
  13274. * @param target defines the target of the animatable
  13275. * @returns the required animatable if found
  13276. */
  13277. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13278. /**
  13279. * Gets all animatables associated with a given target
  13280. * @param target defines the target to look animatables for
  13281. * @returns an array of Animatables
  13282. */
  13283. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13284. /**
  13285. * Stops and removes all animations that have been applied to the scene
  13286. */
  13287. stopAllAnimations(): void;
  13288. }
  13289. }
  13290. module "babylonjs/Bones/bone" {
  13291. interface Bone {
  13292. /**
  13293. * Copy an animation range from another bone
  13294. * @param source defines the source bone
  13295. * @param rangeName defines the range name to copy
  13296. * @param frameOffset defines the frame offset
  13297. * @param rescaleAsRequired defines if rescaling must be applied if required
  13298. * @param skelDimensionsRatio defines the scaling ratio
  13299. * @returns true if operation was successful
  13300. */
  13301. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13302. }
  13303. }
  13304. }
  13305. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13306. /**
  13307. * Class used to override all child animations of a given target
  13308. */
  13309. export class AnimationPropertiesOverride {
  13310. /**
  13311. * Gets or sets a value indicating if animation blending must be used
  13312. */
  13313. enableBlending: boolean;
  13314. /**
  13315. * Gets or sets the blending speed to use when enableBlending is true
  13316. */
  13317. blendingSpeed: number;
  13318. /**
  13319. * Gets or sets the default loop mode to use
  13320. */
  13321. loopMode: number;
  13322. }
  13323. }
  13324. declare module "babylonjs/Bones/skeleton" {
  13325. import { Bone } from "babylonjs/Bones/bone";
  13326. import { Observable } from "babylonjs/Misc/observable";
  13327. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13328. import { Scene } from "babylonjs/scene";
  13329. import { Nullable } from "babylonjs/types";
  13330. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13331. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13332. import { Animatable } from "babylonjs/Animations/animatable";
  13333. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13334. import { Animation } from "babylonjs/Animations/animation";
  13335. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13336. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13337. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13338. /**
  13339. * Class used to handle skinning animations
  13340. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13341. */
  13342. export class Skeleton implements IAnimatable {
  13343. /** defines the skeleton name */
  13344. name: string;
  13345. /** defines the skeleton Id */
  13346. id: string;
  13347. /**
  13348. * Defines the list of child bones
  13349. */
  13350. bones: Bone[];
  13351. /**
  13352. * Defines an estimate of the dimension of the skeleton at rest
  13353. */
  13354. dimensionsAtRest: Vector3;
  13355. /**
  13356. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13357. */
  13358. needInitialSkinMatrix: boolean;
  13359. /**
  13360. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13361. */
  13362. overrideMesh: Nullable<AbstractMesh>;
  13363. /**
  13364. * Gets the list of animations attached to this skeleton
  13365. */
  13366. animations: Array<Animation>;
  13367. private _scene;
  13368. private _isDirty;
  13369. private _transformMatrices;
  13370. private _transformMatrixTexture;
  13371. private _meshesWithPoseMatrix;
  13372. private _animatables;
  13373. private _identity;
  13374. private _synchronizedWithMesh;
  13375. private _ranges;
  13376. private _lastAbsoluteTransformsUpdateId;
  13377. private _canUseTextureForBones;
  13378. private _uniqueId;
  13379. /** @hidden */
  13380. _numBonesWithLinkedTransformNode: number;
  13381. /** @hidden */
  13382. _hasWaitingData: Nullable<boolean>;
  13383. /**
  13384. * Specifies if the skeleton should be serialized
  13385. */
  13386. doNotSerialize: boolean;
  13387. private _useTextureToStoreBoneMatrices;
  13388. /**
  13389. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13390. * Please note that this option is not available if the hardware does not support it
  13391. */
  13392. useTextureToStoreBoneMatrices: boolean;
  13393. private _animationPropertiesOverride;
  13394. /**
  13395. * Gets or sets the animation properties override
  13396. */
  13397. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13398. /**
  13399. * List of inspectable custom properties (used by the Inspector)
  13400. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13401. */
  13402. inspectableCustomProperties: IInspectable[];
  13403. /**
  13404. * An observable triggered before computing the skeleton's matrices
  13405. */
  13406. onBeforeComputeObservable: Observable<Skeleton>;
  13407. /**
  13408. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13409. */
  13410. readonly isUsingTextureForMatrices: boolean;
  13411. /**
  13412. * Gets the unique ID of this skeleton
  13413. */
  13414. readonly uniqueId: number;
  13415. /**
  13416. * Creates a new skeleton
  13417. * @param name defines the skeleton name
  13418. * @param id defines the skeleton Id
  13419. * @param scene defines the hosting scene
  13420. */
  13421. constructor(
  13422. /** defines the skeleton name */
  13423. name: string,
  13424. /** defines the skeleton Id */
  13425. id: string, scene: Scene);
  13426. /**
  13427. * Gets the current object class name.
  13428. * @return the class name
  13429. */
  13430. getClassName(): string;
  13431. /**
  13432. * Returns an array containing the root bones
  13433. * @returns an array containing the root bones
  13434. */
  13435. getChildren(): Array<Bone>;
  13436. /**
  13437. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13438. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13439. * @returns a Float32Array containing matrices data
  13440. */
  13441. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13442. /**
  13443. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13444. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13445. * @returns a raw texture containing the data
  13446. */
  13447. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13448. /**
  13449. * Gets the current hosting scene
  13450. * @returns a scene object
  13451. */
  13452. getScene(): Scene;
  13453. /**
  13454. * Gets a string representing the current skeleton data
  13455. * @param fullDetails defines a boolean indicating if we want a verbose version
  13456. * @returns a string representing the current skeleton data
  13457. */
  13458. toString(fullDetails?: boolean): string;
  13459. /**
  13460. * Get bone's index searching by name
  13461. * @param name defines bone's name to search for
  13462. * @return the indice of the bone. Returns -1 if not found
  13463. */
  13464. getBoneIndexByName(name: string): number;
  13465. /**
  13466. * Creater a new animation range
  13467. * @param name defines the name of the range
  13468. * @param from defines the start key
  13469. * @param to defines the end key
  13470. */
  13471. createAnimationRange(name: string, from: number, to: number): void;
  13472. /**
  13473. * Delete a specific animation range
  13474. * @param name defines the name of the range
  13475. * @param deleteFrames defines if frames must be removed as well
  13476. */
  13477. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13478. /**
  13479. * Gets a specific animation range
  13480. * @param name defines the name of the range to look for
  13481. * @returns the requested animation range or null if not found
  13482. */
  13483. getAnimationRange(name: string): Nullable<AnimationRange>;
  13484. /**
  13485. * Gets the list of all animation ranges defined on this skeleton
  13486. * @returns an array
  13487. */
  13488. getAnimationRanges(): Nullable<AnimationRange>[];
  13489. /**
  13490. * Copy animation range from a source skeleton.
  13491. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13492. * @param source defines the source skeleton
  13493. * @param name defines the name of the range to copy
  13494. * @param rescaleAsRequired defines if rescaling must be applied if required
  13495. * @returns true if operation was successful
  13496. */
  13497. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13498. /**
  13499. * Forces the skeleton to go to rest pose
  13500. */
  13501. returnToRest(): void;
  13502. private _getHighestAnimationFrame;
  13503. /**
  13504. * Begin a specific animation range
  13505. * @param name defines the name of the range to start
  13506. * @param loop defines if looping must be turned on (false by default)
  13507. * @param speedRatio defines the speed ratio to apply (1 by default)
  13508. * @param onAnimationEnd defines a callback which will be called when animation will end
  13509. * @returns a new animatable
  13510. */
  13511. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13512. /** @hidden */
  13513. _markAsDirty(): void;
  13514. /** @hidden */
  13515. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13516. /** @hidden */
  13517. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13518. private _computeTransformMatrices;
  13519. /**
  13520. * Build all resources required to render a skeleton
  13521. */
  13522. prepare(): void;
  13523. /**
  13524. * Gets the list of animatables currently running for this skeleton
  13525. * @returns an array of animatables
  13526. */
  13527. getAnimatables(): IAnimatable[];
  13528. /**
  13529. * Clone the current skeleton
  13530. * @param name defines the name of the new skeleton
  13531. * @param id defines the id of the new skeleton
  13532. * @returns the new skeleton
  13533. */
  13534. clone(name: string, id: string): Skeleton;
  13535. /**
  13536. * Enable animation blending for this skeleton
  13537. * @param blendingSpeed defines the blending speed to apply
  13538. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13539. */
  13540. enableBlending(blendingSpeed?: number): void;
  13541. /**
  13542. * Releases all resources associated with the current skeleton
  13543. */
  13544. dispose(): void;
  13545. /**
  13546. * Serialize the skeleton in a JSON object
  13547. * @returns a JSON object
  13548. */
  13549. serialize(): any;
  13550. /**
  13551. * Creates a new skeleton from serialized data
  13552. * @param parsedSkeleton defines the serialized data
  13553. * @param scene defines the hosting scene
  13554. * @returns a new skeleton
  13555. */
  13556. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13557. /**
  13558. * Compute all node absolute transforms
  13559. * @param forceUpdate defines if computation must be done even if cache is up to date
  13560. */
  13561. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13562. /**
  13563. * Gets the root pose matrix
  13564. * @returns a matrix
  13565. */
  13566. getPoseMatrix(): Nullable<Matrix>;
  13567. /**
  13568. * Sorts bones per internal index
  13569. */
  13570. sortBones(): void;
  13571. private _sortBones;
  13572. }
  13573. }
  13574. declare module "babylonjs/Bones/bone" {
  13575. import { Skeleton } from "babylonjs/Bones/skeleton";
  13576. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13577. import { Nullable } from "babylonjs/types";
  13578. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13579. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13580. import { Node } from "babylonjs/node";
  13581. import { Space } from "babylonjs/Maths/math.axis";
  13582. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13583. /**
  13584. * Class used to store bone information
  13585. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13586. */
  13587. export class Bone extends Node {
  13588. /**
  13589. * defines the bone name
  13590. */
  13591. name: string;
  13592. private static _tmpVecs;
  13593. private static _tmpQuat;
  13594. private static _tmpMats;
  13595. /**
  13596. * Gets the list of child bones
  13597. */
  13598. children: Bone[];
  13599. /** Gets the animations associated with this bone */
  13600. animations: import("babylonjs/Animations/animation").Animation[];
  13601. /**
  13602. * Gets or sets bone length
  13603. */
  13604. length: number;
  13605. /**
  13606. * @hidden Internal only
  13607. * Set this value to map this bone to a different index in the transform matrices
  13608. * Set this value to -1 to exclude the bone from the transform matrices
  13609. */
  13610. _index: Nullable<number>;
  13611. private _skeleton;
  13612. private _localMatrix;
  13613. private _restPose;
  13614. private _baseMatrix;
  13615. private _absoluteTransform;
  13616. private _invertedAbsoluteTransform;
  13617. private _parent;
  13618. private _scalingDeterminant;
  13619. private _worldTransform;
  13620. private _localScaling;
  13621. private _localRotation;
  13622. private _localPosition;
  13623. private _needToDecompose;
  13624. private _needToCompose;
  13625. /** @hidden */
  13626. _linkedTransformNode: Nullable<TransformNode>;
  13627. /** @hidden */
  13628. _waitingTransformNodeId: Nullable<string>;
  13629. /** @hidden */
  13630. /** @hidden */
  13631. _matrix: Matrix;
  13632. /**
  13633. * Create a new bone
  13634. * @param name defines the bone name
  13635. * @param skeleton defines the parent skeleton
  13636. * @param parentBone defines the parent (can be null if the bone is the root)
  13637. * @param localMatrix defines the local matrix
  13638. * @param restPose defines the rest pose matrix
  13639. * @param baseMatrix defines the base matrix
  13640. * @param index defines index of the bone in the hiearchy
  13641. */
  13642. constructor(
  13643. /**
  13644. * defines the bone name
  13645. */
  13646. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13647. /**
  13648. * Gets the current object class name.
  13649. * @return the class name
  13650. */
  13651. getClassName(): string;
  13652. /**
  13653. * Gets the parent skeleton
  13654. * @returns a skeleton
  13655. */
  13656. getSkeleton(): Skeleton;
  13657. /**
  13658. * Gets parent bone
  13659. * @returns a bone or null if the bone is the root of the bone hierarchy
  13660. */
  13661. getParent(): Nullable<Bone>;
  13662. /**
  13663. * Returns an array containing the root bones
  13664. * @returns an array containing the root bones
  13665. */
  13666. getChildren(): Array<Bone>;
  13667. /**
  13668. * Sets the parent bone
  13669. * @param parent defines the parent (can be null if the bone is the root)
  13670. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13671. */
  13672. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13673. /**
  13674. * Gets the local matrix
  13675. * @returns a matrix
  13676. */
  13677. getLocalMatrix(): Matrix;
  13678. /**
  13679. * Gets the base matrix (initial matrix which remains unchanged)
  13680. * @returns a matrix
  13681. */
  13682. getBaseMatrix(): Matrix;
  13683. /**
  13684. * Gets the rest pose matrix
  13685. * @returns a matrix
  13686. */
  13687. getRestPose(): Matrix;
  13688. /**
  13689. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13690. */
  13691. getWorldMatrix(): Matrix;
  13692. /**
  13693. * Sets the local matrix to rest pose matrix
  13694. */
  13695. returnToRest(): void;
  13696. /**
  13697. * Gets the inverse of the absolute transform matrix.
  13698. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13699. * @returns a matrix
  13700. */
  13701. getInvertedAbsoluteTransform(): Matrix;
  13702. /**
  13703. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13704. * @returns a matrix
  13705. */
  13706. getAbsoluteTransform(): Matrix;
  13707. /**
  13708. * Links with the given transform node.
  13709. * The local matrix of this bone is copied from the transform node every frame.
  13710. * @param transformNode defines the transform node to link to
  13711. */
  13712. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13713. /**
  13714. * Gets the node used to drive the bone's transformation
  13715. * @returns a transform node or null
  13716. */
  13717. getTransformNode(): Nullable<TransformNode>;
  13718. /** Gets or sets current position (in local space) */
  13719. position: Vector3;
  13720. /** Gets or sets current rotation (in local space) */
  13721. rotation: Vector3;
  13722. /** Gets or sets current rotation quaternion (in local space) */
  13723. rotationQuaternion: Quaternion;
  13724. /** Gets or sets current scaling (in local space) */
  13725. scaling: Vector3;
  13726. /**
  13727. * Gets the animation properties override
  13728. */
  13729. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13730. private _decompose;
  13731. private _compose;
  13732. /**
  13733. * Update the base and local matrices
  13734. * @param matrix defines the new base or local matrix
  13735. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13736. * @param updateLocalMatrix defines if the local matrix should be updated
  13737. */
  13738. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13739. /** @hidden */
  13740. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13741. /**
  13742. * Flag the bone as dirty (Forcing it to update everything)
  13743. */
  13744. markAsDirty(): void;
  13745. /** @hidden */
  13746. _markAsDirtyAndCompose(): void;
  13747. private _markAsDirtyAndDecompose;
  13748. /**
  13749. * Translate the bone in local or world space
  13750. * @param vec The amount to translate the bone
  13751. * @param space The space that the translation is in
  13752. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13753. */
  13754. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13755. /**
  13756. * Set the postion of the bone in local or world space
  13757. * @param position The position to set the bone
  13758. * @param space The space that the position is in
  13759. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13760. */
  13761. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13762. /**
  13763. * Set the absolute position of the bone (world space)
  13764. * @param position The position to set the bone
  13765. * @param mesh The mesh that this bone is attached to
  13766. */
  13767. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13768. /**
  13769. * Scale the bone on the x, y and z axes (in local space)
  13770. * @param x The amount to scale the bone on the x axis
  13771. * @param y The amount to scale the bone on the y axis
  13772. * @param z The amount to scale the bone on the z axis
  13773. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13774. */
  13775. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13776. /**
  13777. * Set the bone scaling in local space
  13778. * @param scale defines the scaling vector
  13779. */
  13780. setScale(scale: Vector3): void;
  13781. /**
  13782. * Gets the current scaling in local space
  13783. * @returns the current scaling vector
  13784. */
  13785. getScale(): Vector3;
  13786. /**
  13787. * Gets the current scaling in local space and stores it in a target vector
  13788. * @param result defines the target vector
  13789. */
  13790. getScaleToRef(result: Vector3): void;
  13791. /**
  13792. * Set the yaw, pitch, and roll of the bone in local or world space
  13793. * @param yaw The rotation of the bone on the y axis
  13794. * @param pitch The rotation of the bone on the x axis
  13795. * @param roll The rotation of the bone on the z axis
  13796. * @param space The space that the axes of rotation are in
  13797. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13798. */
  13799. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13800. /**
  13801. * Add a rotation to the bone on an axis in local or world space
  13802. * @param axis The axis to rotate the bone on
  13803. * @param amount The amount to rotate the bone
  13804. * @param space The space that the axis is in
  13805. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13806. */
  13807. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13808. /**
  13809. * Set the rotation of the bone to a particular axis angle in local or world space
  13810. * @param axis The axis to rotate the bone on
  13811. * @param angle The angle that the bone should be rotated to
  13812. * @param space The space that the axis is in
  13813. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13814. */
  13815. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13816. /**
  13817. * Set the euler rotation of the bone in local of world space
  13818. * @param rotation The euler rotation that the bone should be set to
  13819. * @param space The space that the rotation is in
  13820. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13821. */
  13822. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13823. /**
  13824. * Set the quaternion rotation of the bone in local of world space
  13825. * @param quat The quaternion rotation that the bone should be set to
  13826. * @param space The space that the rotation is in
  13827. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13828. */
  13829. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13830. /**
  13831. * Set the rotation matrix of the bone in local of world space
  13832. * @param rotMat The rotation matrix that the bone should be set to
  13833. * @param space The space that the rotation is in
  13834. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13835. */
  13836. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13837. private _rotateWithMatrix;
  13838. private _getNegativeRotationToRef;
  13839. /**
  13840. * Get the position of the bone in local or world space
  13841. * @param space The space that the returned position is in
  13842. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13843. * @returns The position of the bone
  13844. */
  13845. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13846. /**
  13847. * Copy the position of the bone to a vector3 in local or world space
  13848. * @param space The space that the returned position is in
  13849. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13850. * @param result The vector3 to copy the position to
  13851. */
  13852. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13853. /**
  13854. * Get the absolute position of the bone (world space)
  13855. * @param mesh The mesh that this bone is attached to
  13856. * @returns The absolute position of the bone
  13857. */
  13858. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13859. /**
  13860. * Copy the absolute position of the bone (world space) to the result param
  13861. * @param mesh The mesh that this bone is attached to
  13862. * @param result The vector3 to copy the absolute position to
  13863. */
  13864. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13865. /**
  13866. * Compute the absolute transforms of this bone and its children
  13867. */
  13868. computeAbsoluteTransforms(): void;
  13869. /**
  13870. * Get the world direction from an axis that is in the local space of the bone
  13871. * @param localAxis The local direction that is used to compute the world direction
  13872. * @param mesh The mesh that this bone is attached to
  13873. * @returns The world direction
  13874. */
  13875. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13876. /**
  13877. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13878. * @param localAxis The local direction that is used to compute the world direction
  13879. * @param mesh The mesh that this bone is attached to
  13880. * @param result The vector3 that the world direction will be copied to
  13881. */
  13882. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13883. /**
  13884. * Get the euler rotation of the bone in local or world space
  13885. * @param space The space that the rotation should be in
  13886. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13887. * @returns The euler rotation
  13888. */
  13889. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13890. /**
  13891. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13892. * @param space The space that the rotation should be in
  13893. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13894. * @param result The vector3 that the rotation should be copied to
  13895. */
  13896. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13897. /**
  13898. * Get the quaternion rotation of the bone in either local or world space
  13899. * @param space The space that the rotation should be in
  13900. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13901. * @returns The quaternion rotation
  13902. */
  13903. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13904. /**
  13905. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13906. * @param space The space that the rotation should be in
  13907. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13908. * @param result The quaternion that the rotation should be copied to
  13909. */
  13910. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13911. /**
  13912. * Get the rotation matrix of the bone in local or world space
  13913. * @param space The space that the rotation should be in
  13914. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13915. * @returns The rotation matrix
  13916. */
  13917. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13918. /**
  13919. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13920. * @param space The space that the rotation should be in
  13921. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13922. * @param result The quaternion that the rotation should be copied to
  13923. */
  13924. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13925. /**
  13926. * Get the world position of a point that is in the local space of the bone
  13927. * @param position The local position
  13928. * @param mesh The mesh that this bone is attached to
  13929. * @returns The world position
  13930. */
  13931. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13932. /**
  13933. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13934. * @param position The local position
  13935. * @param mesh The mesh that this bone is attached to
  13936. * @param result The vector3 that the world position should be copied to
  13937. */
  13938. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13939. /**
  13940. * Get the local position of a point that is in world space
  13941. * @param position The world position
  13942. * @param mesh The mesh that this bone is attached to
  13943. * @returns The local position
  13944. */
  13945. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13946. /**
  13947. * Get the local position of a point that is in world space and copy it to the result param
  13948. * @param position The world position
  13949. * @param mesh The mesh that this bone is attached to
  13950. * @param result The vector3 that the local position should be copied to
  13951. */
  13952. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13953. }
  13954. }
  13955. declare module "babylonjs/Meshes/transformNode" {
  13956. import { DeepImmutable } from "babylonjs/types";
  13957. import { Observable } from "babylonjs/Misc/observable";
  13958. import { Nullable } from "babylonjs/types";
  13959. import { Camera } from "babylonjs/Cameras/camera";
  13960. import { Scene } from "babylonjs/scene";
  13961. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  13962. import { Node } from "babylonjs/node";
  13963. import { Bone } from "babylonjs/Bones/bone";
  13964. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13965. import { Space } from "babylonjs/Maths/math.axis";
  13966. /**
  13967. * A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.
  13968. * @see https://doc.babylonjs.com/how_to/transformnode
  13969. */
  13970. export class TransformNode extends Node {
  13971. /**
  13972. * Object will not rotate to face the camera
  13973. */
  13974. static BILLBOARDMODE_NONE: number;
  13975. /**
  13976. * Object will rotate to face the camera but only on the x axis
  13977. */
  13978. static BILLBOARDMODE_X: number;
  13979. /**
  13980. * Object will rotate to face the camera but only on the y axis
  13981. */
  13982. static BILLBOARDMODE_Y: number;
  13983. /**
  13984. * Object will rotate to face the camera but only on the z axis
  13985. */
  13986. static BILLBOARDMODE_Z: number;
  13987. /**
  13988. * Object will rotate to face the camera
  13989. */
  13990. static BILLBOARDMODE_ALL: number;
  13991. /**
  13992. * Object will rotate to face the camera's position instead of orientation
  13993. */
  13994. static BILLBOARDMODE_USE_POSITION: number;
  13995. private _forward;
  13996. private _forwardInverted;
  13997. private _up;
  13998. private _right;
  13999. private _rightInverted;
  14000. private _position;
  14001. private _rotation;
  14002. private _rotationQuaternion;
  14003. protected _scaling: Vector3;
  14004. protected _isDirty: boolean;
  14005. private _transformToBoneReferal;
  14006. private _isAbsoluteSynced;
  14007. private _billboardMode;
  14008. /**
  14009. * Gets or sets the billboard mode. Default is 0.
  14010. *
  14011. * | Value | Type | Description |
  14012. * | --- | --- | --- |
  14013. * | 0 | BILLBOARDMODE_NONE | |
  14014. * | 1 | BILLBOARDMODE_X | |
  14015. * | 2 | BILLBOARDMODE_Y | |
  14016. * | 4 | BILLBOARDMODE_Z | |
  14017. * | 7 | BILLBOARDMODE_ALL | |
  14018. *
  14019. */
  14020. billboardMode: number;
  14021. private _preserveParentRotationForBillboard;
  14022. /**
  14023. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14024. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14025. */
  14026. preserveParentRotationForBillboard: boolean;
  14027. /**
  14028. * Multiplication factor on scale x/y/z when computing the world matrix. Eg. for a 1x1x1 cube setting this to 2 will make it a 2x2x2 cube
  14029. */
  14030. scalingDeterminant: number;
  14031. private _infiniteDistance;
  14032. /**
  14033. * Gets or sets the distance of the object to max, often used by skybox
  14034. */
  14035. infiniteDistance: boolean;
  14036. /**
  14037. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14038. * By default the system will update normals to compensate
  14039. */
  14040. ignoreNonUniformScaling: boolean;
  14041. /**
  14042. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  14043. */
  14044. reIntegrateRotationIntoRotationQuaternion: boolean;
  14045. /** @hidden */
  14046. _poseMatrix: Nullable<Matrix>;
  14047. /** @hidden */
  14048. _localMatrix: Matrix;
  14049. private _usePivotMatrix;
  14050. private _absolutePosition;
  14051. private _absoluteScaling;
  14052. private _absoluteRotationQuaternion;
  14053. private _pivotMatrix;
  14054. private _pivotMatrixInverse;
  14055. protected _postMultiplyPivotMatrix: boolean;
  14056. protected _isWorldMatrixFrozen: boolean;
  14057. /** @hidden */
  14058. _indexInSceneTransformNodesArray: number;
  14059. /**
  14060. * An event triggered after the world matrix is updated
  14061. */
  14062. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14063. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14064. /**
  14065. * Gets a string identifying the name of the class
  14066. * @returns "TransformNode" string
  14067. */
  14068. getClassName(): string;
  14069. /**
  14070. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14071. */
  14072. position: Vector3;
  14073. /**
  14074. * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  14075. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14076. */
  14077. rotation: Vector3;
  14078. /**
  14079. * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  14080. */
  14081. scaling: Vector3;
  14082. /**
  14083. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
  14084. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14085. */
  14086. rotationQuaternion: Nullable<Quaternion>;
  14087. /**
  14088. * The forward direction of that transform in world space.
  14089. */
  14090. readonly forward: Vector3;
  14091. /**
  14092. * The up direction of that transform in world space.
  14093. */
  14094. readonly up: Vector3;
  14095. /**
  14096. * The right direction of that transform in world space.
  14097. */
  14098. readonly right: Vector3;
  14099. /**
  14100. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14101. * @param matrix the matrix to copy the pose from
  14102. * @returns this TransformNode.
  14103. */
  14104. updatePoseMatrix(matrix: Matrix): TransformNode;
  14105. /**
  14106. * Returns the mesh Pose matrix.
  14107. * @returns the pose matrix
  14108. */
  14109. getPoseMatrix(): Matrix;
  14110. /** @hidden */
  14111. _isSynchronized(): boolean;
  14112. /** @hidden */
  14113. _initCache(): void;
  14114. /**
  14115. * Flag the transform node as dirty (Forcing it to update everything)
  14116. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14117. * @returns this transform node
  14118. */
  14119. markAsDirty(property: string): TransformNode;
  14120. /**
  14121. * Returns the current mesh absolute position.
  14122. * Returns a Vector3.
  14123. */
  14124. readonly absolutePosition: Vector3;
  14125. /**
  14126. * Returns the current mesh absolute scaling.
  14127. * Returns a Vector3.
  14128. */
  14129. readonly absoluteScaling: Vector3;
  14130. /**
  14131. * Returns the current mesh absolute rotation.
  14132. * Returns a Quaternion.
  14133. */
  14134. readonly absoluteRotationQuaternion: Quaternion;
  14135. /**
  14136. * Sets a new matrix to apply before all other transformation
  14137. * @param matrix defines the transform matrix
  14138. * @returns the current TransformNode
  14139. */
  14140. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14141. /**
  14142. * Sets a new pivot matrix to the current node
  14143. * @param matrix defines the new pivot matrix to use
  14144. * @param postMultiplyPivotMatrix defines if the pivot matrix must be cancelled in the world matrix. When this parameter is set to true (default), the inverse of the pivot matrix is also applied at the end to cancel the transformation effect
  14145. * @returns the current TransformNode
  14146. */
  14147. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14148. /**
  14149. * Returns the mesh pivot matrix.
  14150. * Default : Identity.
  14151. * @returns the matrix
  14152. */
  14153. getPivotMatrix(): Matrix;
  14154. /**
  14155. * Instantiate (when possible) or clone that node with its hierarchy
  14156. * @param newParent defines the new parent to use for the instance (or clone)
  14157. * @returns an instance (or a clone) of the current node with its hiearchy
  14158. */
  14159. instantiateHierarychy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  14160. /**
  14161. * Prevents the World matrix to be computed any longer
  14162. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14163. * @returns the TransformNode.
  14164. */
  14165. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14166. /**
  14167. * Allows back the World matrix computation.
  14168. * @returns the TransformNode.
  14169. */
  14170. unfreezeWorldMatrix(): this;
  14171. /**
  14172. * True if the World matrix has been frozen.
  14173. */
  14174. readonly isWorldMatrixFrozen: boolean;
  14175. /**
  14176. * Retuns the mesh absolute position in the World.
  14177. * @returns a Vector3.
  14178. */
  14179. getAbsolutePosition(): Vector3;
  14180. /**
  14181. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14182. * @param absolutePosition the absolute position to set
  14183. * @returns the TransformNode.
  14184. */
  14185. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14186. /**
  14187. * Sets the mesh position in its local space.
  14188. * @param vector3 the position to set in localspace
  14189. * @returns the TransformNode.
  14190. */
  14191. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14192. /**
  14193. * Returns the mesh position in the local space from the current World matrix values.
  14194. * @returns a new Vector3.
  14195. */
  14196. getPositionExpressedInLocalSpace(): Vector3;
  14197. /**
  14198. * Translates the mesh along the passed Vector3 in its local space.
  14199. * @param vector3 the distance to translate in localspace
  14200. * @returns the TransformNode.
  14201. */
  14202. locallyTranslate(vector3: Vector3): TransformNode;
  14203. private static _lookAtVectorCache;
  14204. /**
  14205. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14206. * @param targetPoint the position (must be in same space as current mesh) to look at
  14207. * @param yawCor optional yaw (y-axis) correction in radians
  14208. * @param pitchCor optional pitch (x-axis) correction in radians
  14209. * @param rollCor optional roll (z-axis) correction in radians
  14210. * @param space the choosen space of the target
  14211. * @returns the TransformNode.
  14212. */
  14213. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14214. /**
  14215. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14216. * This Vector3 is expressed in the World space.
  14217. * @param localAxis axis to rotate
  14218. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14219. */
  14220. getDirection(localAxis: Vector3): Vector3;
  14221. /**
  14222. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14223. * localAxis is expressed in the mesh local space.
  14224. * result is computed in the Wordl space from the mesh World matrix.
  14225. * @param localAxis axis to rotate
  14226. * @param result the resulting transformnode
  14227. * @returns this TransformNode.
  14228. */
  14229. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14230. /**
  14231. * Sets this transform node rotation to the given local axis.
  14232. * @param localAxis the axis in local space
  14233. * @param yawCor optional yaw (y-axis) correction in radians
  14234. * @param pitchCor optional pitch (x-axis) correction in radians
  14235. * @param rollCor optional roll (z-axis) correction in radians
  14236. * @returns this TransformNode
  14237. */
  14238. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14239. /**
  14240. * Sets a new pivot point to the current node
  14241. * @param point defines the new pivot point to use
  14242. * @param space defines if the point is in world or local space (local by default)
  14243. * @returns the current TransformNode
  14244. */
  14245. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14246. /**
  14247. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14248. * @returns the pivot point
  14249. */
  14250. getPivotPoint(): Vector3;
  14251. /**
  14252. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14253. * @param result the vector3 to store the result
  14254. * @returns this TransformNode.
  14255. */
  14256. getPivotPointToRef(result: Vector3): TransformNode;
  14257. /**
  14258. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14259. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14260. */
  14261. getAbsolutePivotPoint(): Vector3;
  14262. /**
  14263. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14264. * @param result vector3 to store the result
  14265. * @returns this TransformNode.
  14266. */
  14267. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14268. /**
  14269. * Defines the passed node as the parent of the current node.
  14270. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14271. * @see https://doc.babylonjs.com/how_to/parenting
  14272. * @param node the node ot set as the parent
  14273. * @returns this TransformNode.
  14274. */
  14275. setParent(node: Nullable<Node>): TransformNode;
  14276. private _nonUniformScaling;
  14277. /**
  14278. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14279. */
  14280. readonly nonUniformScaling: boolean;
  14281. /** @hidden */
  14282. _updateNonUniformScalingState(value: boolean): boolean;
  14283. /**
  14284. * Attach the current TransformNode to another TransformNode associated with a bone
  14285. * @param bone Bone affecting the TransformNode
  14286. * @param affectedTransformNode TransformNode associated with the bone
  14287. * @returns this object
  14288. */
  14289. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14290. /**
  14291. * Detach the transform node if its associated with a bone
  14292. * @returns this object
  14293. */
  14294. detachFromBone(): TransformNode;
  14295. private static _rotationAxisCache;
  14296. /**
  14297. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14298. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14299. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14300. * The passed axis is also normalized.
  14301. * @param axis the axis to rotate around
  14302. * @param amount the amount to rotate in radians
  14303. * @param space Space to rotate in (Default: local)
  14304. * @returns the TransformNode.
  14305. */
  14306. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14307. /**
  14308. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14309. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14310. * The passed axis is also normalized. .
  14311. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14312. * @param point the point to rotate around
  14313. * @param axis the axis to rotate around
  14314. * @param amount the amount to rotate in radians
  14315. * @returns the TransformNode
  14316. */
  14317. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14318. /**
  14319. * Translates the mesh along the axis vector for the passed distance in the given space.
  14320. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14321. * @param axis the axis to translate in
  14322. * @param distance the distance to translate
  14323. * @param space Space to rotate in (Default: local)
  14324. * @returns the TransformNode.
  14325. */
  14326. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14327. /**
  14328. * Adds a rotation step to the mesh current rotation.
  14329. * x, y, z are Euler angles expressed in radians.
  14330. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14331. * This means this rotation is made in the mesh local space only.
  14332. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14333. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14334. * ```javascript
  14335. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14336. * ```
  14337. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14338. * Under the hood, only quaternions are used. So it's a little faster is you use .rotationQuaternion because it doesn't need to translate them back to Euler angles.
  14339. * @param x Rotation to add
  14340. * @param y Rotation to add
  14341. * @param z Rotation to add
  14342. * @returns the TransformNode.
  14343. */
  14344. addRotation(x: number, y: number, z: number): TransformNode;
  14345. /**
  14346. * @hidden
  14347. */
  14348. protected _getEffectiveParent(): Nullable<Node>;
  14349. /**
  14350. * Computes the world matrix of the node
  14351. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14352. * @returns the world matrix
  14353. */
  14354. computeWorldMatrix(force?: boolean): Matrix;
  14355. protected _afterComputeWorldMatrix(): void;
  14356. /**
  14357. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14358. * @param func callback function to add
  14359. *
  14360. * @returns the TransformNode.
  14361. */
  14362. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14363. /**
  14364. * Removes a registered callback function.
  14365. * @param func callback function to remove
  14366. * @returns the TransformNode.
  14367. */
  14368. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14369. /**
  14370. * Gets the position of the current mesh in camera space
  14371. * @param camera defines the camera to use
  14372. * @returns a position
  14373. */
  14374. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14375. /**
  14376. * Returns the distance from the mesh to the active camera
  14377. * @param camera defines the camera to use
  14378. * @returns the distance
  14379. */
  14380. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14381. /**
  14382. * Clone the current transform node
  14383. * @param name Name of the new clone
  14384. * @param newParent New parent for the clone
  14385. * @param doNotCloneChildren Do not clone children hierarchy
  14386. * @returns the new transform node
  14387. */
  14388. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14389. /**
  14390. * Serializes the objects information.
  14391. * @param currentSerializationObject defines the object to serialize in
  14392. * @returns the serialized object
  14393. */
  14394. serialize(currentSerializationObject?: any): any;
  14395. /**
  14396. * Returns a new TransformNode object parsed from the source provided.
  14397. * @param parsedTransformNode is the source.
  14398. * @param scene the scne the object belongs to
  14399. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14400. * @returns a new TransformNode object parsed from the source provided.
  14401. */
  14402. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14403. /**
  14404. * Get all child-transformNodes of this node
  14405. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  14406. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  14407. * @returns an array of TransformNode
  14408. */
  14409. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14410. /**
  14411. * Releases resources associated with this transform node.
  14412. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14413. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14414. */
  14415. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14416. /**
  14417. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14418. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14419. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14420. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14421. * @returns the current mesh
  14422. */
  14423. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14424. private _syncAbsoluteScalingAndRotation;
  14425. }
  14426. }
  14427. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14428. import { Observable } from "babylonjs/Misc/observable";
  14429. import { Nullable } from "babylonjs/types";
  14430. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14431. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14432. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14433. import { Ray } from "babylonjs/Culling/ray";
  14434. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14435. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14436. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14437. /**
  14438. * Defines the types of pose enabled controllers that are supported
  14439. */
  14440. export enum PoseEnabledControllerType {
  14441. /**
  14442. * HTC Vive
  14443. */
  14444. VIVE = 0,
  14445. /**
  14446. * Oculus Rift
  14447. */
  14448. OCULUS = 1,
  14449. /**
  14450. * Windows mixed reality
  14451. */
  14452. WINDOWS = 2,
  14453. /**
  14454. * Samsung gear VR
  14455. */
  14456. GEAR_VR = 3,
  14457. /**
  14458. * Google Daydream
  14459. */
  14460. DAYDREAM = 4,
  14461. /**
  14462. * Generic
  14463. */
  14464. GENERIC = 5
  14465. }
  14466. /**
  14467. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14468. */
  14469. export interface MutableGamepadButton {
  14470. /**
  14471. * Value of the button/trigger
  14472. */
  14473. value: number;
  14474. /**
  14475. * If the button/trigger is currently touched
  14476. */
  14477. touched: boolean;
  14478. /**
  14479. * If the button/trigger is currently pressed
  14480. */
  14481. pressed: boolean;
  14482. }
  14483. /**
  14484. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14485. * @hidden
  14486. */
  14487. export interface ExtendedGamepadButton extends GamepadButton {
  14488. /**
  14489. * If the button/trigger is currently pressed
  14490. */
  14491. readonly pressed: boolean;
  14492. /**
  14493. * If the button/trigger is currently touched
  14494. */
  14495. readonly touched: boolean;
  14496. /**
  14497. * Value of the button/trigger
  14498. */
  14499. readonly value: number;
  14500. }
  14501. /** @hidden */
  14502. export interface _GamePadFactory {
  14503. /**
  14504. * Returns wether or not the current gamepad can be created for this type of controller.
  14505. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14506. * @returns true if it can be created, otherwise false
  14507. */
  14508. canCreate(gamepadInfo: any): boolean;
  14509. /**
  14510. * Creates a new instance of the Gamepad.
  14511. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14512. * @returns the new gamepad instance
  14513. */
  14514. create(gamepadInfo: any): Gamepad;
  14515. }
  14516. /**
  14517. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14518. */
  14519. export class PoseEnabledControllerHelper {
  14520. /** @hidden */
  14521. static _ControllerFactories: _GamePadFactory[];
  14522. /** @hidden */
  14523. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14524. /**
  14525. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14526. * @param vrGamepad the gamepad to initialized
  14527. * @returns a vr controller of the type the gamepad identified as
  14528. */
  14529. static InitiateController(vrGamepad: any): Gamepad;
  14530. }
  14531. /**
  14532. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14533. */
  14534. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14535. /**
  14536. * If the controller is used in a webXR session
  14537. */
  14538. isXR: boolean;
  14539. private _deviceRoomPosition;
  14540. private _deviceRoomRotationQuaternion;
  14541. /**
  14542. * The device position in babylon space
  14543. */
  14544. devicePosition: Vector3;
  14545. /**
  14546. * The device rotation in babylon space
  14547. */
  14548. deviceRotationQuaternion: Quaternion;
  14549. /**
  14550. * The scale factor of the device in babylon space
  14551. */
  14552. deviceScaleFactor: number;
  14553. /**
  14554. * (Likely devicePosition should be used instead) The device position in its room space
  14555. */
  14556. position: Vector3;
  14557. /**
  14558. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14559. */
  14560. rotationQuaternion: Quaternion;
  14561. /**
  14562. * The type of controller (Eg. Windows mixed reality)
  14563. */
  14564. controllerType: PoseEnabledControllerType;
  14565. protected _calculatedPosition: Vector3;
  14566. private _calculatedRotation;
  14567. /**
  14568. * The raw pose from the device
  14569. */
  14570. rawPose: DevicePose;
  14571. private _trackPosition;
  14572. private _maxRotationDistFromHeadset;
  14573. private _draggedRoomRotation;
  14574. /**
  14575. * @hidden
  14576. */
  14577. _disableTrackPosition(fixedPosition: Vector3): void;
  14578. /**
  14579. * Internal, the mesh attached to the controller
  14580. * @hidden
  14581. */
  14582. _mesh: Nullable<AbstractMesh>;
  14583. private _poseControlledCamera;
  14584. private _leftHandSystemQuaternion;
  14585. /**
  14586. * Internal, matrix used to convert room space to babylon space
  14587. * @hidden
  14588. */
  14589. _deviceToWorld: Matrix;
  14590. /**
  14591. * Node to be used when casting a ray from the controller
  14592. * @hidden
  14593. */
  14594. _pointingPoseNode: Nullable<TransformNode>;
  14595. /**
  14596. * Name of the child mesh that can be used to cast a ray from the controller
  14597. */
  14598. static readonly POINTING_POSE: string;
  14599. /**
  14600. * Creates a new PoseEnabledController from a gamepad
  14601. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14602. */
  14603. constructor(browserGamepad: any);
  14604. private _workingMatrix;
  14605. /**
  14606. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14607. */
  14608. update(): void;
  14609. /**
  14610. * Updates only the pose device and mesh without doing any button event checking
  14611. */
  14612. protected _updatePoseAndMesh(): void;
  14613. /**
  14614. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14615. * @param poseData raw pose fromthe device
  14616. */
  14617. updateFromDevice(poseData: DevicePose): void;
  14618. /**
  14619. * @hidden
  14620. */
  14621. _meshAttachedObservable: Observable<AbstractMesh>;
  14622. /**
  14623. * Attaches a mesh to the controller
  14624. * @param mesh the mesh to be attached
  14625. */
  14626. attachToMesh(mesh: AbstractMesh): void;
  14627. /**
  14628. * Attaches the controllers mesh to a camera
  14629. * @param camera the camera the mesh should be attached to
  14630. */
  14631. attachToPoseControlledCamera(camera: TargetCamera): void;
  14632. /**
  14633. * Disposes of the controller
  14634. */
  14635. dispose(): void;
  14636. /**
  14637. * The mesh that is attached to the controller
  14638. */
  14639. readonly mesh: Nullable<AbstractMesh>;
  14640. /**
  14641. * Gets the ray of the controller in the direction the controller is pointing
  14642. * @param length the length the resulting ray should be
  14643. * @returns a ray in the direction the controller is pointing
  14644. */
  14645. getForwardRay(length?: number): Ray;
  14646. }
  14647. }
  14648. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14649. import { Observable } from "babylonjs/Misc/observable";
  14650. import { Scene } from "babylonjs/scene";
  14651. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14652. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14653. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14654. /**
  14655. * Defines the WebVRController object that represents controllers tracked in 3D space
  14656. */
  14657. export abstract class WebVRController extends PoseEnabledController {
  14658. /**
  14659. * Internal, the default controller model for the controller
  14660. */
  14661. protected _defaultModel: AbstractMesh;
  14662. /**
  14663. * Fired when the trigger state has changed
  14664. */
  14665. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14666. /**
  14667. * Fired when the main button state has changed
  14668. */
  14669. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14670. /**
  14671. * Fired when the secondary button state has changed
  14672. */
  14673. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14674. /**
  14675. * Fired when the pad state has changed
  14676. */
  14677. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14678. /**
  14679. * Fired when controllers stick values have changed
  14680. */
  14681. onPadValuesChangedObservable: Observable<StickValues>;
  14682. /**
  14683. * Array of button availible on the controller
  14684. */
  14685. protected _buttons: Array<MutableGamepadButton>;
  14686. private _onButtonStateChange;
  14687. /**
  14688. * Fired when a controller button's state has changed
  14689. * @param callback the callback containing the button that was modified
  14690. */
  14691. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14692. /**
  14693. * X and Y axis corresponding to the controllers joystick
  14694. */
  14695. pad: StickValues;
  14696. /**
  14697. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14698. */
  14699. hand: string;
  14700. /**
  14701. * The default controller model for the controller
  14702. */
  14703. readonly defaultModel: AbstractMesh;
  14704. /**
  14705. * Creates a new WebVRController from a gamepad
  14706. * @param vrGamepad the gamepad that the WebVRController should be created from
  14707. */
  14708. constructor(vrGamepad: any);
  14709. /**
  14710. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14711. */
  14712. update(): void;
  14713. /**
  14714. * Function to be called when a button is modified
  14715. */
  14716. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14717. /**
  14718. * Loads a mesh and attaches it to the controller
  14719. * @param scene the scene the mesh should be added to
  14720. * @param meshLoaded callback for when the mesh has been loaded
  14721. */
  14722. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14723. private _setButtonValue;
  14724. private _changes;
  14725. private _checkChanges;
  14726. /**
  14727. * Disposes of th webVRCOntroller
  14728. */
  14729. dispose(): void;
  14730. }
  14731. }
  14732. declare module "babylonjs/Lights/hemisphericLight" {
  14733. import { Nullable } from "babylonjs/types";
  14734. import { Scene } from "babylonjs/scene";
  14735. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14736. import { Color3 } from "babylonjs/Maths/math.color";
  14737. import { Effect } from "babylonjs/Materials/effect";
  14738. import { Light } from "babylonjs/Lights/light";
  14739. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  14740. /**
  14741. * The HemisphericLight simulates the ambient environment light,
  14742. * so the passed direction is the light reflection direction, not the incoming direction.
  14743. */
  14744. export class HemisphericLight extends Light {
  14745. /**
  14746. * The groundColor is the light in the opposite direction to the one specified during creation.
  14747. * You can think of the diffuse and specular light as coming from the centre of the object in the given direction and the groundColor light in the opposite direction.
  14748. */
  14749. groundColor: Color3;
  14750. /**
  14751. * The light reflection direction, not the incoming direction.
  14752. */
  14753. direction: Vector3;
  14754. /**
  14755. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14756. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14757. * The HemisphericLight can't cast shadows.
  14758. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14759. * @param name The friendly name of the light
  14760. * @param direction The direction of the light reflection
  14761. * @param scene The scene the light belongs to
  14762. */
  14763. constructor(name: string, direction: Vector3, scene: Scene);
  14764. protected _buildUniformLayout(): void;
  14765. /**
  14766. * Returns the string "HemisphericLight".
  14767. * @return The class name
  14768. */
  14769. getClassName(): string;
  14770. /**
  14771. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14772. * Returns the updated direction.
  14773. * @param target The target the direction should point to
  14774. * @return The computed direction
  14775. */
  14776. setDirectionToTarget(target: Vector3): Vector3;
  14777. /**
  14778. * Returns the shadow generator associated to the light.
  14779. * @returns Always null for hemispheric lights because it does not support shadows.
  14780. */
  14781. getShadowGenerator(): Nullable<IShadowGenerator>;
  14782. /**
  14783. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14784. * @param effect The effect to update
  14785. * @param lightIndex The index of the light in the effect to update
  14786. * @returns The hemispheric light
  14787. */
  14788. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14789. /**
  14790. * Computes the world matrix of the node
  14791. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14792. * @param useWasUpdatedFlag defines a reserved property
  14793. * @returns the world matrix
  14794. */
  14795. computeWorldMatrix(): Matrix;
  14796. /**
  14797. * Returns the integer 3.
  14798. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14799. */
  14800. getTypeID(): number;
  14801. /**
  14802. * Prepares the list of defines specific to the light type.
  14803. * @param defines the list of defines
  14804. * @param lightIndex defines the index of the light for the effect
  14805. */
  14806. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14807. }
  14808. }
  14809. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  14810. /** @hidden */
  14811. export var vrMultiviewToSingleviewPixelShader: {
  14812. name: string;
  14813. shader: string;
  14814. };
  14815. }
  14816. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  14817. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14818. import { Scene } from "babylonjs/scene";
  14819. /**
  14820. * Renders to multiple views with a single draw call
  14821. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14822. */
  14823. export class MultiviewRenderTarget extends RenderTargetTexture {
  14824. /**
  14825. * Creates a multiview render target
  14826. * @param scene scene used with the render target
  14827. * @param size the size of the render target (used for each view)
  14828. */
  14829. constructor(scene: Scene, size?: number | {
  14830. width: number;
  14831. height: number;
  14832. } | {
  14833. ratio: number;
  14834. });
  14835. /**
  14836. * @hidden
  14837. * @param faceIndex the face index, if its a cube texture
  14838. */
  14839. _bindFrameBuffer(faceIndex?: number): void;
  14840. /**
  14841. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14842. * @returns the view count
  14843. */
  14844. getViewCount(): number;
  14845. }
  14846. }
  14847. declare module "babylonjs/Maths/math.frustum" {
  14848. import { Matrix } from "babylonjs/Maths/math.vector";
  14849. import { DeepImmutable } from "babylonjs/types";
  14850. import { Plane } from "babylonjs/Maths/math.plane";
  14851. /**
  14852. * Reprasents a camera frustum
  14853. */
  14854. export class Frustum {
  14855. /**
  14856. * Gets the planes representing the frustum
  14857. * @param transform matrix to be applied to the returned planes
  14858. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14859. */
  14860. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14861. /**
  14862. * Gets the near frustum plane transformed by the transform matrix
  14863. * @param transform transformation matrix to be applied to the resulting frustum plane
  14864. * @param frustumPlane the resuling frustum plane
  14865. */
  14866. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14867. /**
  14868. * Gets the far frustum plane transformed by the transform matrix
  14869. * @param transform transformation matrix to be applied to the resulting frustum plane
  14870. * @param frustumPlane the resuling frustum plane
  14871. */
  14872. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14873. /**
  14874. * Gets the left frustum plane transformed by the transform matrix
  14875. * @param transform transformation matrix to be applied to the resulting frustum plane
  14876. * @param frustumPlane the resuling frustum plane
  14877. */
  14878. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14879. /**
  14880. * Gets the right frustum plane transformed by the transform matrix
  14881. * @param transform transformation matrix to be applied to the resulting frustum plane
  14882. * @param frustumPlane the resuling frustum plane
  14883. */
  14884. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14885. /**
  14886. * Gets the top frustum plane transformed by the transform matrix
  14887. * @param transform transformation matrix to be applied to the resulting frustum plane
  14888. * @param frustumPlane the resuling frustum plane
  14889. */
  14890. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14891. /**
  14892. * Gets the bottom frustum plane transformed by the transform matrix
  14893. * @param transform transformation matrix to be applied to the resulting frustum plane
  14894. * @param frustumPlane the resuling frustum plane
  14895. */
  14896. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14897. /**
  14898. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14899. * @param transform transformation matrix to be applied to the resulting frustum planes
  14900. * @param frustumPlanes the resuling frustum planes
  14901. */
  14902. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14903. }
  14904. }
  14905. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  14906. import { Camera } from "babylonjs/Cameras/camera";
  14907. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14908. import { Nullable } from "babylonjs/types";
  14909. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14910. import { Matrix } from "babylonjs/Maths/math.vector";
  14911. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  14912. module "babylonjs/Engines/engine" {
  14913. interface Engine {
  14914. /**
  14915. * Creates a new multiview render target
  14916. * @param width defines the width of the texture
  14917. * @param height defines the height of the texture
  14918. * @returns the created multiview texture
  14919. */
  14920. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14921. /**
  14922. * Binds a multiview framebuffer to be drawn to
  14923. * @param multiviewTexture texture to bind
  14924. */
  14925. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14926. }
  14927. }
  14928. module "babylonjs/Cameras/camera" {
  14929. interface Camera {
  14930. /**
  14931. * @hidden
  14932. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  14933. */
  14934. _useMultiviewToSingleView: boolean;
  14935. /**
  14936. * @hidden
  14937. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  14938. */
  14939. _multiviewTexture: Nullable<RenderTargetTexture>;
  14940. /**
  14941. * @hidden
  14942. * ensures the multiview texture of the camera exists and has the specified width/height
  14943. * @param width height to set on the multiview texture
  14944. * @param height width to set on the multiview texture
  14945. */
  14946. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14947. }
  14948. }
  14949. module "babylonjs/scene" {
  14950. interface Scene {
  14951. /** @hidden */
  14952. _transformMatrixR: Matrix;
  14953. /** @hidden */
  14954. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14955. /** @hidden */
  14956. _createMultiviewUbo(): void;
  14957. /** @hidden */
  14958. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14959. /** @hidden */
  14960. _renderMultiviewToSingleView(camera: Camera): void;
  14961. }
  14962. }
  14963. }
  14964. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  14965. import { Camera } from "babylonjs/Cameras/camera";
  14966. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  14967. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  14968. import "babylonjs/Engines/Extensions/engine.multiview";
  14969. /**
  14970. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14971. * This will not be used for webXR as it supports displaying texture arrays directly
  14972. */
  14973. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14974. /**
  14975. * Initializes a VRMultiviewToSingleview
  14976. * @param name name of the post process
  14977. * @param camera camera to be applied to
  14978. * @param scaleFactor scaling factor to the size of the output texture
  14979. */
  14980. constructor(name: string, camera: Camera, scaleFactor: number);
  14981. }
  14982. }
  14983. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  14984. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  14985. import { Nullable } from "babylonjs/types";
  14986. import { Size } from "babylonjs/Maths/math.size";
  14987. import { Observable } from "babylonjs/Misc/observable";
  14988. module "babylonjs/Engines/engine" {
  14989. interface Engine {
  14990. /** @hidden */
  14991. _vrDisplay: any;
  14992. /** @hidden */
  14993. _vrSupported: boolean;
  14994. /** @hidden */
  14995. _oldSize: Size;
  14996. /** @hidden */
  14997. _oldHardwareScaleFactor: number;
  14998. /** @hidden */
  14999. _vrExclusivePointerMode: boolean;
  15000. /** @hidden */
  15001. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15002. /** @hidden */
  15003. _onVRDisplayPointerRestricted: () => void;
  15004. /** @hidden */
  15005. _onVRDisplayPointerUnrestricted: () => void;
  15006. /** @hidden */
  15007. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15008. /** @hidden */
  15009. _onVrDisplayDisconnect: Nullable<() => void>;
  15010. /** @hidden */
  15011. _onVrDisplayPresentChange: Nullable<() => void>;
  15012. /**
  15013. * Observable signaled when VR display mode changes
  15014. */
  15015. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15016. /**
  15017. * Observable signaled when VR request present is complete
  15018. */
  15019. onVRRequestPresentComplete: Observable<boolean>;
  15020. /**
  15021. * Observable signaled when VR request present starts
  15022. */
  15023. onVRRequestPresentStart: Observable<Engine>;
  15024. /**
  15025. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15026. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15027. */
  15028. isInVRExclusivePointerMode: boolean;
  15029. /**
  15030. * Gets a boolean indicating if a webVR device was detected
  15031. * @returns true if a webVR device was detected
  15032. */
  15033. isVRDevicePresent(): boolean;
  15034. /**
  15035. * Gets the current webVR device
  15036. * @returns the current webVR device (or null)
  15037. */
  15038. getVRDevice(): any;
  15039. /**
  15040. * Initializes a webVR display and starts listening to display change events
  15041. * The onVRDisplayChangedObservable will be notified upon these changes
  15042. * @returns A promise containing a VRDisplay and if vr is supported
  15043. */
  15044. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15045. /** @hidden */
  15046. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15047. /**
  15048. * Call this function to switch to webVR mode
  15049. * Will do nothing if webVR is not supported or if there is no webVR device
  15050. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15051. */
  15052. enableVR(): void;
  15053. /** @hidden */
  15054. _onVRFullScreenTriggered(): void;
  15055. }
  15056. }
  15057. }
  15058. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15059. import { Nullable } from "babylonjs/types";
  15060. import { Observable } from "babylonjs/Misc/observable";
  15061. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15062. import { Scene } from "babylonjs/scene";
  15063. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15064. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15065. import { Node } from "babylonjs/node";
  15066. import { Ray } from "babylonjs/Culling/ray";
  15067. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15068. import "babylonjs/Engines/Extensions/engine.webVR";
  15069. /**
  15070. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15071. * IMPORTANT!! The data is right-hand data.
  15072. * @export
  15073. * @interface DevicePose
  15074. */
  15075. export interface DevicePose {
  15076. /**
  15077. * The position of the device, values in array are [x,y,z].
  15078. */
  15079. readonly position: Nullable<Float32Array>;
  15080. /**
  15081. * The linearVelocity of the device, values in array are [x,y,z].
  15082. */
  15083. readonly linearVelocity: Nullable<Float32Array>;
  15084. /**
  15085. * The linearAcceleration of the device, values in array are [x,y,z].
  15086. */
  15087. readonly linearAcceleration: Nullable<Float32Array>;
  15088. /**
  15089. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15090. */
  15091. readonly orientation: Nullable<Float32Array>;
  15092. /**
  15093. * The angularVelocity of the device, values in array are [x,y,z].
  15094. */
  15095. readonly angularVelocity: Nullable<Float32Array>;
  15096. /**
  15097. * The angularAcceleration of the device, values in array are [x,y,z].
  15098. */
  15099. readonly angularAcceleration: Nullable<Float32Array>;
  15100. }
  15101. /**
  15102. * Interface representing a pose controlled object in Babylon.
  15103. * A pose controlled object has both regular pose values as well as pose values
  15104. * from an external device such as a VR head mounted display
  15105. */
  15106. export interface PoseControlled {
  15107. /**
  15108. * The position of the object in babylon space.
  15109. */
  15110. position: Vector3;
  15111. /**
  15112. * The rotation quaternion of the object in babylon space.
  15113. */
  15114. rotationQuaternion: Quaternion;
  15115. /**
  15116. * The position of the device in babylon space.
  15117. */
  15118. devicePosition?: Vector3;
  15119. /**
  15120. * The rotation quaternion of the device in babylon space.
  15121. */
  15122. deviceRotationQuaternion: Quaternion;
  15123. /**
  15124. * The raw pose coming from the device.
  15125. */
  15126. rawPose: Nullable<DevicePose>;
  15127. /**
  15128. * The scale of the device to be used when translating from device space to babylon space.
  15129. */
  15130. deviceScaleFactor: number;
  15131. /**
  15132. * Updates the poseControlled values based on the input device pose.
  15133. * @param poseData the pose data to update the object with
  15134. */
  15135. updateFromDevice(poseData: DevicePose): void;
  15136. }
  15137. /**
  15138. * Set of options to customize the webVRCamera
  15139. */
  15140. export interface WebVROptions {
  15141. /**
  15142. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15143. */
  15144. trackPosition?: boolean;
  15145. /**
  15146. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15147. */
  15148. positionScale?: number;
  15149. /**
  15150. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15151. */
  15152. displayName?: string;
  15153. /**
  15154. * Should the native controller meshes be initialized. (default: true)
  15155. */
  15156. controllerMeshes?: boolean;
  15157. /**
  15158. * Creating a default HemiLight only on controllers. (default: true)
  15159. */
  15160. defaultLightingOnControllers?: boolean;
  15161. /**
  15162. * If you don't want to use the default VR button of the helper. (default: false)
  15163. */
  15164. useCustomVRButton?: boolean;
  15165. /**
  15166. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15167. */
  15168. customVRButton?: HTMLButtonElement;
  15169. /**
  15170. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15171. */
  15172. rayLength?: number;
  15173. /**
  15174. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15175. */
  15176. defaultHeight?: number;
  15177. /**
  15178. * If multiview should be used if availible (default: false)
  15179. */
  15180. useMultiview?: boolean;
  15181. }
  15182. /**
  15183. * This represents a WebVR camera.
  15184. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15185. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15186. */
  15187. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15188. private webVROptions;
  15189. /**
  15190. * @hidden
  15191. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15192. */
  15193. _vrDevice: any;
  15194. /**
  15195. * The rawPose of the vrDevice.
  15196. */
  15197. rawPose: Nullable<DevicePose>;
  15198. private _onVREnabled;
  15199. private _specsVersion;
  15200. private _attached;
  15201. private _frameData;
  15202. protected _descendants: Array<Node>;
  15203. private _deviceRoomPosition;
  15204. /** @hidden */
  15205. _deviceRoomRotationQuaternion: Quaternion;
  15206. private _standingMatrix;
  15207. /**
  15208. * Represents device position in babylon space.
  15209. */
  15210. devicePosition: Vector3;
  15211. /**
  15212. * Represents device rotation in babylon space.
  15213. */
  15214. deviceRotationQuaternion: Quaternion;
  15215. /**
  15216. * The scale of the device to be used when translating from device space to babylon space.
  15217. */
  15218. deviceScaleFactor: number;
  15219. private _deviceToWorld;
  15220. private _worldToDevice;
  15221. /**
  15222. * References to the webVR controllers for the vrDevice.
  15223. */
  15224. controllers: Array<WebVRController>;
  15225. /**
  15226. * Emits an event when a controller is attached.
  15227. */
  15228. onControllersAttachedObservable: Observable<WebVRController[]>;
  15229. /**
  15230. * Emits an event when a controller's mesh has been loaded;
  15231. */
  15232. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15233. /**
  15234. * Emits an event when the HMD's pose has been updated.
  15235. */
  15236. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15237. private _poseSet;
  15238. /**
  15239. * If the rig cameras be used as parent instead of this camera.
  15240. */
  15241. rigParenting: boolean;
  15242. private _lightOnControllers;
  15243. private _defaultHeight?;
  15244. /**
  15245. * Instantiates a WebVRFreeCamera.
  15246. * @param name The name of the WebVRFreeCamera
  15247. * @param position The starting anchor position for the camera
  15248. * @param scene The scene the camera belongs to
  15249. * @param webVROptions a set of customizable options for the webVRCamera
  15250. */
  15251. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15252. /**
  15253. * Gets the device distance from the ground in meters.
  15254. * @returns the distance in meters from the vrDevice to ground in device space. If standing matrix is not supported for the vrDevice 0 is returned.
  15255. */
  15256. deviceDistanceToRoomGround(): number;
  15257. /**
  15258. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15259. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15260. */
  15261. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15262. /**
  15263. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15264. * @returns A promise with a boolean set to if the standing matrix is supported.
  15265. */
  15266. useStandingMatrixAsync(): Promise<boolean>;
  15267. /**
  15268. * Disposes the camera
  15269. */
  15270. dispose(): void;
  15271. /**
  15272. * Gets a vrController by name.
  15273. * @param name The name of the controller to retreive
  15274. * @returns the controller matching the name specified or null if not found
  15275. */
  15276. getControllerByName(name: string): Nullable<WebVRController>;
  15277. private _leftController;
  15278. /**
  15279. * The controller corresponding to the users left hand.
  15280. */
  15281. readonly leftController: Nullable<WebVRController>;
  15282. private _rightController;
  15283. /**
  15284. * The controller corresponding to the users right hand.
  15285. */
  15286. readonly rightController: Nullable<WebVRController>;
  15287. /**
  15288. * Casts a ray forward from the vrCamera's gaze.
  15289. * @param length Length of the ray (default: 100)
  15290. * @returns the ray corresponding to the gaze
  15291. */
  15292. getForwardRay(length?: number): Ray;
  15293. /**
  15294. * @hidden
  15295. * Updates the camera based on device's frame data
  15296. */
  15297. _checkInputs(): void;
  15298. /**
  15299. * Updates the poseControlled values based on the input device pose.
  15300. * @param poseData Pose coming from the device
  15301. */
  15302. updateFromDevice(poseData: DevicePose): void;
  15303. private _htmlElementAttached;
  15304. private _detachIfAttached;
  15305. /**
  15306. * WebVR's attach control will start broadcasting frames to the device.
  15307. * Note that in certain browsers (chrome for example) this function must be called
  15308. * within a user-interaction callback. Example:
  15309. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15310. *
  15311. * @param element html element to attach the vrDevice to
  15312. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15313. */
  15314. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15315. /**
  15316. * Detaches the camera from the html element and disables VR
  15317. *
  15318. * @param element html element to detach from
  15319. */
  15320. detachControl(element: HTMLElement): void;
  15321. /**
  15322. * @returns the name of this class
  15323. */
  15324. getClassName(): string;
  15325. /**
  15326. * Calls resetPose on the vrDisplay
  15327. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15328. */
  15329. resetToCurrentRotation(): void;
  15330. /**
  15331. * @hidden
  15332. * Updates the rig cameras (left and right eye)
  15333. */
  15334. _updateRigCameras(): void;
  15335. private _workingVector;
  15336. private _oneVector;
  15337. private _workingMatrix;
  15338. private updateCacheCalled;
  15339. private _correctPositionIfNotTrackPosition;
  15340. /**
  15341. * @hidden
  15342. * Updates the cached values of the camera
  15343. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15344. */
  15345. _updateCache(ignoreParentClass?: boolean): void;
  15346. /**
  15347. * @hidden
  15348. * Get current device position in babylon world
  15349. */
  15350. _computeDevicePosition(): void;
  15351. /**
  15352. * Updates the current device position and rotation in the babylon world
  15353. */
  15354. update(): void;
  15355. /**
  15356. * @hidden
  15357. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15358. * @returns an identity matrix
  15359. */
  15360. _getViewMatrix(): Matrix;
  15361. private _tmpMatrix;
  15362. /**
  15363. * This function is called by the two RIG cameras.
  15364. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15365. * @hidden
  15366. */
  15367. _getWebVRViewMatrix(): Matrix;
  15368. /** @hidden */
  15369. _getWebVRProjectionMatrix(): Matrix;
  15370. private _onGamepadConnectedObserver;
  15371. private _onGamepadDisconnectedObserver;
  15372. private _updateCacheWhenTrackingDisabledObserver;
  15373. /**
  15374. * Initializes the controllers and their meshes
  15375. */
  15376. initControllers(): void;
  15377. }
  15378. }
  15379. declare module "babylonjs/PostProcesses/postProcess" {
  15380. import { Nullable } from "babylonjs/types";
  15381. import { SmartArray } from "babylonjs/Misc/smartArray";
  15382. import { Observable } from "babylonjs/Misc/observable";
  15383. import { Vector2 } from "babylonjs/Maths/math.vector";
  15384. import { Camera } from "babylonjs/Cameras/camera";
  15385. import { Effect } from "babylonjs/Materials/effect";
  15386. import "babylonjs/Shaders/postprocess.vertex";
  15387. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15388. import { Engine } from "babylonjs/Engines/engine";
  15389. import { Color4 } from "babylonjs/Maths/math.color";
  15390. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15391. /**
  15392. * Size options for a post process
  15393. */
  15394. export type PostProcessOptions = {
  15395. width: number;
  15396. height: number;
  15397. };
  15398. /**
  15399. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15400. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15401. */
  15402. export class PostProcess {
  15403. /** Name of the PostProcess. */
  15404. name: string;
  15405. /**
  15406. * Gets or sets the unique id of the post process
  15407. */
  15408. uniqueId: number;
  15409. /**
  15410. * Width of the texture to apply the post process on
  15411. */
  15412. width: number;
  15413. /**
  15414. * Height of the texture to apply the post process on
  15415. */
  15416. height: number;
  15417. /**
  15418. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15419. * @hidden
  15420. */
  15421. _outputTexture: Nullable<InternalTexture>;
  15422. /**
  15423. * Sampling mode used by the shader
  15424. * See https://doc.babylonjs.com/classes/3.1/texture
  15425. */
  15426. renderTargetSamplingMode: number;
  15427. /**
  15428. * Clear color to use when screen clearing
  15429. */
  15430. clearColor: Color4;
  15431. /**
  15432. * If the buffer needs to be cleared before applying the post process. (default: true)
  15433. * Should be set to false if shader will overwrite all previous pixels.
  15434. */
  15435. autoClear: boolean;
  15436. /**
  15437. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15438. */
  15439. alphaMode: number;
  15440. /**
  15441. * Sets the setAlphaBlendConstants of the babylon engine
  15442. */
  15443. alphaConstants: Color4;
  15444. /**
  15445. * Animations to be used for the post processing
  15446. */
  15447. animations: import("babylonjs/Animations/animation").Animation[];
  15448. /**
  15449. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15450. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15451. */
  15452. enablePixelPerfectMode: boolean;
  15453. /**
  15454. * Force the postprocess to be applied without taking in account viewport
  15455. */
  15456. forceFullscreenViewport: boolean;
  15457. /**
  15458. * List of inspectable custom properties (used by the Inspector)
  15459. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15460. */
  15461. inspectableCustomProperties: IInspectable[];
  15462. /**
  15463. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15464. *
  15465. * | Value | Type | Description |
  15466. * | ----- | ----------------------------------- | ----------- |
  15467. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15468. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15469. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15470. *
  15471. */
  15472. scaleMode: number;
  15473. /**
  15474. * Force textures to be a power of two (default: false)
  15475. */
  15476. alwaysForcePOT: boolean;
  15477. private _samples;
  15478. /**
  15479. * Number of sample textures (default: 1)
  15480. */
  15481. samples: number;
  15482. /**
  15483. * Modify the scale of the post process to be the same as the viewport (default: false)
  15484. */
  15485. adaptScaleToCurrentViewport: boolean;
  15486. private _camera;
  15487. private _scene;
  15488. private _engine;
  15489. private _options;
  15490. private _reusable;
  15491. private _textureType;
  15492. /**
  15493. * Smart array of input and output textures for the post process.
  15494. * @hidden
  15495. */
  15496. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15497. /**
  15498. * The index in _textures that corresponds to the output texture.
  15499. * @hidden
  15500. */
  15501. _currentRenderTextureInd: number;
  15502. private _effect;
  15503. private _samplers;
  15504. private _fragmentUrl;
  15505. private _vertexUrl;
  15506. private _parameters;
  15507. private _scaleRatio;
  15508. protected _indexParameters: any;
  15509. private _shareOutputWithPostProcess;
  15510. private _texelSize;
  15511. private _forcedOutputTexture;
  15512. /**
  15513. * Returns the fragment url or shader name used in the post process.
  15514. * @returns the fragment url or name in the shader store.
  15515. */
  15516. getEffectName(): string;
  15517. /**
  15518. * An event triggered when the postprocess is activated.
  15519. */
  15520. onActivateObservable: Observable<Camera>;
  15521. private _onActivateObserver;
  15522. /**
  15523. * A function that is added to the onActivateObservable
  15524. */
  15525. onActivate: Nullable<(camera: Camera) => void>;
  15526. /**
  15527. * An event triggered when the postprocess changes its size.
  15528. */
  15529. onSizeChangedObservable: Observable<PostProcess>;
  15530. private _onSizeChangedObserver;
  15531. /**
  15532. * A function that is added to the onSizeChangedObservable
  15533. */
  15534. onSizeChanged: (postProcess: PostProcess) => void;
  15535. /**
  15536. * An event triggered when the postprocess applies its effect.
  15537. */
  15538. onApplyObservable: Observable<Effect>;
  15539. private _onApplyObserver;
  15540. /**
  15541. * A function that is added to the onApplyObservable
  15542. */
  15543. onApply: (effect: Effect) => void;
  15544. /**
  15545. * An event triggered before rendering the postprocess
  15546. */
  15547. onBeforeRenderObservable: Observable<Effect>;
  15548. private _onBeforeRenderObserver;
  15549. /**
  15550. * A function that is added to the onBeforeRenderObservable
  15551. */
  15552. onBeforeRender: (effect: Effect) => void;
  15553. /**
  15554. * An event triggered after rendering the postprocess
  15555. */
  15556. onAfterRenderObservable: Observable<Effect>;
  15557. private _onAfterRenderObserver;
  15558. /**
  15559. * A function that is added to the onAfterRenderObservable
  15560. */
  15561. onAfterRender: (efect: Effect) => void;
  15562. /**
  15563. * The input texture for this post process and the output texture of the previous post process. When added to a pipeline the previous post process will
  15564. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15565. */
  15566. inputTexture: InternalTexture;
  15567. /**
  15568. * Gets the camera which post process is applied to.
  15569. * @returns The camera the post process is applied to.
  15570. */
  15571. getCamera(): Camera;
  15572. /**
  15573. * Gets the texel size of the postprocess.
  15574. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15575. */
  15576. readonly texelSize: Vector2;
  15577. /**
  15578. * Creates a new instance PostProcess
  15579. * @param name The name of the PostProcess.
  15580. * @param fragmentUrl The url of the fragment shader to be used.
  15581. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15582. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15583. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15584. * @param camera The camera to apply the render pass to.
  15585. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15586. * @param engine The engine which the post process will be applied. (default: current engine)
  15587. * @param reusable If the post process can be reused on the same frame. (default: false)
  15588. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15589. * @param textureType Type of textures used when performing the post process. (default: 0)
  15590. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15591. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  15592. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15593. */
  15594. constructor(
  15595. /** Name of the PostProcess. */
  15596. name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: Nullable<string>, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean);
  15597. /**
  15598. * Gets a string idenfifying the name of the class
  15599. * @returns "PostProcess" string
  15600. */
  15601. getClassName(): string;
  15602. /**
  15603. * Gets the engine which this post process belongs to.
  15604. * @returns The engine the post process was enabled with.
  15605. */
  15606. getEngine(): Engine;
  15607. /**
  15608. * The effect that is created when initializing the post process.
  15609. * @returns The created effect corresponding the the postprocess.
  15610. */
  15611. getEffect(): Effect;
  15612. /**
  15613. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15614. * @param postProcess The post process to share the output with.
  15615. * @returns This post process.
  15616. */
  15617. shareOutputWith(postProcess: PostProcess): PostProcess;
  15618. /**
  15619. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15620. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15621. */
  15622. useOwnOutput(): void;
  15623. /**
  15624. * Updates the effect with the current post process compile time values and recompiles the shader.
  15625. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15626. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15627. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15628. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  15629. * @param onCompiled Called when the shader has been compiled.
  15630. * @param onError Called if there is an error when compiling a shader.
  15631. */
  15632. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15633. /**
  15634. * The post process is reusable if it can be used multiple times within one frame.
  15635. * @returns If the post process is reusable
  15636. */
  15637. isReusable(): boolean;
  15638. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15639. markTextureDirty(): void;
  15640. /**
  15641. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15642. * When this post process is used in a pipeline, this is call will bind the input texture of this post process to the output of the previous.
  15643. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15644. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15645. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15646. * @returns The target texture that was bound to be written to.
  15647. */
  15648. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15649. /**
  15650. * If the post process is supported.
  15651. */
  15652. readonly isSupported: boolean;
  15653. /**
  15654. * The aspect ratio of the output texture.
  15655. */
  15656. readonly aspectRatio: number;
  15657. /**
  15658. * Get a value indicating if the post-process is ready to be used
  15659. * @returns true if the post-process is ready (shader is compiled)
  15660. */
  15661. isReady(): boolean;
  15662. /**
  15663. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15664. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15665. */
  15666. apply(): Nullable<Effect>;
  15667. private _disposeTextures;
  15668. /**
  15669. * Disposes the post process.
  15670. * @param camera The camera to dispose the post process on.
  15671. */
  15672. dispose(camera?: Camera): void;
  15673. }
  15674. }
  15675. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15676. /** @hidden */
  15677. export var kernelBlurVaryingDeclaration: {
  15678. name: string;
  15679. shader: string;
  15680. };
  15681. }
  15682. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  15683. /** @hidden */
  15684. export var kernelBlurFragment: {
  15685. name: string;
  15686. shader: string;
  15687. };
  15688. }
  15689. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  15690. /** @hidden */
  15691. export var kernelBlurFragment2: {
  15692. name: string;
  15693. shader: string;
  15694. };
  15695. }
  15696. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  15697. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15698. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  15699. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  15700. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  15701. /** @hidden */
  15702. export var kernelBlurPixelShader: {
  15703. name: string;
  15704. shader: string;
  15705. };
  15706. }
  15707. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  15708. /** @hidden */
  15709. export var kernelBlurVertex: {
  15710. name: string;
  15711. shader: string;
  15712. };
  15713. }
  15714. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  15715. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15716. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  15717. /** @hidden */
  15718. export var kernelBlurVertexShader: {
  15719. name: string;
  15720. shader: string;
  15721. };
  15722. }
  15723. declare module "babylonjs/PostProcesses/blurPostProcess" {
  15724. import { Vector2 } from "babylonjs/Maths/math.vector";
  15725. import { Nullable } from "babylonjs/types";
  15726. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  15727. import { Camera } from "babylonjs/Cameras/camera";
  15728. import { Effect } from "babylonjs/Materials/effect";
  15729. import { Engine } from "babylonjs/Engines/engine";
  15730. import "babylonjs/Shaders/kernelBlur.fragment";
  15731. import "babylonjs/Shaders/kernelBlur.vertex";
  15732. /**
  15733. * The Blur Post Process which blurs an image based on a kernel and direction.
  15734. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15735. */
  15736. export class BlurPostProcess extends PostProcess {
  15737. /** The direction in which to blur the image. */
  15738. direction: Vector2;
  15739. private blockCompilation;
  15740. protected _kernel: number;
  15741. protected _idealKernel: number;
  15742. protected _packedFloat: boolean;
  15743. private _staticDefines;
  15744. /**
  15745. * Sets the length in pixels of the blur sample region
  15746. */
  15747. /**
  15748. * Gets the length in pixels of the blur sample region
  15749. */
  15750. kernel: number;
  15751. /**
  15752. * Sets wether or not the blur needs to unpack/repack floats
  15753. */
  15754. /**
  15755. * Gets wether or not the blur is unpacking/repacking floats
  15756. */
  15757. packedFloat: boolean;
  15758. /**
  15759. * Creates a new instance BlurPostProcess
  15760. * @param name The name of the effect.
  15761. * @param direction The direction in which to blur the image.
  15762. * @param kernel The size of the kernel to be used when computing the blur. eg. Size of 3 will blur the center pixel by 2 pixels surrounding it.
  15763. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15764. * @param camera The camera to apply the render pass to.
  15765. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15766. * @param engine The engine which the post process will be applied. (default: current engine)
  15767. * @param reusable If the post process can be reused on the same frame. (default: false)
  15768. * @param textureType Type of textures used when performing the post process. (default: 0)
  15769. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  15770. */
  15771. constructor(name: string,
  15772. /** The direction in which to blur the image. */
  15773. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15774. /**
  15775. * Updates the effect with the current post process compile time values and recompiles the shader.
  15776. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15777. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15778. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15779. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  15780. * @param onCompiled Called when the shader has been compiled.
  15781. * @param onError Called if there is an error when compiling a shader.
  15782. */
  15783. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15784. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15785. /**
  15786. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15787. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15788. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15789. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15790. * The gaps between physical kernels are compensated for in the weighting of the samples
  15791. * @param idealKernel Ideal blur kernel.
  15792. * @return Nearest best kernel.
  15793. */
  15794. protected _nearestBestKernel(idealKernel: number): number;
  15795. /**
  15796. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15797. * @param x The point on the Gaussian distribution to sample.
  15798. * @return the value of the Gaussian function at x.
  15799. */
  15800. protected _gaussianWeight(x: number): number;
  15801. /**
  15802. * Generates a string that can be used as a floating point number in GLSL.
  15803. * @param x Value to print.
  15804. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15805. * @return GLSL float string.
  15806. */
  15807. protected _glslFloat(x: number, decimalFigures?: number): string;
  15808. }
  15809. }
  15810. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  15811. import { Scene } from "babylonjs/scene";
  15812. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15813. import { Plane } from "babylonjs/Maths/math.plane";
  15814. /**
  15815. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15816. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15817. * You can then easily use it as a reflectionTexture on a flat surface.
  15818. * In case the surface is not a plane, please consider relying on reflection probes.
  15819. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15820. */
  15821. export class MirrorTexture extends RenderTargetTexture {
  15822. private scene;
  15823. /**
  15824. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15825. * It is possible to directly set the mirrorPlane by directly using a Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the mirrorPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the reflector as stated in the doc.
  15826. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15827. */
  15828. mirrorPlane: Plane;
  15829. /**
  15830. * Define the blur ratio used to blur the reflection if needed.
  15831. */
  15832. blurRatio: number;
  15833. /**
  15834. * Define the adaptive blur kernel used to blur the reflection if needed.
  15835. * This will autocompute the closest best match for the `blurKernel`
  15836. */
  15837. adaptiveBlurKernel: number;
  15838. /**
  15839. * Define the blur kernel used to blur the reflection if needed.
  15840. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15841. */
  15842. blurKernel: number;
  15843. /**
  15844. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15845. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15846. */
  15847. blurKernelX: number;
  15848. /**
  15849. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15850. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15851. */
  15852. blurKernelY: number;
  15853. private _autoComputeBlurKernel;
  15854. protected _onRatioRescale(): void;
  15855. private _updateGammaSpace;
  15856. private _imageProcessingConfigChangeObserver;
  15857. private _transformMatrix;
  15858. private _mirrorMatrix;
  15859. private _savedViewMatrix;
  15860. private _blurX;
  15861. private _blurY;
  15862. private _adaptiveBlurKernel;
  15863. private _blurKernelX;
  15864. private _blurKernelY;
  15865. private _blurRatio;
  15866. /**
  15867. * Instantiates a Mirror Texture.
  15868. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15869. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15870. * You can then easily use it as a reflectionTexture on a flat surface.
  15871. * In case the surface is not a plane, please consider relying on reflection probes.
  15872. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15873. * @param name
  15874. * @param size
  15875. * @param scene
  15876. * @param generateMipMaps
  15877. * @param type
  15878. * @param samplingMode
  15879. * @param generateDepthBuffer
  15880. */
  15881. constructor(name: string, size: number | {
  15882. width: number;
  15883. height: number;
  15884. } | {
  15885. ratio: number;
  15886. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15887. private _preparePostProcesses;
  15888. /**
  15889. * Clone the mirror texture.
  15890. * @returns the cloned texture
  15891. */
  15892. clone(): MirrorTexture;
  15893. /**
  15894. * Serialize the texture to a JSON representation you could use in Parse later on
  15895. * @returns the serialized JSON representation
  15896. */
  15897. serialize(): any;
  15898. /**
  15899. * Dispose the texture and release its associated resources.
  15900. */
  15901. dispose(): void;
  15902. }
  15903. }
  15904. declare module "babylonjs/Materials/Textures/texture" {
  15905. import { Observable } from "babylonjs/Misc/observable";
  15906. import { Nullable } from "babylonjs/types";
  15907. import { Scene } from "babylonjs/scene";
  15908. import { Matrix } from "babylonjs/Maths/math.vector";
  15909. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15910. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15911. import { Engine } from "babylonjs/Engines/engine";
  15912. /**
  15913. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15914. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15915. */
  15916. export class Texture extends BaseTexture {
  15917. /** @hidden */
  15918. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  15919. /** @hidden */
  15920. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  15921. /** @hidden */
  15922. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  15923. /** nearest is mag = nearest and min = nearest and mip = linear */
  15924. static readonly NEAREST_SAMPLINGMODE: number;
  15925. /** nearest is mag = nearest and min = nearest and mip = linear */
  15926. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15927. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15928. static readonly BILINEAR_SAMPLINGMODE: number;
  15929. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15930. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15931. /** Trilinear is mag = linear and min = linear and mip = linear */
  15932. static readonly TRILINEAR_SAMPLINGMODE: number;
  15933. /** Trilinear is mag = linear and min = linear and mip = linear */
  15934. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15935. /** mag = nearest and min = nearest and mip = nearest */
  15936. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15937. /** mag = nearest and min = linear and mip = nearest */
  15938. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15939. /** mag = nearest and min = linear and mip = linear */
  15940. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15941. /** mag = nearest and min = linear and mip = none */
  15942. static readonly NEAREST_LINEAR: number;
  15943. /** mag = nearest and min = nearest and mip = none */
  15944. static readonly NEAREST_NEAREST: number;
  15945. /** mag = linear and min = nearest and mip = nearest */
  15946. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15947. /** mag = linear and min = nearest and mip = linear */
  15948. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15949. /** mag = linear and min = linear and mip = none */
  15950. static readonly LINEAR_LINEAR: number;
  15951. /** mag = linear and min = nearest and mip = none */
  15952. static readonly LINEAR_NEAREST: number;
  15953. /** Explicit coordinates mode */
  15954. static readonly EXPLICIT_MODE: number;
  15955. /** Spherical coordinates mode */
  15956. static readonly SPHERICAL_MODE: number;
  15957. /** Planar coordinates mode */
  15958. static readonly PLANAR_MODE: number;
  15959. /** Cubic coordinates mode */
  15960. static readonly CUBIC_MODE: number;
  15961. /** Projection coordinates mode */
  15962. static readonly PROJECTION_MODE: number;
  15963. /** Inverse Cubic coordinates mode */
  15964. static readonly SKYBOX_MODE: number;
  15965. /** Inverse Cubic coordinates mode */
  15966. static readonly INVCUBIC_MODE: number;
  15967. /** Equirectangular coordinates mode */
  15968. static readonly EQUIRECTANGULAR_MODE: number;
  15969. /** Equirectangular Fixed coordinates mode */
  15970. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15971. /** Equirectangular Fixed Mirrored coordinates mode */
  15972. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15973. /** Texture is not repeating outside of 0..1 UVs */
  15974. static readonly CLAMP_ADDRESSMODE: number;
  15975. /** Texture is repeating outside of 0..1 UVs */
  15976. static readonly WRAP_ADDRESSMODE: number;
  15977. /** Texture is repeating and mirrored */
  15978. static readonly MIRROR_ADDRESSMODE: number;
  15979. /**
  15980. * Gets or sets a boolean which defines if the texture url must be build from the serialized URL instead of just using the name and loading them side by side with the scene file
  15981. */
  15982. static UseSerializedUrlIfAny: boolean;
  15983. /**
  15984. * Define the url of the texture.
  15985. */
  15986. url: Nullable<string>;
  15987. /**
  15988. * Define an offset on the texture to offset the u coordinates of the UVs
  15989. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15990. */
  15991. uOffset: number;
  15992. /**
  15993. * Define an offset on the texture to offset the v coordinates of the UVs
  15994. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15995. */
  15996. vOffset: number;
  15997. /**
  15998. * Define an offset on the texture to scale the u coordinates of the UVs
  15999. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16000. */
  16001. uScale: number;
  16002. /**
  16003. * Define an offset on the texture to scale the v coordinates of the UVs
  16004. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16005. */
  16006. vScale: number;
  16007. /**
  16008. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16009. * @see http://doc.babylonjs.com/how_to/more_materials
  16010. */
  16011. uAng: number;
  16012. /**
  16013. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16014. * @see http://doc.babylonjs.com/how_to/more_materials
  16015. */
  16016. vAng: number;
  16017. /**
  16018. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16019. * @see http://doc.babylonjs.com/how_to/more_materials
  16020. */
  16021. wAng: number;
  16022. /**
  16023. * Defines the center of rotation (U)
  16024. */
  16025. uRotationCenter: number;
  16026. /**
  16027. * Defines the center of rotation (V)
  16028. */
  16029. vRotationCenter: number;
  16030. /**
  16031. * Defines the center of rotation (W)
  16032. */
  16033. wRotationCenter: number;
  16034. /**
  16035. * Are mip maps generated for this texture or not.
  16036. */
  16037. readonly noMipmap: boolean;
  16038. /**
  16039. * List of inspectable custom properties (used by the Inspector)
  16040. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16041. */
  16042. inspectableCustomProperties: Nullable<IInspectable[]>;
  16043. private _noMipmap;
  16044. /** @hidden */
  16045. _invertY: boolean;
  16046. private _rowGenerationMatrix;
  16047. private _cachedTextureMatrix;
  16048. private _projectionModeMatrix;
  16049. private _t0;
  16050. private _t1;
  16051. private _t2;
  16052. private _cachedUOffset;
  16053. private _cachedVOffset;
  16054. private _cachedUScale;
  16055. private _cachedVScale;
  16056. private _cachedUAng;
  16057. private _cachedVAng;
  16058. private _cachedWAng;
  16059. private _cachedProjectionMatrixId;
  16060. private _cachedCoordinatesMode;
  16061. /** @hidden */
  16062. protected _initialSamplingMode: number;
  16063. /** @hidden */
  16064. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  16065. private _deleteBuffer;
  16066. protected _format: Nullable<number>;
  16067. private _delayedOnLoad;
  16068. private _delayedOnError;
  16069. /**
  16070. * Observable triggered once the texture has been loaded.
  16071. */
  16072. onLoadObservable: Observable<Texture>;
  16073. protected _isBlocking: boolean;
  16074. /**
  16075. * Is the texture preventing material to render while loading.
  16076. * If false, a default texture will be used instead of the loading one during the preparation step.
  16077. */
  16078. isBlocking: boolean;
  16079. /**
  16080. * Get the current sampling mode associated with the texture.
  16081. */
  16082. readonly samplingMode: number;
  16083. /**
  16084. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16085. */
  16086. readonly invertY: boolean;
  16087. /**
  16088. * Instantiates a new texture.
  16089. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16090. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16091. * @param url define the url of the picture to load as a texture
  16092. * @param scene define the scene or engine the texture will belong to
  16093. * @param noMipmap define if the texture will require mip maps or not
  16094. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16095. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16096. * @param onLoad define a callback triggered when the texture has been loaded
  16097. * @param onError define a callback triggered when an error occurred during the loading session
  16098. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16099. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16100. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16101. */
  16102. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  16103. /**
  16104. * Update the url (and optional buffer) of this texture if url was null during construction.
  16105. * @param url the url of the texture
  16106. * @param buffer the buffer of the texture (defaults to null)
  16107. * @param onLoad callback called when the texture is loaded (defaults to null)
  16108. */
  16109. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16110. /**
  16111. * Finish the loading sequence of a texture flagged as delayed load.
  16112. * @hidden
  16113. */
  16114. delayLoad(): void;
  16115. private _prepareRowForTextureGeneration;
  16116. /**
  16117. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16118. * @returns the transform matrix of the texture.
  16119. */
  16120. getTextureMatrix(): Matrix;
  16121. /**
  16122. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16123. * @returns The reflection texture transform
  16124. */
  16125. getReflectionTextureMatrix(): Matrix;
  16126. /**
  16127. * Clones the texture.
  16128. * @returns the cloned texture
  16129. */
  16130. clone(): Texture;
  16131. /**
  16132. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16133. * @returns The JSON representation of the texture
  16134. */
  16135. serialize(): any;
  16136. /**
  16137. * Get the current class name of the texture useful for serialization or dynamic coding.
  16138. * @returns "Texture"
  16139. */
  16140. getClassName(): string;
  16141. /**
  16142. * Dispose the texture and release its associated resources.
  16143. */
  16144. dispose(): void;
  16145. /**
  16146. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16147. * @param parsedTexture Define the JSON representation of the texture
  16148. * @param scene Define the scene the parsed texture should be instantiated in
  16149. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16150. * @returns The parsed texture if successful
  16151. */
  16152. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16153. /**
  16154. * Creates a texture from its base 64 representation.
  16155. * @param data Define the base64 payload without the data: prefix
  16156. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16157. * @param scene Define the scene the texture should belong to
  16158. * @param noMipmap Forces the texture to not create mip map information if true
  16159. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16160. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16161. * @param onLoad define a callback triggered when the texture has been loaded
  16162. * @param onError define a callback triggered when an error occurred during the loading session
  16163. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16164. * @returns the created texture
  16165. */
  16166. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16167. /**
  16168. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16169. * @param data Define the base64 payload without the data: prefix
  16170. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16171. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16172. * @param scene Define the scene the texture should belong to
  16173. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16174. * @param noMipmap Forces the texture to not create mip map information if true
  16175. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16176. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16177. * @param onLoad define a callback triggered when the texture has been loaded
  16178. * @param onError define a callback triggered when an error occurred during the loading session
  16179. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16180. * @returns the created texture
  16181. */
  16182. static LoadFromDataString(name: string, buffer: any, scene: Scene, deleteBuffer?: boolean, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number): Texture;
  16183. }
  16184. }
  16185. declare module "babylonjs/PostProcesses/postProcessManager" {
  16186. import { Nullable } from "babylonjs/types";
  16187. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16188. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16189. import { Scene } from "babylonjs/scene";
  16190. /**
  16191. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16192. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16193. */
  16194. export class PostProcessManager {
  16195. private _scene;
  16196. private _indexBuffer;
  16197. private _vertexBuffers;
  16198. /**
  16199. * Creates a new instance PostProcess
  16200. * @param scene The scene that the post process is associated with.
  16201. */
  16202. constructor(scene: Scene);
  16203. private _prepareBuffers;
  16204. private _buildIndexBuffer;
  16205. /**
  16206. * Rebuilds the vertex buffers of the manager.
  16207. * @hidden
  16208. */
  16209. _rebuild(): void;
  16210. /**
  16211. * Prepares a frame to be run through a post process.
  16212. * @param sourceTexture The input texture to the post procesess. (default: null)
  16213. * @param postProcesses An array of post processes to be run. (default: null)
  16214. * @returns True if the post processes were able to be run.
  16215. * @hidden
  16216. */
  16217. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16218. /**
  16219. * Manually render a set of post processes to a texture.
  16220. * @param postProcesses An array of post processes to be run.
  16221. * @param targetTexture The target texture to render to.
  16222. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16223. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16224. * @param lodLevel defines which lod of the texture to render to
  16225. */
  16226. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16227. /**
  16228. * Finalize the result of the output of the postprocesses.
  16229. * @param doNotPresent If true the result will not be displayed to the screen.
  16230. * @param targetTexture The target texture to render to.
  16231. * @param faceIndex The index of the face to bind the target texture to.
  16232. * @param postProcesses The array of post processes to render.
  16233. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16234. * @hidden
  16235. */
  16236. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16237. /**
  16238. * Disposes of the post process manager.
  16239. */
  16240. dispose(): void;
  16241. }
  16242. }
  16243. declare module "babylonjs/Misc/gradients" {
  16244. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16245. /** Interface used by value gradients (color, factor, ...) */
  16246. export interface IValueGradient {
  16247. /**
  16248. * Gets or sets the gradient value (between 0 and 1)
  16249. */
  16250. gradient: number;
  16251. }
  16252. /** Class used to store color4 gradient */
  16253. export class ColorGradient implements IValueGradient {
  16254. /**
  16255. * Gets or sets the gradient value (between 0 and 1)
  16256. */
  16257. gradient: number;
  16258. /**
  16259. * Gets or sets first associated color
  16260. */
  16261. color1: Color4;
  16262. /**
  16263. * Gets or sets second associated color
  16264. */
  16265. color2?: Color4;
  16266. /**
  16267. * Will get a color picked randomly between color1 and color2.
  16268. * If color2 is undefined then color1 will be used
  16269. * @param result defines the target Color4 to store the result in
  16270. */
  16271. getColorToRef(result: Color4): void;
  16272. }
  16273. /** Class used to store color 3 gradient */
  16274. export class Color3Gradient implements IValueGradient {
  16275. /**
  16276. * Gets or sets the gradient value (between 0 and 1)
  16277. */
  16278. gradient: number;
  16279. /**
  16280. * Gets or sets the associated color
  16281. */
  16282. color: Color3;
  16283. }
  16284. /** Class used to store factor gradient */
  16285. export class FactorGradient implements IValueGradient {
  16286. /**
  16287. * Gets or sets the gradient value (between 0 and 1)
  16288. */
  16289. gradient: number;
  16290. /**
  16291. * Gets or sets first associated factor
  16292. */
  16293. factor1: number;
  16294. /**
  16295. * Gets or sets second associated factor
  16296. */
  16297. factor2?: number;
  16298. /**
  16299. * Will get a number picked randomly between factor1 and factor2.
  16300. * If factor2 is undefined then factor1 will be used
  16301. * @returns the picked number
  16302. */
  16303. getFactor(): number;
  16304. }
  16305. /**
  16306. * Helper used to simplify some generic gradient tasks
  16307. */
  16308. export class GradientHelper {
  16309. /**
  16310. * Gets the current gradient from an array of IValueGradient
  16311. * @param ratio defines the current ratio to get
  16312. * @param gradients defines the array of IValueGradient
  16313. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16314. */
  16315. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16316. }
  16317. }
  16318. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16319. import { Scene } from "babylonjs/scene";
  16320. import { ISceneComponent } from "babylonjs/sceneComponent";
  16321. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16322. module "babylonjs/abstractScene" {
  16323. interface AbstractScene {
  16324. /**
  16325. * The list of procedural textures added to the scene
  16326. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16327. */
  16328. proceduralTextures: Array<ProceduralTexture>;
  16329. }
  16330. }
  16331. /**
  16332. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16333. * in a given scene.
  16334. */
  16335. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16336. /**
  16337. * The component name helpfull to identify the component in the list of scene components.
  16338. */
  16339. readonly name: string;
  16340. /**
  16341. * The scene the component belongs to.
  16342. */
  16343. scene: Scene;
  16344. /**
  16345. * Creates a new instance of the component for the given scene
  16346. * @param scene Defines the scene to register the component in
  16347. */
  16348. constructor(scene: Scene);
  16349. /**
  16350. * Registers the component in a given scene
  16351. */
  16352. register(): void;
  16353. /**
  16354. * Rebuilds the elements related to this component in case of
  16355. * context lost for instance.
  16356. */
  16357. rebuild(): void;
  16358. /**
  16359. * Disposes the component and the associated ressources.
  16360. */
  16361. dispose(): void;
  16362. private _beforeClear;
  16363. }
  16364. }
  16365. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  16366. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16367. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16368. module "babylonjs/Engines/engine" {
  16369. interface Engine {
  16370. /**
  16371. * Creates a new render target cube texture
  16372. * @param size defines the size of the texture
  16373. * @param options defines the options used to create the texture
  16374. * @returns a new render target cube texture stored in an InternalTexture
  16375. */
  16376. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16377. }
  16378. }
  16379. }
  16380. declare module "babylonjs/Shaders/procedural.vertex" {
  16381. /** @hidden */
  16382. export var proceduralVertexShader: {
  16383. name: string;
  16384. shader: string;
  16385. };
  16386. }
  16387. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16388. import { Observable } from "babylonjs/Misc/observable";
  16389. import { Nullable } from "babylonjs/types";
  16390. import { Scene } from "babylonjs/scene";
  16391. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16392. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16393. import { Effect } from "babylonjs/Materials/effect";
  16394. import { Texture } from "babylonjs/Materials/Textures/texture";
  16395. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16396. import "babylonjs/Shaders/procedural.vertex";
  16397. /**
  16398. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes calmpler' images.
  16399. * This is the base class of any Procedural texture and contains most of the shareable code.
  16400. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16401. */
  16402. export class ProceduralTexture extends Texture {
  16403. isCube: boolean;
  16404. /**
  16405. * Define if the texture is enabled or not (disabled texture will not render)
  16406. */
  16407. isEnabled: boolean;
  16408. /**
  16409. * Define if the texture must be cleared before rendering (default is true)
  16410. */
  16411. autoClear: boolean;
  16412. /**
  16413. * Callback called when the texture is generated
  16414. */
  16415. onGenerated: () => void;
  16416. /**
  16417. * Event raised when the texture is generated
  16418. */
  16419. onGeneratedObservable: Observable<ProceduralTexture>;
  16420. /** @hidden */
  16421. _generateMipMaps: boolean;
  16422. /** @hidden **/
  16423. _effect: Effect;
  16424. /** @hidden */
  16425. _textures: {
  16426. [key: string]: Texture;
  16427. };
  16428. private _size;
  16429. private _currentRefreshId;
  16430. private _refreshRate;
  16431. private _vertexBuffers;
  16432. private _indexBuffer;
  16433. private _uniforms;
  16434. private _samplers;
  16435. private _fragment;
  16436. private _floats;
  16437. private _ints;
  16438. private _floatsArrays;
  16439. private _colors3;
  16440. private _colors4;
  16441. private _vectors2;
  16442. private _vectors3;
  16443. private _matrices;
  16444. private _fallbackTexture;
  16445. private _fallbackTextureUsed;
  16446. private _engine;
  16447. private _cachedDefines;
  16448. private _contentUpdateId;
  16449. private _contentData;
  16450. /**
  16451. * Instantiates a new procedural texture.
  16452. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  16453. * This is the base class of any Procedural texture and contains most of the shareable code.
  16454. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16455. * @param name Define the name of the texture
  16456. * @param size Define the size of the texture to create
  16457. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16458. * @param scene Define the scene the texture belongs to
  16459. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16460. * @param generateMipMaps Define if the texture should creates mip maps or not
  16461. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16462. */
  16463. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16464. /**
  16465. * The effect that is created when initializing the post process.
  16466. * @returns The created effect corresponding the the postprocess.
  16467. */
  16468. getEffect(): Effect;
  16469. /**
  16470. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16471. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16472. */
  16473. getContent(): Nullable<ArrayBufferView>;
  16474. private _createIndexBuffer;
  16475. /** @hidden */
  16476. _rebuild(): void;
  16477. /**
  16478. * Resets the texture in order to recreate its associated resources.
  16479. * This can be called in case of context loss
  16480. */
  16481. reset(): void;
  16482. protected _getDefines(): string;
  16483. /**
  16484. * Is the texture ready to be used ? (rendered at least once)
  16485. * @returns true if ready, otherwise, false.
  16486. */
  16487. isReady(): boolean;
  16488. /**
  16489. * Resets the refresh counter of the texture and start bak from scratch.
  16490. * Could be useful to regenerate the texture if it is setup to render only once.
  16491. */
  16492. resetRefreshCounter(): void;
  16493. /**
  16494. * Set the fragment shader to use in order to render the texture.
  16495. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16496. */
  16497. setFragment(fragment: any): void;
  16498. /**
  16499. * Define the refresh rate of the texture or the rendering frequency.
  16500. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16501. */
  16502. refreshRate: number;
  16503. /** @hidden */
  16504. _shouldRender(): boolean;
  16505. /**
  16506. * Get the size the texture is rendering at.
  16507. * @returns the size (texture is always squared)
  16508. */
  16509. getRenderSize(): number;
  16510. /**
  16511. * Resize the texture to new value.
  16512. * @param size Define the new size the texture should have
  16513. * @param generateMipMaps Define whether the new texture should create mip maps
  16514. */
  16515. resize(size: number, generateMipMaps: boolean): void;
  16516. private _checkUniform;
  16517. /**
  16518. * Set a texture in the shader program used to render.
  16519. * @param name Define the name of the uniform samplers as defined in the shader
  16520. * @param texture Define the texture to bind to this sampler
  16521. * @return the texture itself allowing "fluent" like uniform updates
  16522. */
  16523. setTexture(name: string, texture: Texture): ProceduralTexture;
  16524. /**
  16525. * Set a float in the shader.
  16526. * @param name Define the name of the uniform as defined in the shader
  16527. * @param value Define the value to give to the uniform
  16528. * @return the texture itself allowing "fluent" like uniform updates
  16529. */
  16530. setFloat(name: string, value: number): ProceduralTexture;
  16531. /**
  16532. * Set a int in the shader.
  16533. * @param name Define the name of the uniform as defined in the shader
  16534. * @param value Define the value to give to the uniform
  16535. * @return the texture itself allowing "fluent" like uniform updates
  16536. */
  16537. setInt(name: string, value: number): ProceduralTexture;
  16538. /**
  16539. * Set an array of floats in the shader.
  16540. * @param name Define the name of the uniform as defined in the shader
  16541. * @param value Define the value to give to the uniform
  16542. * @return the texture itself allowing "fluent" like uniform updates
  16543. */
  16544. setFloats(name: string, value: number[]): ProceduralTexture;
  16545. /**
  16546. * Set a vec3 in the shader from a Color3.
  16547. * @param name Define the name of the uniform as defined in the shader
  16548. * @param value Define the value to give to the uniform
  16549. * @return the texture itself allowing "fluent" like uniform updates
  16550. */
  16551. setColor3(name: string, value: Color3): ProceduralTexture;
  16552. /**
  16553. * Set a vec4 in the shader from a Color4.
  16554. * @param name Define the name of the uniform as defined in the shader
  16555. * @param value Define the value to give to the uniform
  16556. * @return the texture itself allowing "fluent" like uniform updates
  16557. */
  16558. setColor4(name: string, value: Color4): ProceduralTexture;
  16559. /**
  16560. * Set a vec2 in the shader from a Vector2.
  16561. * @param name Define the name of the uniform as defined in the shader
  16562. * @param value Define the value to give to the uniform
  16563. * @return the texture itself allowing "fluent" like uniform updates
  16564. */
  16565. setVector2(name: string, value: Vector2): ProceduralTexture;
  16566. /**
  16567. * Set a vec3 in the shader from a Vector3.
  16568. * @param name Define the name of the uniform as defined in the shader
  16569. * @param value Define the value to give to the uniform
  16570. * @return the texture itself allowing "fluent" like uniform updates
  16571. */
  16572. setVector3(name: string, value: Vector3): ProceduralTexture;
  16573. /**
  16574. * Set a mat4 in the shader from a MAtrix.
  16575. * @param name Define the name of the uniform as defined in the shader
  16576. * @param value Define the value to give to the uniform
  16577. * @return the texture itself allowing "fluent" like uniform updates
  16578. */
  16579. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16580. /**
  16581. * Render the texture to its associated render target.
  16582. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16583. */
  16584. render(useCameraPostProcess?: boolean): void;
  16585. /**
  16586. * Clone the texture.
  16587. * @returns the cloned texture
  16588. */
  16589. clone(): ProceduralTexture;
  16590. /**
  16591. * Dispose the texture and release its asoociated resources.
  16592. */
  16593. dispose(): void;
  16594. }
  16595. }
  16596. declare module "babylonjs/Particles/baseParticleSystem" {
  16597. import { Nullable } from "babylonjs/types";
  16598. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  16599. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16600. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  16601. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16602. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16603. import { Scene } from "babylonjs/scene";
  16604. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  16605. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16606. import { Texture } from "babylonjs/Materials/Textures/texture";
  16607. import { Color4 } from "babylonjs/Maths/math.color";
  16608. import { Animation } from "babylonjs/Animations/animation";
  16609. /**
  16610. * This represents the base class for particle system in Babylon.
  16611. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  16612. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16613. * @example https://doc.babylonjs.com/babylon101/particles
  16614. */
  16615. export class BaseParticleSystem {
  16616. /**
  16617. * Source color is added to the destination color without alpha affecting the result
  16618. */
  16619. static BLENDMODE_ONEONE: number;
  16620. /**
  16621. * Blend current color and particle color using particle’s alpha
  16622. */
  16623. static BLENDMODE_STANDARD: number;
  16624. /**
  16625. * Add current color and particle color multiplied by particle’s alpha
  16626. */
  16627. static BLENDMODE_ADD: number;
  16628. /**
  16629. * Multiply current color with particle color
  16630. */
  16631. static BLENDMODE_MULTIPLY: number;
  16632. /**
  16633. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16634. */
  16635. static BLENDMODE_MULTIPLYADD: number;
  16636. /**
  16637. * List of animations used by the particle system.
  16638. */
  16639. animations: Animation[];
  16640. /**
  16641. * The id of the Particle system.
  16642. */
  16643. id: string;
  16644. /**
  16645. * The friendly name of the Particle system.
  16646. */
  16647. name: string;
  16648. /**
  16649. * The rendering group used by the Particle system to chose when to render.
  16650. */
  16651. renderingGroupId: number;
  16652. /**
  16653. * The emitter represents the Mesh or position we are attaching the particle system to.
  16654. */
  16655. emitter: Nullable<AbstractMesh | Vector3>;
  16656. /**
  16657. * The maximum number of particles to emit per frame
  16658. */
  16659. emitRate: number;
  16660. /**
  16661. * If you want to launch only a few particles at once, that can be done, as well.
  16662. */
  16663. manualEmitCount: number;
  16664. /**
  16665. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16666. */
  16667. updateSpeed: number;
  16668. /**
  16669. * The amount of time the particle system is running (depends of the overall update speed).
  16670. */
  16671. targetStopDuration: number;
  16672. /**
  16673. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16674. */
  16675. disposeOnStop: boolean;
  16676. /**
  16677. * Minimum power of emitting particles.
  16678. */
  16679. minEmitPower: number;
  16680. /**
  16681. * Maximum power of emitting particles.
  16682. */
  16683. maxEmitPower: number;
  16684. /**
  16685. * Minimum life time of emitting particles.
  16686. */
  16687. minLifeTime: number;
  16688. /**
  16689. * Maximum life time of emitting particles.
  16690. */
  16691. maxLifeTime: number;
  16692. /**
  16693. * Minimum Size of emitting particles.
  16694. */
  16695. minSize: number;
  16696. /**
  16697. * Maximum Size of emitting particles.
  16698. */
  16699. maxSize: number;
  16700. /**
  16701. * Minimum scale of emitting particles on X axis.
  16702. */
  16703. minScaleX: number;
  16704. /**
  16705. * Maximum scale of emitting particles on X axis.
  16706. */
  16707. maxScaleX: number;
  16708. /**
  16709. * Minimum scale of emitting particles on Y axis.
  16710. */
  16711. minScaleY: number;
  16712. /**
  16713. * Maximum scale of emitting particles on Y axis.
  16714. */
  16715. maxScaleY: number;
  16716. /**
  16717. * Gets or sets the minimal initial rotation in radians.
  16718. */
  16719. minInitialRotation: number;
  16720. /**
  16721. * Gets or sets the maximal initial rotation in radians.
  16722. */
  16723. maxInitialRotation: number;
  16724. /**
  16725. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16726. */
  16727. minAngularSpeed: number;
  16728. /**
  16729. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16730. */
  16731. maxAngularSpeed: number;
  16732. /**
  16733. * The texture used to render each particle. (this can be a spritesheet)
  16734. */
  16735. particleTexture: Nullable<Texture>;
  16736. /**
  16737. * The layer mask we are rendering the particles through.
  16738. */
  16739. layerMask: number;
  16740. /**
  16741. * This can help using your own shader to render the particle system.
  16742. * The according effect will be created
  16743. */
  16744. customShader: any;
  16745. /**
  16746. * By default particle system starts as soon as they are created. This prevents the
  16747. * automatic start to happen and let you decide when to start emitting particles.
  16748. */
  16749. preventAutoStart: boolean;
  16750. private _noiseTexture;
  16751. /**
  16752. * Gets or sets a texture used to add random noise to particle positions
  16753. */
  16754. noiseTexture: Nullable<ProceduralTexture>;
  16755. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16756. noiseStrength: Vector3;
  16757. /**
  16758. * Callback triggered when the particle animation is ending.
  16759. */
  16760. onAnimationEnd: Nullable<() => void>;
  16761. /**
  16762. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16763. */
  16764. blendMode: number;
  16765. /**
  16766. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16767. * to override the particles.
  16768. */
  16769. forceDepthWrite: boolean;
  16770. /** Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0 */
  16771. preWarmCycles: number;
  16772. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16773. preWarmStepOffset: number;
  16774. /**
  16775. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  16776. */
  16777. spriteCellChangeSpeed: number;
  16778. /**
  16779. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16780. */
  16781. startSpriteCellID: number;
  16782. /**
  16783. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16784. */
  16785. endSpriteCellID: number;
  16786. /**
  16787. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16788. */
  16789. spriteCellWidth: number;
  16790. /**
  16791. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16792. */
  16793. spriteCellHeight: number;
  16794. /**
  16795. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16796. */
  16797. spriteRandomStartCell: boolean;
  16798. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16799. translationPivot: Vector2;
  16800. /** @hidden */
  16801. protected _isAnimationSheetEnabled: boolean;
  16802. /**
  16803. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16804. */
  16805. beginAnimationOnStart: boolean;
  16806. /**
  16807. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16808. */
  16809. beginAnimationFrom: number;
  16810. /**
  16811. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16812. */
  16813. beginAnimationTo: number;
  16814. /**
  16815. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16816. */
  16817. beginAnimationLoop: boolean;
  16818. /**
  16819. * Gets or sets a world offset applied to all particles
  16820. */
  16821. worldOffset: Vector3;
  16822. /**
  16823. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16824. */
  16825. isAnimationSheetEnabled: boolean;
  16826. /**
  16827. * Get hosting scene
  16828. * @returns the scene
  16829. */
  16830. getScene(): Scene;
  16831. /**
  16832. * You can use gravity if you want to give an orientation to your particles.
  16833. */
  16834. gravity: Vector3;
  16835. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16836. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16837. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16838. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16839. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16840. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16841. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16842. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16843. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16844. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16845. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16846. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16847. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16848. /**
  16849. * Defines the delay in milliseconds before starting the system (0 by default)
  16850. */
  16851. startDelay: number;
  16852. /**
  16853. * Gets the current list of drag gradients.
  16854. * You must use addDragGradient and removeDragGradient to udpate this list
  16855. * @returns the list of drag gradients
  16856. */
  16857. getDragGradients(): Nullable<Array<FactorGradient>>;
  16858. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16859. limitVelocityDamping: number;
  16860. /**
  16861. * Gets the current list of limit velocity gradients.
  16862. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16863. * @returns the list of limit velocity gradients
  16864. */
  16865. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16866. /**
  16867. * Gets the current list of color gradients.
  16868. * You must use addColorGradient and removeColorGradient to udpate this list
  16869. * @returns the list of color gradients
  16870. */
  16871. getColorGradients(): Nullable<Array<ColorGradient>>;
  16872. /**
  16873. * Gets the current list of size gradients.
  16874. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16875. * @returns the list of size gradients
  16876. */
  16877. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16878. /**
  16879. * Gets the current list of color remap gradients.
  16880. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16881. * @returns the list of color remap gradients
  16882. */
  16883. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16884. /**
  16885. * Gets the current list of alpha remap gradients.
  16886. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16887. * @returns the list of alpha remap gradients
  16888. */
  16889. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16890. /**
  16891. * Gets the current list of life time gradients.
  16892. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16893. * @returns the list of life time gradients
  16894. */
  16895. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16896. /**
  16897. * Gets the current list of angular speed gradients.
  16898. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16899. * @returns the list of angular speed gradients
  16900. */
  16901. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16902. /**
  16903. * Gets the current list of velocity gradients.
  16904. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16905. * @returns the list of velocity gradients
  16906. */
  16907. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16908. /**
  16909. * Gets the current list of start size gradients.
  16910. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16911. * @returns the list of start size gradients
  16912. */
  16913. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16914. /**
  16915. * Gets the current list of emit rate gradients.
  16916. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16917. * @returns the list of emit rate gradients
  16918. */
  16919. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16920. /**
  16921. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16922. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16923. */
  16924. direction1: Vector3;
  16925. /**
  16926. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16927. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16928. */
  16929. direction2: Vector3;
  16930. /**
  16931. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  16932. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16933. */
  16934. minEmitBox: Vector3;
  16935. /**
  16936. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  16937. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16938. */
  16939. maxEmitBox: Vector3;
  16940. /**
  16941. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16942. */
  16943. color1: Color4;
  16944. /**
  16945. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16946. */
  16947. color2: Color4;
  16948. /**
  16949. * Color the particle will have at the end of its lifetime
  16950. */
  16951. colorDead: Color4;
  16952. /**
  16953. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16954. */
  16955. textureMask: Color4;
  16956. /**
  16957. * The particle emitter type defines the emitter used by the particle system.
  16958. * It can be for example box, sphere, or cone...
  16959. */
  16960. particleEmitterType: IParticleEmitterType;
  16961. /** @hidden */
  16962. _isSubEmitter: boolean;
  16963. /**
  16964. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16965. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16966. */
  16967. billboardMode: number;
  16968. protected _isBillboardBased: boolean;
  16969. /**
  16970. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16971. */
  16972. isBillboardBased: boolean;
  16973. /**
  16974. * The scene the particle system belongs to.
  16975. */
  16976. protected _scene: Scene;
  16977. /**
  16978. * Local cache of defines for image processing.
  16979. */
  16980. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16981. /**
  16982. * Default configuration related to image processing available in the standard Material.
  16983. */
  16984. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16985. /**
  16986. * Gets the image processing configuration used either in this material.
  16987. */
  16988. /**
  16989. * Sets the Default image processing configuration used either in the this material.
  16990. *
  16991. * If sets to null, the scene one is in use.
  16992. */
  16993. imageProcessingConfiguration: ImageProcessingConfiguration;
  16994. /**
  16995. * Attaches a new image processing configuration to the Standard Material.
  16996. * @param configuration
  16997. */
  16998. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  16999. /** @hidden */
  17000. protected _reset(): void;
  17001. /** @hidden */
  17002. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17003. /**
  17004. * Instantiates a particle system.
  17005. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  17006. * @param name The name of the particle system
  17007. */
  17008. constructor(name: string);
  17009. /**
  17010. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17011. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17012. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17013. * @returns the emitter
  17014. */
  17015. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17016. /**
  17017. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17018. * @param radius The radius of the hemisphere to emit from
  17019. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17020. * @returns the emitter
  17021. */
  17022. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17023. /**
  17024. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17025. * @param radius The radius of the sphere to emit from
  17026. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17027. * @returns the emitter
  17028. */
  17029. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17030. /**
  17031. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17032. * @param radius The radius of the sphere to emit from
  17033. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17034. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17035. * @returns the emitter
  17036. */
  17037. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17038. /**
  17039. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17040. * @param radius The radius of the emission cylinder
  17041. * @param height The height of the emission cylinder
  17042. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17043. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17044. * @returns the emitter
  17045. */
  17046. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17047. /**
  17048. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17049. * @param radius The radius of the cylinder to emit from
  17050. * @param height The height of the emission cylinder
  17051. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17052. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17053. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17054. * @returns the emitter
  17055. */
  17056. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17057. /**
  17058. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17059. * @param radius The radius of the cone to emit from
  17060. * @param angle The base angle of the cone
  17061. * @returns the emitter
  17062. */
  17063. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17064. /**
  17065. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17066. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17067. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17068. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17069. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17070. * @returns the emitter
  17071. */
  17072. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17073. }
  17074. }
  17075. declare module "babylonjs/Particles/subEmitter" {
  17076. import { Scene } from "babylonjs/scene";
  17077. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17078. /**
  17079. * Type of sub emitter
  17080. */
  17081. export enum SubEmitterType {
  17082. /**
  17083. * Attached to the particle over it's lifetime
  17084. */
  17085. ATTACHED = 0,
  17086. /**
  17087. * Created when the particle dies
  17088. */
  17089. END = 1
  17090. }
  17091. /**
  17092. * Sub emitter class used to emit particles from an existing particle
  17093. */
  17094. export class SubEmitter {
  17095. /**
  17096. * the particle system to be used by the sub emitter
  17097. */
  17098. particleSystem: ParticleSystem;
  17099. /**
  17100. * Type of the submitter (Default: END)
  17101. */
  17102. type: SubEmitterType;
  17103. /**
  17104. * If the particle should inherit the direction from the particle it's attached to. (+Y will face the direction the particle is moving) (Default: false)
  17105. * Note: This only is supported when using an emitter of type Mesh
  17106. */
  17107. inheritDirection: boolean;
  17108. /**
  17109. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17110. */
  17111. inheritedVelocityAmount: number;
  17112. /**
  17113. * Creates a sub emitter
  17114. * @param particleSystem the particle system to be used by the sub emitter
  17115. */
  17116. constructor(
  17117. /**
  17118. * the particle system to be used by the sub emitter
  17119. */
  17120. particleSystem: ParticleSystem);
  17121. /**
  17122. * Clones the sub emitter
  17123. * @returns the cloned sub emitter
  17124. */
  17125. clone(): SubEmitter;
  17126. /**
  17127. * Serialize current object to a JSON object
  17128. * @returns the serialized object
  17129. */
  17130. serialize(): any;
  17131. /** @hidden */
  17132. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17133. /**
  17134. * Creates a new SubEmitter from a serialized JSON version
  17135. * @param serializationObject defines the JSON object to read from
  17136. * @param scene defines the hosting scene
  17137. * @param rootUrl defines the rootUrl for data loading
  17138. * @returns a new SubEmitter
  17139. */
  17140. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17141. /** Release associated resources */
  17142. dispose(): void;
  17143. }
  17144. }
  17145. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17146. /** @hidden */
  17147. export var clipPlaneFragmentDeclaration: {
  17148. name: string;
  17149. shader: string;
  17150. };
  17151. }
  17152. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17153. /** @hidden */
  17154. export var imageProcessingDeclaration: {
  17155. name: string;
  17156. shader: string;
  17157. };
  17158. }
  17159. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17160. /** @hidden */
  17161. export var imageProcessingFunctions: {
  17162. name: string;
  17163. shader: string;
  17164. };
  17165. }
  17166. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17167. /** @hidden */
  17168. export var clipPlaneFragment: {
  17169. name: string;
  17170. shader: string;
  17171. };
  17172. }
  17173. declare module "babylonjs/Shaders/particles.fragment" {
  17174. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17175. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17176. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17177. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17178. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17179. /** @hidden */
  17180. export var particlesPixelShader: {
  17181. name: string;
  17182. shader: string;
  17183. };
  17184. }
  17185. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17186. /** @hidden */
  17187. export var clipPlaneVertexDeclaration: {
  17188. name: string;
  17189. shader: string;
  17190. };
  17191. }
  17192. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17193. /** @hidden */
  17194. export var clipPlaneVertex: {
  17195. name: string;
  17196. shader: string;
  17197. };
  17198. }
  17199. declare module "babylonjs/Shaders/particles.vertex" {
  17200. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17201. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17202. /** @hidden */
  17203. export var particlesVertexShader: {
  17204. name: string;
  17205. shader: string;
  17206. };
  17207. }
  17208. declare module "babylonjs/Particles/particleSystem" {
  17209. import { Nullable } from "babylonjs/types";
  17210. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17211. import { Observable } from "babylonjs/Misc/observable";
  17212. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17213. import { Effect } from "babylonjs/Materials/effect";
  17214. import { Scene, IDisposable } from "babylonjs/scene";
  17215. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17216. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17217. import { Particle } from "babylonjs/Particles/particle";
  17218. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17219. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17220. import "babylonjs/Shaders/particles.fragment";
  17221. import "babylonjs/Shaders/particles.vertex";
  17222. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17223. /**
  17224. * This represents a particle system in Babylon.
  17225. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  17226. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17227. * @example https://doc.babylonjs.com/babylon101/particles
  17228. */
  17229. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17230. /**
  17231. * Billboard mode will only apply to Y axis
  17232. */
  17233. static readonly BILLBOARDMODE_Y: number;
  17234. /**
  17235. * Billboard mode will apply to all axes
  17236. */
  17237. static readonly BILLBOARDMODE_ALL: number;
  17238. /**
  17239. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17240. */
  17241. static readonly BILLBOARDMODE_STRETCHED: number;
  17242. /**
  17243. * This function can be defined to provide custom update for active particles.
  17244. * This function will be called instead of regular update (age, position, color, etc.).
  17245. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17246. */
  17247. updateFunction: (particles: Particle[]) => void;
  17248. private _emitterWorldMatrix;
  17249. /**
  17250. * This function can be defined to specify initial direction for every new particle.
  17251. * It by default use the emitterType defined function
  17252. */
  17253. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17254. /**
  17255. * This function can be defined to specify initial position for every new particle.
  17256. * It by default use the emitterType defined function
  17257. */
  17258. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17259. /**
  17260. * @hidden
  17261. */
  17262. _inheritedVelocityOffset: Vector3;
  17263. /**
  17264. * An event triggered when the system is disposed
  17265. */
  17266. onDisposeObservable: Observable<ParticleSystem>;
  17267. private _onDisposeObserver;
  17268. /**
  17269. * Sets a callback that will be triggered when the system is disposed
  17270. */
  17271. onDispose: () => void;
  17272. private _particles;
  17273. private _epsilon;
  17274. private _capacity;
  17275. private _stockParticles;
  17276. private _newPartsExcess;
  17277. private _vertexData;
  17278. private _vertexBuffer;
  17279. private _vertexBuffers;
  17280. private _spriteBuffer;
  17281. private _indexBuffer;
  17282. private _effect;
  17283. private _customEffect;
  17284. private _cachedDefines;
  17285. private _scaledColorStep;
  17286. private _colorDiff;
  17287. private _scaledDirection;
  17288. private _scaledGravity;
  17289. private _currentRenderId;
  17290. private _alive;
  17291. private _useInstancing;
  17292. private _started;
  17293. private _stopped;
  17294. private _actualFrame;
  17295. private _scaledUpdateSpeed;
  17296. private _vertexBufferSize;
  17297. /** @hidden */
  17298. _currentEmitRateGradient: Nullable<FactorGradient>;
  17299. /** @hidden */
  17300. _currentEmitRate1: number;
  17301. /** @hidden */
  17302. _currentEmitRate2: number;
  17303. /** @hidden */
  17304. _currentStartSizeGradient: Nullable<FactorGradient>;
  17305. /** @hidden */
  17306. _currentStartSize1: number;
  17307. /** @hidden */
  17308. _currentStartSize2: number;
  17309. private readonly _rawTextureWidth;
  17310. private _rampGradientsTexture;
  17311. private _useRampGradients;
  17312. /** Gets or sets a boolean indicating that ramp gradients must be used
  17313. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17314. */
  17315. useRampGradients: boolean;
  17316. /**
  17317. * The Sub-emitters templates that will be used to generate the sub particle system to be associated with the system, this property is used by the root particle system only.
  17318. * When a particle is spawned, an array will be chosen at random and all the emitters in that array will be attached to the particle. (Default: [])
  17319. */
  17320. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17321. private _subEmitters;
  17322. /**
  17323. * @hidden
  17324. * If the particle systems emitter should be disposed when the particle system is disposed
  17325. */
  17326. _disposeEmitterOnDispose: boolean;
  17327. /**
  17328. * The current active Sub-systems, this property is used by the root particle system only.
  17329. */
  17330. activeSubSystems: Array<ParticleSystem>;
  17331. private _rootParticleSystem;
  17332. /**
  17333. * Gets the current list of active particles
  17334. */
  17335. readonly particles: Particle[];
  17336. /**
  17337. * Returns the string "ParticleSystem"
  17338. * @returns a string containing the class name
  17339. */
  17340. getClassName(): string;
  17341. /**
  17342. * Instantiates a particle system.
  17343. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  17344. * @param name The name of the particle system
  17345. * @param capacity The max number of particles alive at the same time
  17346. * @param scene The scene the particle system belongs to
  17347. * @param customEffect a custom effect used to change the way particles are rendered by default
  17348. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17349. * @param epsilon Offset used to render the particles
  17350. */
  17351. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17352. private _addFactorGradient;
  17353. private _removeFactorGradient;
  17354. /**
  17355. * Adds a new life time gradient
  17356. * @param gradient defines the gradient to use (between 0 and 1)
  17357. * @param factor defines the life time factor to affect to the specified gradient
  17358. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17359. * @returns the current particle system
  17360. */
  17361. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17362. /**
  17363. * Remove a specific life time gradient
  17364. * @param gradient defines the gradient to remove
  17365. * @returns the current particle system
  17366. */
  17367. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17368. /**
  17369. * Adds a new size gradient
  17370. * @param gradient defines the gradient to use (between 0 and 1)
  17371. * @param factor defines the size factor to affect to the specified gradient
  17372. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17373. * @returns the current particle system
  17374. */
  17375. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17376. /**
  17377. * Remove a specific size gradient
  17378. * @param gradient defines the gradient to remove
  17379. * @returns the current particle system
  17380. */
  17381. removeSizeGradient(gradient: number): IParticleSystem;
  17382. /**
  17383. * Adds a new color remap gradient
  17384. * @param gradient defines the gradient to use (between 0 and 1)
  17385. * @param min defines the color remap minimal range
  17386. * @param max defines the color remap maximal range
  17387. * @returns the current particle system
  17388. */
  17389. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17390. /**
  17391. * Remove a specific color remap gradient
  17392. * @param gradient defines the gradient to remove
  17393. * @returns the current particle system
  17394. */
  17395. removeColorRemapGradient(gradient: number): IParticleSystem;
  17396. /**
  17397. * Adds a new alpha remap gradient
  17398. * @param gradient defines the gradient to use (between 0 and 1)
  17399. * @param min defines the alpha remap minimal range
  17400. * @param max defines the alpha remap maximal range
  17401. * @returns the current particle system
  17402. */
  17403. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17404. /**
  17405. * Remove a specific alpha remap gradient
  17406. * @param gradient defines the gradient to remove
  17407. * @returns the current particle system
  17408. */
  17409. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17410. /**
  17411. * Adds a new angular speed gradient
  17412. * @param gradient defines the gradient to use (between 0 and 1)
  17413. * @param factor defines the angular speed to affect to the specified gradient
  17414. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17415. * @returns the current particle system
  17416. */
  17417. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17418. /**
  17419. * Remove a specific angular speed gradient
  17420. * @param gradient defines the gradient to remove
  17421. * @returns the current particle system
  17422. */
  17423. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17424. /**
  17425. * Adds a new velocity gradient
  17426. * @param gradient defines the gradient to use (between 0 and 1)
  17427. * @param factor defines the velocity to affect to the specified gradient
  17428. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17429. * @returns the current particle system
  17430. */
  17431. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17432. /**
  17433. * Remove a specific velocity gradient
  17434. * @param gradient defines the gradient to remove
  17435. * @returns the current particle system
  17436. */
  17437. removeVelocityGradient(gradient: number): IParticleSystem;
  17438. /**
  17439. * Adds a new limit velocity gradient
  17440. * @param gradient defines the gradient to use (between 0 and 1)
  17441. * @param factor defines the limit velocity value to affect to the specified gradient
  17442. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17443. * @returns the current particle system
  17444. */
  17445. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17446. /**
  17447. * Remove a specific limit velocity gradient
  17448. * @param gradient defines the gradient to remove
  17449. * @returns the current particle system
  17450. */
  17451. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17452. /**
  17453. * Adds a new drag gradient
  17454. * @param gradient defines the gradient to use (between 0 and 1)
  17455. * @param factor defines the drag value to affect to the specified gradient
  17456. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17457. * @returns the current particle system
  17458. */
  17459. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17460. /**
  17461. * Remove a specific drag gradient
  17462. * @param gradient defines the gradient to remove
  17463. * @returns the current particle system
  17464. */
  17465. removeDragGradient(gradient: number): IParticleSystem;
  17466. /**
  17467. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17468. * @param gradient defines the gradient to use (between 0 and 1)
  17469. * @param factor defines the emit rate value to affect to the specified gradient
  17470. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17471. * @returns the current particle system
  17472. */
  17473. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17474. /**
  17475. * Remove a specific emit rate gradient
  17476. * @param gradient defines the gradient to remove
  17477. * @returns the current particle system
  17478. */
  17479. removeEmitRateGradient(gradient: number): IParticleSystem;
  17480. /**
  17481. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17482. * @param gradient defines the gradient to use (between 0 and 1)
  17483. * @param factor defines the start size value to affect to the specified gradient
  17484. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17485. * @returns the current particle system
  17486. */
  17487. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17488. /**
  17489. * Remove a specific start size gradient
  17490. * @param gradient defines the gradient to remove
  17491. * @returns the current particle system
  17492. */
  17493. removeStartSizeGradient(gradient: number): IParticleSystem;
  17494. private _createRampGradientTexture;
  17495. /**
  17496. * Gets the current list of ramp gradients.
  17497. * You must use addRampGradient and removeRampGradient to udpate this list
  17498. * @returns the list of ramp gradients
  17499. */
  17500. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17501. /**
  17502. * Adds a new ramp gradient used to remap particle colors
  17503. * @param gradient defines the gradient to use (between 0 and 1)
  17504. * @param color defines the color to affect to the specified gradient
  17505. * @returns the current particle system
  17506. */
  17507. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17508. /**
  17509. * Remove a specific ramp gradient
  17510. * @param gradient defines the gradient to remove
  17511. * @returns the current particle system
  17512. */
  17513. removeRampGradient(gradient: number): ParticleSystem;
  17514. /**
  17515. * Adds a new color gradient
  17516. * @param gradient defines the gradient to use (between 0 and 1)
  17517. * @param color1 defines the color to affect to the specified gradient
  17518. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17519. * @returns this particle system
  17520. */
  17521. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17522. /**
  17523. * Remove a specific color gradient
  17524. * @param gradient defines the gradient to remove
  17525. * @returns this particle system
  17526. */
  17527. removeColorGradient(gradient: number): IParticleSystem;
  17528. private _fetchR;
  17529. protected _reset(): void;
  17530. private _resetEffect;
  17531. private _createVertexBuffers;
  17532. private _createIndexBuffer;
  17533. /**
  17534. * Gets the maximum number of particles active at the same time.
  17535. * @returns The max number of active particles.
  17536. */
  17537. getCapacity(): number;
  17538. /**
  17539. * Gets whether there are still active particles in the system.
  17540. * @returns True if it is alive, otherwise false.
  17541. */
  17542. isAlive(): boolean;
  17543. /**
  17544. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17545. * @returns True if it has been started, otherwise false.
  17546. */
  17547. isStarted(): boolean;
  17548. private _prepareSubEmitterInternalArray;
  17549. /**
  17550. * Starts the particle system and begins to emit
  17551. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17552. */
  17553. start(delay?: number): void;
  17554. /**
  17555. * Stops the particle system.
  17556. * @param stopSubEmitters if true it will stop the current system and all created sub-Systems if false it will stop the current root system only, this param is used by the root particle system only. the default value is true.
  17557. */
  17558. stop(stopSubEmitters?: boolean): void;
  17559. /**
  17560. * Remove all active particles
  17561. */
  17562. reset(): void;
  17563. /**
  17564. * @hidden (for internal use only)
  17565. */
  17566. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17567. /**
  17568. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17569. * Its lifetime will start back at 0.
  17570. */
  17571. recycleParticle: (particle: Particle) => void;
  17572. private _stopSubEmitters;
  17573. private _createParticle;
  17574. private _removeFromRoot;
  17575. private _emitFromParticle;
  17576. private _update;
  17577. /** @hidden */
  17578. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17579. /** @hidden */
  17580. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17581. /** @hidden */
  17582. private _getEffect;
  17583. /**
  17584. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17585. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17586. */
  17587. animate(preWarmOnly?: boolean): void;
  17588. private _appendParticleVertices;
  17589. /**
  17590. * Rebuilds the particle system.
  17591. */
  17592. rebuild(): void;
  17593. /**
  17594. * Is this system ready to be used/rendered
  17595. * @return true if the system is ready
  17596. */
  17597. isReady(): boolean;
  17598. private _render;
  17599. /**
  17600. * Renders the particle system in its current state.
  17601. * @returns the current number of particles
  17602. */
  17603. render(): number;
  17604. /**
  17605. * Disposes the particle system and free the associated resources
  17606. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17607. */
  17608. dispose(disposeTexture?: boolean): void;
  17609. /**
  17610. * Clones the particle system.
  17611. * @param name The name of the cloned object
  17612. * @param newEmitter The new emitter to use
  17613. * @returns the cloned particle system
  17614. */
  17615. clone(name: string, newEmitter: any): ParticleSystem;
  17616. /**
  17617. * Serializes the particle system to a JSON object.
  17618. * @returns the JSON object
  17619. */
  17620. serialize(): any;
  17621. /** @hidden */
  17622. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17623. /** @hidden */
  17624. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17625. /**
  17626. * Parses a JSON object to create a particle system.
  17627. * @param parsedParticleSystem The JSON object to parse
  17628. * @param scene The scene to create the particle system in
  17629. * @param rootUrl The root url to use to load external dependencies like texture
  17630. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17631. * @returns the Parsed particle system
  17632. */
  17633. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17634. }
  17635. }
  17636. declare module "babylonjs/Particles/particle" {
  17637. import { Nullable } from "babylonjs/types";
  17638. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  17639. import { Color4 } from "babylonjs/Maths/math.color";
  17640. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17641. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17642. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  17643. /**
  17644. * A particle represents one of the element emitted by a particle system.
  17645. * This is mainly define by its coordinates, direction, velocity and age.
  17646. */
  17647. export class Particle {
  17648. /**
  17649. * The particle system the particle belongs to.
  17650. */
  17651. particleSystem: ParticleSystem;
  17652. private static _Count;
  17653. /**
  17654. * Unique ID of the particle
  17655. */
  17656. id: number;
  17657. /**
  17658. * The world position of the particle in the scene.
  17659. */
  17660. position: Vector3;
  17661. /**
  17662. * The world direction of the particle in the scene.
  17663. */
  17664. direction: Vector3;
  17665. /**
  17666. * The color of the particle.
  17667. */
  17668. color: Color4;
  17669. /**
  17670. * The color change of the particle per step.
  17671. */
  17672. colorStep: Color4;
  17673. /**
  17674. * Defines how long will the life of the particle be.
  17675. */
  17676. lifeTime: number;
  17677. /**
  17678. * The current age of the particle.
  17679. */
  17680. age: number;
  17681. /**
  17682. * The current size of the particle.
  17683. */
  17684. size: number;
  17685. /**
  17686. * The current scale of the particle.
  17687. */
  17688. scale: Vector2;
  17689. /**
  17690. * The current angle of the particle.
  17691. */
  17692. angle: number;
  17693. /**
  17694. * Defines how fast is the angle changing.
  17695. */
  17696. angularSpeed: number;
  17697. /**
  17698. * Defines the cell index used by the particle to be rendered from a sprite.
  17699. */
  17700. cellIndex: number;
  17701. /**
  17702. * The information required to support color remapping
  17703. */
  17704. remapData: Vector4;
  17705. /** @hidden */
  17706. _randomCellOffset?: number;
  17707. /** @hidden */
  17708. _initialDirection: Nullable<Vector3>;
  17709. /** @hidden */
  17710. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17711. /** @hidden */
  17712. _initialStartSpriteCellID: number;
  17713. /** @hidden */
  17714. _initialEndSpriteCellID: number;
  17715. /** @hidden */
  17716. _currentColorGradient: Nullable<ColorGradient>;
  17717. /** @hidden */
  17718. _currentColor1: Color4;
  17719. /** @hidden */
  17720. _currentColor2: Color4;
  17721. /** @hidden */
  17722. _currentSizeGradient: Nullable<FactorGradient>;
  17723. /** @hidden */
  17724. _currentSize1: number;
  17725. /** @hidden */
  17726. _currentSize2: number;
  17727. /** @hidden */
  17728. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17729. /** @hidden */
  17730. _currentAngularSpeed1: number;
  17731. /** @hidden */
  17732. _currentAngularSpeed2: number;
  17733. /** @hidden */
  17734. _currentVelocityGradient: Nullable<FactorGradient>;
  17735. /** @hidden */
  17736. _currentVelocity1: number;
  17737. /** @hidden */
  17738. _currentVelocity2: number;
  17739. /** @hidden */
  17740. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17741. /** @hidden */
  17742. _currentLimitVelocity1: number;
  17743. /** @hidden */
  17744. _currentLimitVelocity2: number;
  17745. /** @hidden */
  17746. _currentDragGradient: Nullable<FactorGradient>;
  17747. /** @hidden */
  17748. _currentDrag1: number;
  17749. /** @hidden */
  17750. _currentDrag2: number;
  17751. /** @hidden */
  17752. _randomNoiseCoordinates1: Vector3;
  17753. /** @hidden */
  17754. _randomNoiseCoordinates2: Vector3;
  17755. /**
  17756. * Creates a new instance Particle
  17757. * @param particleSystem the particle system the particle belongs to
  17758. */
  17759. constructor(
  17760. /**
  17761. * The particle system the particle belongs to.
  17762. */
  17763. particleSystem: ParticleSystem);
  17764. private updateCellInfoFromSystem;
  17765. /**
  17766. * Defines how the sprite cell index is updated for the particle
  17767. */
  17768. updateCellIndex(): void;
  17769. /** @hidden */
  17770. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17771. /** @hidden */
  17772. _inheritParticleInfoToSubEmitters(): void;
  17773. /** @hidden */
  17774. _reset(): void;
  17775. /**
  17776. * Copy the properties of particle to another one.
  17777. * @param other the particle to copy the information to.
  17778. */
  17779. copyTo(other: Particle): void;
  17780. }
  17781. }
  17782. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  17783. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17784. import { Effect } from "babylonjs/Materials/effect";
  17785. import { Particle } from "babylonjs/Particles/particle";
  17786. /**
  17787. * Particle emitter represents a volume emitting particles.
  17788. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17789. */
  17790. export interface IParticleEmitterType {
  17791. /**
  17792. * Called by the particle System when the direction is computed for the created particle.
  17793. * @param worldMatrix is the world matrix of the particle system
  17794. * @param directionToUpdate is the direction vector to update with the result
  17795. * @param particle is the particle we are computed the direction for
  17796. */
  17797. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17798. /**
  17799. * Called by the particle System when the position is computed for the created particle.
  17800. * @param worldMatrix is the world matrix of the particle system
  17801. * @param positionToUpdate is the position vector to update with the result
  17802. * @param particle is the particle we are computed the position for
  17803. */
  17804. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17805. /**
  17806. * Clones the current emitter and returns a copy of it
  17807. * @returns the new emitter
  17808. */
  17809. clone(): IParticleEmitterType;
  17810. /**
  17811. * Called by the GPUParticleSystem to setup the update shader
  17812. * @param effect defines the update shader
  17813. */
  17814. applyToShader(effect: Effect): void;
  17815. /**
  17816. * Returns a string to use to update the GPU particles update shader
  17817. * @returns the effect defines string
  17818. */
  17819. getEffectDefines(): string;
  17820. /**
  17821. * Returns a string representing the class name
  17822. * @returns a string containing the class name
  17823. */
  17824. getClassName(): string;
  17825. /**
  17826. * Serializes the particle system to a JSON object.
  17827. * @returns the JSON object
  17828. */
  17829. serialize(): any;
  17830. /**
  17831. * Parse properties from a JSON object
  17832. * @param serializationObject defines the JSON object
  17833. */
  17834. parse(serializationObject: any): void;
  17835. }
  17836. }
  17837. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  17838. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17839. import { Effect } from "babylonjs/Materials/effect";
  17840. import { Particle } from "babylonjs/Particles/particle";
  17841. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17842. /**
  17843. * Particle emitter emitting particles from the inside of a box.
  17844. * It emits the particles randomly between 2 given directions.
  17845. */
  17846. export class BoxParticleEmitter implements IParticleEmitterType {
  17847. /**
  17848. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17849. */
  17850. direction1: Vector3;
  17851. /**
  17852. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17853. */
  17854. direction2: Vector3;
  17855. /**
  17856. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  17857. */
  17858. minEmitBox: Vector3;
  17859. /**
  17860. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  17861. */
  17862. maxEmitBox: Vector3;
  17863. /**
  17864. * Creates a new instance BoxParticleEmitter
  17865. */
  17866. constructor();
  17867. /**
  17868. * Called by the particle System when the direction is computed for the created particle.
  17869. * @param worldMatrix is the world matrix of the particle system
  17870. * @param directionToUpdate is the direction vector to update with the result
  17871. * @param particle is the particle we are computed the direction for
  17872. */
  17873. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17874. /**
  17875. * Called by the particle System when the position is computed for the created particle.
  17876. * @param worldMatrix is the world matrix of the particle system
  17877. * @param positionToUpdate is the position vector to update with the result
  17878. * @param particle is the particle we are computed the position for
  17879. */
  17880. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17881. /**
  17882. * Clones the current emitter and returns a copy of it
  17883. * @returns the new emitter
  17884. */
  17885. clone(): BoxParticleEmitter;
  17886. /**
  17887. * Called by the GPUParticleSystem to setup the update shader
  17888. * @param effect defines the update shader
  17889. */
  17890. applyToShader(effect: Effect): void;
  17891. /**
  17892. * Returns a string to use to update the GPU particles update shader
  17893. * @returns a string containng the defines string
  17894. */
  17895. getEffectDefines(): string;
  17896. /**
  17897. * Returns the string "BoxParticleEmitter"
  17898. * @returns a string containing the class name
  17899. */
  17900. getClassName(): string;
  17901. /**
  17902. * Serializes the particle system to a JSON object.
  17903. * @returns the JSON object
  17904. */
  17905. serialize(): any;
  17906. /**
  17907. * Parse properties from a JSON object
  17908. * @param serializationObject defines the JSON object
  17909. */
  17910. parse(serializationObject: any): void;
  17911. }
  17912. }
  17913. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  17914. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17915. import { Effect } from "babylonjs/Materials/effect";
  17916. import { Particle } from "babylonjs/Particles/particle";
  17917. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17918. /**
  17919. * Particle emitter emitting particles from the inside of a cone.
  17920. * It emits the particles alongside the cone volume from the base to the particle.
  17921. * The emission direction might be randomized.
  17922. */
  17923. export class ConeParticleEmitter implements IParticleEmitterType {
  17924. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17925. directionRandomizer: number;
  17926. private _radius;
  17927. private _angle;
  17928. private _height;
  17929. /**
  17930. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17931. */
  17932. radiusRange: number;
  17933. /**
  17934. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17935. */
  17936. heightRange: number;
  17937. /**
  17938. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17939. */
  17940. emitFromSpawnPointOnly: boolean;
  17941. /**
  17942. * Gets or sets the radius of the emission cone
  17943. */
  17944. radius: number;
  17945. /**
  17946. * Gets or sets the angle of the emission cone
  17947. */
  17948. angle: number;
  17949. private _buildHeight;
  17950. /**
  17951. * Creates a new instance ConeParticleEmitter
  17952. * @param radius the radius of the emission cone (1 by default)
  17953. * @param angle the cone base angle (PI by default)
  17954. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17955. */
  17956. constructor(radius?: number, angle?: number,
  17957. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17958. directionRandomizer?: number);
  17959. /**
  17960. * Called by the particle System when the direction is computed for the created particle.
  17961. * @param worldMatrix is the world matrix of the particle system
  17962. * @param directionToUpdate is the direction vector to update with the result
  17963. * @param particle is the particle we are computed the direction for
  17964. */
  17965. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17966. /**
  17967. * Called by the particle System when the position is computed for the created particle.
  17968. * @param worldMatrix is the world matrix of the particle system
  17969. * @param positionToUpdate is the position vector to update with the result
  17970. * @param particle is the particle we are computed the position for
  17971. */
  17972. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17973. /**
  17974. * Clones the current emitter and returns a copy of it
  17975. * @returns the new emitter
  17976. */
  17977. clone(): ConeParticleEmitter;
  17978. /**
  17979. * Called by the GPUParticleSystem to setup the update shader
  17980. * @param effect defines the update shader
  17981. */
  17982. applyToShader(effect: Effect): void;
  17983. /**
  17984. * Returns a string to use to update the GPU particles update shader
  17985. * @returns a string containng the defines string
  17986. */
  17987. getEffectDefines(): string;
  17988. /**
  17989. * Returns the string "ConeParticleEmitter"
  17990. * @returns a string containing the class name
  17991. */
  17992. getClassName(): string;
  17993. /**
  17994. * Serializes the particle system to a JSON object.
  17995. * @returns the JSON object
  17996. */
  17997. serialize(): any;
  17998. /**
  17999. * Parse properties from a JSON object
  18000. * @param serializationObject defines the JSON object
  18001. */
  18002. parse(serializationObject: any): void;
  18003. }
  18004. }
  18005. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18006. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18007. import { Effect } from "babylonjs/Materials/effect";
  18008. import { Particle } from "babylonjs/Particles/particle";
  18009. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18010. /**
  18011. * Particle emitter emitting particles from the inside of a cylinder.
  18012. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18013. */
  18014. export class CylinderParticleEmitter implements IParticleEmitterType {
  18015. /**
  18016. * The radius of the emission cylinder.
  18017. */
  18018. radius: number;
  18019. /**
  18020. * The height of the emission cylinder.
  18021. */
  18022. height: number;
  18023. /**
  18024. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18025. */
  18026. radiusRange: number;
  18027. /**
  18028. * How much to randomize the particle direction [0-1].
  18029. */
  18030. directionRandomizer: number;
  18031. /**
  18032. * Creates a new instance CylinderParticleEmitter
  18033. * @param radius the radius of the emission cylinder (1 by default)
  18034. * @param height the height of the emission cylinder (1 by default)
  18035. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18036. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18037. */
  18038. constructor(
  18039. /**
  18040. * The radius of the emission cylinder.
  18041. */
  18042. radius?: number,
  18043. /**
  18044. * The height of the emission cylinder.
  18045. */
  18046. height?: number,
  18047. /**
  18048. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18049. */
  18050. radiusRange?: number,
  18051. /**
  18052. * How much to randomize the particle direction [0-1].
  18053. */
  18054. directionRandomizer?: number);
  18055. /**
  18056. * Called by the particle System when the direction is computed for the created particle.
  18057. * @param worldMatrix is the world matrix of the particle system
  18058. * @param directionToUpdate is the direction vector to update with the result
  18059. * @param particle is the particle we are computed the direction for
  18060. */
  18061. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18062. /**
  18063. * Called by the particle System when the position is computed for the created particle.
  18064. * @param worldMatrix is the world matrix of the particle system
  18065. * @param positionToUpdate is the position vector to update with the result
  18066. * @param particle is the particle we are computed the position for
  18067. */
  18068. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18069. /**
  18070. * Clones the current emitter and returns a copy of it
  18071. * @returns the new emitter
  18072. */
  18073. clone(): CylinderParticleEmitter;
  18074. /**
  18075. * Called by the GPUParticleSystem to setup the update shader
  18076. * @param effect defines the update shader
  18077. */
  18078. applyToShader(effect: Effect): void;
  18079. /**
  18080. * Returns a string to use to update the GPU particles update shader
  18081. * @returns a string containng the defines string
  18082. */
  18083. getEffectDefines(): string;
  18084. /**
  18085. * Returns the string "CylinderParticleEmitter"
  18086. * @returns a string containing the class name
  18087. */
  18088. getClassName(): string;
  18089. /**
  18090. * Serializes the particle system to a JSON object.
  18091. * @returns the JSON object
  18092. */
  18093. serialize(): any;
  18094. /**
  18095. * Parse properties from a JSON object
  18096. * @param serializationObject defines the JSON object
  18097. */
  18098. parse(serializationObject: any): void;
  18099. }
  18100. /**
  18101. * Particle emitter emitting particles from the inside of a cylinder.
  18102. * It emits the particles randomly between two vectors.
  18103. */
  18104. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18105. /**
  18106. * The min limit of the emission direction.
  18107. */
  18108. direction1: Vector3;
  18109. /**
  18110. * The max limit of the emission direction.
  18111. */
  18112. direction2: Vector3;
  18113. /**
  18114. * Creates a new instance CylinderDirectedParticleEmitter
  18115. * @param radius the radius of the emission cylinder (1 by default)
  18116. * @param height the height of the emission cylinder (1 by default)
  18117. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18118. * @param direction1 the min limit of the emission direction (up vector by default)
  18119. * @param direction2 the max limit of the emission direction (up vector by default)
  18120. */
  18121. constructor(radius?: number, height?: number, radiusRange?: number,
  18122. /**
  18123. * The min limit of the emission direction.
  18124. */
  18125. direction1?: Vector3,
  18126. /**
  18127. * The max limit of the emission direction.
  18128. */
  18129. direction2?: Vector3);
  18130. /**
  18131. * Called by the particle System when the direction is computed for the created particle.
  18132. * @param worldMatrix is the world matrix of the particle system
  18133. * @param directionToUpdate is the direction vector to update with the result
  18134. * @param particle is the particle we are computed the direction for
  18135. */
  18136. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18137. /**
  18138. * Clones the current emitter and returns a copy of it
  18139. * @returns the new emitter
  18140. */
  18141. clone(): CylinderDirectedParticleEmitter;
  18142. /**
  18143. * Called by the GPUParticleSystem to setup the update shader
  18144. * @param effect defines the update shader
  18145. */
  18146. applyToShader(effect: Effect): void;
  18147. /**
  18148. * Returns a string to use to update the GPU particles update shader
  18149. * @returns a string containng the defines string
  18150. */
  18151. getEffectDefines(): string;
  18152. /**
  18153. * Returns the string "CylinderDirectedParticleEmitter"
  18154. * @returns a string containing the class name
  18155. */
  18156. getClassName(): string;
  18157. /**
  18158. * Serializes the particle system to a JSON object.
  18159. * @returns the JSON object
  18160. */
  18161. serialize(): any;
  18162. /**
  18163. * Parse properties from a JSON object
  18164. * @param serializationObject defines the JSON object
  18165. */
  18166. parse(serializationObject: any): void;
  18167. }
  18168. }
  18169. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18170. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18171. import { Effect } from "babylonjs/Materials/effect";
  18172. import { Particle } from "babylonjs/Particles/particle";
  18173. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18174. /**
  18175. * Particle emitter emitting particles from the inside of a hemisphere.
  18176. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18177. */
  18178. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18179. /**
  18180. * The radius of the emission hemisphere.
  18181. */
  18182. radius: number;
  18183. /**
  18184. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18185. */
  18186. radiusRange: number;
  18187. /**
  18188. * How much to randomize the particle direction [0-1].
  18189. */
  18190. directionRandomizer: number;
  18191. /**
  18192. * Creates a new instance HemisphericParticleEmitter
  18193. * @param radius the radius of the emission hemisphere (1 by default)
  18194. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18195. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18196. */
  18197. constructor(
  18198. /**
  18199. * The radius of the emission hemisphere.
  18200. */
  18201. radius?: number,
  18202. /**
  18203. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18204. */
  18205. radiusRange?: number,
  18206. /**
  18207. * How much to randomize the particle direction [0-1].
  18208. */
  18209. directionRandomizer?: number);
  18210. /**
  18211. * Called by the particle System when the direction is computed for the created particle.
  18212. * @param worldMatrix is the world matrix of the particle system
  18213. * @param directionToUpdate is the direction vector to update with the result
  18214. * @param particle is the particle we are computed the direction for
  18215. */
  18216. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18217. /**
  18218. * Called by the particle System when the position is computed for the created particle.
  18219. * @param worldMatrix is the world matrix of the particle system
  18220. * @param positionToUpdate is the position vector to update with the result
  18221. * @param particle is the particle we are computed the position for
  18222. */
  18223. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18224. /**
  18225. * Clones the current emitter and returns a copy of it
  18226. * @returns the new emitter
  18227. */
  18228. clone(): HemisphericParticleEmitter;
  18229. /**
  18230. * Called by the GPUParticleSystem to setup the update shader
  18231. * @param effect defines the update shader
  18232. */
  18233. applyToShader(effect: Effect): void;
  18234. /**
  18235. * Returns a string to use to update the GPU particles update shader
  18236. * @returns a string containng the defines string
  18237. */
  18238. getEffectDefines(): string;
  18239. /**
  18240. * Returns the string "HemisphericParticleEmitter"
  18241. * @returns a string containing the class name
  18242. */
  18243. getClassName(): string;
  18244. /**
  18245. * Serializes the particle system to a JSON object.
  18246. * @returns the JSON object
  18247. */
  18248. serialize(): any;
  18249. /**
  18250. * Parse properties from a JSON object
  18251. * @param serializationObject defines the JSON object
  18252. */
  18253. parse(serializationObject: any): void;
  18254. }
  18255. }
  18256. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18257. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18258. import { Effect } from "babylonjs/Materials/effect";
  18259. import { Particle } from "babylonjs/Particles/particle";
  18260. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18261. /**
  18262. * Particle emitter emitting particles from a point.
  18263. * It emits the particles randomly between 2 given directions.
  18264. */
  18265. export class PointParticleEmitter implements IParticleEmitterType {
  18266. /**
  18267. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18268. */
  18269. direction1: Vector3;
  18270. /**
  18271. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18272. */
  18273. direction2: Vector3;
  18274. /**
  18275. * Creates a new instance PointParticleEmitter
  18276. */
  18277. constructor();
  18278. /**
  18279. * Called by the particle System when the direction is computed for the created particle.
  18280. * @param worldMatrix is the world matrix of the particle system
  18281. * @param directionToUpdate is the direction vector to update with the result
  18282. * @param particle is the particle we are computed the direction for
  18283. */
  18284. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18285. /**
  18286. * Called by the particle System when the position is computed for the created particle.
  18287. * @param worldMatrix is the world matrix of the particle system
  18288. * @param positionToUpdate is the position vector to update with the result
  18289. * @param particle is the particle we are computed the position for
  18290. */
  18291. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18292. /**
  18293. * Clones the current emitter and returns a copy of it
  18294. * @returns the new emitter
  18295. */
  18296. clone(): PointParticleEmitter;
  18297. /**
  18298. * Called by the GPUParticleSystem to setup the update shader
  18299. * @param effect defines the update shader
  18300. */
  18301. applyToShader(effect: Effect): void;
  18302. /**
  18303. * Returns a string to use to update the GPU particles update shader
  18304. * @returns a string containng the defines string
  18305. */
  18306. getEffectDefines(): string;
  18307. /**
  18308. * Returns the string "PointParticleEmitter"
  18309. * @returns a string containing the class name
  18310. */
  18311. getClassName(): string;
  18312. /**
  18313. * Serializes the particle system to a JSON object.
  18314. * @returns the JSON object
  18315. */
  18316. serialize(): any;
  18317. /**
  18318. * Parse properties from a JSON object
  18319. * @param serializationObject defines the JSON object
  18320. */
  18321. parse(serializationObject: any): void;
  18322. }
  18323. }
  18324. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18325. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18326. import { Effect } from "babylonjs/Materials/effect";
  18327. import { Particle } from "babylonjs/Particles/particle";
  18328. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18329. /**
  18330. * Particle emitter emitting particles from the inside of a sphere.
  18331. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18332. */
  18333. export class SphereParticleEmitter implements IParticleEmitterType {
  18334. /**
  18335. * The radius of the emission sphere.
  18336. */
  18337. radius: number;
  18338. /**
  18339. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18340. */
  18341. radiusRange: number;
  18342. /**
  18343. * How much to randomize the particle direction [0-1].
  18344. */
  18345. directionRandomizer: number;
  18346. /**
  18347. * Creates a new instance SphereParticleEmitter
  18348. * @param radius the radius of the emission sphere (1 by default)
  18349. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18350. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18351. */
  18352. constructor(
  18353. /**
  18354. * The radius of the emission sphere.
  18355. */
  18356. radius?: number,
  18357. /**
  18358. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18359. */
  18360. radiusRange?: number,
  18361. /**
  18362. * How much to randomize the particle direction [0-1].
  18363. */
  18364. directionRandomizer?: number);
  18365. /**
  18366. * Called by the particle System when the direction is computed for the created particle.
  18367. * @param worldMatrix is the world matrix of the particle system
  18368. * @param directionToUpdate is the direction vector to update with the result
  18369. * @param particle is the particle we are computed the direction for
  18370. */
  18371. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18372. /**
  18373. * Called by the particle System when the position is computed for the created particle.
  18374. * @param worldMatrix is the world matrix of the particle system
  18375. * @param positionToUpdate is the position vector to update with the result
  18376. * @param particle is the particle we are computed the position for
  18377. */
  18378. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18379. /**
  18380. * Clones the current emitter and returns a copy of it
  18381. * @returns the new emitter
  18382. */
  18383. clone(): SphereParticleEmitter;
  18384. /**
  18385. * Called by the GPUParticleSystem to setup the update shader
  18386. * @param effect defines the update shader
  18387. */
  18388. applyToShader(effect: Effect): void;
  18389. /**
  18390. * Returns a string to use to update the GPU particles update shader
  18391. * @returns a string containng the defines string
  18392. */
  18393. getEffectDefines(): string;
  18394. /**
  18395. * Returns the string "SphereParticleEmitter"
  18396. * @returns a string containing the class name
  18397. */
  18398. getClassName(): string;
  18399. /**
  18400. * Serializes the particle system to a JSON object.
  18401. * @returns the JSON object
  18402. */
  18403. serialize(): any;
  18404. /**
  18405. * Parse properties from a JSON object
  18406. * @param serializationObject defines the JSON object
  18407. */
  18408. parse(serializationObject: any): void;
  18409. }
  18410. /**
  18411. * Particle emitter emitting particles from the inside of a sphere.
  18412. * It emits the particles randomly between two vectors.
  18413. */
  18414. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18415. /**
  18416. * The min limit of the emission direction.
  18417. */
  18418. direction1: Vector3;
  18419. /**
  18420. * The max limit of the emission direction.
  18421. */
  18422. direction2: Vector3;
  18423. /**
  18424. * Creates a new instance SphereDirectedParticleEmitter
  18425. * @param radius the radius of the emission sphere (1 by default)
  18426. * @param direction1 the min limit of the emission direction (up vector by default)
  18427. * @param direction2 the max limit of the emission direction (up vector by default)
  18428. */
  18429. constructor(radius?: number,
  18430. /**
  18431. * The min limit of the emission direction.
  18432. */
  18433. direction1?: Vector3,
  18434. /**
  18435. * The max limit of the emission direction.
  18436. */
  18437. direction2?: Vector3);
  18438. /**
  18439. * Called by the particle System when the direction is computed for the created particle.
  18440. * @param worldMatrix is the world matrix of the particle system
  18441. * @param directionToUpdate is the direction vector to update with the result
  18442. * @param particle is the particle we are computed the direction for
  18443. */
  18444. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18445. /**
  18446. * Clones the current emitter and returns a copy of it
  18447. * @returns the new emitter
  18448. */
  18449. clone(): SphereDirectedParticleEmitter;
  18450. /**
  18451. * Called by the GPUParticleSystem to setup the update shader
  18452. * @param effect defines the update shader
  18453. */
  18454. applyToShader(effect: Effect): void;
  18455. /**
  18456. * Returns a string to use to update the GPU particles update shader
  18457. * @returns a string containng the defines string
  18458. */
  18459. getEffectDefines(): string;
  18460. /**
  18461. * Returns the string "SphereDirectedParticleEmitter"
  18462. * @returns a string containing the class name
  18463. */
  18464. getClassName(): string;
  18465. /**
  18466. * Serializes the particle system to a JSON object.
  18467. * @returns the JSON object
  18468. */
  18469. serialize(): any;
  18470. /**
  18471. * Parse properties from a JSON object
  18472. * @param serializationObject defines the JSON object
  18473. */
  18474. parse(serializationObject: any): void;
  18475. }
  18476. }
  18477. declare module "babylonjs/Particles/EmitterTypes/index" {
  18478. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18479. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18480. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18481. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18482. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18483. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18484. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18485. }
  18486. declare module "babylonjs/Particles/IParticleSystem" {
  18487. import { Nullable } from "babylonjs/types";
  18488. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18489. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18490. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18491. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18492. import { Texture } from "babylonjs/Materials/Textures/texture";
  18493. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18494. import { Scene } from "babylonjs/scene";
  18495. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18496. import { Animation } from "babylonjs/Animations/animation";
  18497. /**
  18498. * Interface representing a particle system in Babylon.js.
  18499. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18500. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18501. */
  18502. export interface IParticleSystem {
  18503. /**
  18504. * List of animations used by the particle system.
  18505. */
  18506. animations: Animation[];
  18507. /**
  18508. * The id of the Particle system.
  18509. */
  18510. id: string;
  18511. /**
  18512. * The name of the Particle system.
  18513. */
  18514. name: string;
  18515. /**
  18516. * The emitter represents the Mesh or position we are attaching the particle system to.
  18517. */
  18518. emitter: Nullable<AbstractMesh | Vector3>;
  18519. /**
  18520. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18521. */
  18522. isBillboardBased: boolean;
  18523. /**
  18524. * The rendering group used by the Particle system to chose when to render.
  18525. */
  18526. renderingGroupId: number;
  18527. /**
  18528. * The layer mask we are rendering the particles through.
  18529. */
  18530. layerMask: number;
  18531. /**
  18532. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18533. */
  18534. updateSpeed: number;
  18535. /**
  18536. * The amount of time the particle system is running (depends of the overall update speed).
  18537. */
  18538. targetStopDuration: number;
  18539. /**
  18540. * The texture used to render each particle. (this can be a spritesheet)
  18541. */
  18542. particleTexture: Nullable<Texture>;
  18543. /**
  18544. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18545. */
  18546. blendMode: number;
  18547. /**
  18548. * Minimum life time of emitting particles.
  18549. */
  18550. minLifeTime: number;
  18551. /**
  18552. * Maximum life time of emitting particles.
  18553. */
  18554. maxLifeTime: number;
  18555. /**
  18556. * Minimum Size of emitting particles.
  18557. */
  18558. minSize: number;
  18559. /**
  18560. * Maximum Size of emitting particles.
  18561. */
  18562. maxSize: number;
  18563. /**
  18564. * Minimum scale of emitting particles on X axis.
  18565. */
  18566. minScaleX: number;
  18567. /**
  18568. * Maximum scale of emitting particles on X axis.
  18569. */
  18570. maxScaleX: number;
  18571. /**
  18572. * Minimum scale of emitting particles on Y axis.
  18573. */
  18574. minScaleY: number;
  18575. /**
  18576. * Maximum scale of emitting particles on Y axis.
  18577. */
  18578. maxScaleY: number;
  18579. /**
  18580. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18581. */
  18582. color1: Color4;
  18583. /**
  18584. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18585. */
  18586. color2: Color4;
  18587. /**
  18588. * Color the particle will have at the end of its lifetime.
  18589. */
  18590. colorDead: Color4;
  18591. /**
  18592. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18593. */
  18594. emitRate: number;
  18595. /**
  18596. * You can use gravity if you want to give an orientation to your particles.
  18597. */
  18598. gravity: Vector3;
  18599. /**
  18600. * Minimum power of emitting particles.
  18601. */
  18602. minEmitPower: number;
  18603. /**
  18604. * Maximum power of emitting particles.
  18605. */
  18606. maxEmitPower: number;
  18607. /**
  18608. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18609. */
  18610. minAngularSpeed: number;
  18611. /**
  18612. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18613. */
  18614. maxAngularSpeed: number;
  18615. /**
  18616. * Gets or sets the minimal initial rotation in radians.
  18617. */
  18618. minInitialRotation: number;
  18619. /**
  18620. * Gets or sets the maximal initial rotation in radians.
  18621. */
  18622. maxInitialRotation: number;
  18623. /**
  18624. * The particle emitter type defines the emitter used by the particle system.
  18625. * It can be for example box, sphere, or cone...
  18626. */
  18627. particleEmitterType: Nullable<IParticleEmitterType>;
  18628. /**
  18629. * Defines the delay in milliseconds before starting the system (0 by default)
  18630. */
  18631. startDelay: number;
  18632. /**
  18633. * Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0
  18634. */
  18635. preWarmCycles: number;
  18636. /**
  18637. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18638. */
  18639. preWarmStepOffset: number;
  18640. /**
  18641. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  18642. */
  18643. spriteCellChangeSpeed: number;
  18644. /**
  18645. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18646. */
  18647. startSpriteCellID: number;
  18648. /**
  18649. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18650. */
  18651. endSpriteCellID: number;
  18652. /**
  18653. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18654. */
  18655. spriteCellWidth: number;
  18656. /**
  18657. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18658. */
  18659. spriteCellHeight: number;
  18660. /**
  18661. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18662. */
  18663. spriteRandomStartCell: boolean;
  18664. /**
  18665. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18666. */
  18667. isAnimationSheetEnabled: boolean;
  18668. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18669. translationPivot: Vector2;
  18670. /**
  18671. * Gets or sets a texture used to add random noise to particle positions
  18672. */
  18673. noiseTexture: Nullable<BaseTexture>;
  18674. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18675. noiseStrength: Vector3;
  18676. /**
  18677. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18678. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18679. */
  18680. billboardMode: number;
  18681. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18682. limitVelocityDamping: number;
  18683. /**
  18684. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18685. */
  18686. beginAnimationOnStart: boolean;
  18687. /**
  18688. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18689. */
  18690. beginAnimationFrom: number;
  18691. /**
  18692. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18693. */
  18694. beginAnimationTo: number;
  18695. /**
  18696. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18697. */
  18698. beginAnimationLoop: boolean;
  18699. /**
  18700. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18701. */
  18702. disposeOnStop: boolean;
  18703. /**
  18704. * Gets the maximum number of particles active at the same time.
  18705. * @returns The max number of active particles.
  18706. */
  18707. getCapacity(): number;
  18708. /**
  18709. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18710. * @returns True if it has been started, otherwise false.
  18711. */
  18712. isStarted(): boolean;
  18713. /**
  18714. * Animates the particle system for this frame.
  18715. */
  18716. animate(): void;
  18717. /**
  18718. * Renders the particle system in its current state.
  18719. * @returns the current number of particles
  18720. */
  18721. render(): number;
  18722. /**
  18723. * Dispose the particle system and frees its associated resources.
  18724. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18725. */
  18726. dispose(disposeTexture?: boolean): void;
  18727. /**
  18728. * Clones the particle system.
  18729. * @param name The name of the cloned object
  18730. * @param newEmitter The new emitter to use
  18731. * @returns the cloned particle system
  18732. */
  18733. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18734. /**
  18735. * Serializes the particle system to a JSON object.
  18736. * @returns the JSON object
  18737. */
  18738. serialize(): any;
  18739. /**
  18740. * Rebuild the particle system
  18741. */
  18742. rebuild(): void;
  18743. /**
  18744. * Starts the particle system and begins to emit
  18745. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18746. */
  18747. start(delay?: number): void;
  18748. /**
  18749. * Stops the particle system.
  18750. */
  18751. stop(): void;
  18752. /**
  18753. * Remove all active particles
  18754. */
  18755. reset(): void;
  18756. /**
  18757. * Is this system ready to be used/rendered
  18758. * @return true if the system is ready
  18759. */
  18760. isReady(): boolean;
  18761. /**
  18762. * Adds a new color gradient
  18763. * @param gradient defines the gradient to use (between 0 and 1)
  18764. * @param color1 defines the color to affect to the specified gradient
  18765. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18766. * @returns the current particle system
  18767. */
  18768. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18769. /**
  18770. * Remove a specific color gradient
  18771. * @param gradient defines the gradient to remove
  18772. * @returns the current particle system
  18773. */
  18774. removeColorGradient(gradient: number): IParticleSystem;
  18775. /**
  18776. * Adds a new size gradient
  18777. * @param gradient defines the gradient to use (between 0 and 1)
  18778. * @param factor defines the size factor to affect to the specified gradient
  18779. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18780. * @returns the current particle system
  18781. */
  18782. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18783. /**
  18784. * Remove a specific size gradient
  18785. * @param gradient defines the gradient to remove
  18786. * @returns the current particle system
  18787. */
  18788. removeSizeGradient(gradient: number): IParticleSystem;
  18789. /**
  18790. * Gets the current list of color gradients.
  18791. * You must use addColorGradient and removeColorGradient to udpate this list
  18792. * @returns the list of color gradients
  18793. */
  18794. getColorGradients(): Nullable<Array<ColorGradient>>;
  18795. /**
  18796. * Gets the current list of size gradients.
  18797. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18798. * @returns the list of size gradients
  18799. */
  18800. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18801. /**
  18802. * Gets the current list of angular speed gradients.
  18803. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18804. * @returns the list of angular speed gradients
  18805. */
  18806. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18807. /**
  18808. * Adds a new angular speed gradient
  18809. * @param gradient defines the gradient to use (between 0 and 1)
  18810. * @param factor defines the angular speed to affect to the specified gradient
  18811. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18812. * @returns the current particle system
  18813. */
  18814. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18815. /**
  18816. * Remove a specific angular speed gradient
  18817. * @param gradient defines the gradient to remove
  18818. * @returns the current particle system
  18819. */
  18820. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18821. /**
  18822. * Gets the current list of velocity gradients.
  18823. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18824. * @returns the list of velocity gradients
  18825. */
  18826. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18827. /**
  18828. * Adds a new velocity gradient
  18829. * @param gradient defines the gradient to use (between 0 and 1)
  18830. * @param factor defines the velocity to affect to the specified gradient
  18831. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18832. * @returns the current particle system
  18833. */
  18834. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18835. /**
  18836. * Remove a specific velocity gradient
  18837. * @param gradient defines the gradient to remove
  18838. * @returns the current particle system
  18839. */
  18840. removeVelocityGradient(gradient: number): IParticleSystem;
  18841. /**
  18842. * Gets the current list of limit velocity gradients.
  18843. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18844. * @returns the list of limit velocity gradients
  18845. */
  18846. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18847. /**
  18848. * Adds a new limit velocity gradient
  18849. * @param gradient defines the gradient to use (between 0 and 1)
  18850. * @param factor defines the limit velocity to affect to the specified gradient
  18851. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18852. * @returns the current particle system
  18853. */
  18854. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18855. /**
  18856. * Remove a specific limit velocity gradient
  18857. * @param gradient defines the gradient to remove
  18858. * @returns the current particle system
  18859. */
  18860. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18861. /**
  18862. * Adds a new drag gradient
  18863. * @param gradient defines the gradient to use (between 0 and 1)
  18864. * @param factor defines the drag to affect to the specified gradient
  18865. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18866. * @returns the current particle system
  18867. */
  18868. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18869. /**
  18870. * Remove a specific drag gradient
  18871. * @param gradient defines the gradient to remove
  18872. * @returns the current particle system
  18873. */
  18874. removeDragGradient(gradient: number): IParticleSystem;
  18875. /**
  18876. * Gets the current list of drag gradients.
  18877. * You must use addDragGradient and removeDragGradient to udpate this list
  18878. * @returns the list of drag gradients
  18879. */
  18880. getDragGradients(): Nullable<Array<FactorGradient>>;
  18881. /**
  18882. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18883. * @param gradient defines the gradient to use (between 0 and 1)
  18884. * @param factor defines the emit rate to affect to the specified gradient
  18885. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18886. * @returns the current particle system
  18887. */
  18888. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18889. /**
  18890. * Remove a specific emit rate gradient
  18891. * @param gradient defines the gradient to remove
  18892. * @returns the current particle system
  18893. */
  18894. removeEmitRateGradient(gradient: number): IParticleSystem;
  18895. /**
  18896. * Gets the current list of emit rate gradients.
  18897. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18898. * @returns the list of emit rate gradients
  18899. */
  18900. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18901. /**
  18902. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18903. * @param gradient defines the gradient to use (between 0 and 1)
  18904. * @param factor defines the start size to affect to the specified gradient
  18905. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18906. * @returns the current particle system
  18907. */
  18908. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18909. /**
  18910. * Remove a specific start size gradient
  18911. * @param gradient defines the gradient to remove
  18912. * @returns the current particle system
  18913. */
  18914. removeStartSizeGradient(gradient: number): IParticleSystem;
  18915. /**
  18916. * Gets the current list of start size gradients.
  18917. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18918. * @returns the list of start size gradients
  18919. */
  18920. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18921. /**
  18922. * Adds a new life time gradient
  18923. * @param gradient defines the gradient to use (between 0 and 1)
  18924. * @param factor defines the life time factor to affect to the specified gradient
  18925. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18926. * @returns the current particle system
  18927. */
  18928. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18929. /**
  18930. * Remove a specific life time gradient
  18931. * @param gradient defines the gradient to remove
  18932. * @returns the current particle system
  18933. */
  18934. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18935. /**
  18936. * Gets the current list of life time gradients.
  18937. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18938. * @returns the list of life time gradients
  18939. */
  18940. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18941. /**
  18942. * Gets the current list of color gradients.
  18943. * You must use addColorGradient and removeColorGradient to udpate this list
  18944. * @returns the list of color gradients
  18945. */
  18946. getColorGradients(): Nullable<Array<ColorGradient>>;
  18947. /**
  18948. * Adds a new ramp gradient used to remap particle colors
  18949. * @param gradient defines the gradient to use (between 0 and 1)
  18950. * @param color defines the color to affect to the specified gradient
  18951. * @returns the current particle system
  18952. */
  18953. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18954. /**
  18955. * Gets the current list of ramp gradients.
  18956. * You must use addRampGradient and removeRampGradient to udpate this list
  18957. * @returns the list of ramp gradients
  18958. */
  18959. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18960. /** Gets or sets a boolean indicating that ramp gradients must be used
  18961. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18962. */
  18963. useRampGradients: boolean;
  18964. /**
  18965. * Adds a new color remap gradient
  18966. * @param gradient defines the gradient to use (between 0 and 1)
  18967. * @param min defines the color remap minimal range
  18968. * @param max defines the color remap maximal range
  18969. * @returns the current particle system
  18970. */
  18971. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18972. /**
  18973. * Gets the current list of color remap gradients.
  18974. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18975. * @returns the list of color remap gradients
  18976. */
  18977. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18978. /**
  18979. * Adds a new alpha remap gradient
  18980. * @param gradient defines the gradient to use (between 0 and 1)
  18981. * @param min defines the alpha remap minimal range
  18982. * @param max defines the alpha remap maximal range
  18983. * @returns the current particle system
  18984. */
  18985. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18986. /**
  18987. * Gets the current list of alpha remap gradients.
  18988. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18989. * @returns the list of alpha remap gradients
  18990. */
  18991. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18992. /**
  18993. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18994. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18995. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18996. * @returns the emitter
  18997. */
  18998. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18999. /**
  19000. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19001. * @param radius The radius of the hemisphere to emit from
  19002. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19003. * @returns the emitter
  19004. */
  19005. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19006. /**
  19007. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19008. * @param radius The radius of the sphere to emit from
  19009. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19010. * @returns the emitter
  19011. */
  19012. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19013. /**
  19014. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19015. * @param radius The radius of the sphere to emit from
  19016. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19017. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19018. * @returns the emitter
  19019. */
  19020. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19021. /**
  19022. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19023. * @param radius The radius of the emission cylinder
  19024. * @param height The height of the emission cylinder
  19025. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19026. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19027. * @returns the emitter
  19028. */
  19029. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19030. /**
  19031. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19032. * @param radius The radius of the cylinder to emit from
  19033. * @param height The height of the emission cylinder
  19034. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19035. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19036. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19037. * @returns the emitter
  19038. */
  19039. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19040. /**
  19041. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19042. * @param radius The radius of the cone to emit from
  19043. * @param angle The base angle of the cone
  19044. * @returns the emitter
  19045. */
  19046. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19047. /**
  19048. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19049. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19050. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19051. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19052. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19053. * @returns the emitter
  19054. */
  19055. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19056. /**
  19057. * Get hosting scene
  19058. * @returns the scene
  19059. */
  19060. getScene(): Scene;
  19061. }
  19062. }
  19063. declare module "babylonjs/Meshes/instancedMesh" {
  19064. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19065. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19066. import { Camera } from "babylonjs/Cameras/camera";
  19067. import { Node } from "babylonjs/node";
  19068. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19069. import { Mesh } from "babylonjs/Meshes/mesh";
  19070. import { Material } from "babylonjs/Materials/material";
  19071. import { Skeleton } from "babylonjs/Bones/skeleton";
  19072. import { Light } from "babylonjs/Lights/light";
  19073. /**
  19074. * Creates an instance based on a source mesh.
  19075. */
  19076. export class InstancedMesh extends AbstractMesh {
  19077. private _sourceMesh;
  19078. private _currentLOD;
  19079. /** @hidden */
  19080. _indexInSourceMeshInstanceArray: number;
  19081. constructor(name: string, source: Mesh);
  19082. /**
  19083. * Returns the string "InstancedMesh".
  19084. */
  19085. getClassName(): string;
  19086. /** Gets the list of lights affecting that mesh */
  19087. readonly lightSources: Light[];
  19088. _resyncLightSources(): void;
  19089. _resyncLighSource(light: Light): void;
  19090. _removeLightSource(light: Light, dispose: boolean): void;
  19091. /**
  19092. * If the source mesh receives shadows
  19093. */
  19094. readonly receiveShadows: boolean;
  19095. /**
  19096. * The material of the source mesh
  19097. */
  19098. readonly material: Nullable<Material>;
  19099. /**
  19100. * Visibility of the source mesh
  19101. */
  19102. readonly visibility: number;
  19103. /**
  19104. * Skeleton of the source mesh
  19105. */
  19106. readonly skeleton: Nullable<Skeleton>;
  19107. /**
  19108. * Rendering ground id of the source mesh
  19109. */
  19110. renderingGroupId: number;
  19111. /**
  19112. * Returns the total number of vertices (integer).
  19113. */
  19114. getTotalVertices(): number;
  19115. /**
  19116. * Returns a positive integer : the total number of indices in this mesh geometry.
  19117. * @returns the numner of indices or zero if the mesh has no geometry.
  19118. */
  19119. getTotalIndices(): number;
  19120. /**
  19121. * The source mesh of the instance
  19122. */
  19123. readonly sourceMesh: Mesh;
  19124. /**
  19125. * Is this node ready to be used/rendered
  19126. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19127. * @return {boolean} is it ready
  19128. */
  19129. isReady(completeCheck?: boolean): boolean;
  19130. /**
  19131. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19132. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19133. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  19134. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19135. */
  19136. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19137. /**
  19138. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19139. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19140. * The `data` are either a numeric array either a Float32Array.
  19141. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19142. * The parameter `stride` is an optional positive integer, it is usually automatically deducted from the `kind` (3 for positions or normals, 2 for UV, etc).
  19143. * Note that a new underlying VertexBuffer object is created each call.
  19144. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19145. *
  19146. * Possible `kind` values :
  19147. * - VertexBuffer.PositionKind
  19148. * - VertexBuffer.UVKind
  19149. * - VertexBuffer.UV2Kind
  19150. * - VertexBuffer.UV3Kind
  19151. * - VertexBuffer.UV4Kind
  19152. * - VertexBuffer.UV5Kind
  19153. * - VertexBuffer.UV6Kind
  19154. * - VertexBuffer.ColorKind
  19155. * - VertexBuffer.MatricesIndicesKind
  19156. * - VertexBuffer.MatricesIndicesExtraKind
  19157. * - VertexBuffer.MatricesWeightsKind
  19158. * - VertexBuffer.MatricesWeightsExtraKind
  19159. *
  19160. * Returns the Mesh.
  19161. */
  19162. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19163. /**
  19164. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19165. * If the mesh has no geometry, it is simply returned as it is.
  19166. * The `data` are either a numeric array either a Float32Array.
  19167. * No new underlying VertexBuffer object is created.
  19168. * If the `kind` is the `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19169. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19170. *
  19171. * Possible `kind` values :
  19172. * - VertexBuffer.PositionKind
  19173. * - VertexBuffer.UVKind
  19174. * - VertexBuffer.UV2Kind
  19175. * - VertexBuffer.UV3Kind
  19176. * - VertexBuffer.UV4Kind
  19177. * - VertexBuffer.UV5Kind
  19178. * - VertexBuffer.UV6Kind
  19179. * - VertexBuffer.ColorKind
  19180. * - VertexBuffer.MatricesIndicesKind
  19181. * - VertexBuffer.MatricesIndicesExtraKind
  19182. * - VertexBuffer.MatricesWeightsKind
  19183. * - VertexBuffer.MatricesWeightsExtraKind
  19184. *
  19185. * Returns the Mesh.
  19186. */
  19187. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19188. /**
  19189. * Sets the mesh indices.
  19190. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19191. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19192. * This method creates a new index buffer each call.
  19193. * Returns the Mesh.
  19194. */
  19195. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19196. /**
  19197. * Boolean : True if the mesh owns the requested kind of data.
  19198. */
  19199. isVerticesDataPresent(kind: string): boolean;
  19200. /**
  19201. * Returns an array of indices (IndicesArray).
  19202. */
  19203. getIndices(): Nullable<IndicesArray>;
  19204. readonly _positions: Nullable<Vector3[]>;
  19205. /**
  19206. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19207. * This means the mesh underlying bounding box and sphere are recomputed.
  19208. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19209. * @returns the current mesh
  19210. */
  19211. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19212. /** @hidden */
  19213. _preActivate(): InstancedMesh;
  19214. /** @hidden */
  19215. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19216. /** @hidden */
  19217. _postActivate(): void;
  19218. getWorldMatrix(): Matrix;
  19219. readonly isAnInstance: boolean;
  19220. /**
  19221. * Returns the current associated LOD AbstractMesh.
  19222. */
  19223. getLOD(camera: Camera): AbstractMesh;
  19224. /** @hidden */
  19225. _syncSubMeshes(): InstancedMesh;
  19226. /** @hidden */
  19227. _generatePointsArray(): boolean;
  19228. /**
  19229. * Creates a new InstancedMesh from the current mesh.
  19230. * - name (string) : the cloned mesh name
  19231. * - newParent (optional Node) : the optional Node to parent the clone to.
  19232. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19233. *
  19234. * Returns the clone.
  19235. */
  19236. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19237. /**
  19238. * Disposes the InstancedMesh.
  19239. * Returns nothing.
  19240. */
  19241. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19242. }
  19243. }
  19244. declare module "babylonjs/Materials/shaderMaterial" {
  19245. import { Scene } from "babylonjs/scene";
  19246. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19247. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19248. import { Mesh } from "babylonjs/Meshes/mesh";
  19249. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19250. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19251. import { Texture } from "babylonjs/Materials/Textures/texture";
  19252. import { Material } from "babylonjs/Materials/material";
  19253. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19254. /**
  19255. * Defines the options associated with the creation of a shader material.
  19256. */
  19257. export interface IShaderMaterialOptions {
  19258. /**
  19259. * Does the material work in alpha blend mode
  19260. */
  19261. needAlphaBlending: boolean;
  19262. /**
  19263. * Does the material work in alpha test mode
  19264. */
  19265. needAlphaTesting: boolean;
  19266. /**
  19267. * The list of attribute names used in the shader
  19268. */
  19269. attributes: string[];
  19270. /**
  19271. * The list of unifrom names used in the shader
  19272. */
  19273. uniforms: string[];
  19274. /**
  19275. * The list of UBO names used in the shader
  19276. */
  19277. uniformBuffers: string[];
  19278. /**
  19279. * The list of sampler names used in the shader
  19280. */
  19281. samplers: string[];
  19282. /**
  19283. * The list of defines used in the shader
  19284. */
  19285. defines: string[];
  19286. }
  19287. /**
  19288. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  19289. *
  19290. * This returned material effects how the mesh will look based on the code in the shaders.
  19291. *
  19292. * @see http://doc.babylonjs.com/how_to/shader_material
  19293. */
  19294. export class ShaderMaterial extends Material {
  19295. private _shaderPath;
  19296. private _options;
  19297. private _textures;
  19298. private _textureArrays;
  19299. private _floats;
  19300. private _ints;
  19301. private _floatsArrays;
  19302. private _colors3;
  19303. private _colors3Arrays;
  19304. private _colors4;
  19305. private _colors4Arrays;
  19306. private _vectors2;
  19307. private _vectors3;
  19308. private _vectors4;
  19309. private _matrices;
  19310. private _matrices3x3;
  19311. private _matrices2x2;
  19312. private _vectors2Arrays;
  19313. private _vectors3Arrays;
  19314. private _vectors4Arrays;
  19315. private _cachedWorldViewMatrix;
  19316. private _cachedWorldViewProjectionMatrix;
  19317. private _renderId;
  19318. /**
  19319. * Instantiate a new shader material.
  19320. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  19321. * This returned material effects how the mesh will look based on the code in the shaders.
  19322. * @see http://doc.babylonjs.com/how_to/shader_material
  19323. * @param name Define the name of the material in the scene
  19324. * @param scene Define the scene the material belongs to
  19325. * @param shaderPath Defines the route to the shader code in one of three ways:
  19326. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19327. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  19328. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19329. * @param options Define the options used to create the shader
  19330. */
  19331. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19332. /**
  19333. * Gets the options used to compile the shader.
  19334. * They can be modified to trigger a new compilation
  19335. */
  19336. readonly options: IShaderMaterialOptions;
  19337. /**
  19338. * Gets the current class name of the material e.g. "ShaderMaterial"
  19339. * Mainly use in serialization.
  19340. * @returns the class name
  19341. */
  19342. getClassName(): string;
  19343. /**
  19344. * Specifies if the material will require alpha blending
  19345. * @returns a boolean specifying if alpha blending is needed
  19346. */
  19347. needAlphaBlending(): boolean;
  19348. /**
  19349. * Specifies if this material should be rendered in alpha test mode
  19350. * @returns a boolean specifying if an alpha test is needed.
  19351. */
  19352. needAlphaTesting(): boolean;
  19353. private _checkUniform;
  19354. /**
  19355. * Set a texture in the shader.
  19356. * @param name Define the name of the uniform samplers as defined in the shader
  19357. * @param texture Define the texture to bind to this sampler
  19358. * @return the material itself allowing "fluent" like uniform updates
  19359. */
  19360. setTexture(name: string, texture: Texture): ShaderMaterial;
  19361. /**
  19362. * Set a texture array in the shader.
  19363. * @param name Define the name of the uniform sampler array as defined in the shader
  19364. * @param textures Define the list of textures to bind to this sampler
  19365. * @return the material itself allowing "fluent" like uniform updates
  19366. */
  19367. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19368. /**
  19369. * Set a float in the shader.
  19370. * @param name Define the name of the uniform as defined in the shader
  19371. * @param value Define the value to give to the uniform
  19372. * @return the material itself allowing "fluent" like uniform updates
  19373. */
  19374. setFloat(name: string, value: number): ShaderMaterial;
  19375. /**
  19376. * Set a int in the shader.
  19377. * @param name Define the name of the uniform as defined in the shader
  19378. * @param value Define the value to give to the uniform
  19379. * @return the material itself allowing "fluent" like uniform updates
  19380. */
  19381. setInt(name: string, value: number): ShaderMaterial;
  19382. /**
  19383. * Set an array of floats in the shader.
  19384. * @param name Define the name of the uniform as defined in the shader
  19385. * @param value Define the value to give to the uniform
  19386. * @return the material itself allowing "fluent" like uniform updates
  19387. */
  19388. setFloats(name: string, value: number[]): ShaderMaterial;
  19389. /**
  19390. * Set a vec3 in the shader from a Color3.
  19391. * @param name Define the name of the uniform as defined in the shader
  19392. * @param value Define the value to give to the uniform
  19393. * @return the material itself allowing "fluent" like uniform updates
  19394. */
  19395. setColor3(name: string, value: Color3): ShaderMaterial;
  19396. /**
  19397. * Set a vec3 array in the shader from a Color3 array.
  19398. * @param name Define the name of the uniform as defined in the shader
  19399. * @param value Define the value to give to the uniform
  19400. * @return the material itself allowing "fluent" like uniform updates
  19401. */
  19402. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19403. /**
  19404. * Set a vec4 in the shader from a Color4.
  19405. * @param name Define the name of the uniform as defined in the shader
  19406. * @param value Define the value to give to the uniform
  19407. * @return the material itself allowing "fluent" like uniform updates
  19408. */
  19409. setColor4(name: string, value: Color4): ShaderMaterial;
  19410. /**
  19411. * Set a vec4 array in the shader from a Color4 array.
  19412. * @param name Define the name of the uniform as defined in the shader
  19413. * @param value Define the value to give to the uniform
  19414. * @return the material itself allowing "fluent" like uniform updates
  19415. */
  19416. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19417. /**
  19418. * Set a vec2 in the shader from a Vector2.
  19419. * @param name Define the name of the uniform as defined in the shader
  19420. * @param value Define the value to give to the uniform
  19421. * @return the material itself allowing "fluent" like uniform updates
  19422. */
  19423. setVector2(name: string, value: Vector2): ShaderMaterial;
  19424. /**
  19425. * Set a vec3 in the shader from a Vector3.
  19426. * @param name Define the name of the uniform as defined in the shader
  19427. * @param value Define the value to give to the uniform
  19428. * @return the material itself allowing "fluent" like uniform updates
  19429. */
  19430. setVector3(name: string, value: Vector3): ShaderMaterial;
  19431. /**
  19432. * Set a vec4 in the shader from a Vector4.
  19433. * @param name Define the name of the uniform as defined in the shader
  19434. * @param value Define the value to give to the uniform
  19435. * @return the material itself allowing "fluent" like uniform updates
  19436. */
  19437. setVector4(name: string, value: Vector4): ShaderMaterial;
  19438. /**
  19439. * Set a mat4 in the shader from a Matrix.
  19440. * @param name Define the name of the uniform as defined in the shader
  19441. * @param value Define the value to give to the uniform
  19442. * @return the material itself allowing "fluent" like uniform updates
  19443. */
  19444. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19445. /**
  19446. * Set a mat3 in the shader from a Float32Array.
  19447. * @param name Define the name of the uniform as defined in the shader
  19448. * @param value Define the value to give to the uniform
  19449. * @return the material itself allowing "fluent" like uniform updates
  19450. */
  19451. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19452. /**
  19453. * Set a mat2 in the shader from a Float32Array.
  19454. * @param name Define the name of the uniform as defined in the shader
  19455. * @param value Define the value to give to the uniform
  19456. * @return the material itself allowing "fluent" like uniform updates
  19457. */
  19458. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19459. /**
  19460. * Set a vec2 array in the shader from a number array.
  19461. * @param name Define the name of the uniform as defined in the shader
  19462. * @param value Define the value to give to the uniform
  19463. * @return the material itself allowing "fluent" like uniform updates
  19464. */
  19465. setArray2(name: string, value: number[]): ShaderMaterial;
  19466. /**
  19467. * Set a vec3 array in the shader from a number array.
  19468. * @param name Define the name of the uniform as defined in the shader
  19469. * @param value Define the value to give to the uniform
  19470. * @return the material itself allowing "fluent" like uniform updates
  19471. */
  19472. setArray3(name: string, value: number[]): ShaderMaterial;
  19473. /**
  19474. * Set a vec4 array in the shader from a number array.
  19475. * @param name Define the name of the uniform as defined in the shader
  19476. * @param value Define the value to give to the uniform
  19477. * @return the material itself allowing "fluent" like uniform updates
  19478. */
  19479. setArray4(name: string, value: number[]): ShaderMaterial;
  19480. private _checkCache;
  19481. /**
  19482. * Specifies that the submesh is ready to be used
  19483. * @param mesh defines the mesh to check
  19484. * @param subMesh defines which submesh to check
  19485. * @param useInstances specifies that instances should be used
  19486. * @returns a boolean indicating that the submesh is ready or not
  19487. */
  19488. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19489. /**
  19490. * Checks if the material is ready to render the requested mesh
  19491. * @param mesh Define the mesh to render
  19492. * @param useInstances Define whether or not the material is used with instances
  19493. * @returns true if ready, otherwise false
  19494. */
  19495. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19496. /**
  19497. * Binds the world matrix to the material
  19498. * @param world defines the world transformation matrix
  19499. */
  19500. bindOnlyWorldMatrix(world: Matrix): void;
  19501. /**
  19502. * Binds the material to the mesh
  19503. * @param world defines the world transformation matrix
  19504. * @param mesh defines the mesh to bind the material to
  19505. */
  19506. bind(world: Matrix, mesh?: Mesh): void;
  19507. /**
  19508. * Gets the active textures from the material
  19509. * @returns an array of textures
  19510. */
  19511. getActiveTextures(): BaseTexture[];
  19512. /**
  19513. * Specifies if the material uses a texture
  19514. * @param texture defines the texture to check against the material
  19515. * @returns a boolean specifying if the material uses the texture
  19516. */
  19517. hasTexture(texture: BaseTexture): boolean;
  19518. /**
  19519. * Makes a duplicate of the material, and gives it a new name
  19520. * @param name defines the new name for the duplicated material
  19521. * @returns the cloned material
  19522. */
  19523. clone(name: string): ShaderMaterial;
  19524. /**
  19525. * Disposes the material
  19526. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19527. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19528. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19529. */
  19530. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19531. /**
  19532. * Serializes this material in a JSON representation
  19533. * @returns the serialized material object
  19534. */
  19535. serialize(): any;
  19536. /**
  19537. * Creates a shader material from parsed shader material data
  19538. * @param source defines the JSON represnetation of the material
  19539. * @param scene defines the hosting scene
  19540. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19541. * @returns a new material
  19542. */
  19543. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19544. }
  19545. }
  19546. declare module "babylonjs/Shaders/color.fragment" {
  19547. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19548. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19549. /** @hidden */
  19550. export var colorPixelShader: {
  19551. name: string;
  19552. shader: string;
  19553. };
  19554. }
  19555. declare module "babylonjs/Shaders/color.vertex" {
  19556. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19557. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19558. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  19559. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19560. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19561. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19562. /** @hidden */
  19563. export var colorVertexShader: {
  19564. name: string;
  19565. shader: string;
  19566. };
  19567. }
  19568. declare module "babylonjs/Meshes/linesMesh" {
  19569. import { Nullable } from "babylonjs/types";
  19570. import { Scene } from "babylonjs/scene";
  19571. import { Color3 } from "babylonjs/Maths/math.color";
  19572. import { Node } from "babylonjs/node";
  19573. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19574. import { Mesh } from "babylonjs/Meshes/mesh";
  19575. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19576. import { Effect } from "babylonjs/Materials/effect";
  19577. import { Material } from "babylonjs/Materials/material";
  19578. import "babylonjs/Shaders/color.fragment";
  19579. import "babylonjs/Shaders/color.vertex";
  19580. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19581. /**
  19582. * Line mesh
  19583. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19584. */
  19585. export class LinesMesh extends Mesh {
  19586. /**
  19587. * If vertex color should be applied to the mesh
  19588. */
  19589. readonly useVertexColor?: boolean | undefined;
  19590. /**
  19591. * If vertex alpha should be applied to the mesh
  19592. */
  19593. readonly useVertexAlpha?: boolean | undefined;
  19594. /**
  19595. * Color of the line (Default: White)
  19596. */
  19597. color: Color3;
  19598. /**
  19599. * Alpha of the line (Default: 1)
  19600. */
  19601. alpha: number;
  19602. /**
  19603. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19604. * This margin is expressed in world space coordinates, so its value may vary.
  19605. * Default value is 0.1
  19606. */
  19607. intersectionThreshold: number;
  19608. private _colorShader;
  19609. private color4;
  19610. /**
  19611. * Creates a new LinesMesh
  19612. * @param name defines the name
  19613. * @param scene defines the hosting scene
  19614. * @param parent defines the parent mesh if any
  19615. * @param source defines the optional source LinesMesh used to clone data from
  19616. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19617. * When false, achieved by calling a clone(), also passing False.
  19618. * This will make creation of children, recursive.
  19619. * @param useVertexColor defines if this LinesMesh supports vertex color
  19620. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19621. */
  19622. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19623. /**
  19624. * If vertex color should be applied to the mesh
  19625. */
  19626. useVertexColor?: boolean | undefined,
  19627. /**
  19628. * If vertex alpha should be applied to the mesh
  19629. */
  19630. useVertexAlpha?: boolean | undefined);
  19631. private _addClipPlaneDefine;
  19632. private _removeClipPlaneDefine;
  19633. isReady(): boolean;
  19634. /**
  19635. * Returns the string "LineMesh"
  19636. */
  19637. getClassName(): string;
  19638. /**
  19639. * @hidden
  19640. */
  19641. /**
  19642. * @hidden
  19643. */
  19644. material: Material;
  19645. /**
  19646. * @hidden
  19647. */
  19648. readonly checkCollisions: boolean;
  19649. /** @hidden */
  19650. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19651. /** @hidden */
  19652. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19653. /**
  19654. * Disposes of the line mesh
  19655. * @param doNotRecurse If children should be disposed
  19656. */
  19657. dispose(doNotRecurse?: boolean): void;
  19658. /**
  19659. * Returns a new LineMesh object cloned from the current one.
  19660. */
  19661. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19662. /**
  19663. * Creates a new InstancedLinesMesh object from the mesh model.
  19664. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19665. * @param name defines the name of the new instance
  19666. * @returns a new InstancedLinesMesh
  19667. */
  19668. createInstance(name: string): InstancedLinesMesh;
  19669. }
  19670. /**
  19671. * Creates an instance based on a source LinesMesh
  19672. */
  19673. export class InstancedLinesMesh extends InstancedMesh {
  19674. /**
  19675. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19676. * This margin is expressed in world space coordinates, so its value may vary.
  19677. * Initilized with the intersectionThreshold value of the source LinesMesh
  19678. */
  19679. intersectionThreshold: number;
  19680. constructor(name: string, source: LinesMesh);
  19681. /**
  19682. * Returns the string "InstancedLinesMesh".
  19683. */
  19684. getClassName(): string;
  19685. }
  19686. }
  19687. declare module "babylonjs/Shaders/line.fragment" {
  19688. /** @hidden */
  19689. export var linePixelShader: {
  19690. name: string;
  19691. shader: string;
  19692. };
  19693. }
  19694. declare module "babylonjs/Shaders/line.vertex" {
  19695. /** @hidden */
  19696. export var lineVertexShader: {
  19697. name: string;
  19698. shader: string;
  19699. };
  19700. }
  19701. declare module "babylonjs/Rendering/edgesRenderer" {
  19702. import { Nullable } from "babylonjs/types";
  19703. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19704. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19705. import { Vector3 } from "babylonjs/Maths/math.vector";
  19706. import { IDisposable } from "babylonjs/scene";
  19707. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  19708. import "babylonjs/Shaders/line.fragment";
  19709. import "babylonjs/Shaders/line.vertex";
  19710. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  19711. module "babylonjs/Meshes/abstractMesh" {
  19712. interface AbstractMesh {
  19713. /**
  19714. * Gets the edgesRenderer associated with the mesh
  19715. */
  19716. edgesRenderer: Nullable<EdgesRenderer>;
  19717. }
  19718. }
  19719. module "babylonjs/Meshes/linesMesh" {
  19720. interface LinesMesh {
  19721. /**
  19722. * Enables the edge rendering mode on the mesh.
  19723. * This mode makes the mesh edges visible
  19724. * @param epsilon defines the maximal distance between two angles to detect a face
  19725. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19726. * @returns the currentAbstractMesh
  19727. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19728. */
  19729. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19730. }
  19731. }
  19732. module "babylonjs/Meshes/linesMesh" {
  19733. interface InstancedLinesMesh {
  19734. /**
  19735. * Enables the edge rendering mode on the mesh.
  19736. * This mode makes the mesh edges visible
  19737. * @param epsilon defines the maximal distance between two angles to detect a face
  19738. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19739. * @returns the current InstancedLinesMesh
  19740. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19741. */
  19742. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19743. }
  19744. }
  19745. /**
  19746. * Defines the minimum contract an Edges renderer should follow.
  19747. */
  19748. export interface IEdgesRenderer extends IDisposable {
  19749. /**
  19750. * Gets or sets a boolean indicating if the edgesRenderer is active
  19751. */
  19752. isEnabled: boolean;
  19753. /**
  19754. * Renders the edges of the attached mesh,
  19755. */
  19756. render(): void;
  19757. /**
  19758. * Checks wether or not the edges renderer is ready to render.
  19759. * @return true if ready, otherwise false.
  19760. */
  19761. isReady(): boolean;
  19762. }
  19763. /**
  19764. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19765. */
  19766. export class EdgesRenderer implements IEdgesRenderer {
  19767. /**
  19768. * Define the size of the edges with an orthographic camera
  19769. */
  19770. edgesWidthScalerForOrthographic: number;
  19771. /**
  19772. * Define the size of the edges with a perspective camera
  19773. */
  19774. edgesWidthScalerForPerspective: number;
  19775. protected _source: AbstractMesh;
  19776. protected _linesPositions: number[];
  19777. protected _linesNormals: number[];
  19778. protected _linesIndices: number[];
  19779. protected _epsilon: number;
  19780. protected _indicesCount: number;
  19781. protected _lineShader: ShaderMaterial;
  19782. protected _ib: DataBuffer;
  19783. protected _buffers: {
  19784. [key: string]: Nullable<VertexBuffer>;
  19785. };
  19786. protected _checkVerticesInsteadOfIndices: boolean;
  19787. private _meshRebuildObserver;
  19788. private _meshDisposeObserver;
  19789. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19790. isEnabled: boolean;
  19791. /**
  19792. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19793. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19794. * @param source Mesh used to create edges
  19795. * @param epsilon sum of angles in adjacency to check for edge
  19796. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19797. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19798. */
  19799. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19800. protected _prepareRessources(): void;
  19801. /** @hidden */
  19802. _rebuild(): void;
  19803. /**
  19804. * Releases the required resources for the edges renderer
  19805. */
  19806. dispose(): void;
  19807. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19808. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19809. /**
  19810. * Checks if the pair of p0 and p1 is en edge
  19811. * @param faceIndex
  19812. * @param edge
  19813. * @param faceNormals
  19814. * @param p0
  19815. * @param p1
  19816. * @private
  19817. */
  19818. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19819. /**
  19820. * push line into the position, normal and index buffer
  19821. * @protected
  19822. */
  19823. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19824. /**
  19825. * Generates lines edges from adjacencjes
  19826. * @private
  19827. */
  19828. _generateEdgesLines(): void;
  19829. /**
  19830. * Checks wether or not the edges renderer is ready to render.
  19831. * @return true if ready, otherwise false.
  19832. */
  19833. isReady(): boolean;
  19834. /**
  19835. * Renders the edges of the attached mesh,
  19836. */
  19837. render(): void;
  19838. }
  19839. /**
  19840. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19841. */
  19842. export class LineEdgesRenderer extends EdgesRenderer {
  19843. /**
  19844. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19845. * @param source LineMesh used to generate edges
  19846. * @param epsilon not important (specified angle for edge detection)
  19847. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19848. */
  19849. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19850. /**
  19851. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19852. */
  19853. _generateEdgesLines(): void;
  19854. }
  19855. }
  19856. declare module "babylonjs/Rendering/renderingGroup" {
  19857. import { SmartArray } from "babylonjs/Misc/smartArray";
  19858. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19859. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19860. import { Nullable } from "babylonjs/types";
  19861. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  19862. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  19863. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  19864. import { Material } from "babylonjs/Materials/material";
  19865. import { Scene } from "babylonjs/scene";
  19866. /**
  19867. * This represents the object necessary to create a rendering group.
  19868. * This is exclusively used and created by the rendering manager.
  19869. * To modify the behavior, you use the available helpers in your scene or meshes.
  19870. * @hidden
  19871. */
  19872. export class RenderingGroup {
  19873. index: number;
  19874. private static _zeroVector;
  19875. private _scene;
  19876. private _opaqueSubMeshes;
  19877. private _transparentSubMeshes;
  19878. private _alphaTestSubMeshes;
  19879. private _depthOnlySubMeshes;
  19880. private _particleSystems;
  19881. private _spriteManagers;
  19882. private _opaqueSortCompareFn;
  19883. private _alphaTestSortCompareFn;
  19884. private _transparentSortCompareFn;
  19885. private _renderOpaque;
  19886. private _renderAlphaTest;
  19887. private _renderTransparent;
  19888. /** @hidden */
  19889. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19890. onBeforeTransparentRendering: () => void;
  19891. /**
  19892. * Set the opaque sort comparison function.
  19893. * If null the sub meshes will be render in the order they were created
  19894. */
  19895. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19896. /**
  19897. * Set the alpha test sort comparison function.
  19898. * If null the sub meshes will be render in the order they were created
  19899. */
  19900. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19901. /**
  19902. * Set the transparent sort comparison function.
  19903. * If null the sub meshes will be render in the order they were created
  19904. */
  19905. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19906. /**
  19907. * Creates a new rendering group.
  19908. * @param index The rendering group index
  19909. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19910. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19911. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19912. */
  19913. constructor(index: number, scene: Scene, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>);
  19914. /**
  19915. * Render all the sub meshes contained in the group.
  19916. * @param customRenderFunction Used to override the default render behaviour of the group.
  19917. * @returns true if rendered some submeshes.
  19918. */
  19919. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19920. /**
  19921. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19922. * @param subMeshes The submeshes to render
  19923. */
  19924. private renderOpaqueSorted;
  19925. /**
  19926. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19927. * @param subMeshes The submeshes to render
  19928. */
  19929. private renderAlphaTestSorted;
  19930. /**
  19931. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19932. * @param subMeshes The submeshes to render
  19933. */
  19934. private renderTransparentSorted;
  19935. /**
  19936. * Renders the submeshes in a specified order.
  19937. * @param subMeshes The submeshes to sort before render
  19938. * @param sortCompareFn The comparison function use to sort
  19939. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19940. * @param transparent Specifies to activate blending if true
  19941. */
  19942. private static renderSorted;
  19943. /**
  19944. * Renders the submeshes in the order they were dispatched (no sort applied).
  19945. * @param subMeshes The submeshes to render
  19946. */
  19947. private static renderUnsorted;
  19948. /**
  19949. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19950. * are rendered back to front if in the same alpha index.
  19951. *
  19952. * @param a The first submesh
  19953. * @param b The second submesh
  19954. * @returns The result of the comparison
  19955. */
  19956. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19957. /**
  19958. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19959. * are rendered back to front.
  19960. *
  19961. * @param a The first submesh
  19962. * @param b The second submesh
  19963. * @returns The result of the comparison
  19964. */
  19965. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19966. /**
  19967. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19968. * are rendered front to back (prevent overdraw).
  19969. *
  19970. * @param a The first submesh
  19971. * @param b The second submesh
  19972. * @returns The result of the comparison
  19973. */
  19974. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19975. /**
  19976. * Resets the different lists of submeshes to prepare a new frame.
  19977. */
  19978. prepare(): void;
  19979. dispose(): void;
  19980. /**
  19981. * Inserts the submesh in its correct queue depending on its material.
  19982. * @param subMesh The submesh to dispatch
  19983. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19984. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19985. */
  19986. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19987. dispatchSprites(spriteManager: ISpriteManager): void;
  19988. dispatchParticles(particleSystem: IParticleSystem): void;
  19989. private _renderParticles;
  19990. private _renderSprites;
  19991. }
  19992. }
  19993. declare module "babylonjs/Rendering/renderingManager" {
  19994. import { Nullable } from "babylonjs/types";
  19995. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19996. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19997. import { SmartArray } from "babylonjs/Misc/smartArray";
  19998. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  19999. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20000. import { Material } from "babylonjs/Materials/material";
  20001. import { Scene } from "babylonjs/scene";
  20002. import { Camera } from "babylonjs/Cameras/camera";
  20003. /**
  20004. * Interface describing the different options available in the rendering manager
  20005. * regarding Auto Clear between groups.
  20006. */
  20007. export interface IRenderingManagerAutoClearSetup {
  20008. /**
  20009. * Defines whether or not autoclear is enable.
  20010. */
  20011. autoClear: boolean;
  20012. /**
  20013. * Defines whether or not to autoclear the depth buffer.
  20014. */
  20015. depth: boolean;
  20016. /**
  20017. * Defines whether or not to autoclear the stencil buffer.
  20018. */
  20019. stencil: boolean;
  20020. }
  20021. /**
  20022. * This class is used by the onRenderingGroupObservable
  20023. */
  20024. export class RenderingGroupInfo {
  20025. /**
  20026. * The Scene that being rendered
  20027. */
  20028. scene: Scene;
  20029. /**
  20030. * The camera currently used for the rendering pass
  20031. */
  20032. camera: Nullable<Camera>;
  20033. /**
  20034. * The ID of the renderingGroup being processed
  20035. */
  20036. renderingGroupId: number;
  20037. }
  20038. /**
  20039. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20040. * It is enable to manage the different groups as well as the different necessary sort functions.
  20041. * This should not be used directly aside of the few static configurations
  20042. */
  20043. export class RenderingManager {
  20044. /**
  20045. * The max id used for rendering groups (not included)
  20046. */
  20047. static MAX_RENDERINGGROUPS: number;
  20048. /**
  20049. * The min id used for rendering groups (included)
  20050. */
  20051. static MIN_RENDERINGGROUPS: number;
  20052. /**
  20053. * Used to globally prevent autoclearing scenes.
  20054. */
  20055. static AUTOCLEAR: boolean;
  20056. /**
  20057. * @hidden
  20058. */
  20059. _useSceneAutoClearSetup: boolean;
  20060. private _scene;
  20061. private _renderingGroups;
  20062. private _depthStencilBufferAlreadyCleaned;
  20063. private _autoClearDepthStencil;
  20064. private _customOpaqueSortCompareFn;
  20065. private _customAlphaTestSortCompareFn;
  20066. private _customTransparentSortCompareFn;
  20067. private _renderingGroupInfo;
  20068. /**
  20069. * Instantiates a new rendering group for a particular scene
  20070. * @param scene Defines the scene the groups belongs to
  20071. */
  20072. constructor(scene: Scene);
  20073. private _clearDepthStencilBuffer;
  20074. /**
  20075. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20076. * @hidden
  20077. */
  20078. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20079. /**
  20080. * Resets the different information of the group to prepare a new frame
  20081. * @hidden
  20082. */
  20083. reset(): void;
  20084. /**
  20085. * Dispose and release the group and its associated resources.
  20086. * @hidden
  20087. */
  20088. dispose(): void;
  20089. /**
  20090. * Clear the info related to rendering groups preventing retention points during dispose.
  20091. */
  20092. freeRenderingGroups(): void;
  20093. private _prepareRenderingGroup;
  20094. /**
  20095. * Add a sprite manager to the rendering manager in order to render it this frame.
  20096. * @param spriteManager Define the sprite manager to render
  20097. */
  20098. dispatchSprites(spriteManager: ISpriteManager): void;
  20099. /**
  20100. * Add a particle system to the rendering manager in order to render it this frame.
  20101. * @param particleSystem Define the particle system to render
  20102. */
  20103. dispatchParticles(particleSystem: IParticleSystem): void;
  20104. /**
  20105. * Add a submesh to the manager in order to render it this frame
  20106. * @param subMesh The submesh to dispatch
  20107. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20108. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20109. */
  20110. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20111. /**
  20112. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20113. * This allowed control for front to back rendering or reversly depending of the special needs.
  20114. *
  20115. * @param renderingGroupId The rendering group id corresponding to its index
  20116. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20117. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20118. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20119. */
  20120. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  20121. /**
  20122. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20123. *
  20124. * @param renderingGroupId The rendering group id corresponding to its index
  20125. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20126. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20127. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20128. */
  20129. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20130. /**
  20131. * Gets the current auto clear configuration for one rendering group of the rendering
  20132. * manager.
  20133. * @param index the rendering group index to get the information for
  20134. * @returns The auto clear setup for the requested rendering group
  20135. */
  20136. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20137. }
  20138. }
  20139. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20140. import { Observable } from "babylonjs/Misc/observable";
  20141. import { SmartArray } from "babylonjs/Misc/smartArray";
  20142. import { Nullable } from "babylonjs/types";
  20143. import { Camera } from "babylonjs/Cameras/camera";
  20144. import { Scene } from "babylonjs/scene";
  20145. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20146. import { Color4 } from "babylonjs/Maths/math.color";
  20147. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20148. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20149. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20150. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20151. import { Texture } from "babylonjs/Materials/Textures/texture";
  20152. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20153. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20154. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20155. import { Engine } from "babylonjs/Engines/engine";
  20156. /**
  20157. * This Helps creating a texture that will be created from a camera in your scene.
  20158. * It is basically a dynamic texture that could be used to create special effects for instance.
  20159. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20160. */
  20161. export class RenderTargetTexture extends Texture {
  20162. isCube: boolean;
  20163. /**
  20164. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20165. */
  20166. static readonly REFRESHRATE_RENDER_ONCE: number;
  20167. /**
  20168. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20169. */
  20170. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20171. /**
  20172. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20173. * the central point of your effect and can save a lot of performances.
  20174. */
  20175. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20176. /**
  20177. * Use this predicate to dynamically define the list of mesh you want to render.
  20178. * If set, the renderList property will be overwritten.
  20179. */
  20180. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20181. private _renderList;
  20182. /**
  20183. * Use this list to define the list of mesh you want to render.
  20184. */
  20185. renderList: Nullable<Array<AbstractMesh>>;
  20186. private _hookArray;
  20187. /**
  20188. * Define if particles should be rendered in your texture.
  20189. */
  20190. renderParticles: boolean;
  20191. /**
  20192. * Define if sprites should be rendered in your texture.
  20193. */
  20194. renderSprites: boolean;
  20195. /**
  20196. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20197. */
  20198. coordinatesMode: number;
  20199. /**
  20200. * Define the camera used to render the texture.
  20201. */
  20202. activeCamera: Nullable<Camera>;
  20203. /**
  20204. * Override the render function of the texture with your own one.
  20205. */
  20206. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20207. /**
  20208. * Define if camera post processes should be use while rendering the texture.
  20209. */
  20210. useCameraPostProcesses: boolean;
  20211. /**
  20212. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20213. */
  20214. ignoreCameraViewport: boolean;
  20215. private _postProcessManager;
  20216. private _postProcesses;
  20217. private _resizeObserver;
  20218. /**
  20219. * An event triggered when the texture is unbind.
  20220. */
  20221. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20222. /**
  20223. * An event triggered when the texture is unbind.
  20224. */
  20225. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20226. private _onAfterUnbindObserver;
  20227. /**
  20228. * Set a after unbind callback in the texture.
  20229. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20230. */
  20231. onAfterUnbind: () => void;
  20232. /**
  20233. * An event triggered before rendering the texture
  20234. */
  20235. onBeforeRenderObservable: Observable<number>;
  20236. private _onBeforeRenderObserver;
  20237. /**
  20238. * Set a before render callback in the texture.
  20239. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20240. */
  20241. onBeforeRender: (faceIndex: number) => void;
  20242. /**
  20243. * An event triggered after rendering the texture
  20244. */
  20245. onAfterRenderObservable: Observable<number>;
  20246. private _onAfterRenderObserver;
  20247. /**
  20248. * Set a after render callback in the texture.
  20249. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20250. */
  20251. onAfterRender: (faceIndex: number) => void;
  20252. /**
  20253. * An event triggered after the texture clear
  20254. */
  20255. onClearObservable: Observable<Engine>;
  20256. private _onClearObserver;
  20257. /**
  20258. * Set a clear callback in the texture.
  20259. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20260. */
  20261. onClear: (Engine: Engine) => void;
  20262. /**
  20263. * An event triggered when the texture is resized.
  20264. */
  20265. onResizeObservable: Observable<RenderTargetTexture>;
  20266. /**
  20267. * Define the clear color of the Render Target if it should be different from the scene.
  20268. */
  20269. clearColor: Color4;
  20270. protected _size: number | {
  20271. width: number;
  20272. height: number;
  20273. };
  20274. protected _initialSizeParameter: number | {
  20275. width: number;
  20276. height: number;
  20277. } | {
  20278. ratio: number;
  20279. };
  20280. protected _sizeRatio: Nullable<number>;
  20281. /** @hidden */
  20282. _generateMipMaps: boolean;
  20283. protected _renderingManager: RenderingManager;
  20284. /** @hidden */
  20285. _waitingRenderList: string[];
  20286. protected _doNotChangeAspectRatio: boolean;
  20287. protected _currentRefreshId: number;
  20288. protected _refreshRate: number;
  20289. protected _textureMatrix: Matrix;
  20290. protected _samples: number;
  20291. protected _renderTargetOptions: RenderTargetCreationOptions;
  20292. /**
  20293. * Gets render target creation options that were used.
  20294. */
  20295. readonly renderTargetOptions: RenderTargetCreationOptions;
  20296. protected _engine: Engine;
  20297. protected _onRatioRescale(): void;
  20298. /**
  20299. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20300. * It must define where the camera used to render the texture is set
  20301. */
  20302. boundingBoxPosition: Vector3;
  20303. private _boundingBoxSize;
  20304. /**
  20305. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20306. * When defined, the cubemap will switch to local mode
  20307. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20308. * @example https://www.babylonjs-playground.com/#RNASML
  20309. */
  20310. boundingBoxSize: Vector3;
  20311. /**
  20312. * In case the RTT has been created with a depth texture, get the associated
  20313. * depth texture.
  20314. * Otherwise, return null.
  20315. */
  20316. depthStencilTexture: Nullable<InternalTexture>;
  20317. /**
  20318. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20319. * or used a shadow, depth texture...
  20320. * @param name The friendly name of the texture
  20321. * @param size The size of the RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  20322. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20323. * @param generateMipMaps True if mip maps need to be generated after render.
  20324. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20325. * @param type The type of the buffer in the RTT (int, half float, float...)
  20326. * @param isCube True if a cube texture needs to be created
  20327. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20328. * @param generateDepthBuffer True to generate a depth buffer
  20329. * @param generateStencilBuffer True to generate a stencil buffer
  20330. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20331. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20332. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20333. */
  20334. constructor(name: string, size: number | {
  20335. width: number;
  20336. height: number;
  20337. } | {
  20338. ratio: number;
  20339. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20340. /**
  20341. * Creates a depth stencil texture.
  20342. * This is only available in WebGL 2 or with the depth texture extension available.
  20343. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20344. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20345. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20346. */
  20347. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20348. private _processSizeParameter;
  20349. /**
  20350. * Define the number of samples to use in case of MSAA.
  20351. * It defaults to one meaning no MSAA has been enabled.
  20352. */
  20353. samples: number;
  20354. /**
  20355. * Resets the refresh counter of the texture and start bak from scratch.
  20356. * Could be useful to regenerate the texture if it is setup to render only once.
  20357. */
  20358. resetRefreshCounter(): void;
  20359. /**
  20360. * Define the refresh rate of the texture or the rendering frequency.
  20361. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20362. */
  20363. refreshRate: number;
  20364. /**
  20365. * Adds a post process to the render target rendering passes.
  20366. * @param postProcess define the post process to add
  20367. */
  20368. addPostProcess(postProcess: PostProcess): void;
  20369. /**
  20370. * Clear all the post processes attached to the render target
  20371. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20372. */
  20373. clearPostProcesses(dispose?: boolean): void;
  20374. /**
  20375. * Remove one of the post process from the list of attached post processes to the texture
  20376. * @param postProcess define the post process to remove from the list
  20377. */
  20378. removePostProcess(postProcess: PostProcess): void;
  20379. /** @hidden */
  20380. _shouldRender(): boolean;
  20381. /**
  20382. * Gets the actual render size of the texture.
  20383. * @returns the width of the render size
  20384. */
  20385. getRenderSize(): number;
  20386. /**
  20387. * Gets the actual render width of the texture.
  20388. * @returns the width of the render size
  20389. */
  20390. getRenderWidth(): number;
  20391. /**
  20392. * Gets the actual render height of the texture.
  20393. * @returns the height of the render size
  20394. */
  20395. getRenderHeight(): number;
  20396. /**
  20397. * Get if the texture can be rescaled or not.
  20398. */
  20399. readonly canRescale: boolean;
  20400. /**
  20401. * Resize the texture using a ratio.
  20402. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20403. */
  20404. scale(ratio: number): void;
  20405. /**
  20406. * Get the texture reflection matrix used to rotate/transform the reflection.
  20407. * @returns the reflection matrix
  20408. */
  20409. getReflectionTextureMatrix(): Matrix;
  20410. /**
  20411. * Resize the texture to a new desired size.
  20412. * Be carrefull as it will recreate all the data in the new texture.
  20413. * @param size Define the new size. It can be:
  20414. * - a number for squared texture,
  20415. * - an object containing { width: number, height: number }
  20416. * - or an object containing a ratio { ratio: number }
  20417. */
  20418. resize(size: number | {
  20419. width: number;
  20420. height: number;
  20421. } | {
  20422. ratio: number;
  20423. }): void;
  20424. /**
  20425. * Renders all the objects from the render list into the texture.
  20426. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20427. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20428. */
  20429. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20430. private _bestReflectionRenderTargetDimension;
  20431. /**
  20432. * @hidden
  20433. * @param faceIndex face index to bind to if this is a cubetexture
  20434. */
  20435. _bindFrameBuffer(faceIndex?: number): void;
  20436. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20437. private renderToTarget;
  20438. /**
  20439. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20440. * This allowed control for front to back rendering or reversly depending of the special needs.
  20441. *
  20442. * @param renderingGroupId The rendering group id corresponding to its index
  20443. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20444. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20445. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20446. */
  20447. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  20448. /**
  20449. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20450. *
  20451. * @param renderingGroupId The rendering group id corresponding to its index
  20452. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20453. */
  20454. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20455. /**
  20456. * Clones the texture.
  20457. * @returns the cloned texture
  20458. */
  20459. clone(): RenderTargetTexture;
  20460. /**
  20461. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20462. * @returns The JSON representation of the texture
  20463. */
  20464. serialize(): any;
  20465. /**
  20466. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20467. */
  20468. disposeFramebufferObjects(): void;
  20469. /**
  20470. * Dispose the texture and release its associated resources.
  20471. */
  20472. dispose(): void;
  20473. /** @hidden */
  20474. _rebuild(): void;
  20475. /**
  20476. * Clear the info related to rendering groups preventing retention point in material dispose.
  20477. */
  20478. freeRenderingGroups(): void;
  20479. /**
  20480. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20481. * @returns the view count
  20482. */
  20483. getViewCount(): number;
  20484. }
  20485. }
  20486. declare module "babylonjs/Materials/material" {
  20487. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20488. import { SmartArray } from "babylonjs/Misc/smartArray";
  20489. import { Observable } from "babylonjs/Misc/observable";
  20490. import { Nullable } from "babylonjs/types";
  20491. import { Scene } from "babylonjs/scene";
  20492. import { Matrix } from "babylonjs/Maths/math.vector";
  20493. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20494. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20495. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20496. import { Effect } from "babylonjs/Materials/effect";
  20497. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20498. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20499. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20500. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20501. import { Mesh } from "babylonjs/Meshes/mesh";
  20502. import { Animation } from "babylonjs/Animations/animation";
  20503. /**
  20504. * Base class for the main features of a material in Babylon.js
  20505. */
  20506. export class Material implements IAnimatable {
  20507. /**
  20508. * Returns the triangle fill mode
  20509. */
  20510. static readonly TriangleFillMode: number;
  20511. /**
  20512. * Returns the wireframe mode
  20513. */
  20514. static readonly WireFrameFillMode: number;
  20515. /**
  20516. * Returns the point fill mode
  20517. */
  20518. static readonly PointFillMode: number;
  20519. /**
  20520. * Returns the point list draw mode
  20521. */
  20522. static readonly PointListDrawMode: number;
  20523. /**
  20524. * Returns the line list draw mode
  20525. */
  20526. static readonly LineListDrawMode: number;
  20527. /**
  20528. * Returns the line loop draw mode
  20529. */
  20530. static readonly LineLoopDrawMode: number;
  20531. /**
  20532. * Returns the line strip draw mode
  20533. */
  20534. static readonly LineStripDrawMode: number;
  20535. /**
  20536. * Returns the triangle strip draw mode
  20537. */
  20538. static readonly TriangleStripDrawMode: number;
  20539. /**
  20540. * Returns the triangle fan draw mode
  20541. */
  20542. static readonly TriangleFanDrawMode: number;
  20543. /**
  20544. * Stores the clock-wise side orientation
  20545. */
  20546. static readonly ClockWiseSideOrientation: number;
  20547. /**
  20548. * Stores the counter clock-wise side orientation
  20549. */
  20550. static readonly CounterClockWiseSideOrientation: number;
  20551. /**
  20552. * The dirty texture flag value
  20553. */
  20554. static readonly TextureDirtyFlag: number;
  20555. /**
  20556. * The dirty light flag value
  20557. */
  20558. static readonly LightDirtyFlag: number;
  20559. /**
  20560. * The dirty fresnel flag value
  20561. */
  20562. static readonly FresnelDirtyFlag: number;
  20563. /**
  20564. * The dirty attribute flag value
  20565. */
  20566. static readonly AttributesDirtyFlag: number;
  20567. /**
  20568. * The dirty misc flag value
  20569. */
  20570. static readonly MiscDirtyFlag: number;
  20571. /**
  20572. * The all dirty flag value
  20573. */
  20574. static readonly AllDirtyFlag: number;
  20575. /**
  20576. * The ID of the material
  20577. */
  20578. id: string;
  20579. /**
  20580. * Gets or sets the unique id of the material
  20581. */
  20582. uniqueId: number;
  20583. /**
  20584. * The name of the material
  20585. */
  20586. name: string;
  20587. /**
  20588. * Gets or sets user defined metadata
  20589. */
  20590. metadata: any;
  20591. /**
  20592. * For internal use only. Please do not use.
  20593. */
  20594. reservedDataStore: any;
  20595. /**
  20596. * Specifies if the ready state should be checked on each call
  20597. */
  20598. checkReadyOnEveryCall: boolean;
  20599. /**
  20600. * Specifies if the ready state should be checked once
  20601. */
  20602. checkReadyOnlyOnce: boolean;
  20603. /**
  20604. * The state of the material
  20605. */
  20606. state: string;
  20607. /**
  20608. * The alpha value of the material
  20609. */
  20610. protected _alpha: number;
  20611. /**
  20612. * List of inspectable custom properties (used by the Inspector)
  20613. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20614. */
  20615. inspectableCustomProperties: IInspectable[];
  20616. /**
  20617. * Sets the alpha value of the material
  20618. */
  20619. /**
  20620. * Gets the alpha value of the material
  20621. */
  20622. alpha: number;
  20623. /**
  20624. * Specifies if back face culling is enabled
  20625. */
  20626. protected _backFaceCulling: boolean;
  20627. /**
  20628. * Sets the back-face culling state
  20629. */
  20630. /**
  20631. * Gets the back-face culling state
  20632. */
  20633. backFaceCulling: boolean;
  20634. /**
  20635. * Stores the value for side orientation
  20636. */
  20637. sideOrientation: number;
  20638. /**
  20639. * Callback triggered when the material is compiled
  20640. */
  20641. onCompiled: Nullable<(effect: Effect) => void>;
  20642. /**
  20643. * Callback triggered when an error occurs
  20644. */
  20645. onError: Nullable<(effect: Effect, errors: string) => void>;
  20646. /**
  20647. * Callback triggered to get the render target textures
  20648. */
  20649. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20650. /**
  20651. * Gets a boolean indicating that current material needs to register RTT
  20652. */
  20653. readonly hasRenderTargetTextures: boolean;
  20654. /**
  20655. * Specifies if the material should be serialized
  20656. */
  20657. doNotSerialize: boolean;
  20658. /**
  20659. * @hidden
  20660. */
  20661. _storeEffectOnSubMeshes: boolean;
  20662. /**
  20663. * Stores the animations for the material
  20664. */
  20665. animations: Nullable<Array<Animation>>;
  20666. /**
  20667. * An event triggered when the material is disposed
  20668. */
  20669. onDisposeObservable: Observable<Material>;
  20670. /**
  20671. * An observer which watches for dispose events
  20672. */
  20673. private _onDisposeObserver;
  20674. private _onUnBindObservable;
  20675. /**
  20676. * Called during a dispose event
  20677. */
  20678. onDispose: () => void;
  20679. private _onBindObservable;
  20680. /**
  20681. * An event triggered when the material is bound
  20682. */
  20683. readonly onBindObservable: Observable<AbstractMesh>;
  20684. /**
  20685. * An observer which watches for bind events
  20686. */
  20687. private _onBindObserver;
  20688. /**
  20689. * Called during a bind event
  20690. */
  20691. onBind: (Mesh: AbstractMesh) => void;
  20692. /**
  20693. * An event triggered when the material is unbound
  20694. */
  20695. readonly onUnBindObservable: Observable<Material>;
  20696. /**
  20697. * Stores the value of the alpha mode
  20698. */
  20699. private _alphaMode;
  20700. /**
  20701. * Sets the value of the alpha mode.
  20702. *
  20703. * | Value | Type | Description |
  20704. * | --- | --- | --- |
  20705. * | 0 | ALPHA_DISABLE | |
  20706. * | 1 | ALPHA_ADD | |
  20707. * | 2 | ALPHA_COMBINE | |
  20708. * | 3 | ALPHA_SUBTRACT | |
  20709. * | 4 | ALPHA_MULTIPLY | |
  20710. * | 5 | ALPHA_MAXIMIZED | |
  20711. * | 6 | ALPHA_ONEONE | |
  20712. * | 7 | ALPHA_PREMULTIPLIED | |
  20713. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20714. * | 9 | ALPHA_INTERPOLATE | |
  20715. * | 10 | ALPHA_SCREENMODE | |
  20716. *
  20717. */
  20718. /**
  20719. * Gets the value of the alpha mode
  20720. */
  20721. alphaMode: number;
  20722. /**
  20723. * Stores the state of the need depth pre-pass value
  20724. */
  20725. private _needDepthPrePass;
  20726. /**
  20727. * Sets the need depth pre-pass value
  20728. */
  20729. /**
  20730. * Gets the depth pre-pass value
  20731. */
  20732. needDepthPrePass: boolean;
  20733. /**
  20734. * Specifies if depth writing should be disabled
  20735. */
  20736. disableDepthWrite: boolean;
  20737. /**
  20738. * Specifies if depth writing should be forced
  20739. */
  20740. forceDepthWrite: boolean;
  20741. /**
  20742. * Specifies if there should be a separate pass for culling
  20743. */
  20744. separateCullingPass: boolean;
  20745. /**
  20746. * Stores the state specifing if fog should be enabled
  20747. */
  20748. private _fogEnabled;
  20749. /**
  20750. * Sets the state for enabling fog
  20751. */
  20752. /**
  20753. * Gets the value of the fog enabled state
  20754. */
  20755. fogEnabled: boolean;
  20756. /**
  20757. * Stores the size of points
  20758. */
  20759. pointSize: number;
  20760. /**
  20761. * Stores the z offset value
  20762. */
  20763. zOffset: number;
  20764. /**
  20765. * Gets a value specifying if wireframe mode is enabled
  20766. */
  20767. /**
  20768. * Sets the state of wireframe mode
  20769. */
  20770. wireframe: boolean;
  20771. /**
  20772. * Gets the value specifying if point clouds are enabled
  20773. */
  20774. /**
  20775. * Sets the state of point cloud mode
  20776. */
  20777. pointsCloud: boolean;
  20778. /**
  20779. * Gets the material fill mode
  20780. */
  20781. /**
  20782. * Sets the material fill mode
  20783. */
  20784. fillMode: number;
  20785. /**
  20786. * @hidden
  20787. * Stores the effects for the material
  20788. */
  20789. _effect: Nullable<Effect>;
  20790. /**
  20791. * @hidden
  20792. * Specifies if the material was previously ready
  20793. */
  20794. _wasPreviouslyReady: boolean;
  20795. /**
  20796. * Specifies if uniform buffers should be used
  20797. */
  20798. private _useUBO;
  20799. /**
  20800. * Stores a reference to the scene
  20801. */
  20802. private _scene;
  20803. /**
  20804. * Stores the fill mode state
  20805. */
  20806. private _fillMode;
  20807. /**
  20808. * Specifies if the depth write state should be cached
  20809. */
  20810. private _cachedDepthWriteState;
  20811. /**
  20812. * Stores the uniform buffer
  20813. */
  20814. protected _uniformBuffer: UniformBuffer;
  20815. /** @hidden */
  20816. _indexInSceneMaterialArray: number;
  20817. /** @hidden */
  20818. meshMap: Nullable<{
  20819. [id: string]: AbstractMesh | undefined;
  20820. }>;
  20821. /**
  20822. * Creates a material instance
  20823. * @param name defines the name of the material
  20824. * @param scene defines the scene to reference
  20825. * @param doNotAdd specifies if the material should be added to the scene
  20826. */
  20827. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20828. /**
  20829. * Returns a string representation of the current material
  20830. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20831. * @returns a string with material information
  20832. */
  20833. toString(fullDetails?: boolean): string;
  20834. /**
  20835. * Gets the class name of the material
  20836. * @returns a string with the class name of the material
  20837. */
  20838. getClassName(): string;
  20839. /**
  20840. * Specifies if updates for the material been locked
  20841. */
  20842. readonly isFrozen: boolean;
  20843. /**
  20844. * Locks updates for the material
  20845. */
  20846. freeze(): void;
  20847. /**
  20848. * Unlocks updates for the material
  20849. */
  20850. unfreeze(): void;
  20851. /**
  20852. * Specifies if the material is ready to be used
  20853. * @param mesh defines the mesh to check
  20854. * @param useInstances specifies if instances should be used
  20855. * @returns a boolean indicating if the material is ready to be used
  20856. */
  20857. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20858. /**
  20859. * Specifies that the submesh is ready to be used
  20860. * @param mesh defines the mesh to check
  20861. * @param subMesh defines which submesh to check
  20862. * @param useInstances specifies that instances should be used
  20863. * @returns a boolean indicating that the submesh is ready or not
  20864. */
  20865. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20866. /**
  20867. * Returns the material effect
  20868. * @returns the effect associated with the material
  20869. */
  20870. getEffect(): Nullable<Effect>;
  20871. /**
  20872. * Returns the current scene
  20873. * @returns a Scene
  20874. */
  20875. getScene(): Scene;
  20876. /**
  20877. * Specifies if the material will require alpha blending
  20878. * @returns a boolean specifying if alpha blending is needed
  20879. */
  20880. needAlphaBlending(): boolean;
  20881. /**
  20882. * Specifies if the mesh will require alpha blending
  20883. * @param mesh defines the mesh to check
  20884. * @returns a boolean specifying if alpha blending is needed for the mesh
  20885. */
  20886. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20887. /**
  20888. * Specifies if this material should be rendered in alpha test mode
  20889. * @returns a boolean specifying if an alpha test is needed.
  20890. */
  20891. needAlphaTesting(): boolean;
  20892. /**
  20893. * Gets the texture used for the alpha test
  20894. * @returns the texture to use for alpha testing
  20895. */
  20896. getAlphaTestTexture(): Nullable<BaseTexture>;
  20897. /**
  20898. * Marks the material to indicate that it needs to be re-calculated
  20899. */
  20900. markDirty(): void;
  20901. /** @hidden */
  20902. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20903. /**
  20904. * Binds the material to the mesh
  20905. * @param world defines the world transformation matrix
  20906. * @param mesh defines the mesh to bind the material to
  20907. */
  20908. bind(world: Matrix, mesh?: Mesh): void;
  20909. /**
  20910. * Binds the submesh to the material
  20911. * @param world defines the world transformation matrix
  20912. * @param mesh defines the mesh containing the submesh
  20913. * @param subMesh defines the submesh to bind the material to
  20914. */
  20915. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20916. /**
  20917. * Binds the world matrix to the material
  20918. * @param world defines the world transformation matrix
  20919. */
  20920. bindOnlyWorldMatrix(world: Matrix): void;
  20921. /**
  20922. * Binds the scene's uniform buffer to the effect.
  20923. * @param effect defines the effect to bind to the scene uniform buffer
  20924. * @param sceneUbo defines the uniform buffer storing scene data
  20925. */
  20926. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20927. /**
  20928. * Binds the view matrix to the effect
  20929. * @param effect defines the effect to bind the view matrix to
  20930. */
  20931. bindView(effect: Effect): void;
  20932. /**
  20933. * Binds the view projection matrix to the effect
  20934. * @param effect defines the effect to bind the view projection matrix to
  20935. */
  20936. bindViewProjection(effect: Effect): void;
  20937. /**
  20938. * Specifies if material alpha testing should be turned on for the mesh
  20939. * @param mesh defines the mesh to check
  20940. */
  20941. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20942. /**
  20943. * Processes to execute after binding the material to a mesh
  20944. * @param mesh defines the rendered mesh
  20945. */
  20946. protected _afterBind(mesh?: Mesh): void;
  20947. /**
  20948. * Unbinds the material from the mesh
  20949. */
  20950. unbind(): void;
  20951. /**
  20952. * Gets the active textures from the material
  20953. * @returns an array of textures
  20954. */
  20955. getActiveTextures(): BaseTexture[];
  20956. /**
  20957. * Specifies if the material uses a texture
  20958. * @param texture defines the texture to check against the material
  20959. * @returns a boolean specifying if the material uses the texture
  20960. */
  20961. hasTexture(texture: BaseTexture): boolean;
  20962. /**
  20963. * Makes a duplicate of the material, and gives it a new name
  20964. * @param name defines the new name for the duplicated material
  20965. * @returns the cloned material
  20966. */
  20967. clone(name: string): Nullable<Material>;
  20968. /**
  20969. * Gets the meshes bound to the material
  20970. * @returns an array of meshes bound to the material
  20971. */
  20972. getBindedMeshes(): AbstractMesh[];
  20973. /**
  20974. * Force shader compilation
  20975. * @param mesh defines the mesh associated with this material
  20976. * @param onCompiled defines a function to execute once the material is compiled
  20977. * @param options defines the options to configure the compilation
  20978. */
  20979. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20980. clipPlane: boolean;
  20981. }>): void;
  20982. /**
  20983. * Force shader compilation
  20984. * @param mesh defines the mesh that will use this material
  20985. * @param options defines additional options for compiling the shaders
  20986. * @returns a promise that resolves when the compilation completes
  20987. */
  20988. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  20989. clipPlane: boolean;
  20990. }>): Promise<void>;
  20991. private static readonly _AllDirtyCallBack;
  20992. private static readonly _ImageProcessingDirtyCallBack;
  20993. private static readonly _TextureDirtyCallBack;
  20994. private static readonly _FresnelDirtyCallBack;
  20995. private static readonly _MiscDirtyCallBack;
  20996. private static readonly _LightsDirtyCallBack;
  20997. private static readonly _AttributeDirtyCallBack;
  20998. private static _FresnelAndMiscDirtyCallBack;
  20999. private static _TextureAndMiscDirtyCallBack;
  21000. private static readonly _DirtyCallbackArray;
  21001. private static readonly _RunDirtyCallBacks;
  21002. /**
  21003. * Marks a define in the material to indicate that it needs to be re-computed
  21004. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21005. */
  21006. markAsDirty(flag: number): void;
  21007. /**
  21008. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21009. * @param func defines a function which checks material defines against the submeshes
  21010. */
  21011. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21012. /**
  21013. * Indicates that we need to re-calculated for all submeshes
  21014. */
  21015. protected _markAllSubMeshesAsAllDirty(): void;
  21016. /**
  21017. * Indicates that image processing needs to be re-calculated for all submeshes
  21018. */
  21019. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21020. /**
  21021. * Indicates that textures need to be re-calculated for all submeshes
  21022. */
  21023. protected _markAllSubMeshesAsTexturesDirty(): void;
  21024. /**
  21025. * Indicates that fresnel needs to be re-calculated for all submeshes
  21026. */
  21027. protected _markAllSubMeshesAsFresnelDirty(): void;
  21028. /**
  21029. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21030. */
  21031. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21032. /**
  21033. * Indicates that lights need to be re-calculated for all submeshes
  21034. */
  21035. protected _markAllSubMeshesAsLightsDirty(): void;
  21036. /**
  21037. * Indicates that attributes need to be re-calculated for all submeshes
  21038. */
  21039. protected _markAllSubMeshesAsAttributesDirty(): void;
  21040. /**
  21041. * Indicates that misc needs to be re-calculated for all submeshes
  21042. */
  21043. protected _markAllSubMeshesAsMiscDirty(): void;
  21044. /**
  21045. * Indicates that textures and misc need to be re-calculated for all submeshes
  21046. */
  21047. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21048. /**
  21049. * Disposes the material
  21050. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21051. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21052. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21053. */
  21054. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21055. /** @hidden */
  21056. private releaseVertexArrayObject;
  21057. /**
  21058. * Serializes this material
  21059. * @returns the serialized material object
  21060. */
  21061. serialize(): any;
  21062. /**
  21063. * Creates a material from parsed material data
  21064. * @param parsedMaterial defines parsed material data
  21065. * @param scene defines the hosting scene
  21066. * @param rootUrl defines the root URL to use to load textures
  21067. * @returns a new material
  21068. */
  21069. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21070. }
  21071. }
  21072. declare module "babylonjs/Materials/multiMaterial" {
  21073. import { Nullable } from "babylonjs/types";
  21074. import { Scene } from "babylonjs/scene";
  21075. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21076. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21077. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21078. import { Material } from "babylonjs/Materials/material";
  21079. /**
  21080. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21081. * separate meshes. This can be use to improve performances.
  21082. * @see http://doc.babylonjs.com/how_to/multi_materials
  21083. */
  21084. export class MultiMaterial extends Material {
  21085. private _subMaterials;
  21086. /**
  21087. * Gets or Sets the list of Materials used within the multi material.
  21088. * They need to be ordered according to the submeshes order in the associated mesh
  21089. */
  21090. subMaterials: Nullable<Material>[];
  21091. /**
  21092. * Function used to align with Node.getChildren()
  21093. * @returns the list of Materials used within the multi material
  21094. */
  21095. getChildren(): Nullable<Material>[];
  21096. /**
  21097. * Instantiates a new Multi Material
  21098. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21099. * separate meshes. This can be use to improve performances.
  21100. * @see http://doc.babylonjs.com/how_to/multi_materials
  21101. * @param name Define the name in the scene
  21102. * @param scene Define the scene the material belongs to
  21103. */
  21104. constructor(name: string, scene: Scene);
  21105. private _hookArray;
  21106. /**
  21107. * Get one of the submaterial by its index in the submaterials array
  21108. * @param index The index to look the sub material at
  21109. * @returns The Material if the index has been defined
  21110. */
  21111. getSubMaterial(index: number): Nullable<Material>;
  21112. /**
  21113. * Get the list of active textures for the whole sub materials list.
  21114. * @returns All the textures that will be used during the rendering
  21115. */
  21116. getActiveTextures(): BaseTexture[];
  21117. /**
  21118. * Gets the current class name of the material e.g. "MultiMaterial"
  21119. * Mainly use in serialization.
  21120. * @returns the class name
  21121. */
  21122. getClassName(): string;
  21123. /**
  21124. * Checks if the material is ready to render the requested sub mesh
  21125. * @param mesh Define the mesh the submesh belongs to
  21126. * @param subMesh Define the sub mesh to look readyness for
  21127. * @param useInstances Define whether or not the material is used with instances
  21128. * @returns true if ready, otherwise false
  21129. */
  21130. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21131. /**
  21132. * Clones the current material and its related sub materials
  21133. * @param name Define the name of the newly cloned material
  21134. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21135. * @returns the cloned material
  21136. */
  21137. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21138. /**
  21139. * Serializes the materials into a JSON representation.
  21140. * @returns the JSON representation
  21141. */
  21142. serialize(): any;
  21143. /**
  21144. * Dispose the material and release its associated resources
  21145. * @param forceDisposeEffect Define if we want to force disposing the associated effect (if false the shader is not released and could be reuse later on)
  21146. * @param forceDisposeTextures Define if we want to force disposing the associated textures (if false, they will not be disposed and can still be use elsewhere in the app)
  21147. * @param forceDisposeChildren Define if we want to force disposing the associated submaterials (if false, they will not be disposed and can still be use elsewhere in the app)
  21148. */
  21149. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21150. /**
  21151. * Creates a MultiMaterial from parsed MultiMaterial data.
  21152. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21153. * @param scene defines the hosting scene
  21154. * @returns a new MultiMaterial
  21155. */
  21156. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21157. }
  21158. }
  21159. declare module "babylonjs/Meshes/subMesh" {
  21160. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21161. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21162. import { Engine } from "babylonjs/Engines/engine";
  21163. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21164. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21165. import { Effect } from "babylonjs/Materials/effect";
  21166. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21167. import { Plane } from "babylonjs/Maths/math.plane";
  21168. import { Collider } from "babylonjs/Collisions/collider";
  21169. import { Material } from "babylonjs/Materials/material";
  21170. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21171. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21172. import { Mesh } from "babylonjs/Meshes/mesh";
  21173. import { Ray } from "babylonjs/Culling/ray";
  21174. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21175. /**
  21176. * Base class for submeshes
  21177. */
  21178. export class BaseSubMesh {
  21179. /** @hidden */
  21180. _materialDefines: Nullable<MaterialDefines>;
  21181. /** @hidden */
  21182. _materialEffect: Nullable<Effect>;
  21183. /**
  21184. * Gets associated effect
  21185. */
  21186. readonly effect: Nullable<Effect>;
  21187. /**
  21188. * Sets associated effect (effect used to render this submesh)
  21189. * @param effect defines the effect to associate with
  21190. * @param defines defines the set of defines used to compile this effect
  21191. */
  21192. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21193. }
  21194. /**
  21195. * Defines a subdivision inside a mesh
  21196. */
  21197. export class SubMesh extends BaseSubMesh implements ICullable {
  21198. /** the material index to use */
  21199. materialIndex: number;
  21200. /** vertex index start */
  21201. verticesStart: number;
  21202. /** vertices count */
  21203. verticesCount: number;
  21204. /** index start */
  21205. indexStart: number;
  21206. /** indices count */
  21207. indexCount: number;
  21208. /** @hidden */
  21209. _linesIndexCount: number;
  21210. private _mesh;
  21211. private _renderingMesh;
  21212. private _boundingInfo;
  21213. private _linesIndexBuffer;
  21214. /** @hidden */
  21215. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21216. /** @hidden */
  21217. _trianglePlanes: Plane[];
  21218. /** @hidden */
  21219. _lastColliderTransformMatrix: Nullable<Matrix>;
  21220. /** @hidden */
  21221. _renderId: number;
  21222. /** @hidden */
  21223. _alphaIndex: number;
  21224. /** @hidden */
  21225. _distanceToCamera: number;
  21226. /** @hidden */
  21227. _id: number;
  21228. private _currentMaterial;
  21229. /**
  21230. * Add a new submesh to a mesh
  21231. * @param materialIndex defines the material index to use
  21232. * @param verticesStart defines vertex index start
  21233. * @param verticesCount defines vertices count
  21234. * @param indexStart defines index start
  21235. * @param indexCount defines indices count
  21236. * @param mesh defines the parent mesh
  21237. * @param renderingMesh defines an optional rendering mesh
  21238. * @param createBoundingBox defines if bounding box should be created for this submesh
  21239. * @returns the new submesh
  21240. */
  21241. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21242. /**
  21243. * Creates a new submesh
  21244. * @param materialIndex defines the material index to use
  21245. * @param verticesStart defines vertex index start
  21246. * @param verticesCount defines vertices count
  21247. * @param indexStart defines index start
  21248. * @param indexCount defines indices count
  21249. * @param mesh defines the parent mesh
  21250. * @param renderingMesh defines an optional rendering mesh
  21251. * @param createBoundingBox defines if bounding box should be created for this submesh
  21252. */
  21253. constructor(
  21254. /** the material index to use */
  21255. materialIndex: number,
  21256. /** vertex index start */
  21257. verticesStart: number,
  21258. /** vertices count */
  21259. verticesCount: number,
  21260. /** index start */
  21261. indexStart: number,
  21262. /** indices count */
  21263. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21264. /**
  21265. * Returns true if this submesh covers the entire parent mesh
  21266. * @ignorenaming
  21267. */
  21268. readonly IsGlobal: boolean;
  21269. /**
  21270. * Returns the submesh BoudingInfo object
  21271. * @returns current bounding info (or mesh's one if the submesh is global)
  21272. */
  21273. getBoundingInfo(): BoundingInfo;
  21274. /**
  21275. * Sets the submesh BoundingInfo
  21276. * @param boundingInfo defines the new bounding info to use
  21277. * @returns the SubMesh
  21278. */
  21279. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21280. /**
  21281. * Returns the mesh of the current submesh
  21282. * @return the parent mesh
  21283. */
  21284. getMesh(): AbstractMesh;
  21285. /**
  21286. * Returns the rendering mesh of the submesh
  21287. * @returns the rendering mesh (could be different from parent mesh)
  21288. */
  21289. getRenderingMesh(): Mesh;
  21290. /**
  21291. * Returns the submesh material
  21292. * @returns null or the current material
  21293. */
  21294. getMaterial(): Nullable<Material>;
  21295. /**
  21296. * Sets a new updated BoundingInfo object to the submesh
  21297. * @param data defines an optional position array to use to determine the bounding info
  21298. * @returns the SubMesh
  21299. */
  21300. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21301. /** @hidden */
  21302. _checkCollision(collider: Collider): boolean;
  21303. /**
  21304. * Updates the submesh BoundingInfo
  21305. * @param world defines the world matrix to use to update the bounding info
  21306. * @returns the submesh
  21307. */
  21308. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21309. /**
  21310. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21311. * @param frustumPlanes defines the frustum planes
  21312. * @returns true if the submesh is intersecting with the frustum
  21313. */
  21314. isInFrustum(frustumPlanes: Plane[]): boolean;
  21315. /**
  21316. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21317. * @param frustumPlanes defines the frustum planes
  21318. * @returns true if the submesh is inside the frustum
  21319. */
  21320. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21321. /**
  21322. * Renders the submesh
  21323. * @param enableAlphaMode defines if alpha needs to be used
  21324. * @returns the submesh
  21325. */
  21326. render(enableAlphaMode: boolean): SubMesh;
  21327. /**
  21328. * @hidden
  21329. */
  21330. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21331. /**
  21332. * Checks if the submesh intersects with a ray
  21333. * @param ray defines the ray to test
  21334. * @returns true is the passed ray intersects the submesh bounding box
  21335. */
  21336. canIntersects(ray: Ray): boolean;
  21337. /**
  21338. * Intersects current submesh with a ray
  21339. * @param ray defines the ray to test
  21340. * @param positions defines mesh's positions array
  21341. * @param indices defines mesh's indices array
  21342. * @param fastCheck defines if only bounding info should be used
  21343. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21344. * @returns intersection info or null if no intersection
  21345. */
  21346. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21347. /** @hidden */
  21348. private _intersectLines;
  21349. /** @hidden */
  21350. private _intersectUnIndexedLines;
  21351. /** @hidden */
  21352. private _intersectTriangles;
  21353. /** @hidden */
  21354. private _intersectUnIndexedTriangles;
  21355. /** @hidden */
  21356. _rebuild(): void;
  21357. /**
  21358. * Creates a new submesh from the passed mesh
  21359. * @param newMesh defines the new hosting mesh
  21360. * @param newRenderingMesh defines an optional rendering mesh
  21361. * @returns the new submesh
  21362. */
  21363. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21364. /**
  21365. * Release associated resources
  21366. */
  21367. dispose(): void;
  21368. /**
  21369. * Gets the class name
  21370. * @returns the string "SubMesh".
  21371. */
  21372. getClassName(): string;
  21373. /**
  21374. * Creates a new submesh from indices data
  21375. * @param materialIndex the index of the main mesh material
  21376. * @param startIndex the index where to start the copy in the mesh indices array
  21377. * @param indexCount the number of indices to copy then from the startIndex
  21378. * @param mesh the main mesh to create the submesh from
  21379. * @param renderingMesh the optional rendering mesh
  21380. * @returns a new submesh
  21381. */
  21382. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21383. }
  21384. }
  21385. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21386. /**
  21387. * Class used to represent data loading progression
  21388. */
  21389. export class SceneLoaderFlags {
  21390. private static _ForceFullSceneLoadingForIncremental;
  21391. private static _ShowLoadingScreen;
  21392. private static _CleanBoneMatrixWeights;
  21393. private static _loggingLevel;
  21394. /**
  21395. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21396. */
  21397. static ForceFullSceneLoadingForIncremental: boolean;
  21398. /**
  21399. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21400. */
  21401. static ShowLoadingScreen: boolean;
  21402. /**
  21403. * Defines the current logging level (while loading the scene)
  21404. * @ignorenaming
  21405. */
  21406. static loggingLevel: number;
  21407. /**
  21408. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21409. */
  21410. static CleanBoneMatrixWeights: boolean;
  21411. }
  21412. }
  21413. declare module "babylonjs/Meshes/geometry" {
  21414. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21415. import { Scene } from "babylonjs/scene";
  21416. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21417. import { Engine } from "babylonjs/Engines/engine";
  21418. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21419. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21420. import { Effect } from "babylonjs/Materials/effect";
  21421. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21422. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21423. import { Mesh } from "babylonjs/Meshes/mesh";
  21424. /**
  21425. * Class used to store geometry data (vertex buffers + index buffer)
  21426. */
  21427. export class Geometry implements IGetSetVerticesData {
  21428. /**
  21429. * Gets or sets the ID of the geometry
  21430. */
  21431. id: string;
  21432. /**
  21433. * Gets or sets the unique ID of the geometry
  21434. */
  21435. uniqueId: number;
  21436. /**
  21437. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21438. */
  21439. delayLoadState: number;
  21440. /**
  21441. * Gets the file containing the data to load when running in delay load state
  21442. */
  21443. delayLoadingFile: Nullable<string>;
  21444. /**
  21445. * Callback called when the geometry is updated
  21446. */
  21447. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21448. private _scene;
  21449. private _engine;
  21450. private _meshes;
  21451. private _totalVertices;
  21452. /** @hidden */
  21453. _indices: IndicesArray;
  21454. /** @hidden */
  21455. _vertexBuffers: {
  21456. [key: string]: VertexBuffer;
  21457. };
  21458. private _isDisposed;
  21459. private _extend;
  21460. private _boundingBias;
  21461. /** @hidden */
  21462. _delayInfo: Array<string>;
  21463. private _indexBuffer;
  21464. private _indexBufferIsUpdatable;
  21465. /** @hidden */
  21466. _boundingInfo: Nullable<BoundingInfo>;
  21467. /** @hidden */
  21468. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21469. /** @hidden */
  21470. _softwareSkinningFrameId: number;
  21471. private _vertexArrayObjects;
  21472. private _updatable;
  21473. /** @hidden */
  21474. _positions: Nullable<Vector3[]>;
  21475. /**
  21476. * Gets or sets the Bias Vector to apply on the bounding elements (box/sphere), the max extend is computed as v += v * bias.x + bias.y, the min is computed as v -= v * bias.x + bias.y
  21477. */
  21478. /**
  21479. * Gets or sets the Bias Vector to apply on the bounding elements (box/sphere), the max extend is computed as v += v * bias.x + bias.y, the min is computed as v -= v * bias.x + bias.y
  21480. */
  21481. boundingBias: Vector2;
  21482. /**
  21483. * Static function used to attach a new empty geometry to a mesh
  21484. * @param mesh defines the mesh to attach the geometry to
  21485. * @returns the new Geometry
  21486. */
  21487. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21488. /**
  21489. * Creates a new geometry
  21490. * @param id defines the unique ID
  21491. * @param scene defines the hosting scene
  21492. * @param vertexData defines the VertexData used to get geometry data
  21493. * @param updatable defines if geometry must be updatable (false by default)
  21494. * @param mesh defines the mesh that will be associated with the geometry
  21495. */
  21496. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21497. /**
  21498. * Gets the current extend of the geometry
  21499. */
  21500. readonly extend: {
  21501. minimum: Vector3;
  21502. maximum: Vector3;
  21503. };
  21504. /**
  21505. * Gets the hosting scene
  21506. * @returns the hosting Scene
  21507. */
  21508. getScene(): Scene;
  21509. /**
  21510. * Gets the hosting engine
  21511. * @returns the hosting Engine
  21512. */
  21513. getEngine(): Engine;
  21514. /**
  21515. * Defines if the geometry is ready to use
  21516. * @returns true if the geometry is ready to be used
  21517. */
  21518. isReady(): boolean;
  21519. /**
  21520. * Gets a value indicating that the geometry should not be serialized
  21521. */
  21522. readonly doNotSerialize: boolean;
  21523. /** @hidden */
  21524. _rebuild(): void;
  21525. /**
  21526. * Affects all geometry data in one call
  21527. * @param vertexData defines the geometry data
  21528. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21529. */
  21530. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21531. /**
  21532. * Set specific vertex data
  21533. * @param kind defines the data kind (Position, normal, etc...)
  21534. * @param data defines the vertex data to use
  21535. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21536. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21537. */
  21538. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21539. /**
  21540. * Removes a specific vertex data
  21541. * @param kind defines the data kind (Position, normal, etc...)
  21542. */
  21543. removeVerticesData(kind: string): void;
  21544. /**
  21545. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21546. * @param buffer defines the vertex buffer to use
  21547. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21548. */
  21549. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21550. /**
  21551. * Update a specific vertex buffer
  21552. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21553. * It will do nothing if the buffer is not updatable
  21554. * @param kind defines the data kind (Position, normal, etc...)
  21555. * @param data defines the data to use
  21556. * @param offset defines the offset in the target buffer where to store the data
  21557. * @param useBytes set to true if the offset is in bytes
  21558. */
  21559. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21560. /**
  21561. * Update a specific vertex buffer
  21562. * This function will create a new buffer if the current one is not updatable
  21563. * @param kind defines the data kind (Position, normal, etc...)
  21564. * @param data defines the data to use
  21565. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21566. */
  21567. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21568. private _updateBoundingInfo;
  21569. /** @hidden */
  21570. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21571. /**
  21572. * Gets total number of vertices
  21573. * @returns the total number of vertices
  21574. */
  21575. getTotalVertices(): number;
  21576. /**
  21577. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21578. * @param kind defines the data kind (Position, normal, etc...)
  21579. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21580. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21581. * @returns a float array containing vertex data
  21582. */
  21583. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21584. /**
  21585. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21586. * @param kind defines the data kind (Position, normal, etc...)
  21587. * @returns true if the vertex buffer with the specified kind is updatable
  21588. */
  21589. isVertexBufferUpdatable(kind: string): boolean;
  21590. /**
  21591. * Gets a specific vertex buffer
  21592. * @param kind defines the data kind (Position, normal, etc...)
  21593. * @returns a VertexBuffer
  21594. */
  21595. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21596. /**
  21597. * Returns all vertex buffers
  21598. * @return an object holding all vertex buffers indexed by kind
  21599. */
  21600. getVertexBuffers(): Nullable<{
  21601. [key: string]: VertexBuffer;
  21602. }>;
  21603. /**
  21604. * Gets a boolean indicating if specific vertex buffer is present
  21605. * @param kind defines the data kind (Position, normal, etc...)
  21606. * @returns true if data is present
  21607. */
  21608. isVerticesDataPresent(kind: string): boolean;
  21609. /**
  21610. * Gets a list of all attached data kinds (Position, normal, etc...)
  21611. * @returns a list of string containing all kinds
  21612. */
  21613. getVerticesDataKinds(): string[];
  21614. /**
  21615. * Update index buffer
  21616. * @param indices defines the indices to store in the index buffer
  21617. * @param offset defines the offset in the target buffer where to store the data
  21618. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  21619. */
  21620. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21621. /**
  21622. * Creates a new index buffer
  21623. * @param indices defines the indices to store in the index buffer
  21624. * @param totalVertices defines the total number of vertices (could be null)
  21625. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21626. */
  21627. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21628. /**
  21629. * Return the total number of indices
  21630. * @returns the total number of indices
  21631. */
  21632. getTotalIndices(): number;
  21633. /**
  21634. * Gets the index buffer array
  21635. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21636. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21637. * @returns the index buffer array
  21638. */
  21639. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21640. /**
  21641. * Gets the index buffer
  21642. * @return the index buffer
  21643. */
  21644. getIndexBuffer(): Nullable<DataBuffer>;
  21645. /** @hidden */
  21646. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21647. /**
  21648. * Release the associated resources for a specific mesh
  21649. * @param mesh defines the source mesh
  21650. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21651. */
  21652. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21653. /**
  21654. * Apply current geometry to a given mesh
  21655. * @param mesh defines the mesh to apply geometry to
  21656. */
  21657. applyToMesh(mesh: Mesh): void;
  21658. private _updateExtend;
  21659. private _applyToMesh;
  21660. private notifyUpdate;
  21661. /**
  21662. * Load the geometry if it was flagged as delay loaded
  21663. * @param scene defines the hosting scene
  21664. * @param onLoaded defines a callback called when the geometry is loaded
  21665. */
  21666. load(scene: Scene, onLoaded?: () => void): void;
  21667. private _queueLoad;
  21668. /**
  21669. * Invert the geometry to move from a right handed system to a left handed one.
  21670. */
  21671. toLeftHanded(): void;
  21672. /** @hidden */
  21673. _resetPointsArrayCache(): void;
  21674. /** @hidden */
  21675. _generatePointsArray(): boolean;
  21676. /**
  21677. * Gets a value indicating if the geometry is disposed
  21678. * @returns true if the geometry was disposed
  21679. */
  21680. isDisposed(): boolean;
  21681. private _disposeVertexArrayObjects;
  21682. /**
  21683. * Free all associated resources
  21684. */
  21685. dispose(): void;
  21686. /**
  21687. * Clone the current geometry into a new geometry
  21688. * @param id defines the unique ID of the new geometry
  21689. * @returns a new geometry object
  21690. */
  21691. copy(id: string): Geometry;
  21692. /**
  21693. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21694. * @return a JSON representation of the current geometry data (without the vertices data)
  21695. */
  21696. serialize(): any;
  21697. private toNumberArray;
  21698. /**
  21699. * Serialize all vertices data into a JSON oject
  21700. * @returns a JSON representation of the current geometry data
  21701. */
  21702. serializeVerticeData(): any;
  21703. /**
  21704. * Extracts a clone of a mesh geometry
  21705. * @param mesh defines the source mesh
  21706. * @param id defines the unique ID of the new geometry object
  21707. * @returns the new geometry object
  21708. */
  21709. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21710. /**
  21711. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21712. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21713. * Be aware Math.random() could cause collisions, but:
  21714. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  21715. * @returns a string containing a new GUID
  21716. */
  21717. static RandomId(): string;
  21718. /** @hidden */
  21719. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21720. private static _CleanMatricesWeights;
  21721. /**
  21722. * Create a new geometry from persisted data (Using .babylon file format)
  21723. * @param parsedVertexData defines the persisted data
  21724. * @param scene defines the hosting scene
  21725. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21726. * @returns the new geometry object
  21727. */
  21728. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21729. }
  21730. }
  21731. declare module "babylonjs/Meshes/mesh.vertexData" {
  21732. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  21733. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  21734. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  21735. import { Geometry } from "babylonjs/Meshes/geometry";
  21736. import { Mesh } from "babylonjs/Meshes/mesh";
  21737. /**
  21738. * Define an interface for all classes that will get and set the data on vertices
  21739. */
  21740. export interface IGetSetVerticesData {
  21741. /**
  21742. * Gets a boolean indicating if specific vertex data is present
  21743. * @param kind defines the vertex data kind to use
  21744. * @returns true is data kind is present
  21745. */
  21746. isVerticesDataPresent(kind: string): boolean;
  21747. /**
  21748. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21749. * @param kind defines the data kind (Position, normal, etc...)
  21750. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21751. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21752. * @returns a float array containing vertex data
  21753. */
  21754. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21755. /**
  21756. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21757. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  21758. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21759. * @returns the indices array or an empty array if the mesh has no geometry
  21760. */
  21761. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21762. /**
  21763. * Set specific vertex data
  21764. * @param kind defines the data kind (Position, normal, etc...)
  21765. * @param data defines the vertex data to use
  21766. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21767. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21768. */
  21769. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21770. /**
  21771. * Update a specific associated vertex buffer
  21772. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21773. * - VertexBuffer.PositionKind
  21774. * - VertexBuffer.UVKind
  21775. * - VertexBuffer.UV2Kind
  21776. * - VertexBuffer.UV3Kind
  21777. * - VertexBuffer.UV4Kind
  21778. * - VertexBuffer.UV5Kind
  21779. * - VertexBuffer.UV6Kind
  21780. * - VertexBuffer.ColorKind
  21781. * - VertexBuffer.MatricesIndicesKind
  21782. * - VertexBuffer.MatricesIndicesExtraKind
  21783. * - VertexBuffer.MatricesWeightsKind
  21784. * - VertexBuffer.MatricesWeightsExtraKind
  21785. * @param data defines the data source
  21786. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21787. * @param makeItUnique defines if the geometry associated with the mesh must be cloned to make the change only for this mesh (and not all meshes associated with the same geometry)
  21788. */
  21789. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21790. /**
  21791. * Creates a new index buffer
  21792. * @param indices defines the indices to store in the index buffer
  21793. * @param totalVertices defines the total number of vertices (could be null)
  21794. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21795. */
  21796. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21797. }
  21798. /**
  21799. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21800. */
  21801. export class VertexData {
  21802. /**
  21803. * Mesh side orientation : usually the external or front surface
  21804. */
  21805. static readonly FRONTSIDE: number;
  21806. /**
  21807. * Mesh side orientation : usually the internal or back surface
  21808. */
  21809. static readonly BACKSIDE: number;
  21810. /**
  21811. * Mesh side orientation : both internal and external or front and back surfaces
  21812. */
  21813. static readonly DOUBLESIDE: number;
  21814. /**
  21815. * Mesh side orientation : by default, `FRONTSIDE`
  21816. */
  21817. static readonly DEFAULTSIDE: number;
  21818. /**
  21819. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21820. */
  21821. positions: Nullable<FloatArray>;
  21822. /**
  21823. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21824. */
  21825. normals: Nullable<FloatArray>;
  21826. /**
  21827. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21828. */
  21829. tangents: Nullable<FloatArray>;
  21830. /**
  21831. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21832. */
  21833. uvs: Nullable<FloatArray>;
  21834. /**
  21835. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21836. */
  21837. uvs2: Nullable<FloatArray>;
  21838. /**
  21839. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21840. */
  21841. uvs3: Nullable<FloatArray>;
  21842. /**
  21843. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21844. */
  21845. uvs4: Nullable<FloatArray>;
  21846. /**
  21847. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21848. */
  21849. uvs5: Nullable<FloatArray>;
  21850. /**
  21851. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21852. */
  21853. uvs6: Nullable<FloatArray>;
  21854. /**
  21855. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21856. */
  21857. colors: Nullable<FloatArray>;
  21858. /**
  21859. * An array containing the list of indices to the array of matrices produced by bones, each vertex have up to 4 indices (8 if the matricesIndicesExtra is set).
  21860. */
  21861. matricesIndices: Nullable<FloatArray>;
  21862. /**
  21863. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21864. */
  21865. matricesWeights: Nullable<FloatArray>;
  21866. /**
  21867. * An array extending the number of possible indices
  21868. */
  21869. matricesIndicesExtra: Nullable<FloatArray>;
  21870. /**
  21871. * An array extending the number of possible weights when the number of indices is extended
  21872. */
  21873. matricesWeightsExtra: Nullable<FloatArray>;
  21874. /**
  21875. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21876. */
  21877. indices: Nullable<IndicesArray>;
  21878. /**
  21879. * Uses the passed data array to set the set the values for the specified kind of data
  21880. * @param data a linear array of floating numbers
  21881. * @param kind the type of data that is being set, eg positions, colors etc
  21882. */
  21883. set(data: FloatArray, kind: string): void;
  21884. /**
  21885. * Associates the vertexData to the passed Mesh.
  21886. * Sets it as updatable or not (default `false`)
  21887. * @param mesh the mesh the vertexData is applied to
  21888. * @param updatable when used and having the value true allows new data to update the vertexData
  21889. * @returns the VertexData
  21890. */
  21891. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21892. /**
  21893. * Associates the vertexData to the passed Geometry.
  21894. * Sets it as updatable or not (default `false`)
  21895. * @param geometry the geometry the vertexData is applied to
  21896. * @param updatable when used and having the value true allows new data to update the vertexData
  21897. * @returns VertexData
  21898. */
  21899. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21900. /**
  21901. * Updates the associated mesh
  21902. * @param mesh the mesh to be updated
  21903. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21904. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  21905. * @returns VertexData
  21906. */
  21907. updateMesh(mesh: Mesh): VertexData;
  21908. /**
  21909. * Updates the associated geometry
  21910. * @param geometry the geometry to be updated
  21911. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21912. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  21913. * @returns VertexData.
  21914. */
  21915. updateGeometry(geometry: Geometry): VertexData;
  21916. private _applyTo;
  21917. private _update;
  21918. /**
  21919. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21920. * @param matrix the transforming matrix
  21921. * @returns the VertexData
  21922. */
  21923. transform(matrix: Matrix): VertexData;
  21924. /**
  21925. * Merges the passed VertexData into the current one
  21926. * @param other the VertexData to be merged into the current one
  21927. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21928. * @returns the modified VertexData
  21929. */
  21930. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21931. private _mergeElement;
  21932. private _validate;
  21933. /**
  21934. * Serializes the VertexData
  21935. * @returns a serialized object
  21936. */
  21937. serialize(): any;
  21938. /**
  21939. * Extracts the vertexData from a mesh
  21940. * @param mesh the mesh from which to extract the VertexData
  21941. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21942. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21943. * @returns the object VertexData associated to the passed mesh
  21944. */
  21945. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21946. /**
  21947. * Extracts the vertexData from the geometry
  21948. * @param geometry the geometry from which to extract the VertexData
  21949. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21950. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21951. * @returns the object VertexData associated to the passed mesh
  21952. */
  21953. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21954. private static _ExtractFrom;
  21955. /**
  21956. * Creates the VertexData for a Ribbon
  21957. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21958. * * pathArray array of paths, each of which an array of successive Vector3
  21959. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21960. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21961. * * offset a positive integer, only used when pathArray contains a single path (offset = 10 means the point 1 is joined to the point 11), default rounded half size of the pathArray length
  21962. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21963. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  21964. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  21965. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21966. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21967. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21968. * @returns the VertexData of the ribbon
  21969. */
  21970. static CreateRibbon(options: {
  21971. pathArray: Vector3[][];
  21972. closeArray?: boolean;
  21973. closePath?: boolean;
  21974. offset?: number;
  21975. sideOrientation?: number;
  21976. frontUVs?: Vector4;
  21977. backUVs?: Vector4;
  21978. invertUV?: boolean;
  21979. uvs?: Vector2[];
  21980. colors?: Color4[];
  21981. }): VertexData;
  21982. /**
  21983. * Creates the VertexData for a box
  21984. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21985. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21986. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21987. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21988. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21989. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21990. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21991. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21992. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  21993. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  21994. * @returns the VertexData of the box
  21995. */
  21996. static CreateBox(options: {
  21997. size?: number;
  21998. width?: number;
  21999. height?: number;
  22000. depth?: number;
  22001. faceUV?: Vector4[];
  22002. faceColors?: Color4[];
  22003. sideOrientation?: number;
  22004. frontUVs?: Vector4;
  22005. backUVs?: Vector4;
  22006. }): VertexData;
  22007. /**
  22008. * Creates the VertexData for a tiled box
  22009. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22010. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22011. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22012. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22013. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22014. * @returns the VertexData of the box
  22015. */
  22016. static CreateTiledBox(options: {
  22017. pattern?: number;
  22018. width?: number;
  22019. height?: number;
  22020. depth?: number;
  22021. tileSize?: number;
  22022. tileWidth?: number;
  22023. tileHeight?: number;
  22024. alignHorizontal?: number;
  22025. alignVertical?: number;
  22026. faceUV?: Vector4[];
  22027. faceColors?: Color4[];
  22028. sideOrientation?: number;
  22029. }): VertexData;
  22030. /**
  22031. * Creates the VertexData for a tiled plane
  22032. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22033. * * pattern a limited pattern arrangement depending on the number
  22034. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22035. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22036. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22037. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22038. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22039. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22040. * @returns the VertexData of the tiled plane
  22041. */
  22042. static CreateTiledPlane(options: {
  22043. pattern?: number;
  22044. tileSize?: number;
  22045. tileWidth?: number;
  22046. tileHeight?: number;
  22047. size?: number;
  22048. width?: number;
  22049. height?: number;
  22050. alignHorizontal?: number;
  22051. alignVertical?: number;
  22052. sideOrientation?: number;
  22053. frontUVs?: Vector4;
  22054. backUVs?: Vector4;
  22055. }): VertexData;
  22056. /**
  22057. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22058. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22059. * * segments sets the number of horizontal strips optional, default 32
  22060. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22061. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22062. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22063. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22064. * * arc a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the circumference (latitude) given by the arc value, optional, default 1
  22065. * * slice a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the height (latitude) given by the arc value, optional, default 1
  22066. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22067. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22068. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22069. * @returns the VertexData of the ellipsoid
  22070. */
  22071. static CreateSphere(options: {
  22072. segments?: number;
  22073. diameter?: number;
  22074. diameterX?: number;
  22075. diameterY?: number;
  22076. diameterZ?: number;
  22077. arc?: number;
  22078. slice?: number;
  22079. sideOrientation?: number;
  22080. frontUVs?: Vector4;
  22081. backUVs?: Vector4;
  22082. }): VertexData;
  22083. /**
  22084. * Creates the VertexData for a cylinder, cone or prism
  22085. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22086. * * height sets the height (y direction) of the cylinder, optional, default 2
  22087. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22088. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22089. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22090. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22091. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22092. * * arc a number from 0 to 1, to create an unclosed cylinder based on the fraction of the circumference given by the arc value, optional, default 1
  22093. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22094. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22095. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22096. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22097. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22098. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22099. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22100. * @returns the VertexData of the cylinder, cone or prism
  22101. */
  22102. static CreateCylinder(options: {
  22103. height?: number;
  22104. diameterTop?: number;
  22105. diameterBottom?: number;
  22106. diameter?: number;
  22107. tessellation?: number;
  22108. subdivisions?: number;
  22109. arc?: number;
  22110. faceColors?: Color4[];
  22111. faceUV?: Vector4[];
  22112. hasRings?: boolean;
  22113. enclose?: boolean;
  22114. sideOrientation?: number;
  22115. frontUVs?: Vector4;
  22116. backUVs?: Vector4;
  22117. }): VertexData;
  22118. /**
  22119. * Creates the VertexData for a torus
  22120. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22121. * * diameter the diameter of the torus, optional default 1
  22122. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22123. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22124. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22125. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22126. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22127. * @returns the VertexData of the torus
  22128. */
  22129. static CreateTorus(options: {
  22130. diameter?: number;
  22131. thickness?: number;
  22132. tessellation?: number;
  22133. sideOrientation?: number;
  22134. frontUVs?: Vector4;
  22135. backUVs?: Vector4;
  22136. }): VertexData;
  22137. /**
  22138. * Creates the VertexData of the LineSystem
  22139. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22140. * - lines an array of lines, each line being an array of successive Vector3
  22141. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22142. * @returns the VertexData of the LineSystem
  22143. */
  22144. static CreateLineSystem(options: {
  22145. lines: Vector3[][];
  22146. colors?: Nullable<Color4[][]>;
  22147. }): VertexData;
  22148. /**
  22149. * Create the VertexData for a DashedLines
  22150. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22151. * - points an array successive Vector3
  22152. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22153. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22154. * - dashNb the intended total number of dashes, optional, default 200
  22155. * @returns the VertexData for the DashedLines
  22156. */
  22157. static CreateDashedLines(options: {
  22158. points: Vector3[];
  22159. dashSize?: number;
  22160. gapSize?: number;
  22161. dashNb?: number;
  22162. }): VertexData;
  22163. /**
  22164. * Creates the VertexData for a Ground
  22165. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22166. * - width the width (x direction) of the ground, optional, default 1
  22167. * - height the height (z direction) of the ground, optional, default 1
  22168. * - subdivisions the number of subdivisions per side, optional, default 1
  22169. * @returns the VertexData of the Ground
  22170. */
  22171. static CreateGround(options: {
  22172. width?: number;
  22173. height?: number;
  22174. subdivisions?: number;
  22175. subdivisionsX?: number;
  22176. subdivisionsY?: number;
  22177. }): VertexData;
  22178. /**
  22179. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22180. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22181. * * xmin the ground minimum X coordinate, optional, default -1
  22182. * * zmin the ground minimum Z coordinate, optional, default -1
  22183. * * xmax the ground maximum X coordinate, optional, default 1
  22184. * * zmax the ground maximum Z coordinate, optional, default 1
  22185. * * subdivisions a javascript object {w: positive integer, h: positive integer}, `w` and `h` are the numbers of subdivisions on the ground width and height creating 'tiles', default {w: 6, h: 6}
  22186. * * precision a javascript object {w: positive integer, h: positive integer}, `w` and `h` are the numbers of subdivisions on the tile width and height, default {w: 2, h: 2}
  22187. * @returns the VertexData of the TiledGround
  22188. */
  22189. static CreateTiledGround(options: {
  22190. xmin: number;
  22191. zmin: number;
  22192. xmax: number;
  22193. zmax: number;
  22194. subdivisions?: {
  22195. w: number;
  22196. h: number;
  22197. };
  22198. precision?: {
  22199. w: number;
  22200. h: number;
  22201. };
  22202. }): VertexData;
  22203. /**
  22204. * Creates the VertexData of the Ground designed from a heightmap
  22205. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22206. * * width the width (x direction) of the ground
  22207. * * height the height (z direction) of the ground
  22208. * * subdivisions the number of subdivisions per side
  22209. * * minHeight the minimum altitude on the ground, optional, default 0
  22210. * * maxHeight the maximum altitude on the ground, optional default 1
  22211. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22212. * * buffer the array holding the image color data
  22213. * * bufferWidth the width of image
  22214. * * bufferHeight the height of image
  22215. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22216. * @returns the VertexData of the Ground designed from a heightmap
  22217. */
  22218. static CreateGroundFromHeightMap(options: {
  22219. width: number;
  22220. height: number;
  22221. subdivisions: number;
  22222. minHeight: number;
  22223. maxHeight: number;
  22224. colorFilter: Color3;
  22225. buffer: Uint8Array;
  22226. bufferWidth: number;
  22227. bufferHeight: number;
  22228. alphaFilter: number;
  22229. }): VertexData;
  22230. /**
  22231. * Creates the VertexData for a Plane
  22232. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22233. * * size sets the width and height of the plane to the value of size, optional default 1
  22234. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22235. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22236. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22237. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22238. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22239. * @returns the VertexData of the box
  22240. */
  22241. static CreatePlane(options: {
  22242. size?: number;
  22243. width?: number;
  22244. height?: number;
  22245. sideOrientation?: number;
  22246. frontUVs?: Vector4;
  22247. backUVs?: Vector4;
  22248. }): VertexData;
  22249. /**
  22250. * Creates the VertexData of the Disc or regular Polygon
  22251. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22252. * * radius the radius of the disc, optional default 0.5
  22253. * * tessellation the number of polygon sides, optional, default 64
  22254. * * arc a number from 0 to 1, to create an unclosed polygon based on the fraction of the circumference given by the arc value, optional, default 1
  22255. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22256. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22257. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22258. * @returns the VertexData of the box
  22259. */
  22260. static CreateDisc(options: {
  22261. radius?: number;
  22262. tessellation?: number;
  22263. arc?: number;
  22264. sideOrientation?: number;
  22265. frontUVs?: Vector4;
  22266. backUVs?: Vector4;
  22267. }): VertexData;
  22268. /**
  22269. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22270. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22271. * @param polygon a mesh built from polygonTriangulation.build()
  22272. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22273. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22274. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22275. * @param frontUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22276. * @param backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22277. * @returns the VertexData of the Polygon
  22278. */
  22279. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22280. /**
  22281. * Creates the VertexData of the IcoSphere
  22282. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22283. * * radius the radius of the IcoSphere, optional default 1
  22284. * * radiusX allows stretching in the x direction, optional, default radius
  22285. * * radiusY allows stretching in the y direction, optional, default radius
  22286. * * radiusZ allows stretching in the z direction, optional, default radius
  22287. * * flat when true creates a flat shaded mesh, optional, default true
  22288. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22289. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22290. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22291. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22292. * @returns the VertexData of the IcoSphere
  22293. */
  22294. static CreateIcoSphere(options: {
  22295. radius?: number;
  22296. radiusX?: number;
  22297. radiusY?: number;
  22298. radiusZ?: number;
  22299. flat?: boolean;
  22300. subdivisions?: number;
  22301. sideOrientation?: number;
  22302. frontUVs?: Vector4;
  22303. backUVs?: Vector4;
  22304. }): VertexData;
  22305. /**
  22306. * Creates the VertexData for a Polyhedron
  22307. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22308. * * type provided types are:
  22309. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22310. * * 9 : Pentagonal Pyramid (J2), 10 : Triangular Dipyramid (J12), 11 : Pentagonal Dipyramid (J13), 12 : Elongated Square Dipyramid (J15), 13 : Elongated Pentagonal Dipyramid (J16), 14 : Elongated Pentagonal Cupola (J20)
  22311. * * size the size of the IcoSphere, optional default 1
  22312. * * sizeX allows stretching in the x direction, optional, default size
  22313. * * sizeY allows stretching in the y direction, optional, default size
  22314. * * sizeZ allows stretching in the z direction, optional, default size
  22315. * * custom a number that overwrites the type to create from an extended set of polyhedron from https://www.babylonjs-playground.com/#21QRSK#15 with minimised editor
  22316. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22317. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22318. * * flat when true creates a flat shaded mesh, optional, default true
  22319. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22320. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22321. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22322. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22323. * @returns the VertexData of the Polyhedron
  22324. */
  22325. static CreatePolyhedron(options: {
  22326. type?: number;
  22327. size?: number;
  22328. sizeX?: number;
  22329. sizeY?: number;
  22330. sizeZ?: number;
  22331. custom?: any;
  22332. faceUV?: Vector4[];
  22333. faceColors?: Color4[];
  22334. flat?: boolean;
  22335. sideOrientation?: number;
  22336. frontUVs?: Vector4;
  22337. backUVs?: Vector4;
  22338. }): VertexData;
  22339. /**
  22340. * Creates the VertexData for a TorusKnot
  22341. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22342. * * radius the radius of the torus knot, optional, default 2
  22343. * * tube the thickness of the tube, optional, default 0.5
  22344. * * radialSegments the number of sides on each tube segments, optional, default 32
  22345. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22346. * * p the number of windings around the z axis, optional, default 2
  22347. * * q the number of windings around the x axis, optional, default 3
  22348. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22349. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22350. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22351. * @returns the VertexData of the Torus Knot
  22352. */
  22353. static CreateTorusKnot(options: {
  22354. radius?: number;
  22355. tube?: number;
  22356. radialSegments?: number;
  22357. tubularSegments?: number;
  22358. p?: number;
  22359. q?: number;
  22360. sideOrientation?: number;
  22361. frontUVs?: Vector4;
  22362. backUVs?: Vector4;
  22363. }): VertexData;
  22364. /**
  22365. * Compute normals for given positions and indices
  22366. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22367. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22368. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22369. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22370. * * facetNormals : optional array of facet normals (vector3)
  22371. * * facetPositions : optional array of facet positions (vector3)
  22372. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22373. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22374. * * bInfo : optional bounding info, required for facetPartitioning computation
  22375. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22376. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22377. * * useRightHandedSystem: optional boolean to for right handed system computation
  22378. * * depthSort : optional boolean to enable the facet depth sort computation
  22379. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22380. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22381. */
  22382. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22383. facetNormals?: any;
  22384. facetPositions?: any;
  22385. facetPartitioning?: any;
  22386. ratio?: number;
  22387. bInfo?: any;
  22388. bbSize?: Vector3;
  22389. subDiv?: any;
  22390. useRightHandedSystem?: boolean;
  22391. depthSort?: boolean;
  22392. distanceTo?: Vector3;
  22393. depthSortedFacets?: any;
  22394. }): void;
  22395. /** @hidden */
  22396. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22397. /**
  22398. * Applies VertexData created from the imported parameters to the geometry
  22399. * @param parsedVertexData the parsed data from an imported file
  22400. * @param geometry the geometry to apply the VertexData to
  22401. */
  22402. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22403. }
  22404. }
  22405. declare module "babylonjs/Morph/morphTarget" {
  22406. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22407. import { Observable } from "babylonjs/Misc/observable";
  22408. import { Nullable, FloatArray } from "babylonjs/types";
  22409. import { Scene } from "babylonjs/scene";
  22410. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22411. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22412. /**
  22413. * Defines a target to use with MorphTargetManager
  22414. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22415. */
  22416. export class MorphTarget implements IAnimatable {
  22417. /** defines the name of the target */
  22418. name: string;
  22419. /**
  22420. * Gets or sets the list of animations
  22421. */
  22422. animations: import("babylonjs/Animations/animation").Animation[];
  22423. private _scene;
  22424. private _positions;
  22425. private _normals;
  22426. private _tangents;
  22427. private _uvs;
  22428. private _influence;
  22429. /**
  22430. * Observable raised when the influence changes
  22431. */
  22432. onInfluenceChanged: Observable<boolean>;
  22433. /** @hidden */
  22434. _onDataLayoutChanged: Observable<void>;
  22435. /**
  22436. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22437. */
  22438. influence: number;
  22439. /**
  22440. * Gets or sets the id of the morph Target
  22441. */
  22442. id: string;
  22443. private _animationPropertiesOverride;
  22444. /**
  22445. * Gets or sets the animation properties override
  22446. */
  22447. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22448. /**
  22449. * Creates a new MorphTarget
  22450. * @param name defines the name of the target
  22451. * @param influence defines the influence to use
  22452. * @param scene defines the scene the morphtarget belongs to
  22453. */
  22454. constructor(
  22455. /** defines the name of the target */
  22456. name: string, influence?: number, scene?: Nullable<Scene>);
  22457. /**
  22458. * Gets a boolean defining if the target contains position data
  22459. */
  22460. readonly hasPositions: boolean;
  22461. /**
  22462. * Gets a boolean defining if the target contains normal data
  22463. */
  22464. readonly hasNormals: boolean;
  22465. /**
  22466. * Gets a boolean defining if the target contains tangent data
  22467. */
  22468. readonly hasTangents: boolean;
  22469. /**
  22470. * Gets a boolean defining if the target contains texture coordinates data
  22471. */
  22472. readonly hasUVs: boolean;
  22473. /**
  22474. * Affects position data to this target
  22475. * @param data defines the position data to use
  22476. */
  22477. setPositions(data: Nullable<FloatArray>): void;
  22478. /**
  22479. * Gets the position data stored in this target
  22480. * @returns a FloatArray containing the position data (or null if not present)
  22481. */
  22482. getPositions(): Nullable<FloatArray>;
  22483. /**
  22484. * Affects normal data to this target
  22485. * @param data defines the normal data to use
  22486. */
  22487. setNormals(data: Nullable<FloatArray>): void;
  22488. /**
  22489. * Gets the normal data stored in this target
  22490. * @returns a FloatArray containing the normal data (or null if not present)
  22491. */
  22492. getNormals(): Nullable<FloatArray>;
  22493. /**
  22494. * Affects tangent data to this target
  22495. * @param data defines the tangent data to use
  22496. */
  22497. setTangents(data: Nullable<FloatArray>): void;
  22498. /**
  22499. * Gets the tangent data stored in this target
  22500. * @returns a FloatArray containing the tangent data (or null if not present)
  22501. */
  22502. getTangents(): Nullable<FloatArray>;
  22503. /**
  22504. * Affects texture coordinates data to this target
  22505. * @param data defines the texture coordinates data to use
  22506. */
  22507. setUVs(data: Nullable<FloatArray>): void;
  22508. /**
  22509. * Gets the texture coordinates data stored in this target
  22510. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22511. */
  22512. getUVs(): Nullable<FloatArray>;
  22513. /**
  22514. * Serializes the current target into a Serialization object
  22515. * @returns the serialized object
  22516. */
  22517. serialize(): any;
  22518. /**
  22519. * Returns the string "MorphTarget"
  22520. * @returns "MorphTarget"
  22521. */
  22522. getClassName(): string;
  22523. /**
  22524. * Creates a new target from serialized data
  22525. * @param serializationObject defines the serialized data to use
  22526. * @returns a new MorphTarget
  22527. */
  22528. static Parse(serializationObject: any): MorphTarget;
  22529. /**
  22530. * Creates a MorphTarget from mesh data
  22531. * @param mesh defines the source mesh
  22532. * @param name defines the name to use for the new target
  22533. * @param influence defines the influence to attach to the target
  22534. * @returns a new MorphTarget
  22535. */
  22536. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22537. }
  22538. }
  22539. declare module "babylonjs/Morph/morphTargetManager" {
  22540. import { Nullable } from "babylonjs/types";
  22541. import { Scene } from "babylonjs/scene";
  22542. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  22543. /**
  22544. * This class is used to deform meshes using morphing between different targets
  22545. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22546. */
  22547. export class MorphTargetManager {
  22548. private _targets;
  22549. private _targetInfluenceChangedObservers;
  22550. private _targetDataLayoutChangedObservers;
  22551. private _activeTargets;
  22552. private _scene;
  22553. private _influences;
  22554. private _supportsNormals;
  22555. private _supportsTangents;
  22556. private _supportsUVs;
  22557. private _vertexCount;
  22558. private _uniqueId;
  22559. private _tempInfluences;
  22560. /**
  22561. * Gets or sets a boolean indicating if normals must be morphed
  22562. */
  22563. enableNormalMorphing: boolean;
  22564. /**
  22565. * Gets or sets a boolean indicating if tangents must be morphed
  22566. */
  22567. enableTangentMorphing: boolean;
  22568. /**
  22569. * Gets or sets a boolean indicating if UV must be morphed
  22570. */
  22571. enableUVMorphing: boolean;
  22572. /**
  22573. * Creates a new MorphTargetManager
  22574. * @param scene defines the current scene
  22575. */
  22576. constructor(scene?: Nullable<Scene>);
  22577. /**
  22578. * Gets the unique ID of this manager
  22579. */
  22580. readonly uniqueId: number;
  22581. /**
  22582. * Gets the number of vertices handled by this manager
  22583. */
  22584. readonly vertexCount: number;
  22585. /**
  22586. * Gets a boolean indicating if this manager supports morphing of normals
  22587. */
  22588. readonly supportsNormals: boolean;
  22589. /**
  22590. * Gets a boolean indicating if this manager supports morphing of tangents
  22591. */
  22592. readonly supportsTangents: boolean;
  22593. /**
  22594. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22595. */
  22596. readonly supportsUVs: boolean;
  22597. /**
  22598. * Gets the number of targets stored in this manager
  22599. */
  22600. readonly numTargets: number;
  22601. /**
  22602. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22603. */
  22604. readonly numInfluencers: number;
  22605. /**
  22606. * Gets the list of influences (one per target)
  22607. */
  22608. readonly influences: Float32Array;
  22609. /**
  22610. * Gets the active target at specified index. An active target is a target with an influence > 0
  22611. * @param index defines the index to check
  22612. * @returns the requested target
  22613. */
  22614. getActiveTarget(index: number): MorphTarget;
  22615. /**
  22616. * Gets the target at specified index
  22617. * @param index defines the index to check
  22618. * @returns the requested target
  22619. */
  22620. getTarget(index: number): MorphTarget;
  22621. /**
  22622. * Add a new target to this manager
  22623. * @param target defines the target to add
  22624. */
  22625. addTarget(target: MorphTarget): void;
  22626. /**
  22627. * Removes a target from the manager
  22628. * @param target defines the target to remove
  22629. */
  22630. removeTarget(target: MorphTarget): void;
  22631. /**
  22632. * Serializes the current manager into a Serialization object
  22633. * @returns the serialized object
  22634. */
  22635. serialize(): any;
  22636. private _syncActiveTargets;
  22637. /**
  22638. * Syncrhonize the targets with all the meshes using this morph target manager
  22639. */
  22640. synchronize(): void;
  22641. /**
  22642. * Creates a new MorphTargetManager from serialized data
  22643. * @param serializationObject defines the serialized data
  22644. * @param scene defines the hosting scene
  22645. * @returns the new MorphTargetManager
  22646. */
  22647. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22648. }
  22649. }
  22650. declare module "babylonjs/Meshes/meshLODLevel" {
  22651. import { Mesh } from "babylonjs/Meshes/mesh";
  22652. import { Nullable } from "babylonjs/types";
  22653. /**
  22654. * Class used to represent a specific level of detail of a mesh
  22655. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22656. */
  22657. export class MeshLODLevel {
  22658. /** Defines the distance where this level should star being displayed */
  22659. distance: number;
  22660. /** Defines the mesh to use to render this level */
  22661. mesh: Nullable<Mesh>;
  22662. /**
  22663. * Creates a new LOD level
  22664. * @param distance defines the distance where this level should star being displayed
  22665. * @param mesh defines the mesh to use to render this level
  22666. */
  22667. constructor(
  22668. /** Defines the distance where this level should star being displayed */
  22669. distance: number,
  22670. /** Defines the mesh to use to render this level */
  22671. mesh: Nullable<Mesh>);
  22672. }
  22673. }
  22674. declare module "babylonjs/Meshes/groundMesh" {
  22675. import { Scene } from "babylonjs/scene";
  22676. import { Vector3 } from "babylonjs/Maths/math.vector";
  22677. import { Mesh } from "babylonjs/Meshes/mesh";
  22678. /**
  22679. * Mesh representing the gorund
  22680. */
  22681. export class GroundMesh extends Mesh {
  22682. /** If octree should be generated */
  22683. generateOctree: boolean;
  22684. private _heightQuads;
  22685. /** @hidden */
  22686. _subdivisionsX: number;
  22687. /** @hidden */
  22688. _subdivisionsY: number;
  22689. /** @hidden */
  22690. _width: number;
  22691. /** @hidden */
  22692. _height: number;
  22693. /** @hidden */
  22694. _minX: number;
  22695. /** @hidden */
  22696. _maxX: number;
  22697. /** @hidden */
  22698. _minZ: number;
  22699. /** @hidden */
  22700. _maxZ: number;
  22701. constructor(name: string, scene: Scene);
  22702. /**
  22703. * "GroundMesh"
  22704. * @returns "GroundMesh"
  22705. */
  22706. getClassName(): string;
  22707. /**
  22708. * The minimum of x and y subdivisions
  22709. */
  22710. readonly subdivisions: number;
  22711. /**
  22712. * X subdivisions
  22713. */
  22714. readonly subdivisionsX: number;
  22715. /**
  22716. * Y subdivisions
  22717. */
  22718. readonly subdivisionsY: number;
  22719. /**
  22720. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22721. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22722. * @param chunksCount the number of subdivisions for x and y
  22723. * @param octreeBlocksSize (Default: 32)
  22724. */
  22725. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22726. /**
  22727. * Returns a height (y) value in the Worl system :
  22728. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22729. * @param x x coordinate
  22730. * @param z z coordinate
  22731. * @returns the ground y position if (x, z) are outside the ground surface.
  22732. */
  22733. getHeightAtCoordinates(x: number, z: number): number;
  22734. /**
  22735. * Returns a normalized vector (Vector3) orthogonal to the ground
  22736. * at the ground coordinates (x, z) expressed in the World system.
  22737. * @param x x coordinate
  22738. * @param z z coordinate
  22739. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22740. */
  22741. getNormalAtCoordinates(x: number, z: number): Vector3;
  22742. /**
  22743. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22744. * at the ground coordinates (x, z) expressed in the World system.
  22745. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22746. * @param x x coordinate
  22747. * @param z z coordinate
  22748. * @param ref vector to store the result
  22749. * @returns the GroundMesh.
  22750. */
  22751. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22752. /**
  22753. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22754. * if the ground has been updated.
  22755. * This can be used in the render loop.
  22756. * @returns the GroundMesh.
  22757. */
  22758. updateCoordinateHeights(): GroundMesh;
  22759. private _getFacetAt;
  22760. private _initHeightQuads;
  22761. private _computeHeightQuads;
  22762. /**
  22763. * Serializes this ground mesh
  22764. * @param serializationObject object to write serialization to
  22765. */
  22766. serialize(serializationObject: any): void;
  22767. /**
  22768. * Parses a serialized ground mesh
  22769. * @param parsedMesh the serialized mesh
  22770. * @param scene the scene to create the ground mesh in
  22771. * @returns the created ground mesh
  22772. */
  22773. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22774. }
  22775. }
  22776. declare module "babylonjs/Physics/physicsJoint" {
  22777. import { Vector3 } from "babylonjs/Maths/math.vector";
  22778. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  22779. /**
  22780. * Interface for Physics-Joint data
  22781. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22782. */
  22783. export interface PhysicsJointData {
  22784. /**
  22785. * The main pivot of the joint
  22786. */
  22787. mainPivot?: Vector3;
  22788. /**
  22789. * The connected pivot of the joint
  22790. */
  22791. connectedPivot?: Vector3;
  22792. /**
  22793. * The main axis of the joint
  22794. */
  22795. mainAxis?: Vector3;
  22796. /**
  22797. * The connected axis of the joint
  22798. */
  22799. connectedAxis?: Vector3;
  22800. /**
  22801. * The collision of the joint
  22802. */
  22803. collision?: boolean;
  22804. /**
  22805. * Native Oimo/Cannon/Energy data
  22806. */
  22807. nativeParams?: any;
  22808. }
  22809. /**
  22810. * This is a holder class for the physics joint created by the physics plugin
  22811. * It holds a set of functions to control the underlying joint
  22812. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22813. */
  22814. export class PhysicsJoint {
  22815. /**
  22816. * The type of the physics joint
  22817. */
  22818. type: number;
  22819. /**
  22820. * The data for the physics joint
  22821. */
  22822. jointData: PhysicsJointData;
  22823. private _physicsJoint;
  22824. protected _physicsPlugin: IPhysicsEnginePlugin;
  22825. /**
  22826. * Initializes the physics joint
  22827. * @param type The type of the physics joint
  22828. * @param jointData The data for the physics joint
  22829. */
  22830. constructor(
  22831. /**
  22832. * The type of the physics joint
  22833. */
  22834. type: number,
  22835. /**
  22836. * The data for the physics joint
  22837. */
  22838. jointData: PhysicsJointData);
  22839. /**
  22840. * Gets the physics joint
  22841. */
  22842. /**
  22843. * Sets the physics joint
  22844. */
  22845. physicsJoint: any;
  22846. /**
  22847. * Sets the physics plugin
  22848. */
  22849. physicsPlugin: IPhysicsEnginePlugin;
  22850. /**
  22851. * Execute a function that is physics-plugin specific.
  22852. * @param {Function} func the function that will be executed.
  22853. * It accepts two parameters: the physics world and the physics joint
  22854. */
  22855. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22856. /**
  22857. * Distance-Joint type
  22858. */
  22859. static DistanceJoint: number;
  22860. /**
  22861. * Hinge-Joint type
  22862. */
  22863. static HingeJoint: number;
  22864. /**
  22865. * Ball-and-Socket joint type
  22866. */
  22867. static BallAndSocketJoint: number;
  22868. /**
  22869. * Wheel-Joint type
  22870. */
  22871. static WheelJoint: number;
  22872. /**
  22873. * Slider-Joint type
  22874. */
  22875. static SliderJoint: number;
  22876. /**
  22877. * Prismatic-Joint type
  22878. */
  22879. static PrismaticJoint: number;
  22880. /**
  22881. * Universal-Joint type
  22882. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22883. */
  22884. static UniversalJoint: number;
  22885. /**
  22886. * Hinge-Joint 2 type
  22887. */
  22888. static Hinge2Joint: number;
  22889. /**
  22890. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22891. */
  22892. static PointToPointJoint: number;
  22893. /**
  22894. * Spring-Joint type
  22895. */
  22896. static SpringJoint: number;
  22897. /**
  22898. * Lock-Joint type
  22899. */
  22900. static LockJoint: number;
  22901. }
  22902. /**
  22903. * A class representing a physics distance joint
  22904. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22905. */
  22906. export class DistanceJoint extends PhysicsJoint {
  22907. /**
  22908. *
  22909. * @param jointData The data for the Distance-Joint
  22910. */
  22911. constructor(jointData: DistanceJointData);
  22912. /**
  22913. * Update the predefined distance.
  22914. * @param maxDistance The maximum preferred distance
  22915. * @param minDistance The minimum preferred distance
  22916. */
  22917. updateDistance(maxDistance: number, minDistance?: number): void;
  22918. }
  22919. /**
  22920. * Represents a Motor-Enabled Joint
  22921. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22922. */
  22923. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22924. /**
  22925. * Initializes the Motor-Enabled Joint
  22926. * @param type The type of the joint
  22927. * @param jointData The physica joint data for the joint
  22928. */
  22929. constructor(type: number, jointData: PhysicsJointData);
  22930. /**
  22931. * Set the motor values.
  22932. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22933. * @param force the force to apply
  22934. * @param maxForce max force for this motor.
  22935. */
  22936. setMotor(force?: number, maxForce?: number): void;
  22937. /**
  22938. * Set the motor's limits.
  22939. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22940. * @param upperLimit The upper limit of the motor
  22941. * @param lowerLimit The lower limit of the motor
  22942. */
  22943. setLimit(upperLimit: number, lowerLimit?: number): void;
  22944. }
  22945. /**
  22946. * This class represents a single physics Hinge-Joint
  22947. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22948. */
  22949. export class HingeJoint extends MotorEnabledJoint {
  22950. /**
  22951. * Initializes the Hinge-Joint
  22952. * @param jointData The joint data for the Hinge-Joint
  22953. */
  22954. constructor(jointData: PhysicsJointData);
  22955. /**
  22956. * Set the motor values.
  22957. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22958. * @param {number} force the force to apply
  22959. * @param {number} maxForce max force for this motor.
  22960. */
  22961. setMotor(force?: number, maxForce?: number): void;
  22962. /**
  22963. * Set the motor's limits.
  22964. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22965. * @param upperLimit The upper limit of the motor
  22966. * @param lowerLimit The lower limit of the motor
  22967. */
  22968. setLimit(upperLimit: number, lowerLimit?: number): void;
  22969. }
  22970. /**
  22971. * This class represents a dual hinge physics joint (same as wheel joint)
  22972. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22973. */
  22974. export class Hinge2Joint extends MotorEnabledJoint {
  22975. /**
  22976. * Initializes the Hinge2-Joint
  22977. * @param jointData The joint data for the Hinge2-Joint
  22978. */
  22979. constructor(jointData: PhysicsJointData);
  22980. /**
  22981. * Set the motor values.
  22982. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22983. * @param {number} targetSpeed the speed the motor is to reach
  22984. * @param {number} maxForce max force for this motor.
  22985. * @param {motorIndex} the motor's index, 0 or 1.
  22986. */
  22987. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22988. /**
  22989. * Set the motor limits.
  22990. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22991. * @param {number} upperLimit the upper limit
  22992. * @param {number} lowerLimit lower limit
  22993. * @param {motorIndex} the motor's index, 0 or 1.
  22994. */
  22995. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22996. }
  22997. /**
  22998. * Interface for a motor enabled joint
  22999. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23000. */
  23001. export interface IMotorEnabledJoint {
  23002. /**
  23003. * Physics joint
  23004. */
  23005. physicsJoint: any;
  23006. /**
  23007. * Sets the motor of the motor-enabled joint
  23008. * @param force The force of the motor
  23009. * @param maxForce The maximum force of the motor
  23010. * @param motorIndex The index of the motor
  23011. */
  23012. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23013. /**
  23014. * Sets the limit of the motor
  23015. * @param upperLimit The upper limit of the motor
  23016. * @param lowerLimit The lower limit of the motor
  23017. * @param motorIndex The index of the motor
  23018. */
  23019. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23020. }
  23021. /**
  23022. * Joint data for a Distance-Joint
  23023. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23024. */
  23025. export interface DistanceJointData extends PhysicsJointData {
  23026. /**
  23027. * Max distance the 2 joint objects can be apart
  23028. */
  23029. maxDistance: number;
  23030. }
  23031. /**
  23032. * Joint data from a spring joint
  23033. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23034. */
  23035. export interface SpringJointData extends PhysicsJointData {
  23036. /**
  23037. * Length of the spring
  23038. */
  23039. length: number;
  23040. /**
  23041. * Stiffness of the spring
  23042. */
  23043. stiffness: number;
  23044. /**
  23045. * Damping of the spring
  23046. */
  23047. damping: number;
  23048. /** this callback will be called when applying the force to the impostors. */
  23049. forceApplicationCallback: () => void;
  23050. }
  23051. }
  23052. declare module "babylonjs/Physics/physicsRaycastResult" {
  23053. import { Vector3 } from "babylonjs/Maths/math.vector";
  23054. /**
  23055. * Holds the data for the raycast result
  23056. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23057. */
  23058. export class PhysicsRaycastResult {
  23059. private _hasHit;
  23060. private _hitDistance;
  23061. private _hitNormalWorld;
  23062. private _hitPointWorld;
  23063. private _rayFromWorld;
  23064. private _rayToWorld;
  23065. /**
  23066. * Gets if there was a hit
  23067. */
  23068. readonly hasHit: boolean;
  23069. /**
  23070. * Gets the distance from the hit
  23071. */
  23072. readonly hitDistance: number;
  23073. /**
  23074. * Gets the hit normal/direction in the world
  23075. */
  23076. readonly hitNormalWorld: Vector3;
  23077. /**
  23078. * Gets the hit point in the world
  23079. */
  23080. readonly hitPointWorld: Vector3;
  23081. /**
  23082. * Gets the ray "start point" of the ray in the world
  23083. */
  23084. readonly rayFromWorld: Vector3;
  23085. /**
  23086. * Gets the ray "end point" of the ray in the world
  23087. */
  23088. readonly rayToWorld: Vector3;
  23089. /**
  23090. * Sets the hit data (normal & point in world space)
  23091. * @param hitNormalWorld defines the normal in world space
  23092. * @param hitPointWorld defines the point in world space
  23093. */
  23094. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23095. /**
  23096. * Sets the distance from the start point to the hit point
  23097. * @param distance
  23098. */
  23099. setHitDistance(distance: number): void;
  23100. /**
  23101. * Calculates the distance manually
  23102. */
  23103. calculateHitDistance(): void;
  23104. /**
  23105. * Resets all the values to default
  23106. * @param from The from point on world space
  23107. * @param to The to point on world space
  23108. */
  23109. reset(from?: Vector3, to?: Vector3): void;
  23110. }
  23111. /**
  23112. * Interface for the size containing width and height
  23113. */
  23114. interface IXYZ {
  23115. /**
  23116. * X
  23117. */
  23118. x: number;
  23119. /**
  23120. * Y
  23121. */
  23122. y: number;
  23123. /**
  23124. * Z
  23125. */
  23126. z: number;
  23127. }
  23128. }
  23129. declare module "babylonjs/Physics/IPhysicsEngine" {
  23130. import { Nullable } from "babylonjs/types";
  23131. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23132. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23133. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23134. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23135. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23136. /**
  23137. * Interface used to describe a physics joint
  23138. */
  23139. export interface PhysicsImpostorJoint {
  23140. /** Defines the main impostor to which the joint is linked */
  23141. mainImpostor: PhysicsImpostor;
  23142. /** Defines the impostor that is connected to the main impostor using this joint */
  23143. connectedImpostor: PhysicsImpostor;
  23144. /** Defines the joint itself */
  23145. joint: PhysicsJoint;
  23146. }
  23147. /** @hidden */
  23148. export interface IPhysicsEnginePlugin {
  23149. world: any;
  23150. name: string;
  23151. setGravity(gravity: Vector3): void;
  23152. setTimeStep(timeStep: number): void;
  23153. getTimeStep(): number;
  23154. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23155. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23156. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23157. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23158. removePhysicsBody(impostor: PhysicsImpostor): void;
  23159. generateJoint(joint: PhysicsImpostorJoint): void;
  23160. removeJoint(joint: PhysicsImpostorJoint): void;
  23161. isSupported(): boolean;
  23162. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23163. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23164. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23165. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23166. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23167. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23168. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23169. getBodyMass(impostor: PhysicsImpostor): number;
  23170. getBodyFriction(impostor: PhysicsImpostor): number;
  23171. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23172. getBodyRestitution(impostor: PhysicsImpostor): number;
  23173. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23174. getBodyPressure?(impostor: PhysicsImpostor): number;
  23175. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23176. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23177. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23178. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23179. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23180. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23181. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23182. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23183. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23184. sleepBody(impostor: PhysicsImpostor): void;
  23185. wakeUpBody(impostor: PhysicsImpostor): void;
  23186. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23187. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23188. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23189. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23190. getRadius(impostor: PhysicsImpostor): number;
  23191. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23192. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23193. dispose(): void;
  23194. }
  23195. /**
  23196. * Interface used to define a physics engine
  23197. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23198. */
  23199. export interface IPhysicsEngine {
  23200. /**
  23201. * Gets the gravity vector used by the simulation
  23202. */
  23203. gravity: Vector3;
  23204. /**
  23205. * Sets the gravity vector used by the simulation
  23206. * @param gravity defines the gravity vector to use
  23207. */
  23208. setGravity(gravity: Vector3): void;
  23209. /**
  23210. * Set the time step of the physics engine.
  23211. * Default is 1/60.
  23212. * To slow it down, enter 1/600 for example.
  23213. * To speed it up, 1/30
  23214. * @param newTimeStep the new timestep to apply to this world.
  23215. */
  23216. setTimeStep(newTimeStep: number): void;
  23217. /**
  23218. * Get the time step of the physics engine.
  23219. * @returns the current time step
  23220. */
  23221. getTimeStep(): number;
  23222. /**
  23223. * Release all resources
  23224. */
  23225. dispose(): void;
  23226. /**
  23227. * Gets the name of the current physics plugin
  23228. * @returns the name of the plugin
  23229. */
  23230. getPhysicsPluginName(): string;
  23231. /**
  23232. * Adding a new impostor for the impostor tracking.
  23233. * This will be done by the impostor itself.
  23234. * @param impostor the impostor to add
  23235. */
  23236. addImpostor(impostor: PhysicsImpostor): void;
  23237. /**
  23238. * Remove an impostor from the engine.
  23239. * This impostor and its mesh will not longer be updated by the physics engine.
  23240. * @param impostor the impostor to remove
  23241. */
  23242. removeImpostor(impostor: PhysicsImpostor): void;
  23243. /**
  23244. * Add a joint to the physics engine
  23245. * @param mainImpostor defines the main impostor to which the joint is added.
  23246. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23247. * @param joint defines the joint that will connect both impostors.
  23248. */
  23249. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23250. /**
  23251. * Removes a joint from the simulation
  23252. * @param mainImpostor defines the impostor used with the joint
  23253. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23254. * @param joint defines the joint to remove
  23255. */
  23256. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23257. /**
  23258. * Gets the current plugin used to run the simulation
  23259. * @returns current plugin
  23260. */
  23261. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23262. /**
  23263. * Gets the list of physic impostors
  23264. * @returns an array of PhysicsImpostor
  23265. */
  23266. getImpostors(): Array<PhysicsImpostor>;
  23267. /**
  23268. * Gets the impostor for a physics enabled object
  23269. * @param object defines the object impersonated by the impostor
  23270. * @returns the PhysicsImpostor or null if not found
  23271. */
  23272. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23273. /**
  23274. * Gets the impostor for a physics body object
  23275. * @param body defines physics body used by the impostor
  23276. * @returns the PhysicsImpostor or null if not found
  23277. */
  23278. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23279. /**
  23280. * Does a raycast in the physics world
  23281. * @param from when should the ray start?
  23282. * @param to when should the ray end?
  23283. * @returns PhysicsRaycastResult
  23284. */
  23285. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23286. /**
  23287. * Called by the scene. No need to call it.
  23288. * @param delta defines the timespam between frames
  23289. */
  23290. _step(delta: number): void;
  23291. }
  23292. }
  23293. declare module "babylonjs/Physics/physicsImpostor" {
  23294. import { Nullable, IndicesArray } from "babylonjs/types";
  23295. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23296. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23297. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23298. import { Scene } from "babylonjs/scene";
  23299. import { Bone } from "babylonjs/Bones/bone";
  23300. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23301. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23302. import { Space } from "babylonjs/Maths/math.axis";
  23303. /**
  23304. * The interface for the physics imposter parameters
  23305. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23306. */
  23307. export interface PhysicsImpostorParameters {
  23308. /**
  23309. * The mass of the physics imposter
  23310. */
  23311. mass: number;
  23312. /**
  23313. * The friction of the physics imposter
  23314. */
  23315. friction?: number;
  23316. /**
  23317. * The coefficient of restitution of the physics imposter
  23318. */
  23319. restitution?: number;
  23320. /**
  23321. * The native options of the physics imposter
  23322. */
  23323. nativeOptions?: any;
  23324. /**
  23325. * Specifies if the parent should be ignored
  23326. */
  23327. ignoreParent?: boolean;
  23328. /**
  23329. * Specifies if bi-directional transformations should be disabled
  23330. */
  23331. disableBidirectionalTransformation?: boolean;
  23332. /**
  23333. * The pressure inside the physics imposter, soft object only
  23334. */
  23335. pressure?: number;
  23336. /**
  23337. * The stiffness the physics imposter, soft object only
  23338. */
  23339. stiffness?: number;
  23340. /**
  23341. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23342. */
  23343. velocityIterations?: number;
  23344. /**
  23345. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23346. */
  23347. positionIterations?: number;
  23348. /**
  23349. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23350. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23351. * Add to fix multiple points
  23352. */
  23353. fixedPoints?: number;
  23354. /**
  23355. * The collision margin around a soft object
  23356. */
  23357. margin?: number;
  23358. /**
  23359. * The collision margin around a soft object
  23360. */
  23361. damping?: number;
  23362. /**
  23363. * The path for a rope based on an extrusion
  23364. */
  23365. path?: any;
  23366. /**
  23367. * The shape of an extrusion used for a rope based on an extrusion
  23368. */
  23369. shape?: any;
  23370. }
  23371. /**
  23372. * Interface for a physics-enabled object
  23373. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23374. */
  23375. export interface IPhysicsEnabledObject {
  23376. /**
  23377. * The position of the physics-enabled object
  23378. */
  23379. position: Vector3;
  23380. /**
  23381. * The rotation of the physics-enabled object
  23382. */
  23383. rotationQuaternion: Nullable<Quaternion>;
  23384. /**
  23385. * The scale of the physics-enabled object
  23386. */
  23387. scaling: Vector3;
  23388. /**
  23389. * The rotation of the physics-enabled object
  23390. */
  23391. rotation?: Vector3;
  23392. /**
  23393. * The parent of the physics-enabled object
  23394. */
  23395. parent?: any;
  23396. /**
  23397. * The bounding info of the physics-enabled object
  23398. * @returns The bounding info of the physics-enabled object
  23399. */
  23400. getBoundingInfo(): BoundingInfo;
  23401. /**
  23402. * Computes the world matrix
  23403. * @param force Specifies if the world matrix should be computed by force
  23404. * @returns A world matrix
  23405. */
  23406. computeWorldMatrix(force: boolean): Matrix;
  23407. /**
  23408. * Gets the world matrix
  23409. * @returns A world matrix
  23410. */
  23411. getWorldMatrix?(): Matrix;
  23412. /**
  23413. * Gets the child meshes
  23414. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23415. * @returns An array of abstract meshes
  23416. */
  23417. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23418. /**
  23419. * Gets the vertex data
  23420. * @param kind The type of vertex data
  23421. * @returns A nullable array of numbers, or a float32 array
  23422. */
  23423. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23424. /**
  23425. * Gets the indices from the mesh
  23426. * @returns A nullable array of index arrays
  23427. */
  23428. getIndices?(): Nullable<IndicesArray>;
  23429. /**
  23430. * Gets the scene from the mesh
  23431. * @returns the indices array or null
  23432. */
  23433. getScene?(): Scene;
  23434. /**
  23435. * Gets the absolute position from the mesh
  23436. * @returns the absolute position
  23437. */
  23438. getAbsolutePosition(): Vector3;
  23439. /**
  23440. * Gets the absolute pivot point from the mesh
  23441. * @returns the absolute pivot point
  23442. */
  23443. getAbsolutePivotPoint(): Vector3;
  23444. /**
  23445. * Rotates the mesh
  23446. * @param axis The axis of rotation
  23447. * @param amount The amount of rotation
  23448. * @param space The space of the rotation
  23449. * @returns The rotation transform node
  23450. */
  23451. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23452. /**
  23453. * Translates the mesh
  23454. * @param axis The axis of translation
  23455. * @param distance The distance of translation
  23456. * @param space The space of the translation
  23457. * @returns The transform node
  23458. */
  23459. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23460. /**
  23461. * Sets the absolute position of the mesh
  23462. * @param absolutePosition The absolute position of the mesh
  23463. * @returns The transform node
  23464. */
  23465. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23466. /**
  23467. * Gets the class name of the mesh
  23468. * @returns The class name
  23469. */
  23470. getClassName(): string;
  23471. }
  23472. /**
  23473. * Represents a physics imposter
  23474. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23475. */
  23476. export class PhysicsImpostor {
  23477. /**
  23478. * The physics-enabled object used as the physics imposter
  23479. */
  23480. object: IPhysicsEnabledObject;
  23481. /**
  23482. * The type of the physics imposter
  23483. */
  23484. type: number;
  23485. private _options;
  23486. private _scene?;
  23487. /**
  23488. * The default object size of the imposter
  23489. */
  23490. static DEFAULT_OBJECT_SIZE: Vector3;
  23491. /**
  23492. * The identity quaternion of the imposter
  23493. */
  23494. static IDENTITY_QUATERNION: Quaternion;
  23495. /** @hidden */
  23496. _pluginData: any;
  23497. private _physicsEngine;
  23498. private _physicsBody;
  23499. private _bodyUpdateRequired;
  23500. private _onBeforePhysicsStepCallbacks;
  23501. private _onAfterPhysicsStepCallbacks;
  23502. /** @hidden */
  23503. _onPhysicsCollideCallbacks: Array<{
  23504. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23505. otherImpostors: Array<PhysicsImpostor>;
  23506. }>;
  23507. private _deltaPosition;
  23508. private _deltaRotation;
  23509. private _deltaRotationConjugated;
  23510. /** @hidden */
  23511. _isFromLine: boolean;
  23512. private _parent;
  23513. private _isDisposed;
  23514. private static _tmpVecs;
  23515. private static _tmpQuat;
  23516. /**
  23517. * Specifies if the physics imposter is disposed
  23518. */
  23519. readonly isDisposed: boolean;
  23520. /**
  23521. * Gets the mass of the physics imposter
  23522. */
  23523. mass: number;
  23524. /**
  23525. * Gets the coefficient of friction
  23526. */
  23527. /**
  23528. * Sets the coefficient of friction
  23529. */
  23530. friction: number;
  23531. /**
  23532. * Gets the coefficient of restitution
  23533. */
  23534. /**
  23535. * Sets the coefficient of restitution
  23536. */
  23537. restitution: number;
  23538. /**
  23539. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23540. */
  23541. /**
  23542. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23543. */
  23544. pressure: number;
  23545. /**
  23546. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23547. */
  23548. /**
  23549. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23550. */
  23551. stiffness: number;
  23552. /**
  23553. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23554. */
  23555. /**
  23556. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23557. */
  23558. velocityIterations: number;
  23559. /**
  23560. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23561. */
  23562. /**
  23563. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23564. */
  23565. positionIterations: number;
  23566. /**
  23567. * The unique id of the physics imposter
  23568. * set by the physics engine when adding this impostor to the array
  23569. */
  23570. uniqueId: number;
  23571. /**
  23572. * @hidden
  23573. */
  23574. soft: boolean;
  23575. /**
  23576. * @hidden
  23577. */
  23578. segments: number;
  23579. private _joints;
  23580. /**
  23581. * Initializes the physics imposter
  23582. * @param object The physics-enabled object used as the physics imposter
  23583. * @param type The type of the physics imposter
  23584. * @param _options The options for the physics imposter
  23585. * @param _scene The Babylon scene
  23586. */
  23587. constructor(
  23588. /**
  23589. * The physics-enabled object used as the physics imposter
  23590. */
  23591. object: IPhysicsEnabledObject,
  23592. /**
  23593. * The type of the physics imposter
  23594. */
  23595. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23596. /**
  23597. * This function will completly initialize this impostor.
  23598. * It will create a new body - but only if this mesh has no parent.
  23599. * If it has, this impostor will not be used other than to define the impostor
  23600. * of the child mesh.
  23601. * @hidden
  23602. */
  23603. _init(): void;
  23604. private _getPhysicsParent;
  23605. /**
  23606. * Should a new body be generated.
  23607. * @returns boolean specifying if body initialization is required
  23608. */
  23609. isBodyInitRequired(): boolean;
  23610. /**
  23611. * Sets the updated scaling
  23612. * @param updated Specifies if the scaling is updated
  23613. */
  23614. setScalingUpdated(): void;
  23615. /**
  23616. * Force a regeneration of this or the parent's impostor's body.
  23617. * Use under cautious - This will remove all joints already implemented.
  23618. */
  23619. forceUpdate(): void;
  23620. /**
  23621. * Gets the body that holds this impostor. Either its own, or its parent.
  23622. */
  23623. /**
  23624. * Set the physics body. Used mainly by the physics engine/plugin
  23625. */
  23626. physicsBody: any;
  23627. /**
  23628. * Get the parent of the physics imposter
  23629. * @returns Physics imposter or null
  23630. */
  23631. /**
  23632. * Sets the parent of the physics imposter
  23633. */
  23634. parent: Nullable<PhysicsImpostor>;
  23635. /**
  23636. * Resets the update flags
  23637. */
  23638. resetUpdateFlags(): void;
  23639. /**
  23640. * Gets the object extend size
  23641. * @returns the object extend size
  23642. */
  23643. getObjectExtendSize(): Vector3;
  23644. /**
  23645. * Gets the object center
  23646. * @returns The object center
  23647. */
  23648. getObjectCenter(): Vector3;
  23649. /**
  23650. * Get a specific parametes from the options parameter
  23651. * @param paramName The object parameter name
  23652. * @returns The object parameter
  23653. */
  23654. getParam(paramName: string): any;
  23655. /**
  23656. * Sets a specific parameter in the options given to the physics plugin
  23657. * @param paramName The parameter name
  23658. * @param value The value of the parameter
  23659. */
  23660. setParam(paramName: string, value: number): void;
  23661. /**
  23662. * Specifically change the body's mass option. Won't recreate the physics body object
  23663. * @param mass The mass of the physics imposter
  23664. */
  23665. setMass(mass: number): void;
  23666. /**
  23667. * Gets the linear velocity
  23668. * @returns linear velocity or null
  23669. */
  23670. getLinearVelocity(): Nullable<Vector3>;
  23671. /**
  23672. * Sets the linear velocity
  23673. * @param velocity linear velocity or null
  23674. */
  23675. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23676. /**
  23677. * Gets the angular velocity
  23678. * @returns angular velocity or null
  23679. */
  23680. getAngularVelocity(): Nullable<Vector3>;
  23681. /**
  23682. * Sets the angular velocity
  23683. * @param velocity The velocity or null
  23684. */
  23685. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23686. /**
  23687. * Execute a function with the physics plugin native code
  23688. * Provide a function the will have two variables - the world object and the physics body object
  23689. * @param func The function to execute with the physics plugin native code
  23690. */
  23691. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23692. /**
  23693. * Register a function that will be executed before the physics world is stepping forward
  23694. * @param func The function to execute before the physics world is stepped forward
  23695. */
  23696. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23697. /**
  23698. * Unregister a function that will be executed before the physics world is stepping forward
  23699. * @param func The function to execute before the physics world is stepped forward
  23700. */
  23701. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23702. /**
  23703. * Register a function that will be executed after the physics step
  23704. * @param func The function to execute after physics step
  23705. */
  23706. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23707. /**
  23708. * Unregisters a function that will be executed after the physics step
  23709. * @param func The function to execute after physics step
  23710. */
  23711. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23712. /**
  23713. * register a function that will be executed when this impostor collides against a different body
  23714. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23715. * @param func Callback that is executed on collision
  23716. */
  23717. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23718. /**
  23719. * Unregisters the physics imposter on contact
  23720. * @param collideAgainst The physics object to collide against
  23721. * @param func Callback to execute on collision
  23722. */
  23723. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23724. private _tmpQuat;
  23725. private _tmpQuat2;
  23726. /**
  23727. * Get the parent rotation
  23728. * @returns The parent rotation
  23729. */
  23730. getParentsRotation(): Quaternion;
  23731. /**
  23732. * this function is executed by the physics engine.
  23733. */
  23734. beforeStep: () => void;
  23735. /**
  23736. * this function is executed by the physics engine
  23737. */
  23738. afterStep: () => void;
  23739. /**
  23740. * Legacy collision detection event support
  23741. */
  23742. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23743. /**
  23744. * event and body object due to cannon's event-based architecture.
  23745. */
  23746. onCollide: (e: {
  23747. body: any;
  23748. }) => void;
  23749. /**
  23750. * Apply a force
  23751. * @param force The force to apply
  23752. * @param contactPoint The contact point for the force
  23753. * @returns The physics imposter
  23754. */
  23755. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23756. /**
  23757. * Apply an impulse
  23758. * @param force The impulse force
  23759. * @param contactPoint The contact point for the impulse force
  23760. * @returns The physics imposter
  23761. */
  23762. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23763. /**
  23764. * A help function to create a joint
  23765. * @param otherImpostor A physics imposter used to create a joint
  23766. * @param jointType The type of joint
  23767. * @param jointData The data for the joint
  23768. * @returns The physics imposter
  23769. */
  23770. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23771. /**
  23772. * Add a joint to this impostor with a different impostor
  23773. * @param otherImpostor A physics imposter used to add a joint
  23774. * @param joint The joint to add
  23775. * @returns The physics imposter
  23776. */
  23777. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23778. /**
  23779. * Add an anchor to a cloth impostor
  23780. * @param otherImpostor rigid impostor to anchor to
  23781. * @param width ratio across width from 0 to 1
  23782. * @param height ratio up height from 0 to 1
  23783. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23784. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23785. * @returns impostor the soft imposter
  23786. */
  23787. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23788. /**
  23789. * Add a hook to a rope impostor
  23790. * @param otherImpostor rigid impostor to anchor to
  23791. * @param length ratio across rope from 0 to 1
  23792. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23793. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23794. * @returns impostor the rope imposter
  23795. */
  23796. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23797. /**
  23798. * Will keep this body still, in a sleep mode.
  23799. * @returns the physics imposter
  23800. */
  23801. sleep(): PhysicsImpostor;
  23802. /**
  23803. * Wake the body up.
  23804. * @returns The physics imposter
  23805. */
  23806. wakeUp(): PhysicsImpostor;
  23807. /**
  23808. * Clones the physics imposter
  23809. * @param newObject The physics imposter clones to this physics-enabled object
  23810. * @returns A nullable physics imposter
  23811. */
  23812. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23813. /**
  23814. * Disposes the physics imposter
  23815. */
  23816. dispose(): void;
  23817. /**
  23818. * Sets the delta position
  23819. * @param position The delta position amount
  23820. */
  23821. setDeltaPosition(position: Vector3): void;
  23822. /**
  23823. * Sets the delta rotation
  23824. * @param rotation The delta rotation amount
  23825. */
  23826. setDeltaRotation(rotation: Quaternion): void;
  23827. /**
  23828. * Gets the box size of the physics imposter and stores the result in the input parameter
  23829. * @param result Stores the box size
  23830. * @returns The physics imposter
  23831. */
  23832. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23833. /**
  23834. * Gets the radius of the physics imposter
  23835. * @returns Radius of the physics imposter
  23836. */
  23837. getRadius(): number;
  23838. /**
  23839. * Sync a bone with this impostor
  23840. * @param bone The bone to sync to the impostor.
  23841. * @param boneMesh The mesh that the bone is influencing.
  23842. * @param jointPivot The pivot of the joint / bone in local space.
  23843. * @param distToJoint Optional distance from the impostor to the joint.
  23844. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23845. */
  23846. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23847. /**
  23848. * Sync impostor to a bone
  23849. * @param bone The bone that the impostor will be synced to.
  23850. * @param boneMesh The mesh that the bone is influencing.
  23851. * @param jointPivot The pivot of the joint / bone in local space.
  23852. * @param distToJoint Optional distance from the impostor to the joint.
  23853. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23854. * @param boneAxis Optional vector3 axis the bone is aligned with
  23855. */
  23856. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23857. /**
  23858. * No-Imposter type
  23859. */
  23860. static NoImpostor: number;
  23861. /**
  23862. * Sphere-Imposter type
  23863. */
  23864. static SphereImpostor: number;
  23865. /**
  23866. * Box-Imposter type
  23867. */
  23868. static BoxImpostor: number;
  23869. /**
  23870. * Plane-Imposter type
  23871. */
  23872. static PlaneImpostor: number;
  23873. /**
  23874. * Mesh-imposter type
  23875. */
  23876. static MeshImpostor: number;
  23877. /**
  23878. * Capsule-Impostor type (Ammo.js plugin only)
  23879. */
  23880. static CapsuleImpostor: number;
  23881. /**
  23882. * Cylinder-Imposter type
  23883. */
  23884. static CylinderImpostor: number;
  23885. /**
  23886. * Particle-Imposter type
  23887. */
  23888. static ParticleImpostor: number;
  23889. /**
  23890. * Heightmap-Imposter type
  23891. */
  23892. static HeightmapImpostor: number;
  23893. /**
  23894. * ConvexHull-Impostor type (Ammo.js plugin only)
  23895. */
  23896. static ConvexHullImpostor: number;
  23897. /**
  23898. * Rope-Imposter type
  23899. */
  23900. static RopeImpostor: number;
  23901. /**
  23902. * Cloth-Imposter type
  23903. */
  23904. static ClothImpostor: number;
  23905. /**
  23906. * Softbody-Imposter type
  23907. */
  23908. static SoftbodyImpostor: number;
  23909. }
  23910. }
  23911. declare module "babylonjs/Meshes/mesh" {
  23912. import { Observable } from "babylonjs/Misc/observable";
  23913. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23914. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23915. import { Camera } from "babylonjs/Cameras/camera";
  23916. import { Scene } from "babylonjs/scene";
  23917. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  23918. import { Color4 } from "babylonjs/Maths/math.color";
  23919. import { Engine } from "babylonjs/Engines/engine";
  23920. import { Node } from "babylonjs/node";
  23921. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  23922. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  23923. import { Buffer } from "babylonjs/Meshes/buffer";
  23924. import { Geometry } from "babylonjs/Meshes/geometry";
  23925. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23926. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23927. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  23928. import { Effect } from "babylonjs/Materials/effect";
  23929. import { Material } from "babylonjs/Materials/material";
  23930. import { Skeleton } from "babylonjs/Bones/skeleton";
  23931. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  23932. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  23933. import { Path3D } from "babylonjs/Maths/math.path";
  23934. import { Plane } from "babylonjs/Maths/math.plane";
  23935. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23936. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  23937. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  23938. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  23939. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23940. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  23941. /**
  23942. * @hidden
  23943. **/
  23944. export class _CreationDataStorage {
  23945. closePath?: boolean;
  23946. closeArray?: boolean;
  23947. idx: number[];
  23948. dashSize: number;
  23949. gapSize: number;
  23950. path3D: Path3D;
  23951. pathArray: Vector3[][];
  23952. arc: number;
  23953. radius: number;
  23954. cap: number;
  23955. tessellation: number;
  23956. }
  23957. /**
  23958. * @hidden
  23959. **/
  23960. class _InstanceDataStorage {
  23961. visibleInstances: any;
  23962. batchCache: _InstancesBatch;
  23963. instancesBufferSize: number;
  23964. instancesBuffer: Nullable<Buffer>;
  23965. instancesData: Float32Array;
  23966. overridenInstanceCount: number;
  23967. isFrozen: boolean;
  23968. previousBatch: Nullable<_InstancesBatch>;
  23969. hardwareInstancedRendering: boolean;
  23970. sideOrientation: number;
  23971. }
  23972. /**
  23973. * @hidden
  23974. **/
  23975. export class _InstancesBatch {
  23976. mustReturn: boolean;
  23977. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  23978. renderSelf: boolean[];
  23979. hardwareInstancedRendering: boolean[];
  23980. }
  23981. /**
  23982. * Class used to represent renderable models
  23983. */
  23984. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23985. /**
  23986. * Mesh side orientation : usually the external or front surface
  23987. */
  23988. static readonly FRONTSIDE: number;
  23989. /**
  23990. * Mesh side orientation : usually the internal or back surface
  23991. */
  23992. static readonly BACKSIDE: number;
  23993. /**
  23994. * Mesh side orientation : both internal and external or front and back surfaces
  23995. */
  23996. static readonly DOUBLESIDE: number;
  23997. /**
  23998. * Mesh side orientation : by default, `FRONTSIDE`
  23999. */
  24000. static readonly DEFAULTSIDE: number;
  24001. /**
  24002. * Mesh cap setting : no cap
  24003. */
  24004. static readonly NO_CAP: number;
  24005. /**
  24006. * Mesh cap setting : one cap at the beginning of the mesh
  24007. */
  24008. static readonly CAP_START: number;
  24009. /**
  24010. * Mesh cap setting : one cap at the end of the mesh
  24011. */
  24012. static readonly CAP_END: number;
  24013. /**
  24014. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24015. */
  24016. static readonly CAP_ALL: number;
  24017. /**
  24018. * Mesh pattern setting : no flip or rotate
  24019. */
  24020. static readonly NO_FLIP: number;
  24021. /**
  24022. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24023. */
  24024. static readonly FLIP_TILE: number;
  24025. /**
  24026. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24027. */
  24028. static readonly ROTATE_TILE: number;
  24029. /**
  24030. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24031. */
  24032. static readonly FLIP_ROW: number;
  24033. /**
  24034. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24035. */
  24036. static readonly ROTATE_ROW: number;
  24037. /**
  24038. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24039. */
  24040. static readonly FLIP_N_ROTATE_TILE: number;
  24041. /**
  24042. * Mesh pattern setting : rotate pattern and rotate
  24043. */
  24044. static readonly FLIP_N_ROTATE_ROW: number;
  24045. /**
  24046. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24047. */
  24048. static readonly CENTER: number;
  24049. /**
  24050. * Mesh tile positioning : part tiles on left
  24051. */
  24052. static readonly LEFT: number;
  24053. /**
  24054. * Mesh tile positioning : part tiles on right
  24055. */
  24056. static readonly RIGHT: number;
  24057. /**
  24058. * Mesh tile positioning : part tiles on top
  24059. */
  24060. static readonly TOP: number;
  24061. /**
  24062. * Mesh tile positioning : part tiles on bottom
  24063. */
  24064. static readonly BOTTOM: number;
  24065. /**
  24066. * Gets the default side orientation.
  24067. * @param orientation the orientation to value to attempt to get
  24068. * @returns the default orientation
  24069. * @hidden
  24070. */
  24071. static _GetDefaultSideOrientation(orientation?: number): number;
  24072. private _internalMeshDataInfo;
  24073. /**
  24074. * An event triggered before rendering the mesh
  24075. */
  24076. readonly onBeforeRenderObservable: Observable<Mesh>;
  24077. /**
  24078. * An event triggered before binding the mesh
  24079. */
  24080. readonly onBeforeBindObservable: Observable<Mesh>;
  24081. /**
  24082. * An event triggered after rendering the mesh
  24083. */
  24084. readonly onAfterRenderObservable: Observable<Mesh>;
  24085. /**
  24086. * An event triggered before drawing the mesh
  24087. */
  24088. readonly onBeforeDrawObservable: Observable<Mesh>;
  24089. private _onBeforeDrawObserver;
  24090. /**
  24091. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24092. */
  24093. onBeforeDraw: () => void;
  24094. readonly hasInstances: boolean;
  24095. /**
  24096. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24097. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24098. */
  24099. delayLoadState: number;
  24100. /**
  24101. * Gets the list of instances created from this mesh
  24102. * it is not supposed to be modified manually.
  24103. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24104. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24105. */
  24106. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24107. /**
  24108. * Gets the file containing delay loading data for this mesh
  24109. */
  24110. delayLoadingFile: string;
  24111. /** @hidden */
  24112. _binaryInfo: any;
  24113. /**
  24114. * User defined function used to change how LOD level selection is done
  24115. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24116. */
  24117. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24118. /**
  24119. * Gets or sets the morph target manager
  24120. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24121. */
  24122. morphTargetManager: Nullable<MorphTargetManager>;
  24123. /** @hidden */
  24124. _creationDataStorage: Nullable<_CreationDataStorage>;
  24125. /** @hidden */
  24126. _geometry: Nullable<Geometry>;
  24127. /** @hidden */
  24128. _delayInfo: Array<string>;
  24129. /** @hidden */
  24130. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24131. /** @hidden */
  24132. _instanceDataStorage: _InstanceDataStorage;
  24133. private _effectiveMaterial;
  24134. /** @hidden */
  24135. _shouldGenerateFlatShading: boolean;
  24136. /** @hidden */
  24137. _originalBuilderSideOrientation: number;
  24138. /**
  24139. * Use this property to change the original side orientation defined at construction time
  24140. */
  24141. overrideMaterialSideOrientation: Nullable<number>;
  24142. /**
  24143. * Gets the source mesh (the one used to clone this one from)
  24144. */
  24145. readonly source: Nullable<Mesh>;
  24146. /**
  24147. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24148. */
  24149. isUnIndexed: boolean;
  24150. /**
  24151. * @constructor
  24152. * @param name The value used by scene.getMeshByName() to do a lookup.
  24153. * @param scene The scene to add this mesh to.
  24154. * @param parent The parent of this mesh, if it has one
  24155. * @param source An optional Mesh from which geometry is shared, cloned.
  24156. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24157. * When false, achieved by calling a clone(), also passing False.
  24158. * This will make creation of children, recursive.
  24159. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24160. */
  24161. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24162. instantiateHierarychy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  24163. /**
  24164. * Gets the class name
  24165. * @returns the string "Mesh".
  24166. */
  24167. getClassName(): string;
  24168. /** @hidden */
  24169. readonly _isMesh: boolean;
  24170. /**
  24171. * Returns a description of this mesh
  24172. * @param fullDetails define if full details about this mesh must be used
  24173. * @returns a descriptive string representing this mesh
  24174. */
  24175. toString(fullDetails?: boolean): string;
  24176. /** @hidden */
  24177. _unBindEffect(): void;
  24178. /**
  24179. * Gets a boolean indicating if this mesh has LOD
  24180. */
  24181. readonly hasLODLevels: boolean;
  24182. /**
  24183. * Gets the list of MeshLODLevel associated with the current mesh
  24184. * @returns an array of MeshLODLevel
  24185. */
  24186. getLODLevels(): MeshLODLevel[];
  24187. private _sortLODLevels;
  24188. /**
  24189. * Add a mesh as LOD level triggered at the given distance.
  24190. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24191. * @param distance The distance from the center of the object to show this level
  24192. * @param mesh The mesh to be added as LOD level (can be null)
  24193. * @return This mesh (for chaining)
  24194. */
  24195. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24196. /**
  24197. * Returns the LOD level mesh at the passed distance or null if not found.
  24198. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24199. * @param distance The distance from the center of the object to show this level
  24200. * @returns a Mesh or `null`
  24201. */
  24202. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24203. /**
  24204. * Remove a mesh from the LOD array
  24205. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24206. * @param mesh defines the mesh to be removed
  24207. * @return This mesh (for chaining)
  24208. */
  24209. removeLODLevel(mesh: Mesh): Mesh;
  24210. /**
  24211. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24212. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24213. * @param camera defines the camera to use to compute distance
  24214. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24215. * @return This mesh (for chaining)
  24216. */
  24217. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24218. /**
  24219. * Gets the mesh internal Geometry object
  24220. */
  24221. readonly geometry: Nullable<Geometry>;
  24222. /**
  24223. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24224. * @returns the total number of vertices
  24225. */
  24226. getTotalVertices(): number;
  24227. /**
  24228. * Returns the content of an associated vertex buffer
  24229. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24230. * - VertexBuffer.PositionKind
  24231. * - VertexBuffer.UVKind
  24232. * - VertexBuffer.UV2Kind
  24233. * - VertexBuffer.UV3Kind
  24234. * - VertexBuffer.UV4Kind
  24235. * - VertexBuffer.UV5Kind
  24236. * - VertexBuffer.UV6Kind
  24237. * - VertexBuffer.ColorKind
  24238. * - VertexBuffer.MatricesIndicesKind
  24239. * - VertexBuffer.MatricesIndicesExtraKind
  24240. * - VertexBuffer.MatricesWeightsKind
  24241. * - VertexBuffer.MatricesWeightsExtraKind
  24242. * @param copyWhenShared defines a boolean indicating that if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one
  24243. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24244. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24245. */
  24246. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24247. /**
  24248. * Returns the mesh VertexBuffer object from the requested `kind`
  24249. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24250. * - VertexBuffer.PositionKind
  24251. * - VertexBuffer.NormalKind
  24252. * - VertexBuffer.UVKind
  24253. * - VertexBuffer.UV2Kind
  24254. * - VertexBuffer.UV3Kind
  24255. * - VertexBuffer.UV4Kind
  24256. * - VertexBuffer.UV5Kind
  24257. * - VertexBuffer.UV6Kind
  24258. * - VertexBuffer.ColorKind
  24259. * - VertexBuffer.MatricesIndicesKind
  24260. * - VertexBuffer.MatricesIndicesExtraKind
  24261. * - VertexBuffer.MatricesWeightsKind
  24262. * - VertexBuffer.MatricesWeightsExtraKind
  24263. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24264. */
  24265. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24266. /**
  24267. * Tests if a specific vertex buffer is associated with this mesh
  24268. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24269. * - VertexBuffer.PositionKind
  24270. * - VertexBuffer.NormalKind
  24271. * - VertexBuffer.UVKind
  24272. * - VertexBuffer.UV2Kind
  24273. * - VertexBuffer.UV3Kind
  24274. * - VertexBuffer.UV4Kind
  24275. * - VertexBuffer.UV5Kind
  24276. * - VertexBuffer.UV6Kind
  24277. * - VertexBuffer.ColorKind
  24278. * - VertexBuffer.MatricesIndicesKind
  24279. * - VertexBuffer.MatricesIndicesExtraKind
  24280. * - VertexBuffer.MatricesWeightsKind
  24281. * - VertexBuffer.MatricesWeightsExtraKind
  24282. * @returns a boolean
  24283. */
  24284. isVerticesDataPresent(kind: string): boolean;
  24285. /**
  24286. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24287. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24288. * - VertexBuffer.PositionKind
  24289. * - VertexBuffer.UVKind
  24290. * - VertexBuffer.UV2Kind
  24291. * - VertexBuffer.UV3Kind
  24292. * - VertexBuffer.UV4Kind
  24293. * - VertexBuffer.UV5Kind
  24294. * - VertexBuffer.UV6Kind
  24295. * - VertexBuffer.ColorKind
  24296. * - VertexBuffer.MatricesIndicesKind
  24297. * - VertexBuffer.MatricesIndicesExtraKind
  24298. * - VertexBuffer.MatricesWeightsKind
  24299. * - VertexBuffer.MatricesWeightsExtraKind
  24300. * @returns a boolean
  24301. */
  24302. isVertexBufferUpdatable(kind: string): boolean;
  24303. /**
  24304. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24305. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24306. * - VertexBuffer.PositionKind
  24307. * - VertexBuffer.NormalKind
  24308. * - VertexBuffer.UVKind
  24309. * - VertexBuffer.UV2Kind
  24310. * - VertexBuffer.UV3Kind
  24311. * - VertexBuffer.UV4Kind
  24312. * - VertexBuffer.UV5Kind
  24313. * - VertexBuffer.UV6Kind
  24314. * - VertexBuffer.ColorKind
  24315. * - VertexBuffer.MatricesIndicesKind
  24316. * - VertexBuffer.MatricesIndicesExtraKind
  24317. * - VertexBuffer.MatricesWeightsKind
  24318. * - VertexBuffer.MatricesWeightsExtraKind
  24319. * @returns an array of strings
  24320. */
  24321. getVerticesDataKinds(): string[];
  24322. /**
  24323. * Returns a positive integer : the total number of indices in this mesh geometry.
  24324. * @returns the numner of indices or zero if the mesh has no geometry.
  24325. */
  24326. getTotalIndices(): number;
  24327. /**
  24328. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24329. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  24330. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24331. * @returns the indices array or an empty array if the mesh has no geometry
  24332. */
  24333. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24334. readonly isBlocked: boolean;
  24335. /**
  24336. * Determine if the current mesh is ready to be rendered
  24337. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24338. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24339. * @returns true if all associated assets are ready (material, textures, shaders)
  24340. */
  24341. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24342. /**
  24343. * Gets a boolean indicating if the normals aren't to be recomputed on next mesh `positions` array update. This property is pertinent only for updatable parametric shapes.
  24344. */
  24345. readonly areNormalsFrozen: boolean;
  24346. /**
  24347. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It prevents the mesh normals from being recomputed on next `positions` array update.
  24348. * @returns the current mesh
  24349. */
  24350. freezeNormals(): Mesh;
  24351. /**
  24352. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It reactivates the mesh normals computation if it was previously frozen
  24353. * @returns the current mesh
  24354. */
  24355. unfreezeNormals(): Mesh;
  24356. /**
  24357. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24358. */
  24359. overridenInstanceCount: number;
  24360. /** @hidden */
  24361. _preActivate(): Mesh;
  24362. /** @hidden */
  24363. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24364. /** @hidden */
  24365. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24366. /**
  24367. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24368. * This means the mesh underlying bounding box and sphere are recomputed.
  24369. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24370. * @returns the current mesh
  24371. */
  24372. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24373. /** @hidden */
  24374. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24375. /**
  24376. * This function will subdivide the mesh into multiple submeshes
  24377. * @param count defines the expected number of submeshes
  24378. */
  24379. subdivide(count: number): void;
  24380. /**
  24381. * Copy a FloatArray into a specific associated vertex buffer
  24382. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24383. * - VertexBuffer.PositionKind
  24384. * - VertexBuffer.UVKind
  24385. * - VertexBuffer.UV2Kind
  24386. * - VertexBuffer.UV3Kind
  24387. * - VertexBuffer.UV4Kind
  24388. * - VertexBuffer.UV5Kind
  24389. * - VertexBuffer.UV6Kind
  24390. * - VertexBuffer.ColorKind
  24391. * - VertexBuffer.MatricesIndicesKind
  24392. * - VertexBuffer.MatricesIndicesExtraKind
  24393. * - VertexBuffer.MatricesWeightsKind
  24394. * - VertexBuffer.MatricesWeightsExtraKind
  24395. * @param data defines the data source
  24396. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24397. * @param stride defines the data stride size (can be null)
  24398. * @returns the current mesh
  24399. */
  24400. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24401. /**
  24402. * Flags an associated vertex buffer as updatable
  24403. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24404. * - VertexBuffer.PositionKind
  24405. * - VertexBuffer.UVKind
  24406. * - VertexBuffer.UV2Kind
  24407. * - VertexBuffer.UV3Kind
  24408. * - VertexBuffer.UV4Kind
  24409. * - VertexBuffer.UV5Kind
  24410. * - VertexBuffer.UV6Kind
  24411. * - VertexBuffer.ColorKind
  24412. * - VertexBuffer.MatricesIndicesKind
  24413. * - VertexBuffer.MatricesIndicesExtraKind
  24414. * - VertexBuffer.MatricesWeightsKind
  24415. * - VertexBuffer.MatricesWeightsExtraKind
  24416. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24417. */
  24418. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24419. /**
  24420. * Sets the mesh global Vertex Buffer
  24421. * @param buffer defines the buffer to use
  24422. * @returns the current mesh
  24423. */
  24424. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24425. /**
  24426. * Update a specific associated vertex buffer
  24427. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24428. * - VertexBuffer.PositionKind
  24429. * - VertexBuffer.UVKind
  24430. * - VertexBuffer.UV2Kind
  24431. * - VertexBuffer.UV3Kind
  24432. * - VertexBuffer.UV4Kind
  24433. * - VertexBuffer.UV5Kind
  24434. * - VertexBuffer.UV6Kind
  24435. * - VertexBuffer.ColorKind
  24436. * - VertexBuffer.MatricesIndicesKind
  24437. * - VertexBuffer.MatricesIndicesExtraKind
  24438. * - VertexBuffer.MatricesWeightsKind
  24439. * - VertexBuffer.MatricesWeightsExtraKind
  24440. * @param data defines the data source
  24441. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24442. * @param makeItUnique defines if the geometry associated with the mesh must be cloned to make the change only for this mesh (and not all meshes associated with the same geometry)
  24443. * @returns the current mesh
  24444. */
  24445. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24446. /**
  24447. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24448. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24449. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24450. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24451. * @returns the current mesh
  24452. */
  24453. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24454. /**
  24455. * Creates a un-shared specific occurence of the geometry for the mesh.
  24456. * @returns the current mesh
  24457. */
  24458. makeGeometryUnique(): Mesh;
  24459. /**
  24460. * Set the index buffer of this mesh
  24461. * @param indices defines the source data
  24462. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24463. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24464. * @returns the current mesh
  24465. */
  24466. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24467. /**
  24468. * Update the current index buffer
  24469. * @param indices defines the source data
  24470. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24471. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  24472. * @returns the current mesh
  24473. */
  24474. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24475. /**
  24476. * Invert the geometry to move from a right handed system to a left handed one.
  24477. * @returns the current mesh
  24478. */
  24479. toLeftHanded(): Mesh;
  24480. /** @hidden */
  24481. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24482. /** @hidden */
  24483. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24484. /**
  24485. * Registers for this mesh a javascript function called just before the rendering process
  24486. * @param func defines the function to call before rendering this mesh
  24487. * @returns the current mesh
  24488. */
  24489. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24490. /**
  24491. * Disposes a previously registered javascript function called before the rendering
  24492. * @param func defines the function to remove
  24493. * @returns the current mesh
  24494. */
  24495. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24496. /**
  24497. * Registers for this mesh a javascript function called just after the rendering is complete
  24498. * @param func defines the function to call after rendering this mesh
  24499. * @returns the current mesh
  24500. */
  24501. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24502. /**
  24503. * Disposes a previously registered javascript function called after the rendering.
  24504. * @param func defines the function to remove
  24505. * @returns the current mesh
  24506. */
  24507. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24508. /** @hidden */
  24509. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24510. /** @hidden */
  24511. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24512. /** @hidden */
  24513. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24514. /** @hidden */
  24515. _rebuild(): void;
  24516. /** @hidden */
  24517. _freeze(): void;
  24518. /** @hidden */
  24519. _unFreeze(): void;
  24520. /**
  24521. * Triggers the draw call for the mesh. Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager
  24522. * @param subMesh defines the subMesh to render
  24523. * @param enableAlphaMode defines if alpha mode can be changed
  24524. * @returns the current mesh
  24525. */
  24526. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  24527. private _onBeforeDraw;
  24528. /**
  24529. * Renormalize the mesh and patch it up if there are no weights
  24530. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24531. * However in the case of zero weights then we set just a single influence to 1.
  24532. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24533. */
  24534. cleanMatrixWeights(): void;
  24535. private normalizeSkinFourWeights;
  24536. private normalizeSkinWeightsAndExtra;
  24537. /**
  24538. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24539. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24540. * the user know there was an issue with importing the mesh
  24541. * @returns a validation object with skinned, valid and report string
  24542. */
  24543. validateSkinning(): {
  24544. skinned: boolean;
  24545. valid: boolean;
  24546. report: string;
  24547. };
  24548. /** @hidden */
  24549. _checkDelayState(): Mesh;
  24550. private _queueLoad;
  24551. /**
  24552. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24553. * A mesh is in the frustum if its bounding box intersects the frustum
  24554. * @param frustumPlanes defines the frustum to test
  24555. * @returns true if the mesh is in the frustum planes
  24556. */
  24557. isInFrustum(frustumPlanes: Plane[]): boolean;
  24558. /**
  24559. * Sets the mesh material by the material or multiMaterial `id` property
  24560. * @param id is a string identifying the material or the multiMaterial
  24561. * @returns the current mesh
  24562. */
  24563. setMaterialByID(id: string): Mesh;
  24564. /**
  24565. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24566. * @returns an array of IAnimatable
  24567. */
  24568. getAnimatables(): IAnimatable[];
  24569. /**
  24570. * Modifies the mesh geometry according to the passed transformation matrix.
  24571. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24572. * The mesh normals are modified using the same transformation.
  24573. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24574. * @param transform defines the transform matrix to use
  24575. * @see http://doc.babylonjs.com/resources/baking_transformations
  24576. * @returns the current mesh
  24577. */
  24578. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24579. /**
  24580. * Modifies the mesh geometry according to its own current World Matrix.
  24581. * The mesh World Matrix is then reset.
  24582. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24583. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24584. * @see http://doc.babylonjs.com/resources/baking_transformations
  24585. * @returns the current mesh
  24586. */
  24587. bakeCurrentTransformIntoVertices(): Mesh;
  24588. /** @hidden */
  24589. readonly _positions: Nullable<Vector3[]>;
  24590. /** @hidden */
  24591. _resetPointsArrayCache(): Mesh;
  24592. /** @hidden */
  24593. _generatePointsArray(): boolean;
  24594. /**
  24595. * Returns a new Mesh object generated from the current mesh properties.
  24596. * This method must not get confused with createInstance()
  24597. * @param name is a string, the name given to the new mesh
  24598. * @param newParent can be any Node object (default `null`)
  24599. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24600. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24601. * @returns a new mesh
  24602. */
  24603. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24604. /**
  24605. * Releases resources associated with this mesh.
  24606. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24607. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24608. */
  24609. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24610. /**
  24611. * Modifies the mesh geometry according to a displacement map.
  24612. * A displacement map is a colored image. Each pixel color value (actually a gradient computed from red, green, blue values) will give the displacement to apply to each mesh vertex.
  24613. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24614. * @param url is a string, the URL from the image file is to be downloaded.
  24615. * @param minHeight is the lower limit of the displacement.
  24616. * @param maxHeight is the upper limit of the displacement.
  24617. * @param onSuccess is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  24618. * @param uvOffset is an optional vector2 used to offset UV.
  24619. * @param uvScale is an optional vector2 used to scale UV.
  24620. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  24621. * @returns the Mesh.
  24622. */
  24623. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24624. /**
  24625. * Modifies the mesh geometry according to a displacementMap buffer.
  24626. * A displacement map is a colored image. Each pixel color value (actually a gradient computed from red, green, blue values) will give the displacement to apply to each mesh vertex.
  24627. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24628. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24629. * @param heightMapWidth is the width of the buffer image.
  24630. * @param heightMapHeight is the height of the buffer image.
  24631. * @param minHeight is the lower limit of the displacement.
  24632. * @param maxHeight is the upper limit of the displacement.
  24633. * @param onSuccess is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  24634. * @param uvOffset is an optional vector2 used to offset UV.
  24635. * @param uvScale is an optional vector2 used to scale UV.
  24636. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  24637. * @returns the Mesh.
  24638. */
  24639. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24640. /**
  24641. * Modify the mesh to get a flat shading rendering.
  24642. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24643. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24644. * @returns current mesh
  24645. */
  24646. convertToFlatShadedMesh(): Mesh;
  24647. /**
  24648. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24649. * In other words, more vertices, no more indices and a single bigger VBO.
  24650. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24651. * @returns current mesh
  24652. */
  24653. convertToUnIndexedMesh(): Mesh;
  24654. /**
  24655. * Inverses facet orientations.
  24656. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24657. * @param flipNormals will also inverts the normals
  24658. * @returns current mesh
  24659. */
  24660. flipFaces(flipNormals?: boolean): Mesh;
  24661. /**
  24662. * Increase the number of facets and hence vertices in a mesh
  24663. * Vertex normals are interpolated from existing vertex normals
  24664. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24665. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24666. */
  24667. increaseVertices(numberPerEdge: number): void;
  24668. /**
  24669. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24670. * This will undo any application of covertToFlatShadedMesh
  24671. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24672. */
  24673. forceSharedVertices(): void;
  24674. /** @hidden */
  24675. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24676. /** @hidden */
  24677. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24678. /**
  24679. * Creates a new InstancedMesh object from the mesh model.
  24680. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24681. * @param name defines the name of the new instance
  24682. * @returns a new InstancedMesh
  24683. */
  24684. createInstance(name: string): InstancedMesh;
  24685. /**
  24686. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24687. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24688. * @returns the current mesh
  24689. */
  24690. synchronizeInstances(): Mesh;
  24691. /**
  24692. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24693. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24694. * This should be used together with the simplification to avoid disappearing triangles.
  24695. * @param successCallback an optional success callback to be called after the optimization finished.
  24696. * @returns the current mesh
  24697. */
  24698. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24699. /**
  24700. * Serialize current mesh
  24701. * @param serializationObject defines the object which will receive the serialization data
  24702. */
  24703. serialize(serializationObject: any): void;
  24704. /** @hidden */
  24705. _syncGeometryWithMorphTargetManager(): void;
  24706. /** @hidden */
  24707. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24708. /**
  24709. * Returns a new Mesh object parsed from the source provided.
  24710. * @param parsedMesh is the source
  24711. * @param scene defines the hosting scene
  24712. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24713. * @returns a new Mesh
  24714. */
  24715. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24716. /**
  24717. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24718. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24719. * @param name defines the name of the mesh to create
  24720. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24721. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24722. * @param closePath creates a seam between the first and the last points of each path of the path array
  24723. * @param offset is taken in account only if the `pathArray` is containing a single path
  24724. * @param scene defines the hosting scene
  24725. * @param updatable defines if the mesh must be flagged as updatable
  24726. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24727. * @param instance defines an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#ribbon)
  24728. * @returns a new Mesh
  24729. */
  24730. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24731. /**
  24732. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24733. * @param name defines the name of the mesh to create
  24734. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24735. * @param tessellation sets the number of polygon sides (positive integer, default 64). So a tessellation valued to 3 will build a triangle, to 4 a square, etc
  24736. * @param scene defines the hosting scene
  24737. * @param updatable defines if the mesh must be flagged as updatable
  24738. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24739. * @returns a new Mesh
  24740. */
  24741. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24742. /**
  24743. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24744. * @param name defines the name of the mesh to create
  24745. * @param size sets the size (float) of each box side (default 1)
  24746. * @param scene defines the hosting scene
  24747. * @param updatable defines if the mesh must be flagged as updatable
  24748. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24749. * @returns a new Mesh
  24750. */
  24751. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24752. /**
  24753. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24754. * @param name defines the name of the mesh to create
  24755. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24756. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24757. * @param scene defines the hosting scene
  24758. * @param updatable defines if the mesh must be flagged as updatable
  24759. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24760. * @returns a new Mesh
  24761. */
  24762. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24763. /**
  24764. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24765. * @param name defines the name of the mesh to create
  24766. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24767. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24768. * @param scene defines the hosting scene
  24769. * @returns a new Mesh
  24770. */
  24771. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24772. /**
  24773. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24774. * @param name defines the name of the mesh to create
  24775. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24776. * @param diameterTop set the top cap diameter (floats, default 1)
  24777. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24778. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24779. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24780. * @param scene defines the hosting scene
  24781. * @param updatable defines if the mesh must be flagged as updatable
  24782. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24783. * @returns a new Mesh
  24784. */
  24785. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24786. /**
  24787. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24788. * @param name defines the name of the mesh to create
  24789. * @param diameter sets the diameter size (float) of the torus (default 1)
  24790. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24791. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24792. * @param scene defines the hosting scene
  24793. * @param updatable defines if the mesh must be flagged as updatable
  24794. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24795. * @returns a new Mesh
  24796. */
  24797. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24798. /**
  24799. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24800. * @param name defines the name of the mesh to create
  24801. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24802. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24803. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24804. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24805. * @param p the number of windings on X axis (positive integers, default 2)
  24806. * @param q the number of windings on Y axis (positive integers, default 3)
  24807. * @param scene defines the hosting scene
  24808. * @param updatable defines if the mesh must be flagged as updatable
  24809. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24810. * @returns a new Mesh
  24811. */
  24812. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24813. /**
  24814. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24815. * @param name defines the name of the mesh to create
  24816. * @param points is an array successive Vector3
  24817. * @param scene defines the hosting scene
  24818. * @param updatable defines if the mesh must be flagged as updatable
  24819. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines).
  24820. * @returns a new Mesh
  24821. */
  24822. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24823. /**
  24824. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24825. * @param name defines the name of the mesh to create
  24826. * @param points is an array successive Vector3
  24827. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24828. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24829. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24830. * @param scene defines the hosting scene
  24831. * @param updatable defines if the mesh must be flagged as updatable
  24832. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines)
  24833. * @returns a new Mesh
  24834. */
  24835. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24836. /**
  24837. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24838. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24839. * The parameter `shape` is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors.
  24840. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24841. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24842. * Remember you can only change the shape positions, not their number when updating a polygon.
  24843. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24844. * @param name defines the name of the mesh to create
  24845. * @param shape is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  24846. * @param scene defines the hosting scene
  24847. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24848. * @param updatable defines if the mesh must be flagged as updatable
  24849. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24850. * @param earcutInjection can be used to inject your own earcut reference
  24851. * @returns a new Mesh
  24852. */
  24853. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24854. /**
  24855. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24856. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24857. * @param name defines the name of the mesh to create
  24858. * @param shape is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  24859. * @param depth defines the height of extrusion
  24860. * @param scene defines the hosting scene
  24861. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24862. * @param updatable defines if the mesh must be flagged as updatable
  24863. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24864. * @param earcutInjection can be used to inject your own earcut reference
  24865. * @returns a new Mesh
  24866. */
  24867. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24868. /**
  24869. * Creates an extruded shape mesh.
  24870. * The extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters. Please consider using the same method from the MeshBuilder class instead
  24871. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24872. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24873. * @param name defines the name of the mesh to create
  24874. * @param shape is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis
  24875. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24876. * @param scale is the value to scale the shape
  24877. * @param rotation is the angle value to rotate the shape each step (each path point), from the former step (so rotation added each step) along the curve
  24878. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  24879. * @param scene defines the hosting scene
  24880. * @param updatable defines if the mesh must be flagged as updatable
  24881. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24882. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#extruded-shape)
  24883. * @returns a new Mesh
  24884. */
  24885. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24886. /**
  24887. * Creates an custom extruded shape mesh.
  24888. * The custom extrusion is a parametric shape.
  24889. * It has no predefined shape. Its final shape will depend on the input parameters.
  24890. * Please consider using the same method from the MeshBuilder class instead
  24891. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24892. * @param name defines the name of the mesh to create
  24893. * @param shape is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis
  24894. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24895. * @param scaleFunction is a custom Javascript function called on each path point
  24896. * @param rotationFunction is a custom Javascript function called on each path point
  24897. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24898. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24899. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  24900. * @param scene defines the hosting scene
  24901. * @param updatable defines if the mesh must be flagged as updatable
  24902. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24903. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape)
  24904. * @returns a new Mesh
  24905. */
  24906. static ExtrudeShapeCustom(name: string, shape: Vector3[], path: Vector3[], scaleFunction: Function, rotationFunction: Function, ribbonCloseArray: boolean, ribbonClosePath: boolean, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24907. /**
  24908. * Creates lathe mesh.
  24909. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24910. * Please consider using the same method from the MeshBuilder class instead
  24911. * @param name defines the name of the mesh to create
  24912. * @param shape is a required array of successive Vector3. This array depicts the shape to be rotated in its local space : the shape must be designed in the xOy plane and will be rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero
  24913. * @param radius is the radius value of the lathe
  24914. * @param tessellation is the side number of the lathe.
  24915. * @param scene defines the hosting scene
  24916. * @param updatable defines if the mesh must be flagged as updatable
  24917. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24918. * @returns a new Mesh
  24919. */
  24920. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24921. /**
  24922. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24923. * @param name defines the name of the mesh to create
  24924. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24925. * @param scene defines the hosting scene
  24926. * @param updatable defines if the mesh must be flagged as updatable
  24927. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24928. * @returns a new Mesh
  24929. */
  24930. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24931. /**
  24932. * Creates a ground mesh.
  24933. * Please consider using the same method from the MeshBuilder class instead
  24934. * @param name defines the name of the mesh to create
  24935. * @param width set the width of the ground
  24936. * @param height set the height of the ground
  24937. * @param subdivisions sets the number of subdivisions per side
  24938. * @param scene defines the hosting scene
  24939. * @param updatable defines if the mesh must be flagged as updatable
  24940. * @returns a new Mesh
  24941. */
  24942. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24943. /**
  24944. * Creates a tiled ground mesh.
  24945. * Please consider using the same method from the MeshBuilder class instead
  24946. * @param name defines the name of the mesh to create
  24947. * @param xmin set the ground minimum X coordinate
  24948. * @param zmin set the ground minimum Y coordinate
  24949. * @param xmax set the ground maximum X coordinate
  24950. * @param zmax set the ground maximum Z coordinate
  24951. * @param subdivisions is an object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the numbers of subdivisions on the ground width and height. Each subdivision is called a tile
  24952. * @param precision is an object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the numbers of subdivisions on the ground width and height of each tile
  24953. * @param scene defines the hosting scene
  24954. * @param updatable defines if the mesh must be flagged as updatable
  24955. * @returns a new Mesh
  24956. */
  24957. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24958. w: number;
  24959. h: number;
  24960. }, precision: {
  24961. w: number;
  24962. h: number;
  24963. }, scene: Scene, updatable?: boolean): Mesh;
  24964. /**
  24965. * Creates a ground mesh from a height map.
  24966. * Please consider using the same method from the MeshBuilder class instead
  24967. * @see http://doc.babylonjs.com/babylon101/height_map
  24968. * @param name defines the name of the mesh to create
  24969. * @param url sets the URL of the height map image resource
  24970. * @param width set the ground width size
  24971. * @param height set the ground height size
  24972. * @param subdivisions sets the number of subdivision per side
  24973. * @param minHeight is the minimum altitude on the ground
  24974. * @param maxHeight is the maximum altitude on the ground
  24975. * @param scene defines the hosting scene
  24976. * @param updatable defines if the mesh must be flagged as updatable
  24977. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24978. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24979. * @returns a new Mesh
  24980. */
  24981. static CreateGroundFromHeightMap(name: string, url: string, width: number, height: number, subdivisions: number, minHeight: number, maxHeight: number, scene: Scene, updatable?: boolean, onReady?: (mesh: GroundMesh) => void, alphaFilter?: number): GroundMesh;
  24982. /**
  24983. * Creates a tube mesh.
  24984. * The tube is a parametric shape.
  24985. * It has no predefined shape. Its final shape will depend on the input parameters.
  24986. * Please consider using the same method from the MeshBuilder class instead
  24987. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24988. * @param name defines the name of the mesh to create
  24989. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24990. * @param radius sets the tube radius size
  24991. * @param tessellation is the number of sides on the tubular surface
  24992. * @param radiusFunction is a custom function. If it is not null, it overwrittes the parameter `radius`. This function is called on each point of the tube path and is passed the index `i` of the i-th point and the distance of this point from the first point of the path
  24993. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  24994. * @param scene defines the hosting scene
  24995. * @param updatable defines if the mesh must be flagged as updatable
  24996. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24997. * @param instance is an instance of an existing Tube object to be updated with the passed `pathArray` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#tube)
  24998. * @returns a new Mesh
  24999. */
  25000. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25001. (i: number, distance: number): number;
  25002. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25003. /**
  25004. * Creates a polyhedron mesh.
  25005. * Please consider using the same method from the MeshBuilder class instead.
  25006. * * The parameter `type` (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embbeded types. Please refer to the type sheet in the tutorial to choose the wanted type
  25007. * * The parameter `size` (positive float, default 1) sets the polygon size
  25008. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25009. * * You can build other polyhedron types than the 15 embbeded ones by setting the parameter `custom` (`polyhedronObject`, default null). If you set the parameter `custom`, this overwrittes the parameter `type`
  25010. * * A `polyhedronObject` is a formatted javascript object. You'll find a full file with pre-set polyhedra here : https://github.com/BabylonJS/Extensions/tree/master/Polyhedron
  25011. * * You can set the color and the UV of each side of the polyhedron with the parameters `faceColors` (Color4, default `(1, 1, 1, 1)`) and faceUV (Vector4, default `(0, 0, 1, 1)`)
  25012. * * To understand how to set `faceUV` or `faceColors`, please read this by considering the right number of faces of your polyhedron, instead of only 6 for the box : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  25013. * * The parameter `flat` (boolean, default true). If set to false, it gives the polyhedron a single global face, so less vertices and shared normals. In this case, `faceColors` and `faceUV` are ignored
  25014. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25015. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  25016. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25017. * @param name defines the name of the mesh to create
  25018. * @param options defines the options used to create the mesh
  25019. * @param scene defines the hosting scene
  25020. * @returns a new Mesh
  25021. */
  25022. static CreatePolyhedron(name: string, options: {
  25023. type?: number;
  25024. size?: number;
  25025. sizeX?: number;
  25026. sizeY?: number;
  25027. sizeZ?: number;
  25028. custom?: any;
  25029. faceUV?: Vector4[];
  25030. faceColors?: Color4[];
  25031. updatable?: boolean;
  25032. sideOrientation?: number;
  25033. }, scene: Scene): Mesh;
  25034. /**
  25035. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25036. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25037. * * You can set some different icosphere dimensions, for instance to build an ellipsoid, by using the parameters `radiusX`, `radiusY` and `radiusZ` (all by default have the same value than `radius`)
  25038. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25039. * * The parameter `flat` (boolean, default true) gives each side its own normals. Set it to false to get a smooth continuous light reflection on the surface
  25040. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25041. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  25042. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25043. * @param name defines the name of the mesh
  25044. * @param options defines the options used to create the mesh
  25045. * @param scene defines the hosting scene
  25046. * @returns a new Mesh
  25047. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25048. */
  25049. static CreateIcoSphere(name: string, options: {
  25050. radius?: number;
  25051. flat?: boolean;
  25052. subdivisions?: number;
  25053. sideOrientation?: number;
  25054. updatable?: boolean;
  25055. }, scene: Scene): Mesh;
  25056. /**
  25057. * Creates a decal mesh.
  25058. * Please consider using the same method from the MeshBuilder class instead.
  25059. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25060. * @param name defines the name of the mesh
  25061. * @param sourceMesh defines the mesh receiving the decal
  25062. * @param position sets the position of the decal in world coordinates
  25063. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25064. * @param size sets the decal scaling
  25065. * @param angle sets the angle to rotate the decal
  25066. * @returns a new Mesh
  25067. */
  25068. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25069. /**
  25070. * Prepare internal position array for software CPU skinning
  25071. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25072. */
  25073. setPositionsForCPUSkinning(): Float32Array;
  25074. /**
  25075. * Prepare internal normal array for software CPU skinning
  25076. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25077. */
  25078. setNormalsForCPUSkinning(): Float32Array;
  25079. /**
  25080. * Updates the vertex buffer by applying transformation from the bones
  25081. * @param skeleton defines the skeleton to apply to current mesh
  25082. * @returns the current mesh
  25083. */
  25084. applySkeleton(skeleton: Skeleton): Mesh;
  25085. /**
  25086. * Returns an object containing a min and max Vector3 which are the minimum and maximum vectors of each mesh bounding box from the passed array, in the world coordinates
  25087. * @param meshes defines the list of meshes to scan
  25088. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25089. */
  25090. static MinMax(meshes: AbstractMesh[]): {
  25091. min: Vector3;
  25092. max: Vector3;
  25093. };
  25094. /**
  25095. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25096. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25097. * @returns a vector3
  25098. */
  25099. static Center(meshesOrMinMaxVector: {
  25100. min: Vector3;
  25101. max: Vector3;
  25102. } | AbstractMesh[]): Vector3;
  25103. /**
  25104. * Merge the array of meshes into a single mesh for performance reasons.
  25105. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25106. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25107. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25108. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25109. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25110. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25111. * @returns a new mesh
  25112. */
  25113. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25114. /** @hidden */
  25115. addInstance(instance: InstancedMesh): void;
  25116. /** @hidden */
  25117. removeInstance(instance: InstancedMesh): void;
  25118. }
  25119. }
  25120. declare module "babylonjs/Cameras/camera" {
  25121. import { SmartArray } from "babylonjs/Misc/smartArray";
  25122. import { Observable } from "babylonjs/Misc/observable";
  25123. import { Nullable } from "babylonjs/types";
  25124. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25125. import { Scene } from "babylonjs/scene";
  25126. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  25127. import { Node } from "babylonjs/node";
  25128. import { Mesh } from "babylonjs/Meshes/mesh";
  25129. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25130. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25131. import { Viewport } from "babylonjs/Maths/math.viewport";
  25132. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25133. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25134. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25135. import { Ray } from "babylonjs/Culling/ray";
  25136. /**
  25137. * This is the base class of all the camera used in the application.
  25138. * @see http://doc.babylonjs.com/features/cameras
  25139. */
  25140. export class Camera extends Node {
  25141. /** @hidden */
  25142. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25143. /**
  25144. * This is the default projection mode used by the cameras.
  25145. * It helps recreating a feeling of perspective and better appreciate depth.
  25146. * This is the best way to simulate real life cameras.
  25147. */
  25148. static readonly PERSPECTIVE_CAMERA: number;
  25149. /**
  25150. * This helps creating camera with an orthographic mode.
  25151. * Orthographic is commonly used in engineering as a means to produce object specifications that communicate dimensions unambiguously, each line of 1 unit length (cm, meter..whatever) will appear to have the same length everywhere on the drawing. This allows the drafter to dimension only a subset of lines and let the reader know that other lines of that length on the drawing are also that length in reality. Every parallel line in the drawing is also parallel in the object.
  25152. */
  25153. static readonly ORTHOGRAPHIC_CAMERA: number;
  25154. /**
  25155. * This is the default FOV mode for perspective cameras.
  25156. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25157. */
  25158. static readonly FOVMODE_VERTICAL_FIXED: number;
  25159. /**
  25160. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25161. */
  25162. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25163. /**
  25164. * This specifies ther is no need for a camera rig.
  25165. * Basically only one eye is rendered corresponding to the camera.
  25166. */
  25167. static readonly RIG_MODE_NONE: number;
  25168. /**
  25169. * Simulates a camera Rig with one blue eye and one red eye.
  25170. * This can be use with 3d blue and red glasses.
  25171. */
  25172. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25173. /**
  25174. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25175. */
  25176. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25177. /**
  25178. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25179. */
  25180. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25181. /**
  25182. * Defines that both eyes of the camera will be rendered over under each other.
  25183. */
  25184. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25185. /**
  25186. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25187. */
  25188. static readonly RIG_MODE_VR: number;
  25189. /**
  25190. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25191. */
  25192. static readonly RIG_MODE_WEBVR: number;
  25193. /**
  25194. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25195. */
  25196. static readonly RIG_MODE_CUSTOM: number;
  25197. /**
  25198. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25199. */
  25200. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25201. /**
  25202. * Define the input manager associated with the camera.
  25203. */
  25204. inputs: CameraInputsManager<Camera>;
  25205. /** @hidden */
  25206. _position: Vector3;
  25207. /**
  25208. * Define the current local position of the camera in the scene
  25209. */
  25210. position: Vector3;
  25211. /**
  25212. * The vector the camera should consider as up.
  25213. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25214. */
  25215. upVector: Vector3;
  25216. /**
  25217. * Define the current limit on the left side for an orthographic camera
  25218. * In scene unit
  25219. */
  25220. orthoLeft: Nullable<number>;
  25221. /**
  25222. * Define the current limit on the right side for an orthographic camera
  25223. * In scene unit
  25224. */
  25225. orthoRight: Nullable<number>;
  25226. /**
  25227. * Define the current limit on the bottom side for an orthographic camera
  25228. * In scene unit
  25229. */
  25230. orthoBottom: Nullable<number>;
  25231. /**
  25232. * Define the current limit on the top side for an orthographic camera
  25233. * In scene unit
  25234. */
  25235. orthoTop: Nullable<number>;
  25236. /**
  25237. * Field Of View is set in Radians. (default is 0.8)
  25238. */
  25239. fov: number;
  25240. /**
  25241. * Define the minimum distance the camera can see from.
  25242. * This is important to note that the depth buffer are not infinite and the closer it starts
  25243. * the more your scene might encounter depth fighting issue.
  25244. */
  25245. minZ: number;
  25246. /**
  25247. * Define the maximum distance the camera can see to.
  25248. * This is important to note that the depth buffer are not infinite and the further it end
  25249. * the more your scene might encounter depth fighting issue.
  25250. */
  25251. maxZ: number;
  25252. /**
  25253. * Define the default inertia of the camera.
  25254. * This helps giving a smooth feeling to the camera movement.
  25255. */
  25256. inertia: number;
  25257. /**
  25258. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25259. */
  25260. mode: number;
  25261. /**
  25262. * Define wether the camera is intermediate.
  25263. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25264. */
  25265. isIntermediate: boolean;
  25266. /**
  25267. * Define the viewport of the camera.
  25268. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25269. */
  25270. viewport: Viewport;
  25271. /**
  25272. * Restricts the camera to viewing objects with the same layerMask.
  25273. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25274. */
  25275. layerMask: number;
  25276. /**
  25277. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25278. */
  25279. fovMode: number;
  25280. /**
  25281. * Rig mode of the camera.
  25282. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25283. * This is normally controlled byt the camera themselves as internal use.
  25284. */
  25285. cameraRigMode: number;
  25286. /**
  25287. * Defines the distance between both "eyes" in case of a RIG
  25288. */
  25289. interaxialDistance: number;
  25290. /**
  25291. * Defines if stereoscopic rendering is done side by side or over under.
  25292. */
  25293. isStereoscopicSideBySide: boolean;
  25294. /**
  25295. * Defines the list of custom render target which are rendered to and then used as the input to this camera's render. Eg. display another camera view on a TV in the main scene
  25296. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25297. * else in the scene. (Eg. security camera)
  25298. *
  25299. * To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corrisponding to an HMD)
  25300. */
  25301. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25302. /**
  25303. * When set, the camera will render to this render target instead of the default canvas
  25304. *
  25305. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25306. */
  25307. outputRenderTarget: Nullable<RenderTargetTexture>;
  25308. /**
  25309. * Observable triggered when the camera view matrix has changed.
  25310. */
  25311. onViewMatrixChangedObservable: Observable<Camera>;
  25312. /**
  25313. * Observable triggered when the camera Projection matrix has changed.
  25314. */
  25315. onProjectionMatrixChangedObservable: Observable<Camera>;
  25316. /**
  25317. * Observable triggered when the inputs have been processed.
  25318. */
  25319. onAfterCheckInputsObservable: Observable<Camera>;
  25320. /**
  25321. * Observable triggered when reset has been called and applied to the camera.
  25322. */
  25323. onRestoreStateObservable: Observable<Camera>;
  25324. /** @hidden */
  25325. _cameraRigParams: any;
  25326. /** @hidden */
  25327. _rigCameras: Camera[];
  25328. /** @hidden */
  25329. _rigPostProcess: Nullable<PostProcess>;
  25330. protected _webvrViewMatrix: Matrix;
  25331. /** @hidden */
  25332. _skipRendering: boolean;
  25333. /** @hidden */
  25334. _projectionMatrix: Matrix;
  25335. /** @hidden */
  25336. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25337. /** @hidden */
  25338. _activeMeshes: SmartArray<AbstractMesh>;
  25339. protected _globalPosition: Vector3;
  25340. /** @hidden */
  25341. _computedViewMatrix: Matrix;
  25342. private _doNotComputeProjectionMatrix;
  25343. private _transformMatrix;
  25344. private _frustumPlanes;
  25345. private _refreshFrustumPlanes;
  25346. private _storedFov;
  25347. private _stateStored;
  25348. /**
  25349. * Instantiates a new camera object.
  25350. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25351. * @see http://doc.babylonjs.com/features/cameras
  25352. * @param name Defines the name of the camera in the scene
  25353. * @param position Defines the position of the camera
  25354. * @param scene Defines the scene the camera belongs too
  25355. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25356. */
  25357. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25358. /**
  25359. * Store current camera state (fov, position, etc..)
  25360. * @returns the camera
  25361. */
  25362. storeState(): Camera;
  25363. /**
  25364. * Restores the camera state values if it has been stored. You must call storeState() first
  25365. */
  25366. protected _restoreStateValues(): boolean;
  25367. /**
  25368. * Restored camera state. You must call storeState() first.
  25369. * @returns true if restored and false otherwise
  25370. */
  25371. restoreState(): boolean;
  25372. /**
  25373. * Gets the class name of the camera.
  25374. * @returns the class name
  25375. */
  25376. getClassName(): string;
  25377. /** @hidden */
  25378. readonly _isCamera: boolean;
  25379. /**
  25380. * Gets a string representation of the camera useful for debug purpose.
  25381. * @param fullDetails Defines that a more verboe level of logging is required
  25382. * @returns the string representation
  25383. */
  25384. toString(fullDetails?: boolean): string;
  25385. /**
  25386. * Gets the current world space position of the camera.
  25387. */
  25388. readonly globalPosition: Vector3;
  25389. /**
  25390. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25391. * @returns the active meshe list
  25392. */
  25393. getActiveMeshes(): SmartArray<AbstractMesh>;
  25394. /**
  25395. * Check wether a mesh is part of the current active mesh list of the camera
  25396. * @param mesh Defines the mesh to check
  25397. * @returns true if active, false otherwise
  25398. */
  25399. isActiveMesh(mesh: Mesh): boolean;
  25400. /**
  25401. * Is this camera ready to be used/rendered
  25402. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25403. * @return true if the camera is ready
  25404. */
  25405. isReady(completeCheck?: boolean): boolean;
  25406. /** @hidden */
  25407. _initCache(): void;
  25408. /** @hidden */
  25409. _updateCache(ignoreParentClass?: boolean): void;
  25410. /** @hidden */
  25411. _isSynchronized(): boolean;
  25412. /** @hidden */
  25413. _isSynchronizedViewMatrix(): boolean;
  25414. /** @hidden */
  25415. _isSynchronizedProjectionMatrix(): boolean;
  25416. /**
  25417. * Attach the input controls to a specific dom element to get the input from.
  25418. * @param element Defines the element the controls should be listened from
  25419. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25420. */
  25421. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25422. /**
  25423. * Detach the current controls from the specified dom element.
  25424. * @param element Defines the element to stop listening the inputs from
  25425. */
  25426. detachControl(element: HTMLElement): void;
  25427. /**
  25428. * Update the camera state according to the different inputs gathered during the frame.
  25429. */
  25430. update(): void;
  25431. /** @hidden */
  25432. _checkInputs(): void;
  25433. /** @hidden */
  25434. readonly rigCameras: Camera[];
  25435. /**
  25436. * Gets the post process used by the rig cameras
  25437. */
  25438. readonly rigPostProcess: Nullable<PostProcess>;
  25439. /**
  25440. * Internal, gets the first post proces.
  25441. * @returns the first post process to be run on this camera.
  25442. */
  25443. _getFirstPostProcess(): Nullable<PostProcess>;
  25444. private _cascadePostProcessesToRigCams;
  25445. /**
  25446. * Attach a post process to the camera.
  25447. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25448. * @param postProcess The post process to attach to the camera
  25449. * @param insertAt The position of the post process in case several of them are in use in the scene
  25450. * @returns the position the post process has been inserted at
  25451. */
  25452. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25453. /**
  25454. * Detach a post process to the camera.
  25455. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25456. * @param postProcess The post process to detach from the camera
  25457. */
  25458. detachPostProcess(postProcess: PostProcess): void;
  25459. /**
  25460. * Gets the current world matrix of the camera
  25461. */
  25462. getWorldMatrix(): Matrix;
  25463. /** @hidden */
  25464. _getViewMatrix(): Matrix;
  25465. /**
  25466. * Gets the current view matrix of the camera.
  25467. * @param force forces the camera to recompute the matrix without looking at the cached state
  25468. * @returns the view matrix
  25469. */
  25470. getViewMatrix(force?: boolean): Matrix;
  25471. /**
  25472. * Freeze the projection matrix.
  25473. * It will prevent the cache check of the camera projection compute and can speed up perf
  25474. * if no parameter of the camera are meant to change
  25475. * @param projection Defines manually a projection if necessary
  25476. */
  25477. freezeProjectionMatrix(projection?: Matrix): void;
  25478. /**
  25479. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25480. */
  25481. unfreezeProjectionMatrix(): void;
  25482. /**
  25483. * Gets the current projection matrix of the camera.
  25484. * @param force forces the camera to recompute the matrix without looking at the cached state
  25485. * @returns the projection matrix
  25486. */
  25487. getProjectionMatrix(force?: boolean): Matrix;
  25488. /**
  25489. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25490. * @returns a Matrix
  25491. */
  25492. getTransformationMatrix(): Matrix;
  25493. private _updateFrustumPlanes;
  25494. /**
  25495. * Checks if a cullable object (mesh...) is in the camera frustum
  25496. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25497. * @param target The object to check
  25498. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25499. * @returns true if the object is in frustum otherwise false
  25500. */
  25501. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25502. /**
  25503. * Checks if a cullable object (mesh...) is in the camera frustum
  25504. * Unlike isInFrustum this cheks the full bounding box
  25505. * @param target The object to check
  25506. * @returns true if the object is in frustum otherwise false
  25507. */
  25508. isCompletelyInFrustum(target: ICullable): boolean;
  25509. /**
  25510. * Gets a ray in the forward direction from the camera.
  25511. * @param length Defines the length of the ray to create
  25512. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25513. * @param origin Defines the start point of the ray which defaults to the camera position
  25514. * @returns the forward ray
  25515. */
  25516. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25517. /**
  25518. * Releases resources associated with this node.
  25519. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25520. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25521. */
  25522. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25523. /** @hidden */
  25524. _isLeftCamera: boolean;
  25525. /**
  25526. * Gets the left camera of a rig setup in case of Rigged Camera
  25527. */
  25528. readonly isLeftCamera: boolean;
  25529. /** @hidden */
  25530. _isRightCamera: boolean;
  25531. /**
  25532. * Gets the right camera of a rig setup in case of Rigged Camera
  25533. */
  25534. readonly isRightCamera: boolean;
  25535. /**
  25536. * Gets the left camera of a rig setup in case of Rigged Camera
  25537. */
  25538. readonly leftCamera: Nullable<FreeCamera>;
  25539. /**
  25540. * Gets the right camera of a rig setup in case of Rigged Camera
  25541. */
  25542. readonly rightCamera: Nullable<FreeCamera>;
  25543. /**
  25544. * Gets the left camera target of a rig setup in case of Rigged Camera
  25545. * @returns the target position
  25546. */
  25547. getLeftTarget(): Nullable<Vector3>;
  25548. /**
  25549. * Gets the right camera target of a rig setup in case of Rigged Camera
  25550. * @returns the target position
  25551. */
  25552. getRightTarget(): Nullable<Vector3>;
  25553. /**
  25554. * @hidden
  25555. */
  25556. setCameraRigMode(mode: number, rigParams: any): void;
  25557. /** @hidden */
  25558. static _setStereoscopicRigMode(camera: Camera): void;
  25559. /** @hidden */
  25560. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25561. /** @hidden */
  25562. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25563. /** @hidden */
  25564. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25565. /** @hidden */
  25566. _getVRProjectionMatrix(): Matrix;
  25567. protected _updateCameraRotationMatrix(): void;
  25568. protected _updateWebVRCameraRotationMatrix(): void;
  25569. /**
  25570. * This function MUST be overwritten by the different WebVR cameras available.
  25571. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25572. * @hidden
  25573. */
  25574. _getWebVRProjectionMatrix(): Matrix;
  25575. /**
  25576. * This function MUST be overwritten by the different WebVR cameras available.
  25577. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25578. * @hidden
  25579. */
  25580. _getWebVRViewMatrix(): Matrix;
  25581. /** @hidden */
  25582. setCameraRigParameter(name: string, value: any): void;
  25583. /**
  25584. * needs to be overridden by children so sub has required properties to be copied
  25585. * @hidden
  25586. */
  25587. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25588. /**
  25589. * May need to be overridden by children
  25590. * @hidden
  25591. */
  25592. _updateRigCameras(): void;
  25593. /** @hidden */
  25594. _setupInputs(): void;
  25595. /**
  25596. * Serialiaze the camera setup to a json represention
  25597. * @returns the JSON representation
  25598. */
  25599. serialize(): any;
  25600. /**
  25601. * Clones the current camera.
  25602. * @param name The cloned camera name
  25603. * @returns the cloned camera
  25604. */
  25605. clone(name: string): Camera;
  25606. /**
  25607. * Gets the direction of the camera relative to a given local axis.
  25608. * @param localAxis Defines the reference axis to provide a relative direction.
  25609. * @return the direction
  25610. */
  25611. getDirection(localAxis: Vector3): Vector3;
  25612. /**
  25613. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25614. * @param localAxis Defines the reference axis to provide a relative direction.
  25615. * @param result Defines the vector to store the result in
  25616. */
  25617. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25618. /**
  25619. * Gets a camera constructor for a given camera type
  25620. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25621. * @param name The name of the camera the result will be able to instantiate
  25622. * @param scene The scene the result will construct the camera in
  25623. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25624. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25625. * @returns a factory method to construc the camera
  25626. */
  25627. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25628. /**
  25629. * Compute the world matrix of the camera.
  25630. * @returns the camera workd matrix
  25631. */
  25632. computeWorldMatrix(): Matrix;
  25633. /**
  25634. * Parse a JSON and creates the camera from the parsed information
  25635. * @param parsedCamera The JSON to parse
  25636. * @param scene The scene to instantiate the camera in
  25637. * @returns the newly constructed camera
  25638. */
  25639. static Parse(parsedCamera: any, scene: Scene): Camera;
  25640. }
  25641. }
  25642. declare module "babylonjs/Meshes/Builders/discBuilder" {
  25643. import { Nullable } from "babylonjs/types";
  25644. import { Scene } from "babylonjs/scene";
  25645. import { Vector4 } from "babylonjs/Maths/math.vector";
  25646. import { Mesh } from "babylonjs/Meshes/mesh";
  25647. /**
  25648. * Class containing static functions to help procedurally build meshes
  25649. */
  25650. export class DiscBuilder {
  25651. /**
  25652. * Creates a plane polygonal mesh. By default, this is a disc
  25653. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25654. * * The parameter `tessellation` sets the number of polygon sides (positive integer, default 64). So a tessellation valued to 3 will build a triangle, to 4 a square, etc
  25655. * * You can create an unclosed polygon with the parameter `arc` (positive float, default 1), valued between 0 and 1, what is the ratio of the circumference : 2 x PI x ratio
  25656. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25657. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  25658. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25659. * @param name defines the name of the mesh
  25660. * @param options defines the options used to create the mesh
  25661. * @param scene defines the hosting scene
  25662. * @returns the plane polygonal mesh
  25663. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25664. */
  25665. static CreateDisc(name: string, options: {
  25666. radius?: number;
  25667. tessellation?: number;
  25668. arc?: number;
  25669. updatable?: boolean;
  25670. sideOrientation?: number;
  25671. frontUVs?: Vector4;
  25672. backUVs?: Vector4;
  25673. }, scene?: Nullable<Scene>): Mesh;
  25674. }
  25675. }
  25676. declare module "babylonjs/Particles/solidParticleSystem" {
  25677. import { Vector3 } from "babylonjs/Maths/math.vector";
  25678. import { Mesh } from "babylonjs/Meshes/mesh";
  25679. import { Scene, IDisposable } from "babylonjs/scene";
  25680. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  25681. /**
  25682. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25683. *As it is just a mesh, the SPS has all the same properties than any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  25684. * The SPS is also a particle system. It provides some methods to manage the particles.
  25685. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25686. *
  25687. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25688. */
  25689. export class SolidParticleSystem implements IDisposable {
  25690. /**
  25691. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25692. * Example : var p = SPS.particles[i];
  25693. */
  25694. particles: SolidParticle[];
  25695. /**
  25696. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25697. */
  25698. nbParticles: number;
  25699. /**
  25700. * If the particles must ever face the camera (default false). Useful for planar particles.
  25701. */
  25702. billboard: boolean;
  25703. /**
  25704. * Recompute normals when adding a shape
  25705. */
  25706. recomputeNormals: boolean;
  25707. /**
  25708. * This a counter ofr your own usage. It's not set by any SPS functions.
  25709. */
  25710. counter: number;
  25711. /**
  25712. * The SPS name. This name is also given to the underlying mesh.
  25713. */
  25714. name: string;
  25715. /**
  25716. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25717. */
  25718. mesh: Mesh;
  25719. /**
  25720. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25721. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25722. */
  25723. vars: any;
  25724. /**
  25725. * This array is populated when the SPS is set as 'pickable'.
  25726. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25727. * Each element of this array is an object `{idx: int, faceId: int}`.
  25728. * `idx` is the picked particle index in the `SPS.particles` array
  25729. * `faceId` is the picked face index counted within this particle.
  25730. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25731. */
  25732. pickedParticles: {
  25733. idx: number;
  25734. faceId: number;
  25735. }[];
  25736. /**
  25737. * This array is populated when `enableDepthSort` is set to true.
  25738. * Each element of this array is an instance of the class DepthSortedParticle.
  25739. */
  25740. depthSortedParticles: DepthSortedParticle[];
  25741. /**
  25742. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25743. * @hidden
  25744. */
  25745. _bSphereOnly: boolean;
  25746. /**
  25747. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25748. * @hidden
  25749. */
  25750. _bSphereRadiusFactor: number;
  25751. private _scene;
  25752. private _positions;
  25753. private _indices;
  25754. private _normals;
  25755. private _colors;
  25756. private _uvs;
  25757. private _indices32;
  25758. private _positions32;
  25759. private _normals32;
  25760. private _fixedNormal32;
  25761. private _colors32;
  25762. private _uvs32;
  25763. private _index;
  25764. private _updatable;
  25765. private _pickable;
  25766. private _isVisibilityBoxLocked;
  25767. private _alwaysVisible;
  25768. private _depthSort;
  25769. private _shapeCounter;
  25770. private _copy;
  25771. private _color;
  25772. private _computeParticleColor;
  25773. private _computeParticleTexture;
  25774. private _computeParticleRotation;
  25775. private _computeParticleVertex;
  25776. private _computeBoundingBox;
  25777. private _depthSortParticles;
  25778. private _camera;
  25779. private _mustUnrotateFixedNormals;
  25780. private _particlesIntersect;
  25781. private _needs32Bits;
  25782. /**
  25783. * Creates a SPS (Solid Particle System) object.
  25784. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25785. * @param scene (Scene) is the scene in which the SPS is added.
  25786. * @param options defines the options of the sps e.g.
  25787. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25788. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25789. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25790. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25791. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25792. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25793. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25794. */
  25795. constructor(name: string, scene: Scene, options?: {
  25796. updatable?: boolean;
  25797. isPickable?: boolean;
  25798. enableDepthSort?: boolean;
  25799. particleIntersection?: boolean;
  25800. boundingSphereOnly?: boolean;
  25801. bSphereRadiusFactor?: number;
  25802. });
  25803. /**
  25804. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25805. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25806. * @returns the created mesh
  25807. */
  25808. buildMesh(): Mesh;
  25809. /**
  25810. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25811. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25812. * Thus the particles generated from `digest()` have their property `position` set yet.
  25813. * @param mesh ( Mesh ) is the mesh to be digested
  25814. * @param options {facetNb} (optional integer, default 1) is the number of mesh facets per particle, this parameter is overriden by the parameter `number` if any
  25815. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25816. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25817. * @returns the current SPS
  25818. */
  25819. digest(mesh: Mesh, options?: {
  25820. facetNb?: number;
  25821. number?: number;
  25822. delta?: number;
  25823. }): SolidParticleSystem;
  25824. private _unrotateFixedNormals;
  25825. private _resetCopy;
  25826. private _meshBuilder;
  25827. private _posToShape;
  25828. private _uvsToShapeUV;
  25829. private _addParticle;
  25830. /**
  25831. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25832. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25833. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25834. * @param nb (positive integer) the number of particles to be created from this model
  25835. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25836. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25837. * @returns the number of shapes in the system
  25838. */
  25839. addShape(mesh: Mesh, nb: number, options?: {
  25840. positionFunction?: any;
  25841. vertexFunction?: any;
  25842. }): number;
  25843. private _rebuildParticle;
  25844. /**
  25845. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25846. * @returns the SPS.
  25847. */
  25848. rebuildMesh(): SolidParticleSystem;
  25849. /**
  25850. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25851. * This method calls `updateParticle()` for each particle of the SPS.
  25852. * For an animated SPS, it is usually called within the render loop.
  25853. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25854. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25855. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25856. * @returns the SPS.
  25857. */
  25858. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25859. /**
  25860. * Disposes the SPS.
  25861. */
  25862. dispose(): void;
  25863. /**
  25864. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25865. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25866. * @returns the SPS.
  25867. */
  25868. refreshVisibleSize(): SolidParticleSystem;
  25869. /**
  25870. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25871. * @param size the size (float) of the visibility box
  25872. * note : this doesn't lock the SPS mesh bounding box.
  25873. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25874. */
  25875. setVisibilityBox(size: number): void;
  25876. /**
  25877. * Gets whether the SPS as always visible or not
  25878. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25879. */
  25880. /**
  25881. * Sets the SPS as always visible or not
  25882. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25883. */
  25884. isAlwaysVisible: boolean;
  25885. /**
  25886. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25887. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25888. */
  25889. /**
  25890. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25891. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25892. */
  25893. isVisibilityBoxLocked: boolean;
  25894. /**
  25895. * Tells to `setParticles()` to compute the particle rotations or not.
  25896. * Default value : true. The SPS is faster when it's set to false.
  25897. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25898. */
  25899. /**
  25900. * Gets if `setParticles()` computes the particle rotations or not.
  25901. * Default value : true. The SPS is faster when it's set to false.
  25902. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25903. */
  25904. computeParticleRotation: boolean;
  25905. /**
  25906. * Tells to `setParticles()` to compute the particle colors or not.
  25907. * Default value : true. The SPS is faster when it's set to false.
  25908. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25909. */
  25910. /**
  25911. * Gets if `setParticles()` computes the particle colors or not.
  25912. * Default value : true. The SPS is faster when it's set to false.
  25913. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25914. */
  25915. computeParticleColor: boolean;
  25916. /**
  25917. * Gets if `setParticles()` computes the particle textures or not.
  25918. * Default value : true. The SPS is faster when it's set to false.
  25919. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25920. */
  25921. computeParticleTexture: boolean;
  25922. /**
  25923. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25924. * Default value : false. The SPS is faster when it's set to false.
  25925. * Note : the particle custom vertex positions aren't stored values.
  25926. */
  25927. /**
  25928. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25929. * Default value : false. The SPS is faster when it's set to false.
  25930. * Note : the particle custom vertex positions aren't stored values.
  25931. */
  25932. computeParticleVertex: boolean;
  25933. /**
  25934. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25935. */
  25936. /**
  25937. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25938. */
  25939. computeBoundingBox: boolean;
  25940. /**
  25941. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25942. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25943. * Default : `true`
  25944. */
  25945. /**
  25946. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25947. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25948. * Default : `true`
  25949. */
  25950. depthSortParticles: boolean;
  25951. /**
  25952. * This function does nothing. It may be overwritten to set all the particle first values.
  25953. * The SPS doesn't call this function, you may have to call it by your own.
  25954. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25955. */
  25956. initParticles(): void;
  25957. /**
  25958. * This function does nothing. It may be overwritten to recycle a particle.
  25959. * The SPS doesn't call this function, you may have to call it by your own.
  25960. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25961. * @param particle The particle to recycle
  25962. * @returns the recycled particle
  25963. */
  25964. recycleParticle(particle: SolidParticle): SolidParticle;
  25965. /**
  25966. * Updates a particle : this function should be overwritten by the user.
  25967. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25968. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25969. * @example : just set a particle position or velocity and recycle conditions
  25970. * @param particle The particle to update
  25971. * @returns the updated particle
  25972. */
  25973. updateParticle(particle: SolidParticle): SolidParticle;
  25974. /**
  25975. * Updates a vertex of a particle : it can be overwritten by the user.
  25976. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25977. * @param particle the current particle
  25978. * @param vertex the current index of the current particle
  25979. * @param pt the index of the current vertex in the particle shape
  25980. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  25981. * @example : just set a vertex particle position
  25982. * @returns the updated vertex
  25983. */
  25984. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25985. /**
  25986. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25987. * This does nothing and may be overwritten by the user.
  25988. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25989. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25990. * @param update the boolean update value actually passed to setParticles()
  25991. */
  25992. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25993. /**
  25994. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25995. * This will be passed three parameters.
  25996. * This does nothing and may be overwritten by the user.
  25997. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25998. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25999. * @param update the boolean update value actually passed to setParticles()
  26000. */
  26001. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26002. }
  26003. }
  26004. declare module "babylonjs/Particles/solidParticle" {
  26005. import { Nullable } from "babylonjs/types";
  26006. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  26007. import { Color4 } from "babylonjs/Maths/math.color";
  26008. import { Mesh } from "babylonjs/Meshes/mesh";
  26009. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26010. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  26011. import { Plane } from "babylonjs/Maths/math.plane";
  26012. /**
  26013. * Represents one particle of a solid particle system.
  26014. */
  26015. export class SolidParticle {
  26016. /**
  26017. * particle global index
  26018. */
  26019. idx: number;
  26020. /**
  26021. * The color of the particle
  26022. */
  26023. color: Nullable<Color4>;
  26024. /**
  26025. * The world space position of the particle.
  26026. */
  26027. position: Vector3;
  26028. /**
  26029. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  26030. */
  26031. rotation: Vector3;
  26032. /**
  26033. * The world space rotation quaternion of the particle.
  26034. */
  26035. rotationQuaternion: Nullable<Quaternion>;
  26036. /**
  26037. * The scaling of the particle.
  26038. */
  26039. scaling: Vector3;
  26040. /**
  26041. * The uvs of the particle.
  26042. */
  26043. uvs: Vector4;
  26044. /**
  26045. * The current speed of the particle.
  26046. */
  26047. velocity: Vector3;
  26048. /**
  26049. * The pivot point in the particle local space.
  26050. */
  26051. pivot: Vector3;
  26052. /**
  26053. * Must the particle be translated from its pivot point in its local space ?
  26054. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  26055. * Default : false
  26056. */
  26057. translateFromPivot: boolean;
  26058. /**
  26059. * Is the particle active or not ?
  26060. */
  26061. alive: boolean;
  26062. /**
  26063. * Is the particle visible or not ?
  26064. */
  26065. isVisible: boolean;
  26066. /**
  26067. * Index of this particle in the global "positions" array (Internal use)
  26068. * @hidden
  26069. */
  26070. _pos: number;
  26071. /**
  26072. * @hidden Index of this particle in the global "indices" array (Internal use)
  26073. */
  26074. _ind: number;
  26075. /**
  26076. * @hidden ModelShape of this particle (Internal use)
  26077. */
  26078. _model: ModelShape;
  26079. /**
  26080. * ModelShape id of this particle
  26081. */
  26082. shapeId: number;
  26083. /**
  26084. * Index of the particle in its shape id
  26085. */
  26086. idxInShape: number;
  26087. /**
  26088. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26089. */
  26090. _modelBoundingInfo: BoundingInfo;
  26091. /**
  26092. * @hidden Particle BoundingInfo object (Internal use)
  26093. */
  26094. _boundingInfo: BoundingInfo;
  26095. /**
  26096. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26097. */
  26098. _sps: SolidParticleSystem;
  26099. /**
  26100. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26101. */
  26102. _stillInvisible: boolean;
  26103. /**
  26104. * @hidden Last computed particle rotation matrix
  26105. */
  26106. _rotationMatrix: number[];
  26107. /**
  26108. * Parent particle Id, if any.
  26109. * Default null.
  26110. */
  26111. parentId: Nullable<number>;
  26112. /**
  26113. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26114. * The possible values are :
  26115. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26116. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26117. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26118. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26119. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26120. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26121. * */
  26122. cullingStrategy: number;
  26123. /**
  26124. * @hidden Internal global position in the SPS.
  26125. */
  26126. _globalPosition: Vector3;
  26127. /**
  26128. * Creates a Solid Particle object.
  26129. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26130. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  26131. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26132. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26133. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26134. * @param shapeId (integer) is the model shape identifier in the SPS.
  26135. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26136. * @param sps defines the sps it is associated to
  26137. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26138. */
  26139. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26140. /**
  26141. * Legacy support, changed scale to scaling
  26142. */
  26143. /**
  26144. * Legacy support, changed scale to scaling
  26145. */
  26146. scale: Vector3;
  26147. /**
  26148. * Legacy support, changed quaternion to rotationQuaternion
  26149. */
  26150. /**
  26151. * Legacy support, changed quaternion to rotationQuaternion
  26152. */
  26153. quaternion: Nullable<Quaternion>;
  26154. /**
  26155. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26156. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26157. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26158. * @returns true if it intersects
  26159. */
  26160. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26161. /**
  26162. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26163. * A particle is in the frustum if its bounding box intersects the frustum
  26164. * @param frustumPlanes defines the frustum to test
  26165. * @returns true if the particle is in the frustum planes
  26166. */
  26167. isInFrustum(frustumPlanes: Plane[]): boolean;
  26168. /**
  26169. * get the rotation matrix of the particle
  26170. * @hidden
  26171. */
  26172. getRotationMatrix(m: Matrix): void;
  26173. }
  26174. /**
  26175. * Represents the shape of the model used by one particle of a solid particle system.
  26176. * SPS internal tool, don't use it manually.
  26177. */
  26178. export class ModelShape {
  26179. /**
  26180. * The shape id
  26181. * @hidden
  26182. */
  26183. shapeID: number;
  26184. /**
  26185. * flat array of model positions (internal use)
  26186. * @hidden
  26187. */
  26188. _shape: Vector3[];
  26189. /**
  26190. * flat array of model UVs (internal use)
  26191. * @hidden
  26192. */
  26193. _shapeUV: number[];
  26194. /**
  26195. * length of the shape in the model indices array (internal use)
  26196. * @hidden
  26197. */
  26198. _indicesLength: number;
  26199. /**
  26200. * Custom position function (internal use)
  26201. * @hidden
  26202. */
  26203. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26204. /**
  26205. * Custom vertex function (internal use)
  26206. * @hidden
  26207. */
  26208. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26209. /**
  26210. * Creates a ModelShape object. This is an internal simplified reference to a mesh used as for a model to replicate particles from by the SPS.
  26211. * SPS internal tool, don't use it manually.
  26212. * @hidden
  26213. */
  26214. constructor(id: number, shape: Vector3[], indicesLength: number, shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  26215. }
  26216. /**
  26217. * Represents a Depth Sorted Particle in the solid particle system.
  26218. */
  26219. export class DepthSortedParticle {
  26220. /**
  26221. * Index of the particle in the "indices" array
  26222. */
  26223. ind: number;
  26224. /**
  26225. * Length of the particle shape in the "indices" array
  26226. */
  26227. indicesLength: number;
  26228. /**
  26229. * Squared distance from the particle to the camera
  26230. */
  26231. sqDistance: number;
  26232. }
  26233. }
  26234. declare module "babylonjs/Collisions/meshCollisionData" {
  26235. import { Collider } from "babylonjs/Collisions/collider";
  26236. import { Vector3 } from "babylonjs/Maths/math.vector";
  26237. import { Nullable } from "babylonjs/types";
  26238. import { Observer } from "babylonjs/Misc/observable";
  26239. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26240. /**
  26241. * @hidden
  26242. */
  26243. export class _MeshCollisionData {
  26244. _checkCollisions: boolean;
  26245. _collisionMask: number;
  26246. _collisionGroup: number;
  26247. _collider: Nullable<Collider>;
  26248. _oldPositionForCollisions: Vector3;
  26249. _diffPositionForCollisions: Vector3;
  26250. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26251. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26252. }
  26253. }
  26254. declare module "babylonjs/Meshes/abstractMesh" {
  26255. import { Observable } from "babylonjs/Misc/observable";
  26256. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  26257. import { Camera } from "babylonjs/Cameras/camera";
  26258. import { Scene, IDisposable } from "babylonjs/scene";
  26259. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26260. import { Node } from "babylonjs/node";
  26261. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  26262. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26263. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26264. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  26265. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26266. import { Material } from "babylonjs/Materials/material";
  26267. import { Light } from "babylonjs/Lights/light";
  26268. import { Skeleton } from "babylonjs/Bones/skeleton";
  26269. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  26270. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  26271. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26272. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26273. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  26274. import { Plane } from "babylonjs/Maths/math.plane";
  26275. import { Ray } from "babylonjs/Culling/ray";
  26276. import { Collider } from "babylonjs/Collisions/collider";
  26277. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26278. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  26279. /** @hidden */
  26280. class _FacetDataStorage {
  26281. facetPositions: Vector3[];
  26282. facetNormals: Vector3[];
  26283. facetPartitioning: number[][];
  26284. facetNb: number;
  26285. partitioningSubdivisions: number;
  26286. partitioningBBoxRatio: number;
  26287. facetDataEnabled: boolean;
  26288. facetParameters: any;
  26289. bbSize: Vector3;
  26290. subDiv: {
  26291. max: number;
  26292. X: number;
  26293. Y: number;
  26294. Z: number;
  26295. };
  26296. facetDepthSort: boolean;
  26297. facetDepthSortEnabled: boolean;
  26298. depthSortedIndices: IndicesArray;
  26299. depthSortedFacets: {
  26300. ind: number;
  26301. sqDistance: number;
  26302. }[];
  26303. facetDepthSortFunction: (f1: {
  26304. ind: number;
  26305. sqDistance: number;
  26306. }, f2: {
  26307. ind: number;
  26308. sqDistance: number;
  26309. }) => number;
  26310. facetDepthSortFrom: Vector3;
  26311. facetDepthSortOrigin: Vector3;
  26312. invertedMatrix: Matrix;
  26313. }
  26314. /**
  26315. * @hidden
  26316. **/
  26317. class _InternalAbstractMeshDataInfo {
  26318. _hasVertexAlpha: boolean;
  26319. _useVertexColors: boolean;
  26320. _numBoneInfluencers: number;
  26321. _applyFog: boolean;
  26322. _receiveShadows: boolean;
  26323. _facetData: _FacetDataStorage;
  26324. _visibility: number;
  26325. _skeleton: Nullable<Skeleton>;
  26326. _layerMask: number;
  26327. _computeBonesUsingShaders: boolean;
  26328. _isActive: boolean;
  26329. _onlyForInstances: boolean;
  26330. _isActiveIntermediate: boolean;
  26331. _onlyForInstancesIntermediate: boolean;
  26332. }
  26333. /**
  26334. * Class used to store all common mesh properties
  26335. */
  26336. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  26337. /** No occlusion */
  26338. static OCCLUSION_TYPE_NONE: number;
  26339. /** Occlusion set to optimisitic */
  26340. static OCCLUSION_TYPE_OPTIMISTIC: number;
  26341. /** Occlusion set to strict */
  26342. static OCCLUSION_TYPE_STRICT: number;
  26343. /** Use an accurante occlusion algorithm */
  26344. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  26345. /** Use a conservative occlusion algorithm */
  26346. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  26347. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26348. * Test order :
  26349. * Is the bounding sphere outside the frustum ?
  26350. * If not, are the bounding box vertices outside the frustum ?
  26351. * It not, then the cullable object is in the frustum.
  26352. */
  26353. static readonly CULLINGSTRATEGY_STANDARD: number;
  26354. /** Culling strategy : Bounding Sphere Only.
  26355. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26356. * It's also less accurate than the standard because some not visible objects can still be selected.
  26357. * Test : is the bounding sphere outside the frustum ?
  26358. * If not, then the cullable object is in the frustum.
  26359. */
  26360. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  26361. /** Culling strategy : Optimistic Inclusion.
  26362. * This in an inclusion test first, then the standard exclusion test.
  26363. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26364. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  26365. * Anyway, it's as accurate as the standard strategy.
  26366. * Test :
  26367. * Is the cullable object bounding sphere center in the frustum ?
  26368. * If not, apply the default culling strategy.
  26369. */
  26370. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  26371. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26372. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26373. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26374. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  26375. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26376. * Test :
  26377. * Is the cullable object bounding sphere center in the frustum ?
  26378. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26379. */
  26380. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  26381. /**
  26382. * No billboard
  26383. */
  26384. static readonly BILLBOARDMODE_NONE: number;
  26385. /** Billboard on X axis */
  26386. static readonly BILLBOARDMODE_X: number;
  26387. /** Billboard on Y axis */
  26388. static readonly BILLBOARDMODE_Y: number;
  26389. /** Billboard on Z axis */
  26390. static readonly BILLBOARDMODE_Z: number;
  26391. /** Billboard on all axes */
  26392. static readonly BILLBOARDMODE_ALL: number;
  26393. /** Billboard on using position instead of orientation */
  26394. static readonly BILLBOARDMODE_USE_POSITION: number;
  26395. /** @hidden */
  26396. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  26397. /**
  26398. * The culling strategy to use to check whether the mesh must be rendered or not.
  26399. * This value can be changed at any time and will be used on the next render mesh selection.
  26400. * The possible values are :
  26401. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26402. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26403. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26404. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26405. * Please read each static variable documentation to get details about the culling process.
  26406. * */
  26407. cullingStrategy: number;
  26408. /**
  26409. * Gets the number of facets in the mesh
  26410. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26411. */
  26412. readonly facetNb: number;
  26413. /**
  26414. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  26415. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26416. */
  26417. partitioningSubdivisions: number;
  26418. /**
  26419. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  26420. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  26421. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26422. */
  26423. partitioningBBoxRatio: number;
  26424. /**
  26425. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  26426. * Works only for updatable meshes.
  26427. * Doesn't work with multi-materials
  26428. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26429. */
  26430. mustDepthSortFacets: boolean;
  26431. /**
  26432. * The location (Vector3) where the facet depth sort must be computed from.
  26433. * By default, the active camera position.
  26434. * Used only when facet depth sort is enabled
  26435. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26436. */
  26437. facetDepthSortFrom: Vector3;
  26438. /**
  26439. * gets a boolean indicating if facetData is enabled
  26440. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26441. */
  26442. readonly isFacetDataEnabled: boolean;
  26443. /** @hidden */
  26444. _updateNonUniformScalingState(value: boolean): boolean;
  26445. /**
  26446. * An event triggered when this mesh collides with another one
  26447. */
  26448. onCollideObservable: Observable<AbstractMesh>;
  26449. /** Set a function to call when this mesh collides with another one */
  26450. onCollide: () => void;
  26451. /**
  26452. * An event triggered when the collision's position changes
  26453. */
  26454. onCollisionPositionChangeObservable: Observable<Vector3>;
  26455. /** Set a function to call when the collision's position changes */
  26456. onCollisionPositionChange: () => void;
  26457. /**
  26458. * An event triggered when material is changed
  26459. */
  26460. onMaterialChangedObservable: Observable<AbstractMesh>;
  26461. /**
  26462. * Gets or sets the orientation for POV movement & rotation
  26463. */
  26464. definedFacingForward: boolean;
  26465. /** @hidden */
  26466. _occlusionQuery: Nullable<WebGLQuery>;
  26467. /** @hidden */
  26468. _renderingGroup: Nullable<RenderingGroup>;
  26469. /**
  26470. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26471. */
  26472. /**
  26473. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26474. */
  26475. visibility: number;
  26476. /** Gets or sets the alpha index used to sort transparent meshes
  26477. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26478. */
  26479. alphaIndex: number;
  26480. /**
  26481. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26482. */
  26483. isVisible: boolean;
  26484. /**
  26485. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26486. */
  26487. isPickable: boolean;
  26488. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26489. showSubMeshesBoundingBox: boolean;
  26490. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26491. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26492. */
  26493. isBlocker: boolean;
  26494. /**
  26495. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26496. */
  26497. enablePointerMoveEvents: boolean;
  26498. /**
  26499. * Specifies the rendering group id for this mesh (0 by default)
  26500. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26501. */
  26502. renderingGroupId: number;
  26503. private _material;
  26504. /** Gets or sets current material */
  26505. material: Nullable<Material>;
  26506. /**
  26507. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26508. * @see http://doc.babylonjs.com/babylon101/shadows
  26509. */
  26510. receiveShadows: boolean;
  26511. /** Defines color to use when rendering outline */
  26512. outlineColor: Color3;
  26513. /** Define width to use when rendering outline */
  26514. outlineWidth: number;
  26515. /** Defines color to use when rendering overlay */
  26516. overlayColor: Color3;
  26517. /** Defines alpha to use when rendering overlay */
  26518. overlayAlpha: number;
  26519. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26520. hasVertexAlpha: boolean;
  26521. /** Gets or sets a boolean indicating that this mesh needs to use vertex color data to render (if this kind of vertex data is available in the geometry) */
  26522. useVertexColors: boolean;
  26523. /**
  26524. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26525. */
  26526. computeBonesUsingShaders: boolean;
  26527. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26528. numBoneInfluencers: number;
  26529. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26530. applyFog: boolean;
  26531. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26532. useOctreeForRenderingSelection: boolean;
  26533. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26534. useOctreeForPicking: boolean;
  26535. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26536. useOctreeForCollisions: boolean;
  26537. /**
  26538. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26539. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26540. */
  26541. layerMask: number;
  26542. /**
  26543. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26544. */
  26545. alwaysSelectAsActiveMesh: boolean;
  26546. /**
  26547. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26548. */
  26549. doNotSyncBoundingInfo: boolean;
  26550. /**
  26551. * Gets or sets the current action manager
  26552. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26553. */
  26554. actionManager: Nullable<AbstractActionManager>;
  26555. private _meshCollisionData;
  26556. /**
  26557. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26558. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26559. */
  26560. ellipsoid: Vector3;
  26561. /**
  26562. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26563. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26564. */
  26565. ellipsoidOffset: Vector3;
  26566. /**
  26567. * Gets or sets a collision mask used to mask collisions (default is -1).
  26568. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26569. */
  26570. collisionMask: number;
  26571. /**
  26572. * Gets or sets the current collision group mask (-1 by default).
  26573. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26574. */
  26575. collisionGroup: number;
  26576. /**
  26577. * Defines edge width used when edgesRenderer is enabled
  26578. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26579. */
  26580. edgesWidth: number;
  26581. /**
  26582. * Defines edge color used when edgesRenderer is enabled
  26583. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26584. */
  26585. edgesColor: Color4;
  26586. /** @hidden */
  26587. _edgesRenderer: Nullable<IEdgesRenderer>;
  26588. /** @hidden */
  26589. _masterMesh: Nullable<AbstractMesh>;
  26590. /** @hidden */
  26591. _boundingInfo: Nullable<BoundingInfo>;
  26592. /** @hidden */
  26593. _renderId: number;
  26594. /**
  26595. * Gets or sets the list of subMeshes
  26596. * @see http://doc.babylonjs.com/how_to/multi_materials
  26597. */
  26598. subMeshes: SubMesh[];
  26599. /** @hidden */
  26600. _intersectionsInProgress: AbstractMesh[];
  26601. /** @hidden */
  26602. _unIndexed: boolean;
  26603. /** @hidden */
  26604. _lightSources: Light[];
  26605. /** Gets the list of lights affecting that mesh */
  26606. readonly lightSources: Light[];
  26607. /** @hidden */
  26608. readonly _positions: Nullable<Vector3[]>;
  26609. /** @hidden */
  26610. _waitingData: {
  26611. lods: Nullable<any>;
  26612. actions: Nullable<any>;
  26613. freezeWorldMatrix: Nullable<boolean>;
  26614. };
  26615. /** @hidden */
  26616. _bonesTransformMatrices: Nullable<Float32Array>;
  26617. /** @hidden */
  26618. _transformMatrixTexture: Nullable<RawTexture>;
  26619. /**
  26620. * Gets or sets a skeleton to apply skining transformations
  26621. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26622. */
  26623. skeleton: Nullable<Skeleton>;
  26624. /**
  26625. * An event triggered when the mesh is rebuilt.
  26626. */
  26627. onRebuildObservable: Observable<AbstractMesh>;
  26628. /**
  26629. * Creates a new AbstractMesh
  26630. * @param name defines the name of the mesh
  26631. * @param scene defines the hosting scene
  26632. */
  26633. constructor(name: string, scene?: Nullable<Scene>);
  26634. /**
  26635. * Returns the string "AbstractMesh"
  26636. * @returns "AbstractMesh"
  26637. */
  26638. getClassName(): string;
  26639. /**
  26640. * Gets a string representation of the current mesh
  26641. * @param fullDetails defines a boolean indicating if full details must be included
  26642. * @returns a string representation of the current mesh
  26643. */
  26644. toString(fullDetails?: boolean): string;
  26645. /**
  26646. * @hidden
  26647. */
  26648. protected _getEffectiveParent(): Nullable<Node>;
  26649. /** @hidden */
  26650. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26651. /** @hidden */
  26652. _rebuild(): void;
  26653. /** @hidden */
  26654. _resyncLightSources(): void;
  26655. /** @hidden */
  26656. _resyncLighSource(light: Light): void;
  26657. /** @hidden */
  26658. _unBindEffect(): void;
  26659. /** @hidden */
  26660. _removeLightSource(light: Light, dispose: boolean): void;
  26661. private _markSubMeshesAsDirty;
  26662. /** @hidden */
  26663. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  26664. /** @hidden */
  26665. _markSubMeshesAsAttributesDirty(): void;
  26666. /** @hidden */
  26667. _markSubMeshesAsMiscDirty(): void;
  26668. /**
  26669. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26670. */
  26671. scaling: Vector3;
  26672. /**
  26673. * Returns true if the mesh is blocked. Implemented by child classes
  26674. */
  26675. readonly isBlocked: boolean;
  26676. /**
  26677. * Returns the mesh itself by default. Implemented by child classes
  26678. * @param camera defines the camera to use to pick the right LOD level
  26679. * @returns the currentAbstractMesh
  26680. */
  26681. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26682. /**
  26683. * Returns 0 by default. Implemented by child classes
  26684. * @returns an integer
  26685. */
  26686. getTotalVertices(): number;
  26687. /**
  26688. * Returns a positive integer : the total number of indices in this mesh geometry.
  26689. * @returns the numner of indices or zero if the mesh has no geometry.
  26690. */
  26691. getTotalIndices(): number;
  26692. /**
  26693. * Returns null by default. Implemented by child classes
  26694. * @returns null
  26695. */
  26696. getIndices(): Nullable<IndicesArray>;
  26697. /**
  26698. * Returns the array of the requested vertex data kind. Implemented by child classes
  26699. * @param kind defines the vertex data kind to use
  26700. * @returns null
  26701. */
  26702. getVerticesData(kind: string): Nullable<FloatArray>;
  26703. /**
  26704. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26705. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26706. * Note that a new underlying VertexBuffer object is created each call.
  26707. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26708. * @param kind defines vertex data kind:
  26709. * * VertexBuffer.PositionKind
  26710. * * VertexBuffer.UVKind
  26711. * * VertexBuffer.UV2Kind
  26712. * * VertexBuffer.UV3Kind
  26713. * * VertexBuffer.UV4Kind
  26714. * * VertexBuffer.UV5Kind
  26715. * * VertexBuffer.UV6Kind
  26716. * * VertexBuffer.ColorKind
  26717. * * VertexBuffer.MatricesIndicesKind
  26718. * * VertexBuffer.MatricesIndicesExtraKind
  26719. * * VertexBuffer.MatricesWeightsKind
  26720. * * VertexBuffer.MatricesWeightsExtraKind
  26721. * @param data defines the data source
  26722. * @param updatable defines if the data must be flagged as updatable (or static)
  26723. * @param stride defines the vertex stride (size of an entire vertex). Can be null and in this case will be deduced from vertex data kind
  26724. * @returns the current mesh
  26725. */
  26726. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  26727. /**
  26728. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26729. * If the mesh has no geometry, it is simply returned as it is.
  26730. * @param kind defines vertex data kind:
  26731. * * VertexBuffer.PositionKind
  26732. * * VertexBuffer.UVKind
  26733. * * VertexBuffer.UV2Kind
  26734. * * VertexBuffer.UV3Kind
  26735. * * VertexBuffer.UV4Kind
  26736. * * VertexBuffer.UV5Kind
  26737. * * VertexBuffer.UV6Kind
  26738. * * VertexBuffer.ColorKind
  26739. * * VertexBuffer.MatricesIndicesKind
  26740. * * VertexBuffer.MatricesIndicesExtraKind
  26741. * * VertexBuffer.MatricesWeightsKind
  26742. * * VertexBuffer.MatricesWeightsExtraKind
  26743. * @param data defines the data source
  26744. * @param updateExtends If `kind` is `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed
  26745. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26746. * @returns the current mesh
  26747. */
  26748. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26749. /**
  26750. * Sets the mesh indices,
  26751. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26752. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26753. * @param totalVertices Defines the total number of vertices
  26754. * @returns the current mesh
  26755. */
  26756. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26757. /**
  26758. * Gets a boolean indicating if specific vertex data is present
  26759. * @param kind defines the vertex data kind to use
  26760. * @returns true is data kind is present
  26761. */
  26762. isVerticesDataPresent(kind: string): boolean;
  26763. /**
  26764. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26765. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26766. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26767. * @returns a BoundingInfo
  26768. */
  26769. getBoundingInfo(): BoundingInfo;
  26770. /**
  26771. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26772. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26773. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26774. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26775. * @returns the current mesh
  26776. */
  26777. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26778. /**
  26779. * Overwrite the current bounding info
  26780. * @param boundingInfo defines the new bounding info
  26781. * @returns the current mesh
  26782. */
  26783. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26784. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26785. readonly useBones: boolean;
  26786. /** @hidden */
  26787. _preActivate(): void;
  26788. /** @hidden */
  26789. _preActivateForIntermediateRendering(renderId: number): void;
  26790. /** @hidden */
  26791. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26792. /** @hidden */
  26793. _postActivate(): void;
  26794. /** @hidden */
  26795. _freeze(): void;
  26796. /** @hidden */
  26797. _unFreeze(): void;
  26798. /**
  26799. * Gets the current world matrix
  26800. * @returns a Matrix
  26801. */
  26802. getWorldMatrix(): Matrix;
  26803. /** @hidden */
  26804. _getWorldMatrixDeterminant(): number;
  26805. /**
  26806. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26807. */
  26808. readonly isAnInstance: boolean;
  26809. /**
  26810. * Gets a boolean indicating if this mesh has instances
  26811. */
  26812. readonly hasInstances: boolean;
  26813. /**
  26814. * Perform relative position change from the point of view of behind the front of the mesh.
  26815. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26816. * Supports definition of mesh facing forward or backward
  26817. * @param amountRight defines the distance on the right axis
  26818. * @param amountUp defines the distance on the up axis
  26819. * @param amountForward defines the distance on the forward axis
  26820. * @returns the current mesh
  26821. */
  26822. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  26823. /**
  26824. * Calculate relative position change from the point of view of behind the front of the mesh.
  26825. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26826. * Supports definition of mesh facing forward or backward
  26827. * @param amountRight defines the distance on the right axis
  26828. * @param amountUp defines the distance on the up axis
  26829. * @param amountForward defines the distance on the forward axis
  26830. * @returns the new displacement vector
  26831. */
  26832. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  26833. /**
  26834. * Perform relative rotation change from the point of view of behind the front of the mesh.
  26835. * Supports definition of mesh facing forward or backward
  26836. * @param flipBack defines the flip
  26837. * @param twirlClockwise defines the twirl
  26838. * @param tiltRight defines the tilt
  26839. * @returns the current mesh
  26840. */
  26841. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26842. /**
  26843. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26844. * Supports definition of mesh facing forward or backward.
  26845. * @param flipBack defines the flip
  26846. * @param twirlClockwise defines the twirl
  26847. * @param tiltRight defines the tilt
  26848. * @returns the new rotation vector
  26849. */
  26850. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  26851. /**
  26852. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26853. * This means the mesh underlying bounding box and sphere are recomputed.
  26854. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26855. * @returns the current mesh
  26856. */
  26857. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  26858. /** @hidden */
  26859. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  26860. /** @hidden */
  26861. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  26862. /** @hidden */
  26863. _updateBoundingInfo(): AbstractMesh;
  26864. /** @hidden */
  26865. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  26866. /** @hidden */
  26867. protected _afterComputeWorldMatrix(): void;
  26868. /** @hidden */
  26869. readonly _effectiveMesh: AbstractMesh;
  26870. /**
  26871. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26872. * A mesh is in the frustum if its bounding box intersects the frustum
  26873. * @param frustumPlanes defines the frustum to test
  26874. * @returns true if the mesh is in the frustum planes
  26875. */
  26876. isInFrustum(frustumPlanes: Plane[]): boolean;
  26877. /**
  26878. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  26879. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  26880. * @param frustumPlanes defines the frustum to test
  26881. * @returns true if the mesh is completely in the frustum planes
  26882. */
  26883. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26884. /**
  26885. * True if the mesh intersects another mesh or a SolidParticle object
  26886. * @param mesh defines a target mesh or SolidParticle to test
  26887. * @param precise Unless the parameter `precise` is set to `true` the intersection is computed according to Axis Aligned Bounding Boxes (AABB), else according to OBB (Oriented BBoxes)
  26888. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  26889. * @returns true if there is an intersection
  26890. */
  26891. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  26892. /**
  26893. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  26894. * @param point defines the point to test
  26895. * @returns true if there is an intersection
  26896. */
  26897. intersectsPoint(point: Vector3): boolean;
  26898. /**
  26899. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  26900. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26901. */
  26902. checkCollisions: boolean;
  26903. /**
  26904. * Gets Collider object used to compute collisions (not physics)
  26905. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26906. */
  26907. readonly collider: Nullable<Collider>;
  26908. /**
  26909. * Move the mesh using collision engine
  26910. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26911. * @param displacement defines the requested displacement vector
  26912. * @returns the current mesh
  26913. */
  26914. moveWithCollisions(displacement: Vector3): AbstractMesh;
  26915. private _onCollisionPositionChange;
  26916. /** @hidden */
  26917. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  26918. /** @hidden */
  26919. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  26920. /** @hidden */
  26921. _checkCollision(collider: Collider): AbstractMesh;
  26922. /** @hidden */
  26923. _generatePointsArray(): boolean;
  26924. /**
  26925. * Checks if the passed Ray intersects with the mesh
  26926. * @param ray defines the ray to use
  26927. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  26928. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26929. * @returns the picking info
  26930. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  26931. */
  26932. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  26933. /**
  26934. * Clones the current mesh
  26935. * @param name defines the mesh name
  26936. * @param newParent defines the new mesh parent
  26937. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  26938. * @returns the new mesh
  26939. */
  26940. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  26941. /**
  26942. * Disposes all the submeshes of the current meshnp
  26943. * @returns the current mesh
  26944. */
  26945. releaseSubMeshes(): AbstractMesh;
  26946. /**
  26947. * Releases resources associated with this abstract mesh.
  26948. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26949. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26950. */
  26951. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26952. /**
  26953. * Adds the passed mesh as a child to the current mesh
  26954. * @param mesh defines the child mesh
  26955. * @returns the current mesh
  26956. */
  26957. addChild(mesh: AbstractMesh): AbstractMesh;
  26958. /**
  26959. * Removes the passed mesh from the current mesh children list
  26960. * @param mesh defines the child mesh
  26961. * @returns the current mesh
  26962. */
  26963. removeChild(mesh: AbstractMesh): AbstractMesh;
  26964. /** @hidden */
  26965. private _initFacetData;
  26966. /**
  26967. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  26968. * This method can be called within the render loop.
  26969. * You don't need to call this method by yourself in the render loop when you update/morph a mesh with the methods CreateXXX() as they automatically manage this computation
  26970. * @returns the current mesh
  26971. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26972. */
  26973. updateFacetData(): AbstractMesh;
  26974. /**
  26975. * Returns the facetLocalNormals array.
  26976. * The normals are expressed in the mesh local spac
  26977. * @returns an array of Vector3
  26978. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26979. */
  26980. getFacetLocalNormals(): Vector3[];
  26981. /**
  26982. * Returns the facetLocalPositions array.
  26983. * The facet positions are expressed in the mesh local space
  26984. * @returns an array of Vector3
  26985. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26986. */
  26987. getFacetLocalPositions(): Vector3[];
  26988. /**
  26989. * Returns the facetLocalPartioning array
  26990. * @returns an array of array of numbers
  26991. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26992. */
  26993. getFacetLocalPartitioning(): number[][];
  26994. /**
  26995. * Returns the i-th facet position in the world system.
  26996. * This method allocates a new Vector3 per call
  26997. * @param i defines the facet index
  26998. * @returns a new Vector3
  26999. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27000. */
  27001. getFacetPosition(i: number): Vector3;
  27002. /**
  27003. * Sets the reference Vector3 with the i-th facet position in the world system
  27004. * @param i defines the facet index
  27005. * @param ref defines the target vector
  27006. * @returns the current mesh
  27007. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27008. */
  27009. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  27010. /**
  27011. * Returns the i-th facet normal in the world system.
  27012. * This method allocates a new Vector3 per call
  27013. * @param i defines the facet index
  27014. * @returns a new Vector3
  27015. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27016. */
  27017. getFacetNormal(i: number): Vector3;
  27018. /**
  27019. * Sets the reference Vector3 with the i-th facet normal in the world system
  27020. * @param i defines the facet index
  27021. * @param ref defines the target vector
  27022. * @returns the current mesh
  27023. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27024. */
  27025. getFacetNormalToRef(i: number, ref: Vector3): this;
  27026. /**
  27027. * Returns the facets (in an array) in the same partitioning block than the one the passed coordinates are located (expressed in the mesh local system)
  27028. * @param x defines x coordinate
  27029. * @param y defines y coordinate
  27030. * @param z defines z coordinate
  27031. * @returns the array of facet indexes
  27032. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27033. */
  27034. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  27035. /**
  27036. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  27037. * @param projected sets as the (x,y,z) world projection on the facet
  27038. * @param checkFace if true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned
  27039. * @param facing if facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position. If facing si false and checkFace is true, only the facet "turning their backs" to (x, y, z) are returned : negative dot (x, y, z) * facet position
  27040. * @param x defines x coordinate
  27041. * @param y defines y coordinate
  27042. * @param z defines z coordinate
  27043. * @returns the face index if found (or null instead)
  27044. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27045. */
  27046. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27047. /**
  27048. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  27049. * @param projected sets as the (x,y,z) local projection on the facet
  27050. * @param checkFace if true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned
  27051. * @param facing if facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position. If facing si false and checkFace is true, only the facet "turning their backs" to (x, y, z) are returned : negative dot (x, y, z) * facet position
  27052. * @param x defines x coordinate
  27053. * @param y defines y coordinate
  27054. * @param z defines z coordinate
  27055. * @returns the face index if found (or null instead)
  27056. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27057. */
  27058. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27059. /**
  27060. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  27061. * @returns the parameters
  27062. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27063. */
  27064. getFacetDataParameters(): any;
  27065. /**
  27066. * Disables the feature FacetData and frees the related memory
  27067. * @returns the current mesh
  27068. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27069. */
  27070. disableFacetData(): AbstractMesh;
  27071. /**
  27072. * Updates the AbstractMesh indices array
  27073. * @param indices defines the data source
  27074. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27075. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  27076. * @returns the current mesh
  27077. */
  27078. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27079. /**
  27080. * Creates new normals data for the mesh
  27081. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  27082. * @returns the current mesh
  27083. */
  27084. createNormals(updatable: boolean): AbstractMesh;
  27085. /**
  27086. * Align the mesh with a normal
  27087. * @param normal defines the normal to use
  27088. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  27089. * @returns the current mesh
  27090. */
  27091. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27092. /** @hidden */
  27093. _checkOcclusionQuery(): boolean;
  27094. /**
  27095. * Disables the mesh edge rendering mode
  27096. * @returns the currentAbstractMesh
  27097. */
  27098. disableEdgesRendering(): AbstractMesh;
  27099. /**
  27100. * Enables the edge rendering mode on the mesh.
  27101. * This mode makes the mesh edges visible
  27102. * @param epsilon defines the maximal distance between two angles to detect a face
  27103. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27104. * @returns the currentAbstractMesh
  27105. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27106. */
  27107. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27108. }
  27109. }
  27110. declare module "babylonjs/Actions/actionEvent" {
  27111. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27112. import { Nullable } from "babylonjs/types";
  27113. import { Sprite } from "babylonjs/Sprites/sprite";
  27114. import { Scene } from "babylonjs/scene";
  27115. import { Vector2 } from "babylonjs/Maths/math.vector";
  27116. /**
  27117. * Interface used to define ActionEvent
  27118. */
  27119. export interface IActionEvent {
  27120. /** The mesh or sprite that triggered the action */
  27121. source: any;
  27122. /** The X mouse cursor position at the time of the event */
  27123. pointerX: number;
  27124. /** The Y mouse cursor position at the time of the event */
  27125. pointerY: number;
  27126. /** The mesh that is currently pointed at (can be null) */
  27127. meshUnderPointer: Nullable<AbstractMesh>;
  27128. /** the original (browser) event that triggered the ActionEvent */
  27129. sourceEvent?: any;
  27130. /** additional data for the event */
  27131. additionalData?: any;
  27132. }
  27133. /**
  27134. * ActionEvent is the event being sent when an action is triggered.
  27135. */
  27136. export class ActionEvent implements IActionEvent {
  27137. /** The mesh or sprite that triggered the action */
  27138. source: any;
  27139. /** The X mouse cursor position at the time of the event */
  27140. pointerX: number;
  27141. /** The Y mouse cursor position at the time of the event */
  27142. pointerY: number;
  27143. /** The mesh that is currently pointed at (can be null) */
  27144. meshUnderPointer: Nullable<AbstractMesh>;
  27145. /** the original (browser) event that triggered the ActionEvent */
  27146. sourceEvent?: any;
  27147. /** additional data for the event */
  27148. additionalData?: any;
  27149. /**
  27150. * Creates a new ActionEvent
  27151. * @param source The mesh or sprite that triggered the action
  27152. * @param pointerX The X mouse cursor position at the time of the event
  27153. * @param pointerY The Y mouse cursor position at the time of the event
  27154. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27155. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27156. * @param additionalData additional data for the event
  27157. */
  27158. constructor(
  27159. /** The mesh or sprite that triggered the action */
  27160. source: any,
  27161. /** The X mouse cursor position at the time of the event */
  27162. pointerX: number,
  27163. /** The Y mouse cursor position at the time of the event */
  27164. pointerY: number,
  27165. /** The mesh that is currently pointed at (can be null) */
  27166. meshUnderPointer: Nullable<AbstractMesh>,
  27167. /** the original (browser) event that triggered the ActionEvent */
  27168. sourceEvent?: any,
  27169. /** additional data for the event */
  27170. additionalData?: any);
  27171. /**
  27172. * Helper function to auto-create an ActionEvent from a source mesh.
  27173. * @param source The source mesh that triggered the event
  27174. * @param evt The original (browser) event
  27175. * @param additionalData additional data for the event
  27176. * @returns the new ActionEvent
  27177. */
  27178. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27179. /**
  27180. * Helper function to auto-create an ActionEvent from a source sprite
  27181. * @param source The source sprite that triggered the event
  27182. * @param scene Scene associated with the sprite
  27183. * @param evt The original (browser) event
  27184. * @param additionalData additional data for the event
  27185. * @returns the new ActionEvent
  27186. */
  27187. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27188. /**
  27189. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27190. * @param scene the scene where the event occurred
  27191. * @param evt The original (browser) event
  27192. * @returns the new ActionEvent
  27193. */
  27194. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27195. /**
  27196. * Helper function to auto-create an ActionEvent from a primitive
  27197. * @param prim defines the target primitive
  27198. * @param pointerPos defines the pointer position
  27199. * @param evt The original (browser) event
  27200. * @param additionalData additional data for the event
  27201. * @returns the new ActionEvent
  27202. */
  27203. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27204. }
  27205. }
  27206. declare module "babylonjs/Actions/abstractActionManager" {
  27207. import { IDisposable } from "babylonjs/scene";
  27208. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27209. import { IAction } from "babylonjs/Actions/action";
  27210. import { Nullable } from "babylonjs/types";
  27211. /**
  27212. * Abstract class used to decouple action Manager from scene and meshes.
  27213. * Do not instantiate.
  27214. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27215. */
  27216. export abstract class AbstractActionManager implements IDisposable {
  27217. /** Gets the list of active triggers */
  27218. static Triggers: {
  27219. [key: string]: number;
  27220. };
  27221. /** Gets the cursor to use when hovering items */
  27222. hoverCursor: string;
  27223. /** Gets the list of actions */
  27224. actions: IAction[];
  27225. /**
  27226. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27227. */
  27228. isRecursive: boolean;
  27229. /**
  27230. * Releases all associated resources
  27231. */
  27232. abstract dispose(): void;
  27233. /**
  27234. * Does this action manager has pointer triggers
  27235. */
  27236. abstract readonly hasPointerTriggers: boolean;
  27237. /**
  27238. * Does this action manager has pick triggers
  27239. */
  27240. abstract readonly hasPickTriggers: boolean;
  27241. /**
  27242. * Process a specific trigger
  27243. * @param trigger defines the trigger to process
  27244. * @param evt defines the event details to be processed
  27245. */
  27246. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27247. /**
  27248. * Does this action manager handles actions of any of the given triggers
  27249. * @param triggers defines the triggers to be tested
  27250. * @return a boolean indicating whether one (or more) of the triggers is handled
  27251. */
  27252. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27253. /**
  27254. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27255. * speed.
  27256. * @param triggerA defines the trigger to be tested
  27257. * @param triggerB defines the trigger to be tested
  27258. * @return a boolean indicating whether one (or more) of the triggers is handled
  27259. */
  27260. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27261. /**
  27262. * Does this action manager handles actions of a given trigger
  27263. * @param trigger defines the trigger to be tested
  27264. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27265. * @return whether the trigger is handled
  27266. */
  27267. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27268. /**
  27269. * Serialize this manager to a JSON object
  27270. * @param name defines the property name to store this manager
  27271. * @returns a JSON representation of this manager
  27272. */
  27273. abstract serialize(name: string): any;
  27274. /**
  27275. * Registers an action to this action manager
  27276. * @param action defines the action to be registered
  27277. * @return the action amended (prepared) after registration
  27278. */
  27279. abstract registerAction(action: IAction): Nullable<IAction>;
  27280. /**
  27281. * Unregisters an action to this action manager
  27282. * @param action defines the action to be unregistered
  27283. * @return a boolean indicating whether the action has been unregistered
  27284. */
  27285. abstract unregisterAction(action: IAction): Boolean;
  27286. /**
  27287. * Does exist one action manager with at least one trigger
  27288. **/
  27289. static readonly HasTriggers: boolean;
  27290. /**
  27291. * Does exist one action manager with at least one pick trigger
  27292. **/
  27293. static readonly HasPickTriggers: boolean;
  27294. /**
  27295. * Does exist one action manager that handles actions of a given trigger
  27296. * @param trigger defines the trigger to be tested
  27297. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27298. **/
  27299. static HasSpecificTrigger(trigger: number): boolean;
  27300. }
  27301. }
  27302. declare module "babylonjs/node" {
  27303. import { Scene } from "babylonjs/scene";
  27304. import { Nullable } from "babylonjs/types";
  27305. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27306. import { Engine } from "babylonjs/Engines/engine";
  27307. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  27308. import { Observable } from "babylonjs/Misc/observable";
  27309. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  27310. import { IInspectable } from "babylonjs/Misc/iInspectable";
  27311. import { Animatable } from "babylonjs/Animations/animatable";
  27312. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27313. import { Animation } from "babylonjs/Animations/animation";
  27314. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27315. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27316. /**
  27317. * Defines how a node can be built from a string name.
  27318. */
  27319. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  27320. /**
  27321. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  27322. */
  27323. export class Node implements IBehaviorAware<Node> {
  27324. /** @hidden */
  27325. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  27326. private static _NodeConstructors;
  27327. /**
  27328. * Add a new node constructor
  27329. * @param type defines the type name of the node to construct
  27330. * @param constructorFunc defines the constructor function
  27331. */
  27332. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  27333. /**
  27334. * Returns a node constructor based on type name
  27335. * @param type defines the type name
  27336. * @param name defines the new node name
  27337. * @param scene defines the hosting scene
  27338. * @param options defines optional options to transmit to constructors
  27339. * @returns the new constructor or null
  27340. */
  27341. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  27342. /**
  27343. * Gets or sets the name of the node
  27344. */
  27345. name: string;
  27346. /**
  27347. * Gets or sets the id of the node
  27348. */
  27349. id: string;
  27350. /**
  27351. * Gets or sets the unique id of the node
  27352. */
  27353. uniqueId: number;
  27354. /**
  27355. * Gets or sets a string used to store user defined state for the node
  27356. */
  27357. state: string;
  27358. /**
  27359. * Gets or sets an object used to store user defined information for the node
  27360. */
  27361. metadata: any;
  27362. /**
  27363. * For internal use only. Please do not use.
  27364. */
  27365. reservedDataStore: any;
  27366. /**
  27367. * List of inspectable custom properties (used by the Inspector)
  27368. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27369. */
  27370. inspectableCustomProperties: IInspectable[];
  27371. /**
  27372. * Gets or sets a boolean used to define if the node must be serialized
  27373. */
  27374. doNotSerialize: boolean;
  27375. /** @hidden */
  27376. _isDisposed: boolean;
  27377. /**
  27378. * Gets a list of Animations associated with the node
  27379. */
  27380. animations: import("babylonjs/Animations/animation").Animation[];
  27381. protected _ranges: {
  27382. [name: string]: Nullable<AnimationRange>;
  27383. };
  27384. /**
  27385. * Callback raised when the node is ready to be used
  27386. */
  27387. onReady: Nullable<(node: Node) => void>;
  27388. private _isEnabled;
  27389. private _isParentEnabled;
  27390. private _isReady;
  27391. /** @hidden */
  27392. _currentRenderId: number;
  27393. private _parentUpdateId;
  27394. /** @hidden */
  27395. _childUpdateId: number;
  27396. /** @hidden */
  27397. _waitingParentId: Nullable<string>;
  27398. /** @hidden */
  27399. _scene: Scene;
  27400. /** @hidden */
  27401. _cache: any;
  27402. private _parentNode;
  27403. private _children;
  27404. /** @hidden */
  27405. _worldMatrix: Matrix;
  27406. /** @hidden */
  27407. _worldMatrixDeterminant: number;
  27408. /** @hidden */
  27409. _worldMatrixDeterminantIsDirty: boolean;
  27410. /** @hidden */
  27411. private _sceneRootNodesIndex;
  27412. /**
  27413. * Gets a boolean indicating if the node has been disposed
  27414. * @returns true if the node was disposed
  27415. */
  27416. isDisposed(): boolean;
  27417. /**
  27418. * Gets or sets the parent of the node (without keeping the current position in the scene)
  27419. * @see https://doc.babylonjs.com/how_to/parenting
  27420. */
  27421. parent: Nullable<Node>;
  27422. private addToSceneRootNodes;
  27423. private removeFromSceneRootNodes;
  27424. private _animationPropertiesOverride;
  27425. /**
  27426. * Gets or sets the animation properties override
  27427. */
  27428. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  27429. /**
  27430. * Gets a string idenfifying the name of the class
  27431. * @returns "Node" string
  27432. */
  27433. getClassName(): string;
  27434. /** @hidden */
  27435. readonly _isNode: boolean;
  27436. /**
  27437. * An event triggered when the mesh is disposed
  27438. */
  27439. onDisposeObservable: Observable<Node>;
  27440. private _onDisposeObserver;
  27441. /**
  27442. * Sets a callback that will be raised when the node will be disposed
  27443. */
  27444. onDispose: () => void;
  27445. /**
  27446. * Creates a new Node
  27447. * @param name the name and id to be given to this node
  27448. * @param scene the scene this node will be added to
  27449. * @param addToRootNodes the node will be added to scene.rootNodes
  27450. */
  27451. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  27452. /**
  27453. * Gets the scene of the node
  27454. * @returns a scene
  27455. */
  27456. getScene(): Scene;
  27457. /**
  27458. * Gets the engine of the node
  27459. * @returns a Engine
  27460. */
  27461. getEngine(): Engine;
  27462. private _behaviors;
  27463. /**
  27464. * Attach a behavior to the node
  27465. * @see http://doc.babylonjs.com/features/behaviour
  27466. * @param behavior defines the behavior to attach
  27467. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  27468. * @returns the current Node
  27469. */
  27470. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  27471. /**
  27472. * Remove an attached behavior
  27473. * @see http://doc.babylonjs.com/features/behaviour
  27474. * @param behavior defines the behavior to attach
  27475. * @returns the current Node
  27476. */
  27477. removeBehavior(behavior: Behavior<Node>): Node;
  27478. /**
  27479. * Gets the list of attached behaviors
  27480. * @see http://doc.babylonjs.com/features/behaviour
  27481. */
  27482. readonly behaviors: Behavior<Node>[];
  27483. /**
  27484. * Gets an attached behavior by name
  27485. * @param name defines the name of the behavior to look for
  27486. * @see http://doc.babylonjs.com/features/behaviour
  27487. * @returns null if behavior was not found else the requested behavior
  27488. */
  27489. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27490. /**
  27491. * Returns the latest update of the World matrix
  27492. * @returns a Matrix
  27493. */
  27494. getWorldMatrix(): Matrix;
  27495. /** @hidden */
  27496. _getWorldMatrixDeterminant(): number;
  27497. /**
  27498. * Returns directly the latest state of the mesh World matrix.
  27499. * A Matrix is returned.
  27500. */
  27501. readonly worldMatrixFromCache: Matrix;
  27502. /** @hidden */
  27503. _initCache(): void;
  27504. /** @hidden */
  27505. updateCache(force?: boolean): void;
  27506. /** @hidden */
  27507. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27508. /** @hidden */
  27509. _updateCache(ignoreParentClass?: boolean): void;
  27510. /** @hidden */
  27511. _isSynchronized(): boolean;
  27512. /** @hidden */
  27513. _markSyncedWithParent(): void;
  27514. /** @hidden */
  27515. isSynchronizedWithParent(): boolean;
  27516. /** @hidden */
  27517. isSynchronized(): boolean;
  27518. /**
  27519. * Is this node ready to be used/rendered
  27520. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27521. * @return true if the node is ready
  27522. */
  27523. isReady(completeCheck?: boolean): boolean;
  27524. /**
  27525. * Is this node enabled?
  27526. * If the node has a parent, all ancestors will be checked and false will be returned if any are false (not enabled), otherwise will return true
  27527. * @param checkAncestors indicates if this method should check the ancestors. The default is to check the ancestors. If set to false, the method will return the value of this node without checking ancestors
  27528. * @return whether this node (and its parent) is enabled
  27529. */
  27530. isEnabled(checkAncestors?: boolean): boolean;
  27531. /** @hidden */
  27532. protected _syncParentEnabledState(): void;
  27533. /**
  27534. * Set the enabled state of this node
  27535. * @param value defines the new enabled state
  27536. */
  27537. setEnabled(value: boolean): void;
  27538. /**
  27539. * Is this node a descendant of the given node?
  27540. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27541. * @param ancestor defines the parent node to inspect
  27542. * @returns a boolean indicating if this node is a descendant of the given node
  27543. */
  27544. isDescendantOf(ancestor: Node): boolean;
  27545. /** @hidden */
  27546. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27547. /**
  27548. * Will return all nodes that have this node as ascendant
  27549. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  27550. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  27551. * @return all children nodes of all types
  27552. */
  27553. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27554. /**
  27555. * Get all child-meshes of this node
  27556. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: false)
  27557. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  27558. * @returns an array of AbstractMesh
  27559. */
  27560. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27561. /**
  27562. * Get all direct children of this node
  27563. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  27564. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: true)
  27565. * @returns an array of Node
  27566. */
  27567. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27568. /** @hidden */
  27569. _setReady(state: boolean): void;
  27570. /**
  27571. * Get an animation by name
  27572. * @param name defines the name of the animation to look for
  27573. * @returns null if not found else the requested animation
  27574. */
  27575. getAnimationByName(name: string): Nullable<Animation>;
  27576. /**
  27577. * Creates an animation range for this node
  27578. * @param name defines the name of the range
  27579. * @param from defines the starting key
  27580. * @param to defines the end key
  27581. */
  27582. createAnimationRange(name: string, from: number, to: number): void;
  27583. /**
  27584. * Delete a specific animation range
  27585. * @param name defines the name of the range to delete
  27586. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27587. */
  27588. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27589. /**
  27590. * Get an animation range by name
  27591. * @param name defines the name of the animation range to look for
  27592. * @returns null if not found else the requested animation range
  27593. */
  27594. getAnimationRange(name: string): Nullable<AnimationRange>;
  27595. /**
  27596. * Gets the list of all animation ranges defined on this node
  27597. * @returns an array
  27598. */
  27599. getAnimationRanges(): Nullable<AnimationRange>[];
  27600. /**
  27601. * Will start the animation sequence
  27602. * @param name defines the range frames for animation sequence
  27603. * @param loop defines if the animation should loop (false by default)
  27604. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27605. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27606. * @returns the object created for this animation. If range does not exist, it will return null
  27607. */
  27608. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27609. /**
  27610. * Serialize animation ranges into a JSON compatible object
  27611. * @returns serialization object
  27612. */
  27613. serializeAnimationRanges(): any;
  27614. /**
  27615. * Computes the world matrix of the node
  27616. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27617. * @returns the world matrix
  27618. */
  27619. computeWorldMatrix(force?: boolean): Matrix;
  27620. /**
  27621. * Releases resources associated with this node.
  27622. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27623. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27624. */
  27625. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27626. /**
  27627. * Parse animation range data from a serialization object and store them into a given node
  27628. * @param node defines where to store the animation ranges
  27629. * @param parsedNode defines the serialization object to read data from
  27630. * @param scene defines the hosting scene
  27631. */
  27632. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27633. /**
  27634. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27635. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27636. * @param predicate defines a callback function that can be customize to filter what meshes should be included in the list used to compute the bounding vectors
  27637. * @returns the new bounding vectors
  27638. */
  27639. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27640. min: Vector3;
  27641. max: Vector3;
  27642. };
  27643. }
  27644. }
  27645. declare module "babylonjs/Animations/animation" {
  27646. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  27647. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  27648. import { Color3 } from "babylonjs/Maths/math.color";
  27649. import { Nullable } from "babylonjs/types";
  27650. import { Scene } from "babylonjs/scene";
  27651. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  27652. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27653. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  27654. import { Node } from "babylonjs/node";
  27655. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27656. import { Size } from "babylonjs/Maths/math.size";
  27657. import { Animatable } from "babylonjs/Animations/animatable";
  27658. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  27659. /**
  27660. * @hidden
  27661. */
  27662. export class _IAnimationState {
  27663. key: number;
  27664. repeatCount: number;
  27665. workValue?: any;
  27666. loopMode?: number;
  27667. offsetValue?: any;
  27668. highLimitValue?: any;
  27669. }
  27670. /**
  27671. * Class used to store any kind of animation
  27672. */
  27673. export class Animation {
  27674. /**Name of the animation */
  27675. name: string;
  27676. /**Property to animate */
  27677. targetProperty: string;
  27678. /**The frames per second of the animation */
  27679. framePerSecond: number;
  27680. /**The data type of the animation */
  27681. dataType: number;
  27682. /**The loop mode of the animation */
  27683. loopMode?: number | undefined;
  27684. /**Specifies if blending should be enabled */
  27685. enableBlending?: boolean | undefined;
  27686. /**
  27687. * Use matrix interpolation instead of using direct key value when animating matrices
  27688. */
  27689. static AllowMatricesInterpolation: boolean;
  27690. /**
  27691. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  27692. */
  27693. static AllowMatrixDecomposeForInterpolation: boolean;
  27694. /**
  27695. * Stores the key frames of the animation
  27696. */
  27697. private _keys;
  27698. /**
  27699. * Stores the easing function of the animation
  27700. */
  27701. private _easingFunction;
  27702. /**
  27703. * @hidden Internal use only
  27704. */
  27705. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  27706. /**
  27707. * The set of event that will be linked to this animation
  27708. */
  27709. private _events;
  27710. /**
  27711. * Stores an array of target property paths
  27712. */
  27713. targetPropertyPath: string[];
  27714. /**
  27715. * Stores the blending speed of the animation
  27716. */
  27717. blendingSpeed: number;
  27718. /**
  27719. * Stores the animation ranges for the animation
  27720. */
  27721. private _ranges;
  27722. /**
  27723. * @hidden Internal use
  27724. */
  27725. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  27726. /**
  27727. * Sets up an animation
  27728. * @param property The property to animate
  27729. * @param animationType The animation type to apply
  27730. * @param framePerSecond The frames per second of the animation
  27731. * @param easingFunction The easing function used in the animation
  27732. * @returns The created animation
  27733. */
  27734. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  27735. /**
  27736. * Create and start an animation on a node
  27737. * @param name defines the name of the global animation that will be run on all nodes
  27738. * @param node defines the root node where the animation will take place
  27739. * @param targetProperty defines property to animate
  27740. * @param framePerSecond defines the number of frame per second yo use
  27741. * @param totalFrame defines the number of frames in total
  27742. * @param from defines the initial value
  27743. * @param to defines the final value
  27744. * @param loopMode defines which loop mode you want to use (off by default)
  27745. * @param easingFunction defines the easing function to use (linear by default)
  27746. * @param onAnimationEnd defines the callback to call when animation end
  27747. * @returns the animatable created for this animation
  27748. */
  27749. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27750. /**
  27751. * Create and start an animation on a node and its descendants
  27752. * @param name defines the name of the global animation that will be run on all nodes
  27753. * @param node defines the root node where the animation will take place
  27754. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used
  27755. * @param targetProperty defines property to animate
  27756. * @param framePerSecond defines the number of frame per second to use
  27757. * @param totalFrame defines the number of frames in total
  27758. * @param from defines the initial value
  27759. * @param to defines the final value
  27760. * @param loopMode defines which loop mode you want to use (off by default)
  27761. * @param easingFunction defines the easing function to use (linear by default)
  27762. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  27763. * @returns the list of animatables created for all nodes
  27764. * @example https://www.babylonjs-playground.com/#MH0VLI
  27765. */
  27766. static CreateAndStartHierarchyAnimation(name: string, node: Node, directDescendantsOnly: boolean, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable[]>;
  27767. /**
  27768. * Creates a new animation, merges it with the existing animations and starts it
  27769. * @param name Name of the animation
  27770. * @param node Node which contains the scene that begins the animations
  27771. * @param targetProperty Specifies which property to animate
  27772. * @param framePerSecond The frames per second of the animation
  27773. * @param totalFrame The total number of frames
  27774. * @param from The frame at the beginning of the animation
  27775. * @param to The frame at the end of the animation
  27776. * @param loopMode Specifies the loop mode of the animation
  27777. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  27778. * @param onAnimationEnd Callback to run once the animation is complete
  27779. * @returns Nullable animation
  27780. */
  27781. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27782. /**
  27783. * Transition property of an host to the target Value
  27784. * @param property The property to transition
  27785. * @param targetValue The target Value of the property
  27786. * @param host The object where the property to animate belongs
  27787. * @param scene Scene used to run the animation
  27788. * @param frameRate Framerate (in frame/s) to use
  27789. * @param transition The transition type we want to use
  27790. * @param duration The duration of the animation, in milliseconds
  27791. * @param onAnimationEnd Callback trigger at the end of the animation
  27792. * @returns Nullable animation
  27793. */
  27794. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27795. /**
  27796. * Return the array of runtime animations currently using this animation
  27797. */
  27798. readonly runtimeAnimations: RuntimeAnimation[];
  27799. /**
  27800. * Specifies if any of the runtime animations are currently running
  27801. */
  27802. readonly hasRunningRuntimeAnimations: boolean;
  27803. /**
  27804. * Initializes the animation
  27805. * @param name Name of the animation
  27806. * @param targetProperty Property to animate
  27807. * @param framePerSecond The frames per second of the animation
  27808. * @param dataType The data type of the animation
  27809. * @param loopMode The loop mode of the animation
  27810. * @param enableBlending Specifies if blending should be enabled
  27811. */
  27812. constructor(
  27813. /**Name of the animation */
  27814. name: string,
  27815. /**Property to animate */
  27816. targetProperty: string,
  27817. /**The frames per second of the animation */
  27818. framePerSecond: number,
  27819. /**The data type of the animation */
  27820. dataType: number,
  27821. /**The loop mode of the animation */
  27822. loopMode?: number | undefined,
  27823. /**Specifies if blending should be enabled */
  27824. enableBlending?: boolean | undefined);
  27825. /**
  27826. * Converts the animation to a string
  27827. * @param fullDetails support for multiple levels of logging within scene loading
  27828. * @returns String form of the animation
  27829. */
  27830. toString(fullDetails?: boolean): string;
  27831. /**
  27832. * Add an event to this animation
  27833. * @param event Event to add
  27834. */
  27835. addEvent(event: AnimationEvent): void;
  27836. /**
  27837. * Remove all events found at the given frame
  27838. * @param frame The frame to remove events from
  27839. */
  27840. removeEvents(frame: number): void;
  27841. /**
  27842. * Retrieves all the events from the animation
  27843. * @returns Events from the animation
  27844. */
  27845. getEvents(): AnimationEvent[];
  27846. /**
  27847. * Creates an animation range
  27848. * @param name Name of the animation range
  27849. * @param from Starting frame of the animation range
  27850. * @param to Ending frame of the animation
  27851. */
  27852. createRange(name: string, from: number, to: number): void;
  27853. /**
  27854. * Deletes an animation range by name
  27855. * @param name Name of the animation range to delete
  27856. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  27857. */
  27858. deleteRange(name: string, deleteFrames?: boolean): void;
  27859. /**
  27860. * Gets the animation range by name, or null if not defined
  27861. * @param name Name of the animation range
  27862. * @returns Nullable animation range
  27863. */
  27864. getRange(name: string): Nullable<AnimationRange>;
  27865. /**
  27866. * Gets the key frames from the animation
  27867. * @returns The key frames of the animation
  27868. */
  27869. getKeys(): Array<IAnimationKey>;
  27870. /**
  27871. * Gets the highest frame rate of the animation
  27872. * @returns Highest frame rate of the animation
  27873. */
  27874. getHighestFrame(): number;
  27875. /**
  27876. * Gets the easing function of the animation
  27877. * @returns Easing function of the animation
  27878. */
  27879. getEasingFunction(): IEasingFunction;
  27880. /**
  27881. * Sets the easing function of the animation
  27882. * @param easingFunction A custom mathematical formula for animation
  27883. */
  27884. setEasingFunction(easingFunction: EasingFunction): void;
  27885. /**
  27886. * Interpolates a scalar linearly
  27887. * @param startValue Start value of the animation curve
  27888. * @param endValue End value of the animation curve
  27889. * @param gradient Scalar amount to interpolate
  27890. * @returns Interpolated scalar value
  27891. */
  27892. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  27893. /**
  27894. * Interpolates a scalar cubically
  27895. * @param startValue Start value of the animation curve
  27896. * @param outTangent End tangent of the animation
  27897. * @param endValue End value of the animation curve
  27898. * @param inTangent Start tangent of the animation curve
  27899. * @param gradient Scalar amount to interpolate
  27900. * @returns Interpolated scalar value
  27901. */
  27902. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  27903. /**
  27904. * Interpolates a quaternion using a spherical linear interpolation
  27905. * @param startValue Start value of the animation curve
  27906. * @param endValue End value of the animation curve
  27907. * @param gradient Scalar amount to interpolate
  27908. * @returns Interpolated quaternion value
  27909. */
  27910. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  27911. /**
  27912. * Interpolates a quaternion cubically
  27913. * @param startValue Start value of the animation curve
  27914. * @param outTangent End tangent of the animation curve
  27915. * @param endValue End value of the animation curve
  27916. * @param inTangent Start tangent of the animation curve
  27917. * @param gradient Scalar amount to interpolate
  27918. * @returns Interpolated quaternion value
  27919. */
  27920. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  27921. /**
  27922. * Interpolates a Vector3 linearl
  27923. * @param startValue Start value of the animation curve
  27924. * @param endValue End value of the animation curve
  27925. * @param gradient Scalar amount to interpolate
  27926. * @returns Interpolated scalar value
  27927. */
  27928. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  27929. /**
  27930. * Interpolates a Vector3 cubically
  27931. * @param startValue Start value of the animation curve
  27932. * @param outTangent End tangent of the animation
  27933. * @param endValue End value of the animation curve
  27934. * @param inTangent Start tangent of the animation curve
  27935. * @param gradient Scalar amount to interpolate
  27936. * @returns InterpolatedVector3 value
  27937. */
  27938. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  27939. /**
  27940. * Interpolates a Vector2 linearly
  27941. * @param startValue Start value of the animation curve
  27942. * @param endValue End value of the animation curve
  27943. * @param gradient Scalar amount to interpolate
  27944. * @returns Interpolated Vector2 value
  27945. */
  27946. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  27947. /**
  27948. * Interpolates a Vector2 cubically
  27949. * @param startValue Start value of the animation curve
  27950. * @param outTangent End tangent of the animation
  27951. * @param endValue End value of the animation curve
  27952. * @param inTangent Start tangent of the animation curve
  27953. * @param gradient Scalar amount to interpolate
  27954. * @returns Interpolated Vector2 value
  27955. */
  27956. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  27957. /**
  27958. * Interpolates a size linearly
  27959. * @param startValue Start value of the animation curve
  27960. * @param endValue End value of the animation curve
  27961. * @param gradient Scalar amount to interpolate
  27962. * @returns Interpolated Size value
  27963. */
  27964. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  27965. /**
  27966. * Interpolates a Color3 linearly
  27967. * @param startValue Start value of the animation curve
  27968. * @param endValue End value of the animation curve
  27969. * @param gradient Scalar amount to interpolate
  27970. * @returns Interpolated Color3 value
  27971. */
  27972. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  27973. /**
  27974. * @hidden Internal use only
  27975. */
  27976. _getKeyValue(value: any): any;
  27977. /**
  27978. * @hidden Internal use only
  27979. */
  27980. _interpolate(currentFrame: number, state: _IAnimationState): any;
  27981. /**
  27982. * Defines the function to use to interpolate matrices
  27983. * @param startValue defines the start matrix
  27984. * @param endValue defines the end matrix
  27985. * @param gradient defines the gradient between both matrices
  27986. * @param result defines an optional target matrix where to store the interpolation
  27987. * @returns the interpolated matrix
  27988. */
  27989. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  27990. /**
  27991. * Makes a copy of the animation
  27992. * @returns Cloned animation
  27993. */
  27994. clone(): Animation;
  27995. /**
  27996. * Sets the key frames of the animation
  27997. * @param values The animation key frames to set
  27998. */
  27999. setKeys(values: Array<IAnimationKey>): void;
  28000. /**
  28001. * Serializes the animation to an object
  28002. * @returns Serialized object
  28003. */
  28004. serialize(): any;
  28005. /**
  28006. * Float animation type
  28007. */
  28008. private static _ANIMATIONTYPE_FLOAT;
  28009. /**
  28010. * Vector3 animation type
  28011. */
  28012. private static _ANIMATIONTYPE_VECTOR3;
  28013. /**
  28014. * Quaternion animation type
  28015. */
  28016. private static _ANIMATIONTYPE_QUATERNION;
  28017. /**
  28018. * Matrix animation type
  28019. */
  28020. private static _ANIMATIONTYPE_MATRIX;
  28021. /**
  28022. * Color3 animation type
  28023. */
  28024. private static _ANIMATIONTYPE_COLOR3;
  28025. /**
  28026. * Vector2 animation type
  28027. */
  28028. private static _ANIMATIONTYPE_VECTOR2;
  28029. /**
  28030. * Size animation type
  28031. */
  28032. private static _ANIMATIONTYPE_SIZE;
  28033. /**
  28034. * Relative Loop Mode
  28035. */
  28036. private static _ANIMATIONLOOPMODE_RELATIVE;
  28037. /**
  28038. * Cycle Loop Mode
  28039. */
  28040. private static _ANIMATIONLOOPMODE_CYCLE;
  28041. /**
  28042. * Constant Loop Mode
  28043. */
  28044. private static _ANIMATIONLOOPMODE_CONSTANT;
  28045. /**
  28046. * Get the float animation type
  28047. */
  28048. static readonly ANIMATIONTYPE_FLOAT: number;
  28049. /**
  28050. * Get the Vector3 animation type
  28051. */
  28052. static readonly ANIMATIONTYPE_VECTOR3: number;
  28053. /**
  28054. * Get the Vector2 animation type
  28055. */
  28056. static readonly ANIMATIONTYPE_VECTOR2: number;
  28057. /**
  28058. * Get the Size animation type
  28059. */
  28060. static readonly ANIMATIONTYPE_SIZE: number;
  28061. /**
  28062. * Get the Quaternion animation type
  28063. */
  28064. static readonly ANIMATIONTYPE_QUATERNION: number;
  28065. /**
  28066. * Get the Matrix animation type
  28067. */
  28068. static readonly ANIMATIONTYPE_MATRIX: number;
  28069. /**
  28070. * Get the Color3 animation type
  28071. */
  28072. static readonly ANIMATIONTYPE_COLOR3: number;
  28073. /**
  28074. * Get the Relative Loop Mode
  28075. */
  28076. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28077. /**
  28078. * Get the Cycle Loop Mode
  28079. */
  28080. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28081. /**
  28082. * Get the Constant Loop Mode
  28083. */
  28084. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28085. /** @hidden */
  28086. static _UniversalLerp(left: any, right: any, amount: number): any;
  28087. /**
  28088. * Parses an animation object and creates an animation
  28089. * @param parsedAnimation Parsed animation object
  28090. * @returns Animation object
  28091. */
  28092. static Parse(parsedAnimation: any): Animation;
  28093. /**
  28094. * Appends the serialized animations from the source animations
  28095. * @param source Source containing the animations
  28096. * @param destination Target to store the animations
  28097. */
  28098. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28099. }
  28100. }
  28101. declare module "babylonjs/Animations/animatable.interface" {
  28102. import { Nullable } from "babylonjs/types";
  28103. import { Animation } from "babylonjs/Animations/animation";
  28104. /**
  28105. * Interface containing an array of animations
  28106. */
  28107. export interface IAnimatable {
  28108. /**
  28109. * Array of animations
  28110. */
  28111. animations: Nullable<Array<Animation>>;
  28112. }
  28113. }
  28114. declare module "babylonjs/Materials/fresnelParameters" {
  28115. import { Color3 } from "babylonjs/Maths/math.color";
  28116. /**
  28117. * This represents all the required information to add a fresnel effect on a material:
  28118. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28119. */
  28120. export class FresnelParameters {
  28121. private _isEnabled;
  28122. /**
  28123. * Define if the fresnel effect is enable or not.
  28124. */
  28125. isEnabled: boolean;
  28126. /**
  28127. * Define the color used on edges (grazing angle)
  28128. */
  28129. leftColor: Color3;
  28130. /**
  28131. * Define the color used on center
  28132. */
  28133. rightColor: Color3;
  28134. /**
  28135. * Define bias applied to computed fresnel term
  28136. */
  28137. bias: number;
  28138. /**
  28139. * Defined the power exponent applied to fresnel term
  28140. */
  28141. power: number;
  28142. /**
  28143. * Clones the current fresnel and its valuues
  28144. * @returns a clone fresnel configuration
  28145. */
  28146. clone(): FresnelParameters;
  28147. /**
  28148. * Serializes the current fresnel parameters to a JSON representation.
  28149. * @return the JSON serialization
  28150. */
  28151. serialize(): any;
  28152. /**
  28153. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28154. * @param parsedFresnelParameters Define the JSON representation
  28155. * @returns the parsed parameters
  28156. */
  28157. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28158. }
  28159. }
  28160. declare module "babylonjs/Misc/decorators" {
  28161. import { Nullable } from "babylonjs/types";
  28162. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28163. import { Scene } from "babylonjs/scene";
  28164. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28165. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28166. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28167. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28168. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28169. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28170. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28171. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28172. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28173. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28174. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28175. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28176. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28177. /**
  28178. * Decorator used to define property that can be serialized as reference to a camera
  28179. * @param sourceName defines the name of the property to decorate
  28180. */
  28181. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28182. /**
  28183. * Class used to help serialization objects
  28184. */
  28185. export class SerializationHelper {
  28186. /** @hidden */
  28187. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28188. /** @hidden */
  28189. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28190. /** @hidden */
  28191. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28192. /** @hidden */
  28193. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28194. /**
  28195. * Appends the serialized animations from the source animations
  28196. * @param source Source containing the animations
  28197. * @param destination Target to store the animations
  28198. */
  28199. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28200. /**
  28201. * Static function used to serialized a specific entity
  28202. * @param entity defines the entity to serialize
  28203. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28204. * @returns a JSON compatible object representing the serialization of the entity
  28205. */
  28206. static Serialize<T>(entity: T, serializationObject?: any): any;
  28207. /**
  28208. * Creates a new entity from a serialization data object
  28209. * @param creationFunction defines a function used to instanciated the new entity
  28210. * @param source defines the source serialization data
  28211. * @param scene defines the hosting scene
  28212. * @param rootUrl defines the root url for resources
  28213. * @returns a new entity
  28214. */
  28215. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28216. /**
  28217. * Clones an object
  28218. * @param creationFunction defines the function used to instanciate the new object
  28219. * @param source defines the source object
  28220. * @returns the cloned object
  28221. */
  28222. static Clone<T>(creationFunction: () => T, source: T): T;
  28223. /**
  28224. * Instanciates a new object based on a source one (some data will be shared between both object)
  28225. * @param creationFunction defines the function used to instanciate the new object
  28226. * @param source defines the source object
  28227. * @returns the new object
  28228. */
  28229. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28230. }
  28231. }
  28232. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  28233. import { Nullable } from "babylonjs/types";
  28234. /**
  28235. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  28236. */
  28237. export interface CubeMapInfo {
  28238. /**
  28239. * The pixel array for the front face.
  28240. * This is stored in format, left to right, up to down format.
  28241. */
  28242. front: Nullable<ArrayBufferView>;
  28243. /**
  28244. * The pixel array for the back face.
  28245. * This is stored in format, left to right, up to down format.
  28246. */
  28247. back: Nullable<ArrayBufferView>;
  28248. /**
  28249. * The pixel array for the left face.
  28250. * This is stored in format, left to right, up to down format.
  28251. */
  28252. left: Nullable<ArrayBufferView>;
  28253. /**
  28254. * The pixel array for the right face.
  28255. * This is stored in format, left to right, up to down format.
  28256. */
  28257. right: Nullable<ArrayBufferView>;
  28258. /**
  28259. * The pixel array for the up face.
  28260. * This is stored in format, left to right, up to down format.
  28261. */
  28262. up: Nullable<ArrayBufferView>;
  28263. /**
  28264. * The pixel array for the down face.
  28265. * This is stored in format, left to right, up to down format.
  28266. */
  28267. down: Nullable<ArrayBufferView>;
  28268. /**
  28269. * The size of the cubemap stored.
  28270. *
  28271. * Each faces will be size * size pixels.
  28272. */
  28273. size: number;
  28274. /**
  28275. * The format of the texture.
  28276. *
  28277. * RGBA, RGB.
  28278. */
  28279. format: number;
  28280. /**
  28281. * The type of the texture data.
  28282. *
  28283. * UNSIGNED_INT, FLOAT.
  28284. */
  28285. type: number;
  28286. /**
  28287. * Specifies whether the texture is in gamma space.
  28288. */
  28289. gammaSpace: boolean;
  28290. }
  28291. /**
  28292. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  28293. */
  28294. export class PanoramaToCubeMapTools {
  28295. private static FACE_FRONT;
  28296. private static FACE_BACK;
  28297. private static FACE_RIGHT;
  28298. private static FACE_LEFT;
  28299. private static FACE_DOWN;
  28300. private static FACE_UP;
  28301. /**
  28302. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  28303. *
  28304. * @param float32Array The source data.
  28305. * @param inputWidth The width of the input panorama.
  28306. * @param inputHeight The height of the input panorama.
  28307. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  28308. * @return The cubemap data
  28309. */
  28310. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  28311. private static CreateCubemapTexture;
  28312. private static CalcProjectionSpherical;
  28313. }
  28314. }
  28315. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  28316. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28317. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28318. import { Nullable } from "babylonjs/types";
  28319. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  28320. /**
  28321. * Helper class dealing with the extraction of spherical polynomial dataArray
  28322. * from a cube map.
  28323. */
  28324. export class CubeMapToSphericalPolynomialTools {
  28325. private static FileFaces;
  28326. /**
  28327. * Converts a texture to the according Spherical Polynomial data.
  28328. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28329. *
  28330. * @param texture The texture to extract the information from.
  28331. * @return The Spherical Polynomial data.
  28332. */
  28333. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  28334. /**
  28335. * Converts a cubemap to the according Spherical Polynomial data.
  28336. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28337. *
  28338. * @param cubeInfo The Cube map to extract the information from.
  28339. * @return The Spherical Polynomial data.
  28340. */
  28341. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  28342. }
  28343. }
  28344. declare module "babylonjs/Misc/guid" {
  28345. /**
  28346. * Class used to manipulate GUIDs
  28347. */
  28348. export class GUID {
  28349. /**
  28350. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28351. * Be aware Math.random() could cause collisions, but:
  28352. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  28353. * @returns a pseudo random id
  28354. */
  28355. static RandomId(): string;
  28356. }
  28357. }
  28358. declare module "babylonjs/Materials/Textures/baseTexture" {
  28359. import { Observable } from "babylonjs/Misc/observable";
  28360. import { Nullable } from "babylonjs/types";
  28361. import { Scene } from "babylonjs/scene";
  28362. import { Matrix } from "babylonjs/Maths/math.vector";
  28363. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28364. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28365. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28366. import { ISize } from "babylonjs/Maths/math.size";
  28367. /**
  28368. * Base class of all the textures in babylon.
  28369. * It groups all the common properties the materials, post process, lights... might need
  28370. * in order to make a correct use of the texture.
  28371. */
  28372. export class BaseTexture implements IAnimatable {
  28373. /**
  28374. * Default anisotropic filtering level for the application.
  28375. * It is set to 4 as a good tradeoff between perf and quality.
  28376. */
  28377. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28378. /**
  28379. * Gets or sets the unique id of the texture
  28380. */
  28381. uniqueId: number;
  28382. /**
  28383. * Define the name of the texture.
  28384. */
  28385. name: string;
  28386. /**
  28387. * Gets or sets an object used to store user defined information.
  28388. */
  28389. metadata: any;
  28390. /**
  28391. * For internal use only. Please do not use.
  28392. */
  28393. reservedDataStore: any;
  28394. private _hasAlpha;
  28395. /**
  28396. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28397. */
  28398. hasAlpha: boolean;
  28399. /**
  28400. * Defines if the alpha value should be determined via the rgb values.
  28401. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28402. */
  28403. getAlphaFromRGB: boolean;
  28404. /**
  28405. * Intensity or strength of the texture.
  28406. * It is commonly used by materials to fine tune the intensity of the texture
  28407. */
  28408. level: number;
  28409. /**
  28410. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28411. * This is part of the texture as textures usually maps to one uv set.
  28412. */
  28413. coordinatesIndex: number;
  28414. private _coordinatesMode;
  28415. /**
  28416. * How a texture is mapped.
  28417. *
  28418. * | Value | Type | Description |
  28419. * | ----- | ----------------------------------- | ----------- |
  28420. * | 0 | EXPLICIT_MODE | |
  28421. * | 1 | SPHERICAL_MODE | |
  28422. * | 2 | PLANAR_MODE | |
  28423. * | 3 | CUBIC_MODE | |
  28424. * | 4 | PROJECTION_MODE | |
  28425. * | 5 | SKYBOX_MODE | |
  28426. * | 6 | INVCUBIC_MODE | |
  28427. * | 7 | EQUIRECTANGULAR_MODE | |
  28428. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28429. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28430. */
  28431. coordinatesMode: number;
  28432. /**
  28433. * | Value | Type | Description |
  28434. * | ----- | ------------------ | ----------- |
  28435. * | 0 | CLAMP_ADDRESSMODE | |
  28436. * | 1 | WRAP_ADDRESSMODE | |
  28437. * | 2 | MIRROR_ADDRESSMODE | |
  28438. */
  28439. wrapU: number;
  28440. /**
  28441. * | Value | Type | Description |
  28442. * | ----- | ------------------ | ----------- |
  28443. * | 0 | CLAMP_ADDRESSMODE | |
  28444. * | 1 | WRAP_ADDRESSMODE | |
  28445. * | 2 | MIRROR_ADDRESSMODE | |
  28446. */
  28447. wrapV: number;
  28448. /**
  28449. * | Value | Type | Description |
  28450. * | ----- | ------------------ | ----------- |
  28451. * | 0 | CLAMP_ADDRESSMODE | |
  28452. * | 1 | WRAP_ADDRESSMODE | |
  28453. * | 2 | MIRROR_ADDRESSMODE | |
  28454. */
  28455. wrapR: number;
  28456. /**
  28457. * With compliant hardware and browser (supporting anisotropic filtering)
  28458. * this defines the level of anisotropic filtering in the texture.
  28459. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  28460. */
  28461. anisotropicFilteringLevel: number;
  28462. /**
  28463. * Define if the texture is a cube texture or if false a 2d texture.
  28464. */
  28465. isCube: boolean;
  28466. /**
  28467. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  28468. */
  28469. is3D: boolean;
  28470. /**
  28471. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  28472. * HDR texture are usually stored in linear space.
  28473. * This only impacts the PBR and Background materials
  28474. */
  28475. gammaSpace: boolean;
  28476. /**
  28477. * Gets whether or not the texture contains RGBD data.
  28478. */
  28479. readonly isRGBD: boolean;
  28480. /**
  28481. * Is Z inverted in the texture (useful in a cube texture).
  28482. */
  28483. invertZ: boolean;
  28484. /**
  28485. * Are mip maps generated for this texture or not.
  28486. */
  28487. readonly noMipmap: boolean;
  28488. /**
  28489. * @hidden
  28490. */
  28491. lodLevelInAlpha: boolean;
  28492. /**
  28493. * With prefiltered texture, defined the offset used during the prefiltering steps.
  28494. */
  28495. lodGenerationOffset: number;
  28496. /**
  28497. * With prefiltered texture, defined the scale used during the prefiltering steps.
  28498. */
  28499. lodGenerationScale: number;
  28500. /**
  28501. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  28502. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  28503. * average roughness values.
  28504. */
  28505. linearSpecularLOD: boolean;
  28506. /**
  28507. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  28508. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  28509. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  28510. */
  28511. irradianceTexture: Nullable<BaseTexture>;
  28512. /**
  28513. * Define if the texture is a render target.
  28514. */
  28515. isRenderTarget: boolean;
  28516. /**
  28517. * Define the unique id of the texture in the scene.
  28518. */
  28519. readonly uid: string;
  28520. /**
  28521. * Return a string representation of the texture.
  28522. * @returns the texture as a string
  28523. */
  28524. toString(): string;
  28525. /**
  28526. * Get the class name of the texture.
  28527. * @returns "BaseTexture"
  28528. */
  28529. getClassName(): string;
  28530. /**
  28531. * Define the list of animation attached to the texture.
  28532. */
  28533. animations: import("babylonjs/Animations/animation").Animation[];
  28534. /**
  28535. * An event triggered when the texture is disposed.
  28536. */
  28537. onDisposeObservable: Observable<BaseTexture>;
  28538. private _onDisposeObserver;
  28539. /**
  28540. * Callback triggered when the texture has been disposed.
  28541. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28542. */
  28543. onDispose: () => void;
  28544. /**
  28545. * Define the current state of the loading sequence when in delayed load mode.
  28546. */
  28547. delayLoadState: number;
  28548. private _scene;
  28549. /** @hidden */
  28550. _texture: Nullable<InternalTexture>;
  28551. private _uid;
  28552. /**
  28553. * Define if the texture is preventinga material to render or not.
  28554. * If not and the texture is not ready, the engine will use a default black texture instead.
  28555. */
  28556. readonly isBlocking: boolean;
  28557. /**
  28558. * Instantiates a new BaseTexture.
  28559. * Base class of all the textures in babylon.
  28560. * It groups all the common properties the materials, post process, lights... might need
  28561. * in order to make a correct use of the texture.
  28562. * @param scene Define the scene the texture blongs to
  28563. */
  28564. constructor(scene: Nullable<Scene>);
  28565. /**
  28566. * Get the scene the texture belongs to.
  28567. * @returns the scene or null if undefined
  28568. */
  28569. getScene(): Nullable<Scene>;
  28570. /**
  28571. * Get the texture transform matrix used to offset tile the texture for istance.
  28572. * @returns the transformation matrix
  28573. */
  28574. getTextureMatrix(): Matrix;
  28575. /**
  28576. * Get the texture reflection matrix used to rotate/transform the reflection.
  28577. * @returns the reflection matrix
  28578. */
  28579. getReflectionTextureMatrix(): Matrix;
  28580. /**
  28581. * Get the underlying lower level texture from Babylon.
  28582. * @returns the insternal texture
  28583. */
  28584. getInternalTexture(): Nullable<InternalTexture>;
  28585. /**
  28586. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28587. * @returns true if ready or not blocking
  28588. */
  28589. isReadyOrNotBlocking(): boolean;
  28590. /**
  28591. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28592. * @returns true if fully ready
  28593. */
  28594. isReady(): boolean;
  28595. private _cachedSize;
  28596. /**
  28597. * Get the size of the texture.
  28598. * @returns the texture size.
  28599. */
  28600. getSize(): ISize;
  28601. /**
  28602. * Get the base size of the texture.
  28603. * It can be different from the size if the texture has been resized for POT for instance
  28604. * @returns the base size
  28605. */
  28606. getBaseSize(): ISize;
  28607. /**
  28608. * Update the sampling mode of the texture.
  28609. * Default is Trilinear mode.
  28610. *
  28611. * | Value | Type | Description |
  28612. * | ----- | ------------------ | ----------- |
  28613. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28614. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28615. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28616. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28617. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28618. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28619. * | 7 | NEAREST_LINEAR | |
  28620. * | 8 | NEAREST_NEAREST | |
  28621. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28622. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28623. * | 11 | LINEAR_LINEAR | |
  28624. * | 12 | LINEAR_NEAREST | |
  28625. *
  28626. * > _mag_: magnification filter (close to the viewer)
  28627. * > _min_: minification filter (far from the viewer)
  28628. * > _mip_: filter used between mip map levels
  28629. *@param samplingMode Define the new sampling mode of the texture
  28630. */
  28631. updateSamplingMode(samplingMode: number): void;
  28632. /**
  28633. * Scales the texture if is `canRescale()`
  28634. * @param ratio the resize factor we want to use to rescale
  28635. */
  28636. scale(ratio: number): void;
  28637. /**
  28638. * Get if the texture can rescale.
  28639. */
  28640. readonly canRescale: boolean;
  28641. /** @hidden */
  28642. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28643. /** @hidden */
  28644. _rebuild(): void;
  28645. /**
  28646. * Triggers the load sequence in delayed load mode.
  28647. */
  28648. delayLoad(): void;
  28649. /**
  28650. * Clones the texture.
  28651. * @returns the cloned texture
  28652. */
  28653. clone(): Nullable<BaseTexture>;
  28654. /**
  28655. * Get the texture underlying type (INT, FLOAT...)
  28656. */
  28657. readonly textureType: number;
  28658. /**
  28659. * Get the texture underlying format (RGB, RGBA...)
  28660. */
  28661. readonly textureFormat: number;
  28662. /**
  28663. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28664. * This will returns an RGBA array buffer containing either in values (0-255) or
  28665. * float values (0-1) depending of the underlying buffer type.
  28666. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28667. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28668. * @param buffer defines a user defined buffer to fill with data (can be null)
  28669. * @returns The Array buffer containing the pixels data.
  28670. */
  28671. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28672. /**
  28673. * Release and destroy the underlying lower level texture aka internalTexture.
  28674. */
  28675. releaseInternalTexture(): void;
  28676. /**
  28677. * Get the polynomial representation of the texture data.
  28678. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  28679. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  28680. */
  28681. sphericalPolynomial: Nullable<SphericalPolynomial>;
  28682. /** @hidden */
  28683. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28684. /** @hidden */
  28685. readonly _lodTextureMid: Nullable<BaseTexture>;
  28686. /** @hidden */
  28687. readonly _lodTextureLow: Nullable<BaseTexture>;
  28688. /**
  28689. * Dispose the texture and release its associated resources.
  28690. */
  28691. dispose(): void;
  28692. /**
  28693. * Serialize the texture into a JSON representation that can be parsed later on.
  28694. * @returns the JSON representation of the texture
  28695. */
  28696. serialize(): any;
  28697. /**
  28698. * Helper function to be called back once a list of texture contains only ready textures.
  28699. * @param textures Define the list of textures to wait for
  28700. * @param callback Define the callback triggered once the entire list will be ready
  28701. */
  28702. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28703. }
  28704. }
  28705. declare module "babylonjs/Materials/Textures/internalTexture" {
  28706. import { Observable } from "babylonjs/Misc/observable";
  28707. import { Nullable, int } from "babylonjs/types";
  28708. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28709. import { Engine } from "babylonjs/Engines/engine";
  28710. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28711. /**
  28712. * Class used to store data associated with WebGL texture data for the engine
  28713. * This class should not be used directly
  28714. */
  28715. export class InternalTexture {
  28716. /** @hidden */
  28717. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  28718. /**
  28719. * The source of the texture data is unknown
  28720. */
  28721. static DATASOURCE_UNKNOWN: number;
  28722. /**
  28723. * Texture data comes from an URL
  28724. */
  28725. static DATASOURCE_URL: number;
  28726. /**
  28727. * Texture data is only used for temporary storage
  28728. */
  28729. static DATASOURCE_TEMP: number;
  28730. /**
  28731. * Texture data comes from raw data (ArrayBuffer)
  28732. */
  28733. static DATASOURCE_RAW: number;
  28734. /**
  28735. * Texture content is dynamic (video or dynamic texture)
  28736. */
  28737. static DATASOURCE_DYNAMIC: number;
  28738. /**
  28739. * Texture content is generated by rendering to it
  28740. */
  28741. static DATASOURCE_RENDERTARGET: number;
  28742. /**
  28743. * Texture content is part of a multi render target process
  28744. */
  28745. static DATASOURCE_MULTIRENDERTARGET: number;
  28746. /**
  28747. * Texture data comes from a cube data file
  28748. */
  28749. static DATASOURCE_CUBE: number;
  28750. /**
  28751. * Texture data comes from a raw cube data
  28752. */
  28753. static DATASOURCE_CUBERAW: number;
  28754. /**
  28755. * Texture data come from a prefiltered cube data file
  28756. */
  28757. static DATASOURCE_CUBEPREFILTERED: number;
  28758. /**
  28759. * Texture content is raw 3D data
  28760. */
  28761. static DATASOURCE_RAW3D: number;
  28762. /**
  28763. * Texture content is a depth texture
  28764. */
  28765. static DATASOURCE_DEPTHTEXTURE: number;
  28766. /**
  28767. * Texture data comes from a raw cube data encoded with RGBD
  28768. */
  28769. static DATASOURCE_CUBERAW_RGBD: number;
  28770. /**
  28771. * Defines if the texture is ready
  28772. */
  28773. isReady: boolean;
  28774. /**
  28775. * Defines if the texture is a cube texture
  28776. */
  28777. isCube: boolean;
  28778. /**
  28779. * Defines if the texture contains 3D data
  28780. */
  28781. is3D: boolean;
  28782. /**
  28783. * Defines if the texture contains multiview data
  28784. */
  28785. isMultiview: boolean;
  28786. /**
  28787. * Gets the URL used to load this texture
  28788. */
  28789. url: string;
  28790. /**
  28791. * Gets the sampling mode of the texture
  28792. */
  28793. samplingMode: number;
  28794. /**
  28795. * Gets a boolean indicating if the texture needs mipmaps generation
  28796. */
  28797. generateMipMaps: boolean;
  28798. /**
  28799. * Gets the number of samples used by the texture (WebGL2+ only)
  28800. */
  28801. samples: number;
  28802. /**
  28803. * Gets the type of the texture (int, float...)
  28804. */
  28805. type: number;
  28806. /**
  28807. * Gets the format of the texture (RGB, RGBA...)
  28808. */
  28809. format: number;
  28810. /**
  28811. * Observable called when the texture is loaded
  28812. */
  28813. onLoadedObservable: Observable<InternalTexture>;
  28814. /**
  28815. * Gets the width of the texture
  28816. */
  28817. width: number;
  28818. /**
  28819. * Gets the height of the texture
  28820. */
  28821. height: number;
  28822. /**
  28823. * Gets the depth of the texture
  28824. */
  28825. depth: number;
  28826. /**
  28827. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  28828. */
  28829. baseWidth: number;
  28830. /**
  28831. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  28832. */
  28833. baseHeight: number;
  28834. /**
  28835. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  28836. */
  28837. baseDepth: number;
  28838. /**
  28839. * Gets a boolean indicating if the texture is inverted on Y axis
  28840. */
  28841. invertY: boolean;
  28842. /** @hidden */
  28843. _invertVScale: boolean;
  28844. /** @hidden */
  28845. _associatedChannel: number;
  28846. /** @hidden */
  28847. _dataSource: number;
  28848. /** @hidden */
  28849. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  28850. /** @hidden */
  28851. _bufferView: Nullable<ArrayBufferView>;
  28852. /** @hidden */
  28853. _bufferViewArray: Nullable<ArrayBufferView[]>;
  28854. /** @hidden */
  28855. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  28856. /** @hidden */
  28857. _size: number;
  28858. /** @hidden */
  28859. _extension: string;
  28860. /** @hidden */
  28861. _files: Nullable<string[]>;
  28862. /** @hidden */
  28863. _workingCanvas: Nullable<HTMLCanvasElement>;
  28864. /** @hidden */
  28865. _workingContext: Nullable<CanvasRenderingContext2D>;
  28866. /** @hidden */
  28867. _framebuffer: Nullable<WebGLFramebuffer>;
  28868. /** @hidden */
  28869. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  28870. /** @hidden */
  28871. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  28872. /** @hidden */
  28873. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  28874. /** @hidden */
  28875. _attachments: Nullable<number[]>;
  28876. /** @hidden */
  28877. _cachedCoordinatesMode: Nullable<number>;
  28878. /** @hidden */
  28879. _cachedWrapU: Nullable<number>;
  28880. /** @hidden */
  28881. _cachedWrapV: Nullable<number>;
  28882. /** @hidden */
  28883. _cachedWrapR: Nullable<number>;
  28884. /** @hidden */
  28885. _cachedAnisotropicFilteringLevel: Nullable<number>;
  28886. /** @hidden */
  28887. _isDisabled: boolean;
  28888. /** @hidden */
  28889. _compression: Nullable<string>;
  28890. /** @hidden */
  28891. _generateStencilBuffer: boolean;
  28892. /** @hidden */
  28893. _generateDepthBuffer: boolean;
  28894. /** @hidden */
  28895. _comparisonFunction: number;
  28896. /** @hidden */
  28897. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  28898. /** @hidden */
  28899. _lodGenerationScale: number;
  28900. /** @hidden */
  28901. _lodGenerationOffset: number;
  28902. /** @hidden */
  28903. _colorTextureArray: Nullable<WebGLTexture>;
  28904. /** @hidden */
  28905. _depthStencilTextureArray: Nullable<WebGLTexture>;
  28906. /** @hidden */
  28907. _lodTextureHigh: Nullable<BaseTexture>;
  28908. /** @hidden */
  28909. _lodTextureMid: Nullable<BaseTexture>;
  28910. /** @hidden */
  28911. _lodTextureLow: Nullable<BaseTexture>;
  28912. /** @hidden */
  28913. _isRGBD: boolean;
  28914. /** @hidden */
  28915. _linearSpecularLOD: boolean;
  28916. /** @hidden */
  28917. _irradianceTexture: Nullable<BaseTexture>;
  28918. /** @hidden */
  28919. _webGLTexture: Nullable<WebGLTexture>;
  28920. /** @hidden */
  28921. _references: number;
  28922. private _engine;
  28923. /**
  28924. * Gets the Engine the texture belongs to.
  28925. * @returns The babylon engine
  28926. */
  28927. getEngine(): Engine;
  28928. /**
  28929. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  28930. */
  28931. readonly dataSource: number;
  28932. /**
  28933. * Creates a new InternalTexture
  28934. * @param engine defines the engine to use
  28935. * @param dataSource defines the type of data that will be used
  28936. * @param delayAllocation if the texture allocation should be delayed (default: false)
  28937. */
  28938. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  28939. /**
  28940. * Increments the number of references (ie. the number of Texture that point to it)
  28941. */
  28942. incrementReferences(): void;
  28943. /**
  28944. * Change the size of the texture (not the size of the content)
  28945. * @param width defines the new width
  28946. * @param height defines the new height
  28947. * @param depth defines the new depth (1 by default)
  28948. */
  28949. updateSize(width: int, height: int, depth?: int): void;
  28950. /** @hidden */
  28951. _rebuild(): void;
  28952. /** @hidden */
  28953. _swapAndDie(target: InternalTexture): void;
  28954. /**
  28955. * Dispose the current allocated resources
  28956. */
  28957. dispose(): void;
  28958. }
  28959. }
  28960. declare module "babylonjs/Materials/effect" {
  28961. import { Observable } from "babylonjs/Misc/observable";
  28962. import { Nullable } from "babylonjs/types";
  28963. import { IDisposable } from "babylonjs/scene";
  28964. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  28965. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  28966. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  28967. import { Engine } from "babylonjs/Engines/engine";
  28968. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28969. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28970. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28971. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28972. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28973. /**
  28974. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28975. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28976. */
  28977. export class EffectFallbacks {
  28978. private _defines;
  28979. private _currentRank;
  28980. private _maxRank;
  28981. private _mesh;
  28982. /**
  28983. * Removes the fallback from the bound mesh.
  28984. */
  28985. unBindMesh(): void;
  28986. /**
  28987. * Adds a fallback on the specified property.
  28988. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28989. * @param define The name of the define in the shader
  28990. */
  28991. addFallback(rank: number, define: string): void;
  28992. /**
  28993. * Sets the mesh to use CPU skinning when needing to fallback.
  28994. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28995. * @param mesh The mesh to use the fallbacks.
  28996. */
  28997. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28998. /**
  28999. * Checks to see if more fallbacks are still availible.
  29000. */
  29001. readonly hasMoreFallbacks: boolean;
  29002. /**
  29003. * Removes the defines that should be removed when falling back.
  29004. * @param currentDefines defines the current define statements for the shader.
  29005. * @param effect defines the current effect we try to compile
  29006. * @returns The resulting defines with defines of the current rank removed.
  29007. */
  29008. reduce(currentDefines: string, effect: Effect): string;
  29009. }
  29010. /**
  29011. * Options to be used when creating an effect.
  29012. */
  29013. export class EffectCreationOptions {
  29014. /**
  29015. * Atrributes that will be used in the shader.
  29016. */
  29017. attributes: string[];
  29018. /**
  29019. * Uniform varible names that will be set in the shader.
  29020. */
  29021. uniformsNames: string[];
  29022. /**
  29023. * Uniform buffer varible names that will be set in the shader.
  29024. */
  29025. uniformBuffersNames: string[];
  29026. /**
  29027. * Sampler texture variable names that will be set in the shader.
  29028. */
  29029. samplers: string[];
  29030. /**
  29031. * Define statements that will be set in the shader.
  29032. */
  29033. defines: any;
  29034. /**
  29035. * Possible fallbacks for this effect to improve performance when needed.
  29036. */
  29037. fallbacks: Nullable<EffectFallbacks>;
  29038. /**
  29039. * Callback that will be called when the shader is compiled.
  29040. */
  29041. onCompiled: Nullable<(effect: Effect) => void>;
  29042. /**
  29043. * Callback that will be called if an error occurs during shader compilation.
  29044. */
  29045. onError: Nullable<(effect: Effect, errors: string) => void>;
  29046. /**
  29047. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29048. */
  29049. indexParameters: any;
  29050. /**
  29051. * Max number of lights that can be used in the shader.
  29052. */
  29053. maxSimultaneousLights: number;
  29054. /**
  29055. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29056. */
  29057. transformFeedbackVaryings: Nullable<string[]>;
  29058. }
  29059. /**
  29060. * Effect containing vertex and fragment shader that can be executed on an object.
  29061. */
  29062. export class Effect implements IDisposable {
  29063. /**
  29064. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29065. */
  29066. static ShadersRepository: string;
  29067. /**
  29068. * Name of the effect.
  29069. */
  29070. name: any;
  29071. /**
  29072. * String container all the define statements that should be set on the shader.
  29073. */
  29074. defines: string;
  29075. /**
  29076. * Callback that will be called when the shader is compiled.
  29077. */
  29078. onCompiled: Nullable<(effect: Effect) => void>;
  29079. /**
  29080. * Callback that will be called if an error occurs during shader compilation.
  29081. */
  29082. onError: Nullable<(effect: Effect, errors: string) => void>;
  29083. /**
  29084. * Callback that will be called when effect is bound.
  29085. */
  29086. onBind: Nullable<(effect: Effect) => void>;
  29087. /**
  29088. * Unique ID of the effect.
  29089. */
  29090. uniqueId: number;
  29091. /**
  29092. * Observable that will be called when the shader is compiled.
  29093. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29094. */
  29095. onCompileObservable: Observable<Effect>;
  29096. /**
  29097. * Observable that will be called if an error occurs during shader compilation.
  29098. */
  29099. onErrorObservable: Observable<Effect>;
  29100. /** @hidden */
  29101. _onBindObservable: Nullable<Observable<Effect>>;
  29102. /**
  29103. * Observable that will be called when effect is bound.
  29104. */
  29105. readonly onBindObservable: Observable<Effect>;
  29106. /** @hidden */
  29107. _bonesComputationForcedToCPU: boolean;
  29108. private static _uniqueIdSeed;
  29109. private _engine;
  29110. private _uniformBuffersNames;
  29111. private _uniformsNames;
  29112. private _samplerList;
  29113. private _samplers;
  29114. private _isReady;
  29115. private _compilationError;
  29116. private _attributesNames;
  29117. private _attributes;
  29118. private _uniforms;
  29119. /**
  29120. * Key for the effect.
  29121. * @hidden
  29122. */
  29123. _key: string;
  29124. private _indexParameters;
  29125. private _fallbacks;
  29126. private _vertexSourceCode;
  29127. private _fragmentSourceCode;
  29128. private _vertexSourceCodeOverride;
  29129. private _fragmentSourceCodeOverride;
  29130. private _transformFeedbackVaryings;
  29131. /**
  29132. * Compiled shader to webGL program.
  29133. * @hidden
  29134. */
  29135. _pipelineContext: Nullable<IPipelineContext>;
  29136. private _valueCache;
  29137. private static _baseCache;
  29138. /**
  29139. * Instantiates an effect.
  29140. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29141. * @param baseName Name of the effect.
  29142. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29143. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29144. * @param samplers List of sampler variables that will be passed to the shader.
  29145. * @param engine Engine to be used to render the effect
  29146. * @param defines Define statements to be added to the shader.
  29147. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29148. * @param onCompiled Callback that will be called when the shader is compiled.
  29149. * @param onError Callback that will be called if an error occurs during shader compilation.
  29150. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29151. */
  29152. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable<string[]>, engine?: Engine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  29153. private _useFinalCode;
  29154. /**
  29155. * Unique key for this effect
  29156. */
  29157. readonly key: string;
  29158. /**
  29159. * If the effect has been compiled and prepared.
  29160. * @returns if the effect is compiled and prepared.
  29161. */
  29162. isReady(): boolean;
  29163. private _isReadyInternal;
  29164. /**
  29165. * The engine the effect was initialized with.
  29166. * @returns the engine.
  29167. */
  29168. getEngine(): Engine;
  29169. /**
  29170. * The pipeline context for this effect
  29171. * @returns the associated pipeline context
  29172. */
  29173. getPipelineContext(): Nullable<IPipelineContext>;
  29174. /**
  29175. * The set of names of attribute variables for the shader.
  29176. * @returns An array of attribute names.
  29177. */
  29178. getAttributesNames(): string[];
  29179. /**
  29180. * Returns the attribute at the given index.
  29181. * @param index The index of the attribute.
  29182. * @returns The location of the attribute.
  29183. */
  29184. getAttributeLocation(index: number): number;
  29185. /**
  29186. * Returns the attribute based on the name of the variable.
  29187. * @param name of the attribute to look up.
  29188. * @returns the attribute location.
  29189. */
  29190. getAttributeLocationByName(name: string): number;
  29191. /**
  29192. * The number of attributes.
  29193. * @returns the numnber of attributes.
  29194. */
  29195. getAttributesCount(): number;
  29196. /**
  29197. * Gets the index of a uniform variable.
  29198. * @param uniformName of the uniform to look up.
  29199. * @returns the index.
  29200. */
  29201. getUniformIndex(uniformName: string): number;
  29202. /**
  29203. * Returns the attribute based on the name of the variable.
  29204. * @param uniformName of the uniform to look up.
  29205. * @returns the location of the uniform.
  29206. */
  29207. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29208. /**
  29209. * Returns an array of sampler variable names
  29210. * @returns The array of sampler variable neames.
  29211. */
  29212. getSamplers(): string[];
  29213. /**
  29214. * The error from the last compilation.
  29215. * @returns the error string.
  29216. */
  29217. getCompilationError(): string;
  29218. /**
  29219. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29220. * @param func The callback to be used.
  29221. */
  29222. executeWhenCompiled(func: (effect: Effect) => void): void;
  29223. private _checkIsReady;
  29224. /** @hidden */
  29225. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29226. /** @hidden */
  29227. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29228. /** @hidden */
  29229. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29230. /**
  29231. * Recompiles the webGL program
  29232. * @param vertexSourceCode The source code for the vertex shader.
  29233. * @param fragmentSourceCode The source code for the fragment shader.
  29234. * @param onCompiled Callback called when completed.
  29235. * @param onError Callback called on error.
  29236. * @hidden
  29237. */
  29238. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29239. /**
  29240. * Prepares the effect
  29241. * @hidden
  29242. */
  29243. _prepareEffect(): void;
  29244. private _processCompilationErrors;
  29245. /**
  29246. * Checks if the effect is supported. (Must be called after compilation)
  29247. */
  29248. readonly isSupported: boolean;
  29249. /**
  29250. * Binds a texture to the engine to be used as output of the shader.
  29251. * @param channel Name of the output variable.
  29252. * @param texture Texture to bind.
  29253. * @hidden
  29254. */
  29255. _bindTexture(channel: string, texture: InternalTexture): void;
  29256. /**
  29257. * Sets a texture on the engine to be used in the shader.
  29258. * @param channel Name of the sampler variable.
  29259. * @param texture Texture to set.
  29260. */
  29261. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29262. /**
  29263. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29264. * @param channel Name of the sampler variable.
  29265. * @param texture Texture to set.
  29266. */
  29267. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29268. /**
  29269. * Sets an array of textures on the engine to be used in the shader.
  29270. * @param channel Name of the variable.
  29271. * @param textures Textures to set.
  29272. */
  29273. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29274. /**
  29275. * Sets a texture to be the input of the specified post process. (To use the output, pass in the next post process in the pipeline)
  29276. * @param channel Name of the sampler variable.
  29277. * @param postProcess Post process to get the input texture from.
  29278. */
  29279. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29280. /**
  29281. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29282. * Sets the input texture of the passed in post process to be input of this effect. (To use the output of the passed in post process use setTextureFromPostProcessOutput)
  29283. * @param channel Name of the sampler variable.
  29284. * @param postProcess Post process to get the output texture from.
  29285. */
  29286. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29287. /** @hidden */
  29288. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29289. /** @hidden */
  29290. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29291. /** @hidden */
  29292. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29293. /** @hidden */
  29294. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29295. /**
  29296. * Binds a buffer to a uniform.
  29297. * @param buffer Buffer to bind.
  29298. * @param name Name of the uniform variable to bind to.
  29299. */
  29300. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29301. /**
  29302. * Binds block to a uniform.
  29303. * @param blockName Name of the block to bind.
  29304. * @param index Index to bind.
  29305. */
  29306. bindUniformBlock(blockName: string, index: number): void;
  29307. /**
  29308. * Sets an interger value on a uniform variable.
  29309. * @param uniformName Name of the variable.
  29310. * @param value Value to be set.
  29311. * @returns this effect.
  29312. */
  29313. setInt(uniformName: string, value: number): Effect;
  29314. /**
  29315. * Sets an int array on a uniform variable.
  29316. * @param uniformName Name of the variable.
  29317. * @param array array to be set.
  29318. * @returns this effect.
  29319. */
  29320. setIntArray(uniformName: string, array: Int32Array): Effect;
  29321. /**
  29322. * Sets an int array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  29323. * @param uniformName Name of the variable.
  29324. * @param array array to be set.
  29325. * @returns this effect.
  29326. */
  29327. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29328. /**
  29329. * Sets an int array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  29330. * @param uniformName Name of the variable.
  29331. * @param array array to be set.
  29332. * @returns this effect.
  29333. */
  29334. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29335. /**
  29336. * Sets an int array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  29337. * @param uniformName Name of the variable.
  29338. * @param array array to be set.
  29339. * @returns this effect.
  29340. */
  29341. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29342. /**
  29343. * Sets an float array on a uniform variable.
  29344. * @param uniformName Name of the variable.
  29345. * @param array array to be set.
  29346. * @returns this effect.
  29347. */
  29348. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29349. /**
  29350. * Sets an float array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  29351. * @param uniformName Name of the variable.
  29352. * @param array array to be set.
  29353. * @returns this effect.
  29354. */
  29355. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29356. /**
  29357. * Sets an float array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  29358. * @param uniformName Name of the variable.
  29359. * @param array array to be set.
  29360. * @returns this effect.
  29361. */
  29362. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29363. /**
  29364. * Sets an float array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  29365. * @param uniformName Name of the variable.
  29366. * @param array array to be set.
  29367. * @returns this effect.
  29368. */
  29369. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29370. /**
  29371. * Sets an array on a uniform variable.
  29372. * @param uniformName Name of the variable.
  29373. * @param array array to be set.
  29374. * @returns this effect.
  29375. */
  29376. setArray(uniformName: string, array: number[]): Effect;
  29377. /**
  29378. * Sets an array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  29379. * @param uniformName Name of the variable.
  29380. * @param array array to be set.
  29381. * @returns this effect.
  29382. */
  29383. setArray2(uniformName: string, array: number[]): Effect;
  29384. /**
  29385. * Sets an array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  29386. * @param uniformName Name of the variable.
  29387. * @param array array to be set.
  29388. * @returns this effect.
  29389. */
  29390. setArray3(uniformName: string, array: number[]): Effect;
  29391. /**
  29392. * Sets an array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  29393. * @param uniformName Name of the variable.
  29394. * @param array array to be set.
  29395. * @returns this effect.
  29396. */
  29397. setArray4(uniformName: string, array: number[]): Effect;
  29398. /**
  29399. * Sets matrices on a uniform variable.
  29400. * @param uniformName Name of the variable.
  29401. * @param matrices matrices to be set.
  29402. * @returns this effect.
  29403. */
  29404. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29405. /**
  29406. * Sets matrix on a uniform variable.
  29407. * @param uniformName Name of the variable.
  29408. * @param matrix matrix to be set.
  29409. * @returns this effect.
  29410. */
  29411. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29412. /**
  29413. * Sets a 3x3 matrix on a uniform variable. (Speicified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  29414. * @param uniformName Name of the variable.
  29415. * @param matrix matrix to be set.
  29416. * @returns this effect.
  29417. */
  29418. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29419. /**
  29420. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29421. * @param uniformName Name of the variable.
  29422. * @param matrix matrix to be set.
  29423. * @returns this effect.
  29424. */
  29425. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29426. /**
  29427. * Sets a float on a uniform variable.
  29428. * @param uniformName Name of the variable.
  29429. * @param value value to be set.
  29430. * @returns this effect.
  29431. */
  29432. setFloat(uniformName: string, value: number): Effect;
  29433. /**
  29434. * Sets a boolean on a uniform variable.
  29435. * @param uniformName Name of the variable.
  29436. * @param bool value to be set.
  29437. * @returns this effect.
  29438. */
  29439. setBool(uniformName: string, bool: boolean): Effect;
  29440. /**
  29441. * Sets a Vector2 on a uniform variable.
  29442. * @param uniformName Name of the variable.
  29443. * @param vector2 vector2 to be set.
  29444. * @returns this effect.
  29445. */
  29446. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29447. /**
  29448. * Sets a float2 on a uniform variable.
  29449. * @param uniformName Name of the variable.
  29450. * @param x First float in float2.
  29451. * @param y Second float in float2.
  29452. * @returns this effect.
  29453. */
  29454. setFloat2(uniformName: string, x: number, y: number): Effect;
  29455. /**
  29456. * Sets a Vector3 on a uniform variable.
  29457. * @param uniformName Name of the variable.
  29458. * @param vector3 Value to be set.
  29459. * @returns this effect.
  29460. */
  29461. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29462. /**
  29463. * Sets a float3 on a uniform variable.
  29464. * @param uniformName Name of the variable.
  29465. * @param x First float in float3.
  29466. * @param y Second float in float3.
  29467. * @param z Third float in float3.
  29468. * @returns this effect.
  29469. */
  29470. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29471. /**
  29472. * Sets a Vector4 on a uniform variable.
  29473. * @param uniformName Name of the variable.
  29474. * @param vector4 Value to be set.
  29475. * @returns this effect.
  29476. */
  29477. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29478. /**
  29479. * Sets a float4 on a uniform variable.
  29480. * @param uniformName Name of the variable.
  29481. * @param x First float in float4.
  29482. * @param y Second float in float4.
  29483. * @param z Third float in float4.
  29484. * @param w Fourth float in float4.
  29485. * @returns this effect.
  29486. */
  29487. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29488. /**
  29489. * Sets a Color3 on a uniform variable.
  29490. * @param uniformName Name of the variable.
  29491. * @param color3 Value to be set.
  29492. * @returns this effect.
  29493. */
  29494. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29495. /**
  29496. * Sets a Color4 on a uniform variable.
  29497. * @param uniformName Name of the variable.
  29498. * @param color3 Value to be set.
  29499. * @param alpha Alpha value to be set.
  29500. * @returns this effect.
  29501. */
  29502. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29503. /**
  29504. * Sets a Color4 on a uniform variable
  29505. * @param uniformName defines the name of the variable
  29506. * @param color4 defines the value to be set
  29507. * @returns this effect.
  29508. */
  29509. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29510. /** Release all associated resources */
  29511. dispose(): void;
  29512. /**
  29513. * This function will add a new shader to the shader store
  29514. * @param name the name of the shader
  29515. * @param pixelShader optional pixel shader content
  29516. * @param vertexShader optional vertex shader content
  29517. */
  29518. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29519. /**
  29520. * Store of each shader (The can be looked up using effect.key)
  29521. */
  29522. static ShadersStore: {
  29523. [key: string]: string;
  29524. };
  29525. /**
  29526. * Store of each included file for a shader (The can be looked up using effect.key)
  29527. */
  29528. static IncludesShadersStore: {
  29529. [key: string]: string;
  29530. };
  29531. /**
  29532. * Resets the cache of effects.
  29533. */
  29534. static ResetCache(): void;
  29535. }
  29536. }
  29537. declare module "babylonjs/Materials/uniformBuffer" {
  29538. import { Nullable, FloatArray } from "babylonjs/types";
  29539. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  29540. import { Engine } from "babylonjs/Engines/engine";
  29541. import { Effect } from "babylonjs/Materials/effect";
  29542. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29543. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29544. import { Color3 } from "babylonjs/Maths/math.color";
  29545. /**
  29546. * Uniform buffer objects.
  29547. *
  29548. * Handles blocks of uniform on the GPU.
  29549. *
  29550. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  29551. *
  29552. * For more information, please refer to :
  29553. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  29554. */
  29555. export class UniformBuffer {
  29556. private _engine;
  29557. private _buffer;
  29558. private _data;
  29559. private _bufferData;
  29560. private _dynamic?;
  29561. private _uniformLocations;
  29562. private _uniformSizes;
  29563. private _uniformLocationPointer;
  29564. private _needSync;
  29565. private _noUBO;
  29566. private _currentEffect;
  29567. private static _MAX_UNIFORM_SIZE;
  29568. private static _tempBuffer;
  29569. /**
  29570. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  29571. * This is dynamic to allow compat with webgl 1 and 2.
  29572. * You will need to pass the name of the uniform as well as the value.
  29573. */
  29574. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  29575. /**
  29576. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  29577. * This is dynamic to allow compat with webgl 1 and 2.
  29578. * You will need to pass the name of the uniform as well as the value.
  29579. */
  29580. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  29581. /**
  29582. * Lambda to Update a single float in a uniform buffer.
  29583. * This is dynamic to allow compat with webgl 1 and 2.
  29584. * You will need to pass the name of the uniform as well as the value.
  29585. */
  29586. updateFloat: (name: string, x: number) => void;
  29587. /**
  29588. * Lambda to Update a vec2 of float in a uniform buffer.
  29589. * This is dynamic to allow compat with webgl 1 and 2.
  29590. * You will need to pass the name of the uniform as well as the value.
  29591. */
  29592. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  29593. /**
  29594. * Lambda to Update a vec3 of float in a uniform buffer.
  29595. * This is dynamic to allow compat with webgl 1 and 2.
  29596. * You will need to pass the name of the uniform as well as the value.
  29597. */
  29598. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  29599. /**
  29600. * Lambda to Update a vec4 of float in a uniform buffer.
  29601. * This is dynamic to allow compat with webgl 1 and 2.
  29602. * You will need to pass the name of the uniform as well as the value.
  29603. */
  29604. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  29605. /**
  29606. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  29607. * This is dynamic to allow compat with webgl 1 and 2.
  29608. * You will need to pass the name of the uniform as well as the value.
  29609. */
  29610. updateMatrix: (name: string, mat: Matrix) => void;
  29611. /**
  29612. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  29613. * This is dynamic to allow compat with webgl 1 and 2.
  29614. * You will need to pass the name of the uniform as well as the value.
  29615. */
  29616. updateVector3: (name: string, vector: Vector3) => void;
  29617. /**
  29618. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  29619. * This is dynamic to allow compat with webgl 1 and 2.
  29620. * You will need to pass the name of the uniform as well as the value.
  29621. */
  29622. updateVector4: (name: string, vector: Vector4) => void;
  29623. /**
  29624. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  29625. * This is dynamic to allow compat with webgl 1 and 2.
  29626. * You will need to pass the name of the uniform as well as the value.
  29627. */
  29628. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  29629. /**
  29630. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  29631. * This is dynamic to allow compat with webgl 1 and 2.
  29632. * You will need to pass the name of the uniform as well as the value.
  29633. */
  29634. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  29635. /**
  29636. * Instantiates a new Uniform buffer objects.
  29637. *
  29638. * Handles blocks of uniform on the GPU.
  29639. *
  29640. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  29641. *
  29642. * For more information, please refer to :
  29643. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  29644. * @param engine Define the engine the buffer is associated with
  29645. * @param data Define the data contained in the buffer
  29646. * @param dynamic Define if the buffer is updatable
  29647. */
  29648. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  29649. /**
  29650. * Indicates if the buffer is using the WebGL2 UBO implementation,
  29651. * or just falling back on setUniformXXX calls.
  29652. */
  29653. readonly useUbo: boolean;
  29654. /**
  29655. * Indicates if the WebGL underlying uniform buffer is in sync
  29656. * with the javascript cache data.
  29657. */
  29658. readonly isSync: boolean;
  29659. /**
  29660. * Indicates if the WebGL underlying uniform buffer is dynamic.
  29661. * Also, a dynamic UniformBuffer will disable cache verification and always
  29662. * update the underlying WebGL uniform buffer to the GPU.
  29663. * @returns if Dynamic, otherwise false
  29664. */
  29665. isDynamic(): boolean;
  29666. /**
  29667. * The data cache on JS side.
  29668. * @returns the underlying data as a float array
  29669. */
  29670. getData(): Float32Array;
  29671. /**
  29672. * The underlying WebGL Uniform buffer.
  29673. * @returns the webgl buffer
  29674. */
  29675. getBuffer(): Nullable<DataBuffer>;
  29676. /**
  29677. * std140 layout specifies how to align data within an UBO structure.
  29678. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  29679. * for specs.
  29680. */
  29681. private _fillAlignment;
  29682. /**
  29683. * Adds an uniform in the buffer.
  29684. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  29685. * for the layout to be correct !
  29686. * @param name Name of the uniform, as used in the uniform block in the shader.
  29687. * @param size Data size, or data directly.
  29688. */
  29689. addUniform(name: string, size: number | number[]): void;
  29690. /**
  29691. * Adds a Matrix 4x4 to the uniform buffer.
  29692. * @param name Name of the uniform, as used in the uniform block in the shader.
  29693. * @param mat A 4x4 matrix.
  29694. */
  29695. addMatrix(name: string, mat: Matrix): void;
  29696. /**
  29697. * Adds a vec2 to the uniform buffer.
  29698. * @param name Name of the uniform, as used in the uniform block in the shader.
  29699. * @param x Define the x component value of the vec2
  29700. * @param y Define the y component value of the vec2
  29701. */
  29702. addFloat2(name: string, x: number, y: number): void;
  29703. /**
  29704. * Adds a vec3 to the uniform buffer.
  29705. * @param name Name of the uniform, as used in the uniform block in the shader.
  29706. * @param x Define the x component value of the vec3
  29707. * @param y Define the y component value of the vec3
  29708. * @param z Define the z component value of the vec3
  29709. */
  29710. addFloat3(name: string, x: number, y: number, z: number): void;
  29711. /**
  29712. * Adds a vec3 to the uniform buffer.
  29713. * @param name Name of the uniform, as used in the uniform block in the shader.
  29714. * @param color Define the vec3 from a Color
  29715. */
  29716. addColor3(name: string, color: Color3): void;
  29717. /**
  29718. * Adds a vec4 to the uniform buffer.
  29719. * @param name Name of the uniform, as used in the uniform block in the shader.
  29720. * @param color Define the rgb components from a Color
  29721. * @param alpha Define the a component of the vec4
  29722. */
  29723. addColor4(name: string, color: Color3, alpha: number): void;
  29724. /**
  29725. * Adds a vec3 to the uniform buffer.
  29726. * @param name Name of the uniform, as used in the uniform block in the shader.
  29727. * @param vector Define the vec3 components from a Vector
  29728. */
  29729. addVector3(name: string, vector: Vector3): void;
  29730. /**
  29731. * Adds a Matrix 3x3 to the uniform buffer.
  29732. * @param name Name of the uniform, as used in the uniform block in the shader.
  29733. */
  29734. addMatrix3x3(name: string): void;
  29735. /**
  29736. * Adds a Matrix 2x2 to the uniform buffer.
  29737. * @param name Name of the uniform, as used in the uniform block in the shader.
  29738. */
  29739. addMatrix2x2(name: string): void;
  29740. /**
  29741. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  29742. */
  29743. create(): void;
  29744. /** @hidden */
  29745. _rebuild(): void;
  29746. /**
  29747. * Updates the WebGL Uniform Buffer on the GPU.
  29748. * If the `dynamic` flag is set to true, no cache comparison is done.
  29749. * Otherwise, the buffer will be updated only if the cache differs.
  29750. */
  29751. update(): void;
  29752. /**
  29753. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  29754. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  29755. * @param data Define the flattened data
  29756. * @param size Define the size of the data.
  29757. */
  29758. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  29759. private _valueCache;
  29760. private _cacheMatrix;
  29761. private _updateMatrix3x3ForUniform;
  29762. private _updateMatrix3x3ForEffect;
  29763. private _updateMatrix2x2ForEffect;
  29764. private _updateMatrix2x2ForUniform;
  29765. private _updateFloatForEffect;
  29766. private _updateFloatForUniform;
  29767. private _updateFloat2ForEffect;
  29768. private _updateFloat2ForUniform;
  29769. private _updateFloat3ForEffect;
  29770. private _updateFloat3ForUniform;
  29771. private _updateFloat4ForEffect;
  29772. private _updateFloat4ForUniform;
  29773. private _updateMatrixForEffect;
  29774. private _updateMatrixForUniform;
  29775. private _updateVector3ForEffect;
  29776. private _updateVector3ForUniform;
  29777. private _updateVector4ForEffect;
  29778. private _updateVector4ForUniform;
  29779. private _updateColor3ForEffect;
  29780. private _updateColor3ForUniform;
  29781. private _updateColor4ForEffect;
  29782. private _updateColor4ForUniform;
  29783. /**
  29784. * Sets a sampler uniform on the effect.
  29785. * @param name Define the name of the sampler.
  29786. * @param texture Define the texture to set in the sampler
  29787. */
  29788. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  29789. /**
  29790. * Directly updates the value of the uniform in the cache AND on the GPU.
  29791. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  29792. * @param data Define the flattened data
  29793. */
  29794. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  29795. /**
  29796. * Binds this uniform buffer to an effect.
  29797. * @param effect Define the effect to bind the buffer to
  29798. * @param name Name of the uniform block in the shader.
  29799. */
  29800. bindToEffect(effect: Effect, name: string): void;
  29801. /**
  29802. * Disposes the uniform buffer.
  29803. */
  29804. dispose(): void;
  29805. }
  29806. }
  29807. declare module "babylonjs/Audio/analyser" {
  29808. import { Scene } from "babylonjs/scene";
  29809. /**
  29810. * Class used to work with sound analyzer using fast fourier transform (FFT)
  29811. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29812. */
  29813. export class Analyser {
  29814. /**
  29815. * Gets or sets the smoothing
  29816. * @ignorenaming
  29817. */
  29818. SMOOTHING: number;
  29819. /**
  29820. * Gets or sets the FFT table size
  29821. * @ignorenaming
  29822. */
  29823. FFT_SIZE: number;
  29824. /**
  29825. * Gets or sets the bar graph amplitude
  29826. * @ignorenaming
  29827. */
  29828. BARGRAPHAMPLITUDE: number;
  29829. /**
  29830. * Gets or sets the position of the debug canvas
  29831. * @ignorenaming
  29832. */
  29833. DEBUGCANVASPOS: {
  29834. x: number;
  29835. y: number;
  29836. };
  29837. /**
  29838. * Gets or sets the debug canvas size
  29839. * @ignorenaming
  29840. */
  29841. DEBUGCANVASSIZE: {
  29842. width: number;
  29843. height: number;
  29844. };
  29845. private _byteFreqs;
  29846. private _byteTime;
  29847. private _floatFreqs;
  29848. private _webAudioAnalyser;
  29849. private _debugCanvas;
  29850. private _debugCanvasContext;
  29851. private _scene;
  29852. private _registerFunc;
  29853. private _audioEngine;
  29854. /**
  29855. * Creates a new analyser
  29856. * @param scene defines hosting scene
  29857. */
  29858. constructor(scene: Scene);
  29859. /**
  29860. * Get the number of data values you will have to play with for the visualization
  29861. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  29862. * @returns a number
  29863. */
  29864. getFrequencyBinCount(): number;
  29865. /**
  29866. * Gets the current frequency data as a byte array
  29867. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29868. * @returns a Uint8Array
  29869. */
  29870. getByteFrequencyData(): Uint8Array;
  29871. /**
  29872. * Gets the current waveform as a byte array
  29873. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  29874. * @returns a Uint8Array
  29875. */
  29876. getByteTimeDomainData(): Uint8Array;
  29877. /**
  29878. * Gets the current frequency data as a float array
  29879. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29880. * @returns a Float32Array
  29881. */
  29882. getFloatFrequencyData(): Float32Array;
  29883. /**
  29884. * Renders the debug canvas
  29885. */
  29886. drawDebugCanvas(): void;
  29887. /**
  29888. * Stops rendering the debug canvas and removes it
  29889. */
  29890. stopDebugCanvas(): void;
  29891. /**
  29892. * Connects two audio nodes
  29893. * @param inputAudioNode defines first node to connect
  29894. * @param outputAudioNode defines second node to connect
  29895. */
  29896. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  29897. /**
  29898. * Releases all associated resources
  29899. */
  29900. dispose(): void;
  29901. }
  29902. }
  29903. declare module "babylonjs/Audio/audioEngine" {
  29904. import { IDisposable } from "babylonjs/scene";
  29905. import { Analyser } from "babylonjs/Audio/analyser";
  29906. import { Nullable } from "babylonjs/types";
  29907. import { Observable } from "babylonjs/Misc/observable";
  29908. /**
  29909. * This represents an audio engine and it is responsible
  29910. * to play, synchronize and analyse sounds throughout the application.
  29911. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29912. */
  29913. export interface IAudioEngine extends IDisposable {
  29914. /**
  29915. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29916. */
  29917. readonly canUseWebAudio: boolean;
  29918. /**
  29919. * Gets the current AudioContext if available.
  29920. */
  29921. readonly audioContext: Nullable<AudioContext>;
  29922. /**
  29923. * The master gain node defines the global audio volume of your audio engine.
  29924. */
  29925. readonly masterGain: GainNode;
  29926. /**
  29927. * Gets whether or not mp3 are supported by your browser.
  29928. */
  29929. readonly isMP3supported: boolean;
  29930. /**
  29931. * Gets whether or not ogg are supported by your browser.
  29932. */
  29933. readonly isOGGsupported: boolean;
  29934. /**
  29935. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29936. * @ignoreNaming
  29937. */
  29938. WarnedWebAudioUnsupported: boolean;
  29939. /**
  29940. * Defines if the audio engine relies on a custom unlocked button.
  29941. * In this case, the embedded button will not be displayed.
  29942. */
  29943. useCustomUnlockedButton: boolean;
  29944. /**
  29945. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  29946. */
  29947. readonly unlocked: boolean;
  29948. /**
  29949. * Event raised when audio has been unlocked on the browser.
  29950. */
  29951. onAudioUnlockedObservable: Observable<AudioEngine>;
  29952. /**
  29953. * Event raised when audio has been locked on the browser.
  29954. */
  29955. onAudioLockedObservable: Observable<AudioEngine>;
  29956. /**
  29957. * Flags the audio engine in Locked state.
  29958. * This happens due to new browser policies preventing audio to autoplay.
  29959. */
  29960. lock(): void;
  29961. /**
  29962. * Unlocks the audio engine once a user action has been done on the dom.
  29963. * This is helpful to resume play once browser policies have been satisfied.
  29964. */
  29965. unlock(): void;
  29966. }
  29967. /**
  29968. * This represents the default audio engine used in babylon.
  29969. * It is responsible to play, synchronize and analyse sounds throughout the application.
  29970. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29971. */
  29972. export class AudioEngine implements IAudioEngine {
  29973. private _audioContext;
  29974. private _audioContextInitialized;
  29975. private _muteButton;
  29976. private _hostElement;
  29977. /**
  29978. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29979. */
  29980. canUseWebAudio: boolean;
  29981. /**
  29982. * The master gain node defines the global audio volume of your audio engine.
  29983. */
  29984. masterGain: GainNode;
  29985. /**
  29986. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29987. * @ignoreNaming
  29988. */
  29989. WarnedWebAudioUnsupported: boolean;
  29990. /**
  29991. * Gets whether or not mp3 are supported by your browser.
  29992. */
  29993. isMP3supported: boolean;
  29994. /**
  29995. * Gets whether or not ogg are supported by your browser.
  29996. */
  29997. isOGGsupported: boolean;
  29998. /**
  29999. * Gets whether audio has been unlocked on the device.
  30000. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  30001. * a user interaction has happened.
  30002. */
  30003. unlocked: boolean;
  30004. /**
  30005. * Defines if the audio engine relies on a custom unlocked button.
  30006. * In this case, the embedded button will not be displayed.
  30007. */
  30008. useCustomUnlockedButton: boolean;
  30009. /**
  30010. * Event raised when audio has been unlocked on the browser.
  30011. */
  30012. onAudioUnlockedObservable: Observable<AudioEngine>;
  30013. /**
  30014. * Event raised when audio has been locked on the browser.
  30015. */
  30016. onAudioLockedObservable: Observable<AudioEngine>;
  30017. /**
  30018. * Gets the current AudioContext if available.
  30019. */
  30020. readonly audioContext: Nullable<AudioContext>;
  30021. private _connectedAnalyser;
  30022. /**
  30023. * Instantiates a new audio engine.
  30024. *
  30025. * There should be only one per page as some browsers restrict the number
  30026. * of audio contexts you can create.
  30027. * @param hostElement defines the host element where to display the mute icon if necessary
  30028. */
  30029. constructor(hostElement?: Nullable<HTMLElement>);
  30030. /**
  30031. * Flags the audio engine in Locked state.
  30032. * This happens due to new browser policies preventing audio to autoplay.
  30033. */
  30034. lock(): void;
  30035. /**
  30036. * Unlocks the audio engine once a user action has been done on the dom.
  30037. * This is helpful to resume play once browser policies have been satisfied.
  30038. */
  30039. unlock(): void;
  30040. private _resumeAudioContext;
  30041. private _initializeAudioContext;
  30042. private _tryToRun;
  30043. private _triggerRunningState;
  30044. private _triggerSuspendedState;
  30045. private _displayMuteButton;
  30046. private _moveButtonToTopLeft;
  30047. private _onResize;
  30048. private _hideMuteButton;
  30049. /**
  30050. * Destroy and release the resources associated with the audio ccontext.
  30051. */
  30052. dispose(): void;
  30053. /**
  30054. * Gets the global volume sets on the master gain.
  30055. * @returns the global volume if set or -1 otherwise
  30056. */
  30057. getGlobalVolume(): number;
  30058. /**
  30059. * Sets the global volume of your experience (sets on the master gain).
  30060. * @param newVolume Defines the new global volume of the application
  30061. */
  30062. setGlobalVolume(newVolume: number): void;
  30063. /**
  30064. * Connect the audio engine to an audio analyser allowing some amazing
  30065. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  30066. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  30067. * @param analyser The analyser to connect to the engine
  30068. */
  30069. connectToAnalyser(analyser: Analyser): void;
  30070. }
  30071. }
  30072. declare module "babylonjs/Loading/loadingScreen" {
  30073. /**
  30074. * Interface used to present a loading screen while loading a scene
  30075. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30076. */
  30077. export interface ILoadingScreen {
  30078. /**
  30079. * Function called to display the loading screen
  30080. */
  30081. displayLoadingUI: () => void;
  30082. /**
  30083. * Function called to hide the loading screen
  30084. */
  30085. hideLoadingUI: () => void;
  30086. /**
  30087. * Gets or sets the color to use for the background
  30088. */
  30089. loadingUIBackgroundColor: string;
  30090. /**
  30091. * Gets or sets the text to display while loading
  30092. */
  30093. loadingUIText: string;
  30094. }
  30095. /**
  30096. * Class used for the default loading screen
  30097. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30098. */
  30099. export class DefaultLoadingScreen implements ILoadingScreen {
  30100. private _renderingCanvas;
  30101. private _loadingText;
  30102. private _loadingDivBackgroundColor;
  30103. private _loadingDiv;
  30104. private _loadingTextDiv;
  30105. /** Gets or sets the logo url to use for the default loading screen */
  30106. static DefaultLogoUrl: string;
  30107. /** Gets or sets the spinner url to use for the default loading screen */
  30108. static DefaultSpinnerUrl: string;
  30109. /**
  30110. * Creates a new default loading screen
  30111. * @param _renderingCanvas defines the canvas used to render the scene
  30112. * @param _loadingText defines the default text to display
  30113. * @param _loadingDivBackgroundColor defines the default background color
  30114. */
  30115. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  30116. /**
  30117. * Function called to display the loading screen
  30118. */
  30119. displayLoadingUI(): void;
  30120. /**
  30121. * Function called to hide the loading screen
  30122. */
  30123. hideLoadingUI(): void;
  30124. /**
  30125. * Gets or sets the text to display while loading
  30126. */
  30127. loadingUIText: string;
  30128. /**
  30129. * Gets or sets the color to use for the background
  30130. */
  30131. loadingUIBackgroundColor: string;
  30132. private _resizeLoadingUI;
  30133. }
  30134. }
  30135. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  30136. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30137. import { Engine } from "babylonjs/Engines/engine";
  30138. import { Nullable } from "babylonjs/types";
  30139. /** @hidden */
  30140. export class WebGLPipelineContext implements IPipelineContext {
  30141. engine: Engine;
  30142. program: Nullable<WebGLProgram>;
  30143. context?: WebGLRenderingContext;
  30144. vertexShader?: WebGLShader;
  30145. fragmentShader?: WebGLShader;
  30146. isParallelCompiled: boolean;
  30147. onCompiled?: () => void;
  30148. transformFeedback?: WebGLTransformFeedback | null;
  30149. readonly isAsync: boolean;
  30150. readonly isReady: boolean;
  30151. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  30152. }
  30153. }
  30154. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  30155. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30156. /** @hidden */
  30157. export class WebGLDataBuffer extends DataBuffer {
  30158. private _buffer;
  30159. constructor(resource: WebGLBuffer);
  30160. readonly underlyingResource: any;
  30161. }
  30162. }
  30163. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  30164. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30165. /** @hidden */
  30166. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30167. attributeProcessor(attribute: string): string;
  30168. varyingProcessor(varying: string, isFragment: boolean): string;
  30169. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30170. }
  30171. }
  30172. declare module "babylonjs/Misc/perfCounter" {
  30173. /**
  30174. * This class is used to track a performance counter which is number based.
  30175. * The user has access to many properties which give statistics of different nature.
  30176. *
  30177. * The implementer can track two kinds of Performance Counter: time and count.
  30178. * For time you can optionally call fetchNewFrame() to notify the start of a new frame to monitor, then call beginMonitoring() to start and endMonitoring() to record the lapsed time. endMonitoring takes a newFrame parameter for you to specify if the monitored time should be set for a new frame or accumulated to the current frame being monitored.
  30179. * For count you first have to call fetchNewFrame() to notify the start of a new frame to monitor, then call addCount() how many time required to increment the count value you monitor.
  30180. */
  30181. export class PerfCounter {
  30182. /**
  30183. * Gets or sets a global boolean to turn on and off all the counters
  30184. */
  30185. static Enabled: boolean;
  30186. /**
  30187. * Returns the smallest value ever
  30188. */
  30189. readonly min: number;
  30190. /**
  30191. * Returns the biggest value ever
  30192. */
  30193. readonly max: number;
  30194. /**
  30195. * Returns the average value since the performance counter is running
  30196. */
  30197. readonly average: number;
  30198. /**
  30199. * Returns the average value of the last second the counter was monitored
  30200. */
  30201. readonly lastSecAverage: number;
  30202. /**
  30203. * Returns the current value
  30204. */
  30205. readonly current: number;
  30206. /**
  30207. * Gets the accumulated total
  30208. */
  30209. readonly total: number;
  30210. /**
  30211. * Gets the total value count
  30212. */
  30213. readonly count: number;
  30214. /**
  30215. * Creates a new counter
  30216. */
  30217. constructor();
  30218. /**
  30219. * Call this method to start monitoring a new frame.
  30220. * This scenario is typically used when you accumulate monitoring time many times for a single frame, you call this method at the start of the frame, then beginMonitoring to start recording and endMonitoring(false) to accumulated the recorded time to the PerfCounter or addCount() to accumulate a monitored count.
  30221. */
  30222. fetchNewFrame(): void;
  30223. /**
  30224. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30225. * @param newCount the count value to add to the monitored count
  30226. * @param fetchResult true when it's the last time in the frame you add to the counter and you wish to update the statistics properties (min/max/average), false if you only want to update statistics.
  30227. */
  30228. addCount(newCount: number, fetchResult: boolean): void;
  30229. /**
  30230. * Start monitoring this performance counter
  30231. */
  30232. beginMonitoring(): void;
  30233. /**
  30234. * Compute the time lapsed since the previous beginMonitoring() call.
  30235. * @param newFrame true by default to fetch the result and monitor a new frame, if false the time monitored will be added to the current frame counter
  30236. */
  30237. endMonitoring(newFrame?: boolean): void;
  30238. private _fetchResult;
  30239. private _startMonitoringTime;
  30240. private _min;
  30241. private _max;
  30242. private _average;
  30243. private _current;
  30244. private _totalValueCount;
  30245. private _totalAccumulated;
  30246. private _lastSecAverage;
  30247. private _lastSecAccumulated;
  30248. private _lastSecTime;
  30249. private _lastSecValueCount;
  30250. }
  30251. }
  30252. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  30253. /**
  30254. * Interface for any object that can request an animation frame
  30255. */
  30256. export interface ICustomAnimationFrameRequester {
  30257. /**
  30258. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30259. */
  30260. renderFunction?: Function;
  30261. /**
  30262. * Called to request the next frame to render to
  30263. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30264. */
  30265. requestAnimationFrame: Function;
  30266. /**
  30267. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30268. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30269. */
  30270. requestID?: number;
  30271. }
  30272. }
  30273. declare module "babylonjs/Materials/Textures/videoTexture" {
  30274. import { Observable } from "babylonjs/Misc/observable";
  30275. import { Nullable } from "babylonjs/types";
  30276. import { Scene } from "babylonjs/scene";
  30277. import { Texture } from "babylonjs/Materials/Textures/texture";
  30278. /**
  30279. * Settings for finer control over video usage
  30280. */
  30281. export interface VideoTextureSettings {
  30282. /**
  30283. * Applies `autoplay` to video, if specified
  30284. */
  30285. autoPlay?: boolean;
  30286. /**
  30287. * Applies `loop` to video, if specified
  30288. */
  30289. loop?: boolean;
  30290. /**
  30291. * Automatically updates internal texture from video at every frame in the render loop
  30292. */
  30293. autoUpdateTexture: boolean;
  30294. /**
  30295. * Image src displayed during the video loading or until the user interacts with the video.
  30296. */
  30297. poster?: string;
  30298. }
  30299. /**
  30300. * If you want to display a video in your scene, this is the special texture for that.
  30301. * This special texture works similar to other textures, with the exception of a few parameters.
  30302. * @see https://doc.babylonjs.com/how_to/video_texture
  30303. */
  30304. export class VideoTexture extends Texture {
  30305. /**
  30306. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30307. */
  30308. readonly autoUpdateTexture: boolean;
  30309. /**
  30310. * The video instance used by the texture internally
  30311. */
  30312. readonly video: HTMLVideoElement;
  30313. private _onUserActionRequestedObservable;
  30314. /**
  30315. * Event triggerd when a dom action is required by the user to play the video.
  30316. * This happens due to recent changes in browser policies preventing video to auto start.
  30317. */
  30318. readonly onUserActionRequestedObservable: Observable<Texture>;
  30319. private _generateMipMaps;
  30320. private _engine;
  30321. private _stillImageCaptured;
  30322. private _displayingPosterTexture;
  30323. private _settings;
  30324. private _createInternalTextureOnEvent;
  30325. private _frameId;
  30326. /**
  30327. * Creates a video texture.
  30328. * If you want to display a video in your scene, this is the special texture for that.
  30329. * This special texture works similar to other textures, with the exception of a few parameters.
  30330. * @see https://doc.babylonjs.com/how_to/video_texture
  30331. * @param name optional name, will detect from video source, if not defined
  30332. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30333. * @param scene is obviously the current scene.
  30334. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30335. * @param invertY is false by default but can be used to invert video on Y axis
  30336. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30337. * @param settings allows finer control over video usage
  30338. */
  30339. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30340. private _getName;
  30341. private _getVideo;
  30342. private _createInternalTexture;
  30343. private reset;
  30344. /**
  30345. * @hidden Internal method to initiate `update`.
  30346. */
  30347. _rebuild(): void;
  30348. /**
  30349. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30350. */
  30351. update(): void;
  30352. /**
  30353. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30354. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30355. */
  30356. updateTexture(isVisible: boolean): void;
  30357. protected _updateInternalTexture: () => void;
  30358. /**
  30359. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30360. * @param url New url.
  30361. */
  30362. updateURL(url: string): void;
  30363. /**
  30364. * Dispose the texture and release its associated resources.
  30365. */
  30366. dispose(): void;
  30367. /**
  30368. * Creates a video texture straight from a stream.
  30369. * @param scene Define the scene the texture should be created in
  30370. * @param stream Define the stream the texture should be created from
  30371. * @returns The created video texture as a promise
  30372. */
  30373. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30374. /**
  30375. * Creates a video texture straight from your WebCam video feed.
  30376. * @param scene Define the scene the texture should be created in
  30377. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30378. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30379. * @returns The created video texture as a promise
  30380. */
  30381. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30382. minWidth: number;
  30383. maxWidth: number;
  30384. minHeight: number;
  30385. maxHeight: number;
  30386. deviceId: string;
  30387. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30388. /**
  30389. * Creates a video texture straight from your WebCam video feed.
  30390. * @param scene Define the scene the texture should be created in
  30391. * @param onReady Define a callback to triggered once the texture will be ready
  30392. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30393. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30394. */
  30395. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30396. minWidth: number;
  30397. maxWidth: number;
  30398. minHeight: number;
  30399. maxHeight: number;
  30400. deviceId: string;
  30401. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30402. }
  30403. }
  30404. declare module "babylonjs/Engines/engine" {
  30405. import { Observable } from "babylonjs/Misc/observable";
  30406. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  30407. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  30408. import { Scene } from "babylonjs/scene";
  30409. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  30410. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30411. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  30412. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  30413. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30414. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30415. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  30416. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30417. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  30418. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  30419. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  30420. import { WebRequest } from "babylonjs/Misc/webRequest";
  30421. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  30422. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30423. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30424. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30425. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  30426. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  30427. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  30428. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  30429. import { Material } from "babylonjs/Materials/material";
  30430. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30431. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30432. /**
  30433. * Defines the interface used by objects containing a viewport (like a camera)
  30434. */
  30435. interface IViewportOwnerLike {
  30436. /**
  30437. * Gets or sets the viewport
  30438. */
  30439. viewport: IViewportLike;
  30440. }
  30441. /**
  30442. * Interface for attribute information associated with buffer instanciation
  30443. */
  30444. export class InstancingAttributeInfo {
  30445. /**
  30446. * Index/offset of the attribute in the vertex shader
  30447. */
  30448. index: number;
  30449. /**
  30450. * size of the attribute, 1, 2, 3 or 4
  30451. */
  30452. attributeSize: number;
  30453. /**
  30454. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30455. * default is FLOAT
  30456. */
  30457. attribyteType: number;
  30458. /**
  30459. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30460. */
  30461. normalized: boolean;
  30462. /**
  30463. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30464. */
  30465. offset: number;
  30466. /**
  30467. * Name of the GLSL attribute, for debugging purpose only
  30468. */
  30469. attributeName: string;
  30470. }
  30471. /**
  30472. * Define options used to create a depth texture
  30473. */
  30474. export class DepthTextureCreationOptions {
  30475. /** Specifies whether or not a stencil should be allocated in the texture */
  30476. generateStencil?: boolean;
  30477. /** Specifies whether or not bilinear filtering is enable on the texture */
  30478. bilinearFiltering?: boolean;
  30479. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  30480. comparisonFunction?: number;
  30481. /** Specifies if the created texture is a cube texture */
  30482. isCube?: boolean;
  30483. }
  30484. /**
  30485. * Class used to describe the capabilities of the engine relatively to the current browser
  30486. */
  30487. export class EngineCapabilities {
  30488. /** Maximum textures units per fragment shader */
  30489. maxTexturesImageUnits: number;
  30490. /** Maximum texture units per vertex shader */
  30491. maxVertexTextureImageUnits: number;
  30492. /** Maximum textures units in the entire pipeline */
  30493. maxCombinedTexturesImageUnits: number;
  30494. /** Maximum texture size */
  30495. maxTextureSize: number;
  30496. /** Maximum cube texture size */
  30497. maxCubemapTextureSize: number;
  30498. /** Maximum render texture size */
  30499. maxRenderTextureSize: number;
  30500. /** Maximum number of vertex attributes */
  30501. maxVertexAttribs: number;
  30502. /** Maximum number of varyings */
  30503. maxVaryingVectors: number;
  30504. /** Maximum number of uniforms per vertex shader */
  30505. maxVertexUniformVectors: number;
  30506. /** Maximum number of uniforms per fragment shader */
  30507. maxFragmentUniformVectors: number;
  30508. /** Defines if standard derivates (dx/dy) are supported */
  30509. standardDerivatives: boolean;
  30510. /** Defines if s3tc texture compression is supported */
  30511. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  30512. /** Defines if pvrtc texture compression is supported */
  30513. pvrtc: any;
  30514. /** Defines if etc1 texture compression is supported */
  30515. etc1: any;
  30516. /** Defines if etc2 texture compression is supported */
  30517. etc2: any;
  30518. /** Defines if astc texture compression is supported */
  30519. astc: any;
  30520. /** Defines if float textures are supported */
  30521. textureFloat: boolean;
  30522. /** Defines if vertex array objects are supported */
  30523. vertexArrayObject: boolean;
  30524. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30525. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  30526. /** Gets the maximum level of anisotropy supported */
  30527. maxAnisotropy: number;
  30528. /** Defines if instancing is supported */
  30529. instancedArrays: boolean;
  30530. /** Defines if 32 bits indices are supported */
  30531. uintIndices: boolean;
  30532. /** Defines if high precision shaders are supported */
  30533. highPrecisionShaderSupported: boolean;
  30534. /** Defines if depth reading in the fragment shader is supported */
  30535. fragmentDepthSupported: boolean;
  30536. /** Defines if float texture linear filtering is supported*/
  30537. textureFloatLinearFiltering: boolean;
  30538. /** Defines if rendering to float textures is supported */
  30539. textureFloatRender: boolean;
  30540. /** Defines if half float textures are supported*/
  30541. textureHalfFloat: boolean;
  30542. /** Defines if half float texture linear filtering is supported*/
  30543. textureHalfFloatLinearFiltering: boolean;
  30544. /** Defines if rendering to half float textures is supported */
  30545. textureHalfFloatRender: boolean;
  30546. /** Defines if textureLOD shader command is supported */
  30547. textureLOD: boolean;
  30548. /** Defines if draw buffers extension is supported */
  30549. drawBuffersExtension: boolean;
  30550. /** Defines if depth textures are supported */
  30551. depthTextureExtension: boolean;
  30552. /** Defines if float color buffer are supported */
  30553. colorBufferFloat: boolean;
  30554. /** Gets disjoint timer query extension (null if not supported) */
  30555. timerQuery: EXT_disjoint_timer_query;
  30556. /** Defines if timestamp can be used with timer query */
  30557. canUseTimestampForTimerQuery: boolean;
  30558. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30559. multiview: any;
  30560. /** Function used to let the system compiles shaders in background */
  30561. parallelShaderCompile: {
  30562. COMPLETION_STATUS_KHR: number;
  30563. };
  30564. /** Max number of texture samples for MSAA */
  30565. maxMSAASamples: number;
  30566. }
  30567. /** Interface defining initialization parameters for Engine class */
  30568. export interface EngineOptions extends WebGLContextAttributes {
  30569. /**
  30570. * Defines if the engine should no exceed a specified device ratio
  30571. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30572. */
  30573. limitDeviceRatio?: number;
  30574. /**
  30575. * Defines if webvr should be enabled automatically
  30576. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30577. */
  30578. autoEnableWebVR?: boolean;
  30579. /**
  30580. * Defines if webgl2 should be turned off even if supported
  30581. * @see http://doc.babylonjs.com/features/webgl2
  30582. */
  30583. disableWebGL2Support?: boolean;
  30584. /**
  30585. * Defines if webaudio should be initialized as well
  30586. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30587. */
  30588. audioEngine?: boolean;
  30589. /**
  30590. * Defines if animations should run using a deterministic lock step
  30591. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30592. */
  30593. deterministicLockstep?: boolean;
  30594. /** Defines the maximum steps to use with deterministic lock step mode */
  30595. lockstepMaxSteps?: number;
  30596. /**
  30597. * Defines that engine should ignore context lost events
  30598. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30599. */
  30600. doNotHandleContextLost?: boolean;
  30601. /**
  30602. * Defines that engine should ignore modifying touch action attribute and style
  30603. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30604. */
  30605. doNotHandleTouchAction?: boolean;
  30606. /**
  30607. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30608. */
  30609. useHighPrecisionFloats?: boolean;
  30610. }
  30611. /**
  30612. * Defines the interface used by display changed events
  30613. */
  30614. export interface IDisplayChangedEventArgs {
  30615. /** Gets the vrDisplay object (if any) */
  30616. vrDisplay: Nullable<any>;
  30617. /** Gets a boolean indicating if webVR is supported */
  30618. vrSupported: boolean;
  30619. }
  30620. /**
  30621. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  30622. */
  30623. export class Engine {
  30624. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30625. static ExceptionList: ({
  30626. key: string;
  30627. capture: string;
  30628. captureConstraint: number;
  30629. targets: string[];
  30630. } | {
  30631. key: string;
  30632. capture: null;
  30633. captureConstraint: null;
  30634. targets: string[];
  30635. })[];
  30636. /** Gets the list of created engines */
  30637. static readonly Instances: Engine[];
  30638. /**
  30639. * Gets the latest created engine
  30640. */
  30641. static readonly LastCreatedEngine: Nullable<Engine>;
  30642. /**
  30643. * Gets the latest created scene
  30644. */
  30645. static readonly LastCreatedScene: Nullable<Scene>;
  30646. /**
  30647. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  30648. * @param flag defines which part of the materials must be marked as dirty
  30649. * @param predicate defines a predicate used to filter which materials should be affected
  30650. */
  30651. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  30652. /** @hidden */
  30653. static _TextureLoaders: IInternalTextureLoader[];
  30654. /** Defines that alpha blending is disabled */
  30655. static readonly ALPHA_DISABLE: number;
  30656. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  30657. static readonly ALPHA_ADD: number;
  30658. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  30659. static readonly ALPHA_COMBINE: number;
  30660. /** Defines that alpha blending to DEST - SRC * DEST */
  30661. static readonly ALPHA_SUBTRACT: number;
  30662. /** Defines that alpha blending to SRC * DEST */
  30663. static readonly ALPHA_MULTIPLY: number;
  30664. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  30665. static readonly ALPHA_MAXIMIZED: number;
  30666. /** Defines that alpha blending to SRC + DEST */
  30667. static readonly ALPHA_ONEONE: number;
  30668. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  30669. static readonly ALPHA_PREMULTIPLIED: number;
  30670. /**
  30671. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  30672. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  30673. */
  30674. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  30675. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  30676. static readonly ALPHA_INTERPOLATE: number;
  30677. /**
  30678. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  30679. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  30680. */
  30681. static readonly ALPHA_SCREENMODE: number;
  30682. /** Defines that the ressource is not delayed*/
  30683. static readonly DELAYLOADSTATE_NONE: number;
  30684. /** Defines that the ressource was successfully delay loaded */
  30685. static readonly DELAYLOADSTATE_LOADED: number;
  30686. /** Defines that the ressource is currently delay loading */
  30687. static readonly DELAYLOADSTATE_LOADING: number;
  30688. /** Defines that the ressource is delayed and has not started loading */
  30689. static readonly DELAYLOADSTATE_NOTLOADED: number;
  30690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  30691. static readonly NEVER: number;
  30692. /** 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 */
  30693. static readonly ALWAYS: number;
  30694. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  30695. static readonly LESS: number;
  30696. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  30697. static readonly EQUAL: number;
  30698. /** 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 */
  30699. static readonly LEQUAL: number;
  30700. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  30701. static readonly GREATER: number;
  30702. /** 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 */
  30703. static readonly GEQUAL: number;
  30704. /** 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 */
  30705. static readonly NOTEQUAL: number;
  30706. /** Passed to stencilOperation to specify that stencil value must be kept */
  30707. static readonly KEEP: number;
  30708. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30709. static readonly REPLACE: number;
  30710. /** Passed to stencilOperation to specify that stencil value must be incremented */
  30711. static readonly INCR: number;
  30712. /** Passed to stencilOperation to specify that stencil value must be decremented */
  30713. static readonly DECR: number;
  30714. /** Passed to stencilOperation to specify that stencil value must be inverted */
  30715. static readonly INVERT: number;
  30716. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  30717. static readonly INCR_WRAP: number;
  30718. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  30719. static readonly DECR_WRAP: number;
  30720. /** Texture is not repeating outside of 0..1 UVs */
  30721. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  30722. /** Texture is repeating outside of 0..1 UVs */
  30723. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  30724. /** Texture is repeating and mirrored */
  30725. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  30726. /** ALPHA */
  30727. static readonly TEXTUREFORMAT_ALPHA: number;
  30728. /** LUMINANCE */
  30729. static readonly TEXTUREFORMAT_LUMINANCE: number;
  30730. /** LUMINANCE_ALPHA */
  30731. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  30732. /** RGB */
  30733. static readonly TEXTUREFORMAT_RGB: number;
  30734. /** RGBA */
  30735. static readonly TEXTUREFORMAT_RGBA: number;
  30736. /** RED */
  30737. static readonly TEXTUREFORMAT_RED: number;
  30738. /** RED (2nd reference) */
  30739. static readonly TEXTUREFORMAT_R: number;
  30740. /** RG */
  30741. static readonly TEXTUREFORMAT_RG: number;
  30742. /** RED_INTEGER */
  30743. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  30744. /** RED_INTEGER (2nd reference) */
  30745. static readonly TEXTUREFORMAT_R_INTEGER: number;
  30746. /** RG_INTEGER */
  30747. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  30748. /** RGB_INTEGER */
  30749. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  30750. /** RGBA_INTEGER */
  30751. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  30752. /** UNSIGNED_BYTE */
  30753. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  30754. /** UNSIGNED_BYTE (2nd reference) */
  30755. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  30756. /** FLOAT */
  30757. static readonly TEXTURETYPE_FLOAT: number;
  30758. /** HALF_FLOAT */
  30759. static readonly TEXTURETYPE_HALF_FLOAT: number;
  30760. /** BYTE */
  30761. static readonly TEXTURETYPE_BYTE: number;
  30762. /** SHORT */
  30763. static readonly TEXTURETYPE_SHORT: number;
  30764. /** UNSIGNED_SHORT */
  30765. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  30766. /** INT */
  30767. static readonly TEXTURETYPE_INT: number;
  30768. /** UNSIGNED_INT */
  30769. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  30770. /** UNSIGNED_SHORT_4_4_4_4 */
  30771. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  30772. /** UNSIGNED_SHORT_5_5_5_1 */
  30773. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  30774. /** UNSIGNED_SHORT_5_6_5 */
  30775. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  30776. /** UNSIGNED_INT_2_10_10_10_REV */
  30777. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  30778. /** UNSIGNED_INT_24_8 */
  30779. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  30780. /** UNSIGNED_INT_10F_11F_11F_REV */
  30781. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  30782. /** UNSIGNED_INT_5_9_9_9_REV */
  30783. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  30784. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  30785. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  30786. /** nearest is mag = nearest and min = nearest and mip = linear */
  30787. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  30788. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30789. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  30790. /** Trilinear is mag = linear and min = linear and mip = linear */
  30791. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  30792. /** nearest is mag = nearest and min = nearest and mip = linear */
  30793. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  30794. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30795. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  30796. /** Trilinear is mag = linear and min = linear and mip = linear */
  30797. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  30798. /** mag = nearest and min = nearest and mip = nearest */
  30799. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  30800. /** mag = nearest and min = linear and mip = nearest */
  30801. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  30802. /** mag = nearest and min = linear and mip = linear */
  30803. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  30804. /** mag = nearest and min = linear and mip = none */
  30805. static readonly TEXTURE_NEAREST_LINEAR: number;
  30806. /** mag = nearest and min = nearest and mip = none */
  30807. static readonly TEXTURE_NEAREST_NEAREST: number;
  30808. /** mag = linear and min = nearest and mip = nearest */
  30809. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  30810. /** mag = linear and min = nearest and mip = linear */
  30811. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  30812. /** mag = linear and min = linear and mip = none */
  30813. static readonly TEXTURE_LINEAR_LINEAR: number;
  30814. /** mag = linear and min = nearest and mip = none */
  30815. static readonly TEXTURE_LINEAR_NEAREST: number;
  30816. /** Explicit coordinates mode */
  30817. static readonly TEXTURE_EXPLICIT_MODE: number;
  30818. /** Spherical coordinates mode */
  30819. static readonly TEXTURE_SPHERICAL_MODE: number;
  30820. /** Planar coordinates mode */
  30821. static readonly TEXTURE_PLANAR_MODE: number;
  30822. /** Cubic coordinates mode */
  30823. static readonly TEXTURE_CUBIC_MODE: number;
  30824. /** Projection coordinates mode */
  30825. static readonly TEXTURE_PROJECTION_MODE: number;
  30826. /** Skybox coordinates mode */
  30827. static readonly TEXTURE_SKYBOX_MODE: number;
  30828. /** Inverse Cubic coordinates mode */
  30829. static readonly TEXTURE_INVCUBIC_MODE: number;
  30830. /** Equirectangular coordinates mode */
  30831. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  30832. /** Equirectangular Fixed coordinates mode */
  30833. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  30834. /** Equirectangular Fixed Mirrored coordinates mode */
  30835. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  30836. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  30837. static readonly SCALEMODE_FLOOR: number;
  30838. /** Defines that texture rescaling will look for the nearest power of 2 size */
  30839. static readonly SCALEMODE_NEAREST: number;
  30840. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  30841. static readonly SCALEMODE_CEILING: number;
  30842. /**
  30843. * Returns the current npm package of the sdk
  30844. */
  30845. static readonly NpmPackage: string;
  30846. /**
  30847. * Returns the current version of the framework
  30848. */
  30849. static readonly Version: string;
  30850. /**
  30851. * Returns a string describing the current engine
  30852. */
  30853. readonly description: string;
  30854. /**
  30855. * Gets or sets the epsilon value used by collision engine
  30856. */
  30857. static CollisionsEpsilon: number;
  30858. /**
  30859. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30860. */
  30861. static ShadersRepository: string;
  30862. /**
  30863. * Method called to create the default loading screen.
  30864. * This can be overriden in your own app.
  30865. * @param canvas The rendering canvas element
  30866. * @returns The loading screen
  30867. */
  30868. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  30869. /**
  30870. * Method called to create the default rescale post process on each engine.
  30871. */
  30872. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  30873. /** @hidden */
  30874. _shaderProcessor: IShaderProcessor;
  30875. /**
  30876. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30877. */
  30878. forcePOTTextures: boolean;
  30879. /**
  30880. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30881. */
  30882. isFullscreen: boolean;
  30883. /**
  30884. * Gets a boolean indicating if the pointer is currently locked
  30885. */
  30886. isPointerLock: boolean;
  30887. /**
  30888. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30889. */
  30890. cullBackFaces: boolean;
  30891. /**
  30892. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30893. */
  30894. renderEvenInBackground: boolean;
  30895. /**
  30896. * Gets or sets a boolean indicating that cache can be kept between frames
  30897. */
  30898. preventCacheWipeBetweenFrames: boolean;
  30899. /**
  30900. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  30901. **/
  30902. enableOfflineSupport: boolean;
  30903. /**
  30904. * 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)
  30905. **/
  30906. disableManifestCheck: boolean;
  30907. /**
  30908. * Gets the list of created scenes
  30909. */
  30910. scenes: Scene[];
  30911. /**
  30912. * Event raised when a new scene is created
  30913. */
  30914. onNewSceneAddedObservable: Observable<Scene>;
  30915. /**
  30916. * Gets the list of created postprocesses
  30917. */
  30918. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  30919. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30920. validateShaderPrograms: boolean;
  30921. /**
  30922. * Observable event triggered each time the rendering canvas is resized
  30923. */
  30924. onResizeObservable: Observable<Engine>;
  30925. /**
  30926. * Observable event triggered each time the canvas loses focus
  30927. */
  30928. onCanvasBlurObservable: Observable<Engine>;
  30929. /**
  30930. * Observable event triggered each time the canvas gains focus
  30931. */
  30932. onCanvasFocusObservable: Observable<Engine>;
  30933. /**
  30934. * Observable event triggered each time the canvas receives pointerout event
  30935. */
  30936. onCanvasPointerOutObservable: Observable<PointerEvent>;
  30937. /**
  30938. * Observable event triggered before each texture is initialized
  30939. */
  30940. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  30941. /**
  30942. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30943. */
  30944. disableUniformBuffers: boolean;
  30945. /** @hidden */
  30946. _uniformBuffers: UniformBuffer[];
  30947. /**
  30948. * Gets a boolean indicating that the engine supports uniform buffers
  30949. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30950. */
  30951. readonly supportsUniformBuffers: boolean;
  30952. /**
  30953. * Observable raised when the engine begins a new frame
  30954. */
  30955. onBeginFrameObservable: Observable<Engine>;
  30956. /**
  30957. * If set, will be used to request the next animation frame for the render loop
  30958. */
  30959. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  30960. /**
  30961. * Observable raised when the engine ends the current frame
  30962. */
  30963. onEndFrameObservable: Observable<Engine>;
  30964. /**
  30965. * Observable raised when the engine is about to compile a shader
  30966. */
  30967. onBeforeShaderCompilationObservable: Observable<Engine>;
  30968. /**
  30969. * Observable raised when the engine has jsut compiled a shader
  30970. */
  30971. onAfterShaderCompilationObservable: Observable<Engine>;
  30972. /** @hidden */
  30973. _gl: WebGLRenderingContext;
  30974. private _renderingCanvas;
  30975. private _windowIsBackground;
  30976. private _webGLVersion;
  30977. protected _highPrecisionShadersAllowed: boolean;
  30978. /** @hidden */
  30979. readonly _shouldUseHighPrecisionShader: boolean;
  30980. /**
  30981. * Gets a boolean indicating that only power of 2 textures are supported
  30982. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30983. */
  30984. readonly needPOTTextures: boolean;
  30985. /** @hidden */
  30986. _badOS: boolean;
  30987. /** @hidden */
  30988. _badDesktopOS: boolean;
  30989. /**
  30990. * Gets the audio engine
  30991. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30992. * @ignorenaming
  30993. */
  30994. static audioEngine: IAudioEngine;
  30995. /**
  30996. * Default AudioEngine factory responsible of creating the Audio Engine.
  30997. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  30998. */
  30999. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  31000. /**
  31001. * Default offline support factory responsible of creating a tool used to store data locally.
  31002. * By default, this will create a Database object if the workload has been embedded.
  31003. */
  31004. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  31005. private _onFocus;
  31006. private _onBlur;
  31007. private _onCanvasPointerOut;
  31008. private _onCanvasBlur;
  31009. private _onCanvasFocus;
  31010. private _onFullscreenChange;
  31011. private _onPointerLockChange;
  31012. private _hardwareScalingLevel;
  31013. /** @hidden */
  31014. _caps: EngineCapabilities;
  31015. private _pointerLockRequested;
  31016. private _isStencilEnable;
  31017. private _colorWrite;
  31018. private _loadingScreen;
  31019. /** @hidden */
  31020. _drawCalls: PerfCounter;
  31021. private _glVersion;
  31022. private _glRenderer;
  31023. private _glVendor;
  31024. private _videoTextureSupported;
  31025. private _renderingQueueLaunched;
  31026. private _activeRenderLoops;
  31027. private _deterministicLockstep;
  31028. private _lockstepMaxSteps;
  31029. /**
  31030. * Observable signaled when a context lost event is raised
  31031. */
  31032. onContextLostObservable: Observable<Engine>;
  31033. /**
  31034. * Observable signaled when a context restored event is raised
  31035. */
  31036. onContextRestoredObservable: Observable<Engine>;
  31037. private _onContextLost;
  31038. private _onContextRestored;
  31039. private _contextWasLost;
  31040. /** @hidden */
  31041. _doNotHandleContextLost: boolean;
  31042. /**
  31043. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31044. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31045. */
  31046. doNotHandleContextLost: boolean;
  31047. private _performanceMonitor;
  31048. private _fps;
  31049. private _deltaTime;
  31050. /**
  31051. * Turn this value on if you want to pause FPS computation when in background
  31052. */
  31053. disablePerformanceMonitorInBackground: boolean;
  31054. /**
  31055. * Gets the performance monitor attached to this engine
  31056. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  31057. */
  31058. readonly performanceMonitor: PerformanceMonitor;
  31059. /**
  31060. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31061. */
  31062. disableVertexArrayObjects: boolean;
  31063. /** @hidden */
  31064. protected _depthCullingState: _DepthCullingState;
  31065. /** @hidden */
  31066. protected _stencilState: _StencilState;
  31067. /** @hidden */
  31068. protected _alphaState: _AlphaState;
  31069. /** @hidden */
  31070. protected _alphaMode: number;
  31071. /** @hidden */
  31072. _internalTexturesCache: InternalTexture[];
  31073. /** @hidden */
  31074. protected _activeChannel: number;
  31075. private _currentTextureChannel;
  31076. /** @hidden */
  31077. protected _boundTexturesCache: {
  31078. [key: string]: Nullable<InternalTexture>;
  31079. };
  31080. /** @hidden */
  31081. protected _currentEffect: Nullable<Effect>;
  31082. /** @hidden */
  31083. protected _currentProgram: Nullable<WebGLProgram>;
  31084. private _compiledEffects;
  31085. private _vertexAttribArraysEnabled;
  31086. /** @hidden */
  31087. protected _cachedViewport: Nullable<IViewportLike>;
  31088. private _cachedVertexArrayObject;
  31089. /** @hidden */
  31090. protected _cachedVertexBuffers: any;
  31091. /** @hidden */
  31092. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31093. /** @hidden */
  31094. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31095. /** @hidden */
  31096. _currentRenderTarget: Nullable<InternalTexture>;
  31097. private _uintIndicesCurrentlySet;
  31098. private _currentBoundBuffer;
  31099. /** @hidden */
  31100. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31101. private _currentBufferPointers;
  31102. private _currentInstanceLocations;
  31103. private _currentInstanceBuffers;
  31104. private _textureUnits;
  31105. /** @hidden */
  31106. _workingCanvas: Nullable<HTMLCanvasElement>;
  31107. /** @hidden */
  31108. _workingContext: Nullable<CanvasRenderingContext2D>;
  31109. private _rescalePostProcess;
  31110. private _dummyFramebuffer;
  31111. private _externalData;
  31112. /** @hidden */
  31113. _bindedRenderFunction: any;
  31114. private _vaoRecordInProgress;
  31115. private _mustWipeVertexAttributes;
  31116. private _emptyTexture;
  31117. private _emptyCubeTexture;
  31118. private _emptyTexture3D;
  31119. /** @hidden */
  31120. _frameHandler: number;
  31121. private _nextFreeTextureSlots;
  31122. private _maxSimultaneousTextures;
  31123. private _activeRequests;
  31124. private _texturesSupported;
  31125. /** @hidden */
  31126. _textureFormatInUse: Nullable<string>;
  31127. /**
  31128. * Gets the list of texture formats supported
  31129. */
  31130. readonly texturesSupported: Array<string>;
  31131. /**
  31132. * Gets the list of texture formats in use
  31133. */
  31134. readonly textureFormatInUse: Nullable<string>;
  31135. /**
  31136. * Gets the current viewport
  31137. */
  31138. readonly currentViewport: Nullable<IViewportLike>;
  31139. /**
  31140. * Gets the default empty texture
  31141. */
  31142. readonly emptyTexture: InternalTexture;
  31143. /**
  31144. * Gets the default empty 3D texture
  31145. */
  31146. readonly emptyTexture3D: InternalTexture;
  31147. /**
  31148. * Gets the default empty cube texture
  31149. */
  31150. readonly emptyCubeTexture: InternalTexture;
  31151. /**
  31152. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31153. */
  31154. readonly premultipliedAlpha: boolean;
  31155. /**
  31156. * Creates a new engine
  31157. * @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
  31158. * @param antialias defines enable antialiasing (default: false)
  31159. * @param options defines further options to be sent to the getContext() function
  31160. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31161. */
  31162. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31163. /**
  31164. * Initializes a webVR display and starts listening to display change events
  31165. * The onVRDisplayChangedObservable will be notified upon these changes
  31166. * @returns The onVRDisplayChangedObservable
  31167. */
  31168. initWebVR(): Observable<IDisplayChangedEventArgs>;
  31169. /** @hidden */
  31170. _prepareVRComponent(): void;
  31171. /** @hidden */
  31172. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  31173. /** @hidden */
  31174. _submitVRFrame(): void;
  31175. /**
  31176. * Call this function to leave webVR mode
  31177. * Will do nothing if webVR is not supported or if there is no webVR device
  31178. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31179. */
  31180. disableVR(): void;
  31181. /**
  31182. * Gets a boolean indicating that the system is in VR mode and is presenting
  31183. * @returns true if VR mode is engaged
  31184. */
  31185. isVRPresenting(): boolean;
  31186. /** @hidden */
  31187. _requestVRFrame(): void;
  31188. private _disableTouchAction;
  31189. private _rebuildInternalTextures;
  31190. private _rebuildEffects;
  31191. /**
  31192. * Gets a boolean indicating if all created effects are ready
  31193. * @returns true if all effects are ready
  31194. */
  31195. areAllEffectsReady(): boolean;
  31196. private _rebuildBuffers;
  31197. private _initGLContext;
  31198. /**
  31199. * Gets version of the current webGL context
  31200. */
  31201. readonly webGLVersion: number;
  31202. /**
  31203. * Gets a string idenfifying the name of the class
  31204. * @returns "Engine" string
  31205. */
  31206. getClassName(): string;
  31207. /**
  31208. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31209. */
  31210. readonly isStencilEnable: boolean;
  31211. /** @hidden */
  31212. _prepareWorkingCanvas(): void;
  31213. /**
  31214. * Reset the texture cache to empty state
  31215. */
  31216. resetTextureCache(): void;
  31217. /**
  31218. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  31219. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31220. * @returns true if engine is in deterministic lock step mode
  31221. */
  31222. isDeterministicLockStep(): boolean;
  31223. /**
  31224. * Gets the max steps when engine is running in deterministic lock step
  31225. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31226. * @returns the max steps
  31227. */
  31228. getLockstepMaxSteps(): number;
  31229. /**
  31230. * Gets an object containing information about the current webGL context
  31231. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31232. */
  31233. getGlInfo(): {
  31234. vendor: string;
  31235. renderer: string;
  31236. version: string;
  31237. };
  31238. /**
  31239. * Gets current aspect ratio
  31240. * @param viewportOwner defines the camera to use to get the aspect ratio
  31241. * @param useScreen defines if screen size must be used (or the current render target if any)
  31242. * @returns a number defining the aspect ratio
  31243. */
  31244. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  31245. /**
  31246. * Gets current screen aspect ratio
  31247. * @returns a number defining the aspect ratio
  31248. */
  31249. getScreenAspectRatio(): number;
  31250. /**
  31251. * Gets the current render width
  31252. * @param useScreen defines if screen size must be used (or the current render target if any)
  31253. * @returns a number defining the current render width
  31254. */
  31255. getRenderWidth(useScreen?: boolean): number;
  31256. /**
  31257. * Gets the current render height
  31258. * @param useScreen defines if screen size must be used (or the current render target if any)
  31259. * @returns a number defining the current render height
  31260. */
  31261. getRenderHeight(useScreen?: boolean): number;
  31262. /**
  31263. * Gets the HTML canvas attached with the current webGL context
  31264. * @returns a HTML canvas
  31265. */
  31266. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31267. /**
  31268. * Gets host window
  31269. * @returns the host window object
  31270. */
  31271. getHostWindow(): Window;
  31272. /**
  31273. * Gets host document
  31274. * @returns the host document object
  31275. */
  31276. getHostDocument(): Document;
  31277. /**
  31278. * Gets the client rect of the HTML canvas attached with the current webGL context
  31279. * @returns a client rectanglee
  31280. */
  31281. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  31282. /**
  31283. * Defines the hardware scaling level.
  31284. * By default the hardware scaling level is computed from the window device ratio.
  31285. * 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.
  31286. * @param level defines the level to use
  31287. */
  31288. setHardwareScalingLevel(level: number): void;
  31289. /**
  31290. * Gets the current hardware scaling level.
  31291. * By default the hardware scaling level is computed from the window device ratio.
  31292. * 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.
  31293. * @returns a number indicating the current hardware scaling level
  31294. */
  31295. getHardwareScalingLevel(): number;
  31296. /**
  31297. * Gets the list of loaded textures
  31298. * @returns an array containing all loaded textures
  31299. */
  31300. getLoadedTexturesCache(): InternalTexture[];
  31301. /**
  31302. * Gets the object containing all engine capabilities
  31303. * @returns the EngineCapabilities object
  31304. */
  31305. getCaps(): EngineCapabilities;
  31306. /**
  31307. * Gets the current depth function
  31308. * @returns a number defining the depth function
  31309. */
  31310. getDepthFunction(): Nullable<number>;
  31311. /**
  31312. * Sets the current depth function
  31313. * @param depthFunc defines the function to use
  31314. */
  31315. setDepthFunction(depthFunc: number): void;
  31316. /**
  31317. * Sets the current depth function to GREATER
  31318. */
  31319. setDepthFunctionToGreater(): void;
  31320. /**
  31321. * Sets the current depth function to GEQUAL
  31322. */
  31323. setDepthFunctionToGreaterOrEqual(): void;
  31324. /**
  31325. * Sets the current depth function to LESS
  31326. */
  31327. setDepthFunctionToLess(): void;
  31328. private _cachedStencilBuffer;
  31329. private _cachedStencilFunction;
  31330. private _cachedStencilMask;
  31331. private _cachedStencilOperationPass;
  31332. private _cachedStencilOperationFail;
  31333. private _cachedStencilOperationDepthFail;
  31334. private _cachedStencilReference;
  31335. /**
  31336. * Caches the the state of the stencil buffer
  31337. */
  31338. cacheStencilState(): void;
  31339. /**
  31340. * Restores the state of the stencil buffer
  31341. */
  31342. restoreStencilState(): void;
  31343. /**
  31344. * Sets the current depth function to LEQUAL
  31345. */
  31346. setDepthFunctionToLessOrEqual(): void;
  31347. /**
  31348. * Gets a boolean indicating if stencil buffer is enabled
  31349. * @returns the current stencil buffer state
  31350. */
  31351. getStencilBuffer(): boolean;
  31352. /**
  31353. * Enable or disable the stencil buffer
  31354. * @param enable defines if the stencil buffer must be enabled or disabled
  31355. */
  31356. setStencilBuffer(enable: boolean): void;
  31357. /**
  31358. * Gets the current stencil mask
  31359. * @returns a number defining the new stencil mask to use
  31360. */
  31361. getStencilMask(): number;
  31362. /**
  31363. * Sets the current stencil mask
  31364. * @param mask defines the new stencil mask to use
  31365. */
  31366. setStencilMask(mask: number): void;
  31367. /**
  31368. * Gets the current stencil function
  31369. * @returns a number defining the stencil function to use
  31370. */
  31371. getStencilFunction(): number;
  31372. /**
  31373. * Gets the current stencil reference value
  31374. * @returns a number defining the stencil reference value to use
  31375. */
  31376. getStencilFunctionReference(): number;
  31377. /**
  31378. * Gets the current stencil mask
  31379. * @returns a number defining the stencil mask to use
  31380. */
  31381. getStencilFunctionMask(): number;
  31382. /**
  31383. * Sets the current stencil function
  31384. * @param stencilFunc defines the new stencil function to use
  31385. */
  31386. setStencilFunction(stencilFunc: number): void;
  31387. /**
  31388. * Sets the current stencil reference
  31389. * @param reference defines the new stencil reference to use
  31390. */
  31391. setStencilFunctionReference(reference: number): void;
  31392. /**
  31393. * Sets the current stencil mask
  31394. * @param mask defines the new stencil mask to use
  31395. */
  31396. setStencilFunctionMask(mask: number): void;
  31397. /**
  31398. * Gets the current stencil operation when stencil fails
  31399. * @returns a number defining stencil operation to use when stencil fails
  31400. */
  31401. getStencilOperationFail(): number;
  31402. /**
  31403. * Gets the current stencil operation when depth fails
  31404. * @returns a number defining stencil operation to use when depth fails
  31405. */
  31406. getStencilOperationDepthFail(): number;
  31407. /**
  31408. * Gets the current stencil operation when stencil passes
  31409. * @returns a number defining stencil operation to use when stencil passes
  31410. */
  31411. getStencilOperationPass(): number;
  31412. /**
  31413. * Sets the stencil operation to use when stencil fails
  31414. * @param operation defines the stencil operation to use when stencil fails
  31415. */
  31416. setStencilOperationFail(operation: number): void;
  31417. /**
  31418. * Sets the stencil operation to use when depth fails
  31419. * @param operation defines the stencil operation to use when depth fails
  31420. */
  31421. setStencilOperationDepthFail(operation: number): void;
  31422. /**
  31423. * Sets the stencil operation to use when stencil passes
  31424. * @param operation defines the stencil operation to use when stencil passes
  31425. */
  31426. setStencilOperationPass(operation: number): void;
  31427. /**
  31428. * Sets a boolean indicating if the dithering state is enabled or disabled
  31429. * @param value defines the dithering state
  31430. */
  31431. setDitheringState(value: boolean): void;
  31432. /**
  31433. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  31434. * @param value defines the rasterizer state
  31435. */
  31436. setRasterizerState(value: boolean): void;
  31437. /**
  31438. * stop executing a render loop function and remove it from the execution array
  31439. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31440. */
  31441. stopRenderLoop(renderFunction?: () => void): void;
  31442. /** @hidden */
  31443. _renderLoop(): void;
  31444. /**
  31445. * Register and execute a render loop. The engine can have more than one render function
  31446. * @param renderFunction defines the function to continuously execute
  31447. */
  31448. runRenderLoop(renderFunction: () => void): void;
  31449. /**
  31450. * Toggle full screen mode
  31451. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31452. */
  31453. switchFullscreen(requestPointerLock: boolean): void;
  31454. /**
  31455. * Enters full screen mode
  31456. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31457. */
  31458. enterFullscreen(requestPointerLock: boolean): void;
  31459. /**
  31460. * Exits full screen mode
  31461. */
  31462. exitFullscreen(): void;
  31463. /**
  31464. * Enters Pointerlock mode
  31465. */
  31466. enterPointerlock(): void;
  31467. /**
  31468. * Exits Pointerlock mode
  31469. */
  31470. exitPointerlock(): void;
  31471. /**
  31472. * Clear the current render buffer or the current render target (if any is set up)
  31473. * @param color defines the color to use
  31474. * @param backBuffer defines if the back buffer must be cleared
  31475. * @param depth defines if the depth buffer must be cleared
  31476. * @param stencil defines if the stencil buffer must be cleared
  31477. */
  31478. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31479. /**
  31480. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  31481. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31482. * @param y defines the y-coordinate of the corner of the clear rectangle
  31483. * @param width defines the width of the clear rectangle
  31484. * @param height defines the height of the clear rectangle
  31485. * @param clearColor defines the clear color
  31486. */
  31487. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  31488. /**
  31489. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  31490. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31491. * @param y defines the y-coordinate of the corner of the clear rectangle
  31492. * @param width defines the width of the clear rectangle
  31493. * @param height defines the height of the clear rectangle
  31494. */
  31495. enableScissor(x: number, y: number, width: number, height: number): void;
  31496. /**
  31497. * Disable previously set scissor test rectangle
  31498. */
  31499. disableScissor(): void;
  31500. private _viewportCached;
  31501. /** @hidden */
  31502. _viewport(x: number, y: number, width: number, height: number): void;
  31503. /**
  31504. * Set the WebGL's viewport
  31505. * @param viewport defines the viewport element to be used
  31506. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31507. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31508. */
  31509. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31510. /**
  31511. * Directly set the WebGL Viewport
  31512. * @param x defines the x coordinate of the viewport (in screen space)
  31513. * @param y defines the y coordinate of the viewport (in screen space)
  31514. * @param width defines the width of the viewport (in screen space)
  31515. * @param height defines the height of the viewport (in screen space)
  31516. * @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
  31517. */
  31518. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  31519. /**
  31520. * Begin a new frame
  31521. */
  31522. beginFrame(): void;
  31523. /**
  31524. * Enf the current frame
  31525. */
  31526. endFrame(): void;
  31527. /**
  31528. * Resize the view according to the canvas' size
  31529. */
  31530. resize(): void;
  31531. /**
  31532. * Force a specific size of the canvas
  31533. * @param width defines the new canvas' width
  31534. * @param height defines the new canvas' height
  31535. */
  31536. setSize(width: number, height: number): void;
  31537. /**
  31538. * Binds the frame buffer to the specified texture.
  31539. * @param texture The texture to render to or null for the default canvas
  31540. * @param faceIndex The face of the texture to render to in case of cube texture
  31541. * @param requiredWidth The width of the target to render to
  31542. * @param requiredHeight The height of the target to render to
  31543. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31544. * @param depthStencilTexture The depth stencil texture to use to render
  31545. * @param lodLevel defines le lod level to bind to the frame buffer
  31546. */
  31547. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  31548. /** @hidden */
  31549. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31550. /**
  31551. * Unbind the current render target texture from the webGL context
  31552. * @param texture defines the render target texture to unbind
  31553. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31554. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31555. */
  31556. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31557. /**
  31558. * Force the mipmap generation for the given render target texture
  31559. * @param texture defines the render target texture to use
  31560. */
  31561. generateMipMapsForCubemap(texture: InternalTexture): void;
  31562. /**
  31563. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31564. */
  31565. flushFramebuffer(): void;
  31566. /**
  31567. * Unbind the current render target and bind the default framebuffer
  31568. */
  31569. restoreDefaultFramebuffer(): void;
  31570. /**
  31571. * Create an uniform buffer
  31572. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31573. * @param elements defines the content of the uniform buffer
  31574. * @returns the webGL uniform buffer
  31575. */
  31576. createUniformBuffer(elements: FloatArray): DataBuffer;
  31577. /**
  31578. * Create a dynamic uniform buffer
  31579. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31580. * @param elements defines the content of the uniform buffer
  31581. * @returns the webGL uniform buffer
  31582. */
  31583. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  31584. /**
  31585. * Update an existing uniform buffer
  31586. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31587. * @param uniformBuffer defines the target uniform buffer
  31588. * @param elements defines the content to update
  31589. * @param offset defines the offset in the uniform buffer where update should start
  31590. * @param count defines the size of the data to update
  31591. */
  31592. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  31593. private _resetVertexBufferBinding;
  31594. /**
  31595. * Creates a vertex buffer
  31596. * @param data the data for the vertex buffer
  31597. * @returns the new WebGL static buffer
  31598. */
  31599. createVertexBuffer(data: DataArray): DataBuffer;
  31600. /**
  31601. * Creates a dynamic vertex buffer
  31602. * @param data the data for the dynamic vertex buffer
  31603. * @returns the new WebGL dynamic buffer
  31604. */
  31605. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31606. /**
  31607. * Update a dynamic index buffer
  31608. * @param indexBuffer defines the target index buffer
  31609. * @param indices defines the data to update
  31610. * @param offset defines the offset in the target index buffer where update should start
  31611. */
  31612. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  31613. /**
  31614. * Updates a dynamic vertex buffer.
  31615. * @param vertexBuffer the vertex buffer to update
  31616. * @param data the data used to update the vertex buffer
  31617. * @param byteOffset the byte offset of the data
  31618. * @param byteLength the byte length of the data
  31619. */
  31620. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  31621. private _resetIndexBufferBinding;
  31622. /**
  31623. * Creates a new index buffer
  31624. * @param indices defines the content of the index buffer
  31625. * @param updatable defines if the index buffer must be updatable
  31626. * @returns a new webGL buffer
  31627. */
  31628. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31629. /**
  31630. * Bind a webGL buffer to the webGL context
  31631. * @param buffer defines the buffer to bind
  31632. */
  31633. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31634. /**
  31635. * Bind an uniform buffer to the current webGL context
  31636. * @param buffer defines the buffer to bind
  31637. */
  31638. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  31639. /**
  31640. * Bind a buffer to the current webGL context at a given location
  31641. * @param buffer defines the buffer to bind
  31642. * @param location defines the index where to bind the buffer
  31643. */
  31644. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  31645. /**
  31646. * Bind a specific block at a given index in a specific shader program
  31647. * @param pipelineContext defines the pipeline context to use
  31648. * @param blockName defines the block name
  31649. * @param index defines the index where to bind the block
  31650. */
  31651. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  31652. private bindIndexBuffer;
  31653. private bindBuffer;
  31654. /**
  31655. * update the bound buffer with the given data
  31656. * @param data defines the data to update
  31657. */
  31658. updateArrayBuffer(data: Float32Array): void;
  31659. private _vertexAttribPointer;
  31660. private _bindIndexBufferWithCache;
  31661. private _bindVertexBuffersAttributes;
  31662. /**
  31663. * Records a vertex array object
  31664. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31665. * @param vertexBuffers defines the list of vertex buffers to store
  31666. * @param indexBuffer defines the index buffer to store
  31667. * @param effect defines the effect to store
  31668. * @returns the new vertex array object
  31669. */
  31670. recordVertexArrayObject(vertexBuffers: {
  31671. [key: string]: VertexBuffer;
  31672. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31673. /**
  31674. * Bind a specific vertex array object
  31675. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31676. * @param vertexArrayObject defines the vertex array object to bind
  31677. * @param indexBuffer defines the index buffer to bind
  31678. */
  31679. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31680. /**
  31681. * Bind webGl buffers directly to the webGL context
  31682. * @param vertexBuffer defines the vertex buffer to bind
  31683. * @param indexBuffer defines the index buffer to bind
  31684. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31685. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31686. * @param effect defines the effect associated with the vertex buffer
  31687. */
  31688. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31689. private _unbindVertexArrayObject;
  31690. /**
  31691. * Bind a list of vertex buffers to the webGL context
  31692. * @param vertexBuffers defines the list of vertex buffers to bind
  31693. * @param indexBuffer defines the index buffer to bind
  31694. * @param effect defines the effect associated with the vertex buffers
  31695. */
  31696. bindBuffers(vertexBuffers: {
  31697. [key: string]: Nullable<VertexBuffer>;
  31698. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31699. /**
  31700. * Unbind all instance attributes
  31701. */
  31702. unbindInstanceAttributes(): void;
  31703. /**
  31704. * Release and free the memory of a vertex array object
  31705. * @param vao defines the vertex array object to delete
  31706. */
  31707. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31708. /** @hidden */
  31709. _releaseBuffer(buffer: DataBuffer): boolean;
  31710. /**
  31711. * Creates a webGL buffer to use with instanciation
  31712. * @param capacity defines the size of the buffer
  31713. * @returns the webGL buffer
  31714. */
  31715. createInstancesBuffer(capacity: number): DataBuffer;
  31716. /**
  31717. * Delete a webGL buffer used with instanciation
  31718. * @param buffer defines the webGL buffer to delete
  31719. */
  31720. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  31721. /**
  31722. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31723. * @param instancesBuffer defines the webGL buffer to update and bind
  31724. * @param data defines the data to store in the buffer
  31725. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31726. */
  31727. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31728. /**
  31729. * Apply all cached states (depth, culling, stencil and alpha)
  31730. */
  31731. applyStates(): void;
  31732. /**
  31733. * Send a draw order
  31734. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31735. * @param indexStart defines the starting index
  31736. * @param indexCount defines the number of index to draw
  31737. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31738. */
  31739. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31740. /**
  31741. * Draw a list of points
  31742. * @param verticesStart defines the index of first vertex to draw
  31743. * @param verticesCount defines the count of vertices to draw
  31744. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31745. */
  31746. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31747. /**
  31748. * Draw a list of unindexed primitives
  31749. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31750. * @param verticesStart defines the index of first vertex to draw
  31751. * @param verticesCount defines the count of vertices to draw
  31752. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31753. */
  31754. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31755. /**
  31756. * Draw a list of indexed primitives
  31757. * @param fillMode defines the primitive to use
  31758. * @param indexStart defines the starting index
  31759. * @param indexCount defines the number of index to draw
  31760. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31761. */
  31762. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31763. /**
  31764. * Draw a list of unindexed primitives
  31765. * @param fillMode defines the primitive to use
  31766. * @param verticesStart defines the index of first vertex to draw
  31767. * @param verticesCount defines the count of vertices to draw
  31768. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31769. */
  31770. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31771. private _drawMode;
  31772. /** @hidden */
  31773. _releaseEffect(effect: Effect): void;
  31774. /** @hidden */
  31775. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31776. /**
  31777. * Create a new effect (used to store vertex/fragment shaders)
  31778. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31779. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  31780. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31781. * @param samplers defines an array of string used to represent textures
  31782. * @param defines defines the string containing the defines to use to compile the shaders
  31783. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31784. * @param onCompiled defines a function to call when the effect creation is successful
  31785. * @param onError defines a function to call when the effect creation has failed
  31786. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31787. * @returns the new Effect
  31788. */
  31789. 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;
  31790. private _compileShader;
  31791. private _compileRawShader;
  31792. /**
  31793. * Directly creates a webGL program
  31794. * @param pipelineContext defines the pipeline context to attach to
  31795. * @param vertexCode defines the vertex shader code to use
  31796. * @param fragmentCode defines the fragment shader code to use
  31797. * @param context defines the webGL context to use (if not set, the current one will be used)
  31798. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31799. * @returns the new webGL program
  31800. */
  31801. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31802. /**
  31803. * Creates a webGL program
  31804. * @param pipelineContext defines the pipeline context to attach to
  31805. * @param vertexCode defines the vertex shader code to use
  31806. * @param fragmentCode defines the fragment shader code to use
  31807. * @param defines defines the string containing the defines to use to compile the shaders
  31808. * @param context defines the webGL context to use (if not set, the current one will be used)
  31809. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31810. * @returns the new webGL program
  31811. */
  31812. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31813. /**
  31814. * Creates a new pipeline context
  31815. * @returns the new pipeline
  31816. */
  31817. createPipelineContext(): WebGLPipelineContext;
  31818. private _createShaderProgram;
  31819. private _finalizePipelineContext;
  31820. /** @hidden */
  31821. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31822. /** @hidden */
  31823. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31824. /** @hidden */
  31825. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31826. /**
  31827. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31828. * @param pipelineContext defines the pipeline context to use
  31829. * @param uniformsNames defines the list of uniform names
  31830. * @returns an array of webGL uniform locations
  31831. */
  31832. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31833. /**
  31834. * Gets the lsit of active attributes for a given webGL program
  31835. * @param pipelineContext defines the pipeline context to use
  31836. * @param attributesNames defines the list of attribute names to get
  31837. * @returns an array of indices indicating the offset of each attribute
  31838. */
  31839. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31840. /**
  31841. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31842. * @param effect defines the effect to activate
  31843. */
  31844. enableEffect(effect: Nullable<Effect>): void;
  31845. /**
  31846. * Set the value of an uniform to an array of int32
  31847. * @param uniform defines the webGL uniform location where to store the value
  31848. * @param array defines the array of int32 to store
  31849. */
  31850. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31851. /**
  31852. * Set the value of an uniform to an array of int32 (stored as vec2)
  31853. * @param uniform defines the webGL uniform location where to store the value
  31854. * @param array defines the array of int32 to store
  31855. */
  31856. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31857. /**
  31858. * Set the value of an uniform to an array of int32 (stored as vec3)
  31859. * @param uniform defines the webGL uniform location where to store the value
  31860. * @param array defines the array of int32 to store
  31861. */
  31862. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31863. /**
  31864. * Set the value of an uniform to an array of int32 (stored as vec4)
  31865. * @param uniform defines the webGL uniform location where to store the value
  31866. * @param array defines the array of int32 to store
  31867. */
  31868. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31869. /**
  31870. * Set the value of an uniform to an array of float32
  31871. * @param uniform defines the webGL uniform location where to store the value
  31872. * @param array defines the array of float32 to store
  31873. */
  31874. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31875. /**
  31876. * Set the value of an uniform to an array of float32 (stored as vec2)
  31877. * @param uniform defines the webGL uniform location where to store the value
  31878. * @param array defines the array of float32 to store
  31879. */
  31880. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31881. /**
  31882. * Set the value of an uniform to an array of float32 (stored as vec3)
  31883. * @param uniform defines the webGL uniform location where to store the value
  31884. * @param array defines the array of float32 to store
  31885. */
  31886. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31887. /**
  31888. * Set the value of an uniform to an array of float32 (stored as vec4)
  31889. * @param uniform defines the webGL uniform location where to store the value
  31890. * @param array defines the array of float32 to store
  31891. */
  31892. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31893. /**
  31894. * Set the value of an uniform to an array of number
  31895. * @param uniform defines the webGL uniform location where to store the value
  31896. * @param array defines the array of number to store
  31897. */
  31898. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31899. /**
  31900. * Set the value of an uniform to an array of number (stored as vec2)
  31901. * @param uniform defines the webGL uniform location where to store the value
  31902. * @param array defines the array of number to store
  31903. */
  31904. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31905. /**
  31906. * Set the value of an uniform to an array of number (stored as vec3)
  31907. * @param uniform defines the webGL uniform location where to store the value
  31908. * @param array defines the array of number to store
  31909. */
  31910. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31911. /**
  31912. * Set the value of an uniform to an array of number (stored as vec4)
  31913. * @param uniform defines the webGL uniform location where to store the value
  31914. * @param array defines the array of number to store
  31915. */
  31916. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31917. /**
  31918. * Set the value of an uniform to an array of float32 (stored as matrices)
  31919. * @param uniform defines the webGL uniform location where to store the value
  31920. * @param matrices defines the array of float32 to store
  31921. */
  31922. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31923. /**
  31924. * Set the value of an uniform to a matrix (3x3)
  31925. * @param uniform defines the webGL uniform location where to store the value
  31926. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31927. */
  31928. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31929. /**
  31930. * Set the value of an uniform to a matrix (2x2)
  31931. * @param uniform defines the webGL uniform location where to store the value
  31932. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31933. */
  31934. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31935. /**
  31936. * Set the value of an uniform to a number (int)
  31937. * @param uniform defines the webGL uniform location where to store the value
  31938. * @param value defines the int number to store
  31939. */
  31940. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31941. /**
  31942. * Set the value of an uniform to a number (float)
  31943. * @param uniform defines the webGL uniform location where to store the value
  31944. * @param value defines the float number to store
  31945. */
  31946. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31947. /**
  31948. * Set the value of an uniform to a vec2
  31949. * @param uniform defines the webGL uniform location where to store the value
  31950. * @param x defines the 1st component of the value
  31951. * @param y defines the 2nd component of the value
  31952. */
  31953. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31954. /**
  31955. * Set the value of an uniform to a vec3
  31956. * @param uniform defines the webGL uniform location where to store the value
  31957. * @param x defines the 1st component of the value
  31958. * @param y defines the 2nd component of the value
  31959. * @param z defines the 3rd component of the value
  31960. */
  31961. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31962. /**
  31963. * Set the value of an uniform to a boolean
  31964. * @param uniform defines the webGL uniform location where to store the value
  31965. * @param bool defines the boolean to store
  31966. */
  31967. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  31968. /**
  31969. * Set the value of an uniform to a vec4
  31970. * @param uniform defines the webGL uniform location where to store the value
  31971. * @param x defines the 1st component of the value
  31972. * @param y defines the 2nd component of the value
  31973. * @param z defines the 3rd component of the value
  31974. * @param w defines the 4th component of the value
  31975. */
  31976. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31977. /**
  31978. * Sets a Color4 on a uniform variable
  31979. * @param uniform defines the uniform location
  31980. * @param color4 defines the value to be set
  31981. */
  31982. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  31983. /**
  31984. * Set various states to the webGL context
  31985. * @param culling defines backface culling state
  31986. * @param zOffset defines the value to apply to zOffset (0 by default)
  31987. * @param force defines if states must be applied even if cache is up to date
  31988. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  31989. */
  31990. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  31991. /**
  31992. * Set the z offset to apply to current rendering
  31993. * @param value defines the offset to apply
  31994. */
  31995. setZOffset(value: number): void;
  31996. /**
  31997. * Gets the current value of the zOffset
  31998. * @returns the current zOffset state
  31999. */
  32000. getZOffset(): number;
  32001. /**
  32002. * Enable or disable depth buffering
  32003. * @param enable defines the state to set
  32004. */
  32005. setDepthBuffer(enable: boolean): void;
  32006. /**
  32007. * Gets a boolean indicating if depth writing is enabled
  32008. * @returns the current depth writing state
  32009. */
  32010. getDepthWrite(): boolean;
  32011. /**
  32012. * Enable or disable depth writing
  32013. * @param enable defines the state to set
  32014. */
  32015. setDepthWrite(enable: boolean): void;
  32016. /**
  32017. * Enable or disable color writing
  32018. * @param enable defines the state to set
  32019. */
  32020. setColorWrite(enable: boolean): void;
  32021. /**
  32022. * Gets a boolean indicating if color writing is enabled
  32023. * @returns the current color writing state
  32024. */
  32025. getColorWrite(): boolean;
  32026. /**
  32027. * Sets alpha constants used by some alpha blending modes
  32028. * @param r defines the red component
  32029. * @param g defines the green component
  32030. * @param b defines the blue component
  32031. * @param a defines the alpha component
  32032. */
  32033. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32034. /**
  32035. * Sets the current alpha mode
  32036. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32037. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32038. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32039. */
  32040. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32041. /**
  32042. * Gets the current alpha mode
  32043. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32044. * @returns the current alpha mode
  32045. */
  32046. getAlphaMode(): number;
  32047. /**
  32048. * Clears the list of texture accessible through engine.
  32049. * This can help preventing texture load conflict due to name collision.
  32050. */
  32051. clearInternalTexturesCache(): void;
  32052. /**
  32053. * Force the entire cache to be cleared
  32054. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32055. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32056. */
  32057. wipeCaches(bruteForce?: boolean): void;
  32058. /**
  32059. * Set the compressed texture format to use, based on the formats you have, and the formats
  32060. * supported by the hardware / browser.
  32061. *
  32062. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  32063. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  32064. * to API arguments needed to compressed textures. This puts the burden on the container
  32065. * generator to house the arcane code for determining these for current & future formats.
  32066. *
  32067. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  32068. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  32069. *
  32070. * Note: The result of this call is not taken into account when a texture is base64.
  32071. *
  32072. * @param formatsAvailable defines the list of those format families you have created
  32073. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  32074. *
  32075. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  32076. * @returns The extension selected.
  32077. */
  32078. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  32079. /** @hidden */
  32080. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32081. min: number;
  32082. mag: number;
  32083. };
  32084. /** @hidden */
  32085. _createTexture(): WebGLTexture;
  32086. /**
  32087. * Usually called from Texture.ts.
  32088. * Passed information to create a WebGLTexture
  32089. * @param urlArg defines a value which contains one of the following:
  32090. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32091. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32092. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32093. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32094. * @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)
  32095. * @param scene needed for loading to the correct scene
  32096. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32097. * @param onLoad optional callback to be called upon successful completion
  32098. * @param onError optional callback to be called upon failure
  32099. * @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
  32100. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32101. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32102. * @param forcedExtension defines the extension to use to pick the right loader
  32103. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  32104. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32105. */
  32106. 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;
  32107. /**
  32108. * @hidden
  32109. * Rescales a texture
  32110. * @param source input texutre
  32111. * @param destination destination texture
  32112. * @param scene scene to use to render the resize
  32113. * @param internalFormat format to use when resizing
  32114. * @param onComplete callback to be called when resize has completed
  32115. */
  32116. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  32117. private _unpackFlipYCached;
  32118. /**
  32119. * In case you are sharing the context with other applications, it might
  32120. * be interested to not cache the unpack flip y state to ensure a consistent
  32121. * value would be set.
  32122. */
  32123. enableUnpackFlipYCached: boolean;
  32124. /** @hidden */
  32125. _unpackFlipY(value: boolean): void;
  32126. /** @hidden */
  32127. _getUnpackAlignement(): number;
  32128. /**
  32129. * Creates a dynamic texture
  32130. * @param width defines the width of the texture
  32131. * @param height defines the height of the texture
  32132. * @param generateMipMaps defines if the engine should generate the mip levels
  32133. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32134. * @returns the dynamic texture inside an InternalTexture
  32135. */
  32136. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  32137. /**
  32138. * Update the sampling mode of a given texture
  32139. * @param samplingMode defines the required sampling mode
  32140. * @param texture defines the texture to update
  32141. */
  32142. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  32143. /**
  32144. * Update the content of a dynamic texture
  32145. * @param texture defines the texture to update
  32146. * @param canvas defines the canvas containing the source
  32147. * @param invertY defines if data must be stored with Y axis inverted
  32148. * @param premulAlpha defines if alpha is stored as premultiplied
  32149. * @param format defines the format of the data
  32150. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  32151. */
  32152. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  32153. /**
  32154. * Update a video texture
  32155. * @param texture defines the texture to update
  32156. * @param video defines the video element to use
  32157. * @param invertY defines if data must be stored with Y axis inverted
  32158. */
  32159. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  32160. /**
  32161. * Updates a depth texture Comparison Mode and Function.
  32162. * If the comparison Function is equal to 0, the mode will be set to none.
  32163. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  32164. * @param texture The texture to set the comparison function for
  32165. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  32166. */
  32167. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  32168. /** @hidden */
  32169. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32170. width: number;
  32171. height: number;
  32172. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32173. /**
  32174. * Creates a depth stencil texture.
  32175. * This is only available in WebGL 2 or with the depth texture extension available.
  32176. * @param size The size of face edge in the texture.
  32177. * @param options The options defining the texture.
  32178. * @returns The texture
  32179. */
  32180. createDepthStencilTexture(size: number | {
  32181. width: number;
  32182. height: number;
  32183. }, options: DepthTextureCreationOptions): InternalTexture;
  32184. /**
  32185. * Creates a depth stencil texture.
  32186. * This is only available in WebGL 2 or with the depth texture extension available.
  32187. * @param size The size of face edge in the texture.
  32188. * @param options The options defining the texture.
  32189. * @returns The texture
  32190. */
  32191. private _createDepthStencilTexture;
  32192. /**
  32193. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  32194. * @param renderTarget The render target to set the frame buffer for
  32195. */
  32196. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  32197. /**
  32198. * Creates a new render target texture
  32199. * @param size defines the size of the texture
  32200. * @param options defines the options used to create the texture
  32201. * @returns a new render target texture stored in an InternalTexture
  32202. */
  32203. createRenderTargetTexture(size: number | {
  32204. width: number;
  32205. height: number;
  32206. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  32207. /** @hidden */
  32208. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32209. /**
  32210. * Updates the sample count of a render target texture
  32211. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32212. * @param texture defines the texture to update
  32213. * @param samples defines the sample count to set
  32214. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32215. */
  32216. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  32217. /** @hidden */
  32218. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32219. /** @hidden */
  32220. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32221. /** @hidden */
  32222. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32223. /** @hidden */
  32224. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  32225. /**
  32226. * @hidden
  32227. */
  32228. _setCubeMapTextureParams(loadMipmap: boolean): void;
  32229. private _prepareWebGLTextureContinuation;
  32230. private _prepareWebGLTexture;
  32231. /** @hidden */
  32232. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32233. /** @hidden */
  32234. _releaseFramebufferObjects(texture: InternalTexture): void;
  32235. /** @hidden */
  32236. _releaseTexture(texture: InternalTexture): void;
  32237. private setProgram;
  32238. private _boundUniforms;
  32239. /**
  32240. * Binds an effect to the webGL context
  32241. * @param effect defines the effect to bind
  32242. */
  32243. bindSamplers(effect: Effect): void;
  32244. private _activateCurrentTexture;
  32245. /** @hidden */
  32246. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32247. /** @hidden */
  32248. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32249. /**
  32250. * Sets a texture to the webGL context from a postprocess
  32251. * @param channel defines the channel to use
  32252. * @param postProcess defines the source postprocess
  32253. */
  32254. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32255. /**
  32256. * Binds the output of the passed in post process to the texture channel specified
  32257. * @param channel The channel the texture should be bound to
  32258. * @param postProcess The post process which's output should be bound
  32259. */
  32260. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32261. /**
  32262. * Unbind all textures from the webGL context
  32263. */
  32264. unbindAllTextures(): void;
  32265. /**
  32266. * Sets a texture to the according uniform.
  32267. * @param channel The texture channel
  32268. * @param uniform The uniform to set
  32269. * @param texture The texture to apply
  32270. */
  32271. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32272. /**
  32273. * Sets a depth stencil texture from a render target to the according uniform.
  32274. * @param channel The texture channel
  32275. * @param uniform The uniform to set
  32276. * @param texture The render target texture containing the depth stencil texture to apply
  32277. */
  32278. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32279. private _bindSamplerUniformToChannel;
  32280. private _getTextureWrapMode;
  32281. private _setTexture;
  32282. /**
  32283. * Sets an array of texture to the webGL context
  32284. * @param channel defines the channel where the texture array must be set
  32285. * @param uniform defines the associated uniform location
  32286. * @param textures defines the array of textures to bind
  32287. */
  32288. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32289. /** @hidden */
  32290. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  32291. private _setTextureParameterFloat;
  32292. private _setTextureParameterInteger;
  32293. /**
  32294. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32295. * @param x defines the x coordinate of the rectangle where pixels must be read
  32296. * @param y defines the y coordinate of the rectangle where pixels must be read
  32297. * @param width defines the width of the rectangle where pixels must be read
  32298. * @param height defines the height of the rectangle where pixels must be read
  32299. * @returns a Uint8Array containing RGBA colors
  32300. */
  32301. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32302. /**
  32303. * Add an externaly attached data from its key.
  32304. * This method call will fail and return false, if such key already exists.
  32305. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  32306. * @param key the unique key that identifies the data
  32307. * @param data the data object to associate to the key for this Engine instance
  32308. * @return true if no such key were already present and the data was added successfully, false otherwise
  32309. */
  32310. addExternalData<T>(key: string, data: T): boolean;
  32311. /**
  32312. * Get an externaly attached data from its key
  32313. * @param key the unique key that identifies the data
  32314. * @return the associated data, if present (can be null), or undefined if not present
  32315. */
  32316. getExternalData<T>(key: string): T;
  32317. /**
  32318. * Get an externaly attached data from its key, create it using a factory if it's not already present
  32319. * @param key the unique key that identifies the data
  32320. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  32321. * @return the associated data, can be null if the factory returned null.
  32322. */
  32323. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  32324. /**
  32325. * Remove an externaly attached data from the Engine instance
  32326. * @param key the unique key that identifies the data
  32327. * @return true if the data was successfully removed, false if it doesn't exist
  32328. */
  32329. removeExternalData(key: string): boolean;
  32330. /**
  32331. * Unbind all vertex attributes from the webGL context
  32332. */
  32333. unbindAllAttributes(): void;
  32334. /**
  32335. * 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
  32336. */
  32337. releaseEffects(): void;
  32338. /**
  32339. * Dispose and release all associated resources
  32340. */
  32341. dispose(): void;
  32342. /**
  32343. * Display the loading screen
  32344. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32345. */
  32346. displayLoadingUI(): void;
  32347. /**
  32348. * Hide the loading screen
  32349. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32350. */
  32351. hideLoadingUI(): void;
  32352. /**
  32353. * Gets the current loading screen object
  32354. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32355. */
  32356. /**
  32357. * Sets the current loading screen object
  32358. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32359. */
  32360. loadingScreen: ILoadingScreen;
  32361. /**
  32362. * Sets the current loading screen text
  32363. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32364. */
  32365. loadingUIText: string;
  32366. /**
  32367. * Sets the current loading screen background color
  32368. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32369. */
  32370. loadingUIBackgroundColor: string;
  32371. /**
  32372. * Attach a new callback raised when context lost event is fired
  32373. * @param callback defines the callback to call
  32374. */
  32375. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32376. /**
  32377. * Attach a new callback raised when context restored event is fired
  32378. * @param callback defines the callback to call
  32379. */
  32380. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32381. /**
  32382. * Gets the source code of the vertex shader associated with a specific webGL program
  32383. * @param program defines the program to use
  32384. * @returns a string containing the source code of the vertex shader associated with the program
  32385. */
  32386. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32387. /**
  32388. * Gets the source code of the fragment shader associated with a specific webGL program
  32389. * @param program defines the program to use
  32390. * @returns a string containing the source code of the fragment shader associated with the program
  32391. */
  32392. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32393. /**
  32394. * Get the current error code of the webGL context
  32395. * @returns the error code
  32396. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32397. */
  32398. getError(): number;
  32399. /**
  32400. * Gets the current framerate
  32401. * @returns a number representing the framerate
  32402. */
  32403. getFps(): number;
  32404. /**
  32405. * Gets the time spent between current and previous frame
  32406. * @returns a number representing the delta time in ms
  32407. */
  32408. getDeltaTime(): number;
  32409. private _measureFps;
  32410. /** @hidden */
  32411. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  32412. private _canRenderToFloatFramebuffer;
  32413. private _canRenderToHalfFloatFramebuffer;
  32414. private _canRenderToFramebuffer;
  32415. /** @hidden */
  32416. _getWebGLTextureType(type: number): number;
  32417. /** @hidden */
  32418. _getInternalFormat(format: number): number;
  32419. /** @hidden */
  32420. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32421. /** @hidden */
  32422. _getRGBAMultiSampleBufferFormat(type: number): number;
  32423. /** @hidden */
  32424. _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;
  32425. /** @hidden */
  32426. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32427. /**
  32428. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32429. * @returns true if the engine can be created
  32430. * @ignorenaming
  32431. */
  32432. static isSupported(): boolean;
  32433. /**
  32434. * Find the next highest power of two.
  32435. * @param x Number to start search from.
  32436. * @return Next highest power of two.
  32437. */
  32438. static CeilingPOT(x: number): number;
  32439. /**
  32440. * Find the next lowest power of two.
  32441. * @param x Number to start search from.
  32442. * @return Next lowest power of two.
  32443. */
  32444. static FloorPOT(x: number): number;
  32445. /**
  32446. * Find the nearest power of two.
  32447. * @param x Number to start search from.
  32448. * @return Next nearest power of two.
  32449. */
  32450. static NearestPOT(x: number): number;
  32451. /**
  32452. * Get the closest exponent of two
  32453. * @param value defines the value to approximate
  32454. * @param max defines the maximum value to return
  32455. * @param mode defines how to define the closest value
  32456. * @returns closest exponent of two of the given value
  32457. */
  32458. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32459. /**
  32460. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32461. * @param func - the function to be called
  32462. * @param requester - the object that will request the next frame. Falls back to window.
  32463. * @returns frame number
  32464. */
  32465. static QueueNewFrame(func: () => void, requester?: any): number;
  32466. /**
  32467. * Ask the browser to promote the current element to pointerlock mode
  32468. * @param element defines the DOM element to promote
  32469. */
  32470. static _RequestPointerlock(element: HTMLElement): void;
  32471. /**
  32472. * Asks the browser to exit pointerlock mode
  32473. */
  32474. static _ExitPointerlock(): void;
  32475. /**
  32476. * Ask the browser to promote the current element to fullscreen rendering mode
  32477. * @param element defines the DOM element to promote
  32478. */
  32479. static _RequestFullscreen(element: HTMLElement): void;
  32480. /**
  32481. * Asks the browser to exit fullscreen mode
  32482. */
  32483. static _ExitFullscreen(): void;
  32484. }
  32485. }
  32486. declare module "babylonjs/Engines/engineStore" {
  32487. import { Nullable } from "babylonjs/types";
  32488. import { Engine } from "babylonjs/Engines/engine";
  32489. import { Scene } from "babylonjs/scene";
  32490. /**
  32491. * The engine store class is responsible to hold all the instances of Engine and Scene created
  32492. * during the life time of the application.
  32493. */
  32494. export class EngineStore {
  32495. /** Gets the list of created engines */
  32496. static Instances: import("babylonjs/Engines/engine").Engine[];
  32497. /** @hidden */
  32498. static _LastCreatedScene: Nullable<Scene>;
  32499. /**
  32500. * Gets the latest created engine
  32501. */
  32502. static readonly LastCreatedEngine: Nullable<Engine>;
  32503. /**
  32504. * Gets the latest created scene
  32505. */
  32506. static readonly LastCreatedScene: Nullable<Scene>;
  32507. /**
  32508. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32509. * @ignorenaming
  32510. */
  32511. static UseFallbackTexture: boolean;
  32512. /**
  32513. * Texture content used if a texture cannot loaded
  32514. * @ignorenaming
  32515. */
  32516. static FallbackTexture: string;
  32517. }
  32518. }
  32519. declare module "babylonjs/Misc/promise" {
  32520. /**
  32521. * Helper class that provides a small promise polyfill
  32522. */
  32523. export class PromisePolyfill {
  32524. /**
  32525. * Static function used to check if the polyfill is required
  32526. * If this is the case then the function will inject the polyfill to window.Promise
  32527. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  32528. */
  32529. static Apply(force?: boolean): void;
  32530. }
  32531. }
  32532. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  32533. /**
  32534. * Interface for screenshot methods with describe argument called `size` as object with options
  32535. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  32536. */
  32537. export interface IScreenshotSize {
  32538. /**
  32539. * number in pixels for canvas height
  32540. */
  32541. height?: number;
  32542. /**
  32543. * multiplier allowing render at a higher or lower resolution
  32544. * If value is defined then height and width will be ignored and taken from camera
  32545. */
  32546. precision?: number;
  32547. /**
  32548. * number in pixels for canvas width
  32549. */
  32550. width?: number;
  32551. }
  32552. }
  32553. declare module "babylonjs/Misc/tools" {
  32554. import { Nullable, float } from "babylonjs/types";
  32555. import { DomManagement } from "babylonjs/Misc/domManagement";
  32556. import { WebRequest } from "babylonjs/Misc/webRequest";
  32557. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32558. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32559. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  32560. import { Camera } from "babylonjs/Cameras/camera";
  32561. import { Engine } from "babylonjs/Engines/engine";
  32562. interface IColor4Like {
  32563. r: float;
  32564. g: float;
  32565. b: float;
  32566. a: float;
  32567. }
  32568. /**
  32569. * Class containing a set of static utilities functions
  32570. */
  32571. export class Tools {
  32572. /**
  32573. * Gets or sets the base URL to use to load assets
  32574. */
  32575. static BaseUrl: string;
  32576. /**
  32577. * Enable/Disable Custom HTTP Request Headers globally.
  32578. * default = false
  32579. * @see CustomRequestHeaders
  32580. */
  32581. static UseCustomRequestHeaders: boolean;
  32582. /**
  32583. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32584. * i.e. when loading files, where the server/service expects an Authorization header
  32585. */
  32586. static CustomRequestHeaders: {
  32587. [key: string]: string;
  32588. };
  32589. /**
  32590. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32591. */
  32592. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  32593. /**
  32594. * Default behaviour for cors in the application.
  32595. * It can be a string if the expected behavior is identical in the entire app.
  32596. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32597. */
  32598. static CorsBehavior: string | ((url: string | string[]) => string);
  32599. /**
  32600. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32601. * @ignorenaming
  32602. */
  32603. static UseFallbackTexture: boolean;
  32604. /**
  32605. * Use this object to register external classes like custom textures or material
  32606. * to allow the laoders to instantiate them
  32607. */
  32608. static RegisteredExternalClasses: {
  32609. [key: string]: Object;
  32610. };
  32611. /**
  32612. * Texture content used if a texture cannot loaded
  32613. * @ignorenaming
  32614. */
  32615. static fallbackTexture: string;
  32616. /**
  32617. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32618. * @param u defines the coordinate on X axis
  32619. * @param v defines the coordinate on Y axis
  32620. * @param width defines the width of the source data
  32621. * @param height defines the height of the source data
  32622. * @param pixels defines the source byte array
  32623. * @param color defines the output color
  32624. */
  32625. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  32626. /**
  32627. * Interpolates between a and b via alpha
  32628. * @param a The lower value (returned when alpha = 0)
  32629. * @param b The upper value (returned when alpha = 1)
  32630. * @param alpha The interpolation-factor
  32631. * @return The mixed value
  32632. */
  32633. static Mix(a: number, b: number, alpha: number): number;
  32634. /**
  32635. * Tries to instantiate a new object from a given class name
  32636. * @param className defines the class name to instantiate
  32637. * @returns the new object or null if the system was not able to do the instantiation
  32638. */
  32639. static Instantiate(className: string): any;
  32640. /**
  32641. * Provides a slice function that will work even on IE
  32642. * @param data defines the array to slice
  32643. * @param start defines the start of the data (optional)
  32644. * @param end defines the end of the data (optional)
  32645. * @returns the new sliced array
  32646. */
  32647. static Slice<T>(data: T, start?: number, end?: number): T;
  32648. /**
  32649. * Polyfill for setImmediate
  32650. * @param action defines the action to execute after the current execution block
  32651. */
  32652. static SetImmediate(action: () => void): void;
  32653. /**
  32654. * Function indicating if a number is an exponent of 2
  32655. * @param value defines the value to test
  32656. * @returns true if the value is an exponent of 2
  32657. */
  32658. static IsExponentOfTwo(value: number): boolean;
  32659. private static _tmpFloatArray;
  32660. /**
  32661. * Returns the nearest 32-bit single precision float representation of a Number
  32662. * @param value A Number. If the parameter is of a different type, it will get converted
  32663. * to a number or to NaN if it cannot be converted
  32664. * @returns number
  32665. */
  32666. static FloatRound(value: number): number;
  32667. /**
  32668. * Extracts the filename from a path
  32669. * @param path defines the path to use
  32670. * @returns the filename
  32671. */
  32672. static GetFilename(path: string): string;
  32673. /**
  32674. * Extracts the "folder" part of a path (everything before the filename).
  32675. * @param uri The URI to extract the info from
  32676. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32677. * @returns The "folder" part of the path
  32678. */
  32679. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32680. /**
  32681. * Extracts text content from a DOM element hierarchy
  32682. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32683. */
  32684. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32685. /**
  32686. * Convert an angle in radians to degrees
  32687. * @param angle defines the angle to convert
  32688. * @returns the angle in degrees
  32689. */
  32690. static ToDegrees(angle: number): number;
  32691. /**
  32692. * Convert an angle in degrees to radians
  32693. * @param angle defines the angle to convert
  32694. * @returns the angle in radians
  32695. */
  32696. static ToRadians(angle: number): number;
  32697. /**
  32698. * Encode a buffer to a base64 string
  32699. * @param buffer defines the buffer to encode
  32700. * @returns the encoded string
  32701. */
  32702. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32703. /**
  32704. * Returns an array if obj is not an array
  32705. * @param obj defines the object to evaluate as an array
  32706. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32707. * @returns either obj directly if obj is an array or a new array containing obj
  32708. */
  32709. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32710. /**
  32711. * Gets the pointer prefix to use
  32712. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32713. */
  32714. static GetPointerPrefix(): string;
  32715. /**
  32716. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32717. * @param url define the url we are trying
  32718. * @param element define the dom element where to configure the cors policy
  32719. */
  32720. static SetCorsBehavior(url: string | string[], element: {
  32721. crossOrigin: string | null;
  32722. }): void;
  32723. /**
  32724. * Removes unwanted characters from an url
  32725. * @param url defines the url to clean
  32726. * @returns the cleaned url
  32727. */
  32728. static CleanUrl(url: string): string;
  32729. /**
  32730. * Gets or sets a function used to pre-process url before using them to load assets
  32731. */
  32732. static PreprocessUrl: (url: string) => string;
  32733. /**
  32734. * Loads an image as an HTMLImageElement.
  32735. * @param input url string, ArrayBuffer, or Blob to load
  32736. * @param onLoad callback called when the image successfully loads
  32737. * @param onError callback called when the image fails to load
  32738. * @param offlineProvider offline provider for caching
  32739. * @returns the HTMLImageElement of the loaded image
  32740. */
  32741. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32742. /**
  32743. * Loads a file
  32744. * @param url url string, ArrayBuffer, or Blob to load
  32745. * @param onSuccess callback called when the file successfully loads
  32746. * @param onProgress callback called while file is loading (if the server supports this mode)
  32747. * @param offlineProvider defines the offline provider for caching
  32748. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32749. * @param onError callback called when the file fails to load
  32750. * @returns a file request object
  32751. */
  32752. 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;
  32753. /**
  32754. * Loads a file from a url
  32755. * @param url the file url to load
  32756. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32757. */
  32758. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32759. /**
  32760. * Load a script (identified by an url). When the url returns, the
  32761. * content of this file is added into a new script element, attached to the DOM (body element)
  32762. * @param scriptUrl defines the url of the script to laod
  32763. * @param onSuccess defines the callback called when the script is loaded
  32764. * @param onError defines the callback to call if an error occurs
  32765. * @param scriptId defines the id of the script element
  32766. */
  32767. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32768. /**
  32769. * Load an asynchronous script (identified by an url). When the url returns, the
  32770. * content of this file is added into a new script element, attached to the DOM (body element)
  32771. * @param scriptUrl defines the url of the script to laod
  32772. * @param scriptId defines the id of the script element
  32773. * @returns a promise request object
  32774. */
  32775. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32776. /**
  32777. * Loads a file from a blob
  32778. * @param fileToLoad defines the blob to use
  32779. * @param callback defines the callback to call when data is loaded
  32780. * @param progressCallback defines the callback to call during loading process
  32781. * @returns a file request object
  32782. */
  32783. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32784. /**
  32785. * Loads a file
  32786. * @param fileToLoad defines the file to load
  32787. * @param callback defines the callback to call when data is loaded
  32788. * @param progressCallBack defines the callback to call during loading process
  32789. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32790. * @returns a file request object
  32791. */
  32792. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32793. /**
  32794. * Creates a data url from a given string content
  32795. * @param content defines the content to convert
  32796. * @returns the new data url link
  32797. */
  32798. static FileAsURL(content: string): string;
  32799. /**
  32800. * Format the given number to a specific decimal format
  32801. * @param value defines the number to format
  32802. * @param decimals defines the number of decimals to use
  32803. * @returns the formatted string
  32804. */
  32805. static Format(value: number, decimals?: number): string;
  32806. /**
  32807. * Tries to copy an object by duplicating every property
  32808. * @param source defines the source object
  32809. * @param destination defines the target object
  32810. * @param doNotCopyList defines a list of properties to avoid
  32811. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32812. */
  32813. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32814. /**
  32815. * Gets a boolean indicating if the given object has no own property
  32816. * @param obj defines the object to test
  32817. * @returns true if object has no own property
  32818. */
  32819. static IsEmpty(obj: any): boolean;
  32820. /**
  32821. * Function used to register events at window level
  32822. * @param windowElement defines the Window object to use
  32823. * @param events defines the events to register
  32824. */
  32825. static RegisterTopRootEvents(windowElement: Window, events: {
  32826. name: string;
  32827. handler: Nullable<(e: FocusEvent) => any>;
  32828. }[]): void;
  32829. /**
  32830. * Function used to unregister events from window level
  32831. * @param windowElement defines the Window object to use
  32832. * @param events defines the events to unregister
  32833. */
  32834. static UnregisterTopRootEvents(windowElement: Window, events: {
  32835. name: string;
  32836. handler: Nullable<(e: FocusEvent) => any>;
  32837. }[]): void;
  32838. /**
  32839. * @ignore
  32840. */
  32841. static _ScreenshotCanvas: HTMLCanvasElement;
  32842. /**
  32843. * Dumps the current bound framebuffer
  32844. * @param width defines the rendering width
  32845. * @param height defines the rendering height
  32846. * @param engine defines the hosting engine
  32847. * @param successCallback defines the callback triggered once the data are available
  32848. * @param mimeType defines the mime type of the result
  32849. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32850. */
  32851. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32852. /**
  32853. * Converts the canvas data to blob.
  32854. * This acts as a polyfill for browsers not supporting the to blob function.
  32855. * @param canvas Defines the canvas to extract the data from
  32856. * @param successCallback Defines the callback triggered once the data are available
  32857. * @param mimeType Defines the mime type of the result
  32858. */
  32859. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32860. /**
  32861. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32862. * @param successCallback defines the callback triggered once the data are available
  32863. * @param mimeType defines the mime type of the result
  32864. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32865. */
  32866. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32867. /**
  32868. * Downloads a blob in the browser
  32869. * @param blob defines the blob to download
  32870. * @param fileName defines the name of the downloaded file
  32871. */
  32872. static Download(blob: Blob, fileName: string): void;
  32873. /**
  32874. * Captures a screenshot of the current rendering
  32875. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32876. * @param engine defines the rendering engine
  32877. * @param camera defines the source camera
  32878. * @param size This parameter can be set to a single number or to an object with the
  32879. * following (optional) properties: precision, width, height. If a single number is passed,
  32880. * it will be used for both width and height. If an object is passed, the screenshot size
  32881. * will be derived from the parameters. The precision property is a multiplier allowing
  32882. * rendering at a higher or lower resolution
  32883. * @param successCallback defines the callback receives a single parameter which contains the
  32884. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32885. * src parameter of an <img> to display it
  32886. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32887. * Check your browser for supported MIME types
  32888. */
  32889. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  32890. /**
  32891. * Captures a screenshot of the current rendering
  32892. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32893. * @param engine defines the rendering engine
  32894. * @param camera defines the source camera
  32895. * @param size This parameter can be set to a single number or to an object with the
  32896. * following (optional) properties: precision, width, height. If a single number is passed,
  32897. * it will be used for both width and height. If an object is passed, the screenshot size
  32898. * will be derived from the parameters. The precision property is a multiplier allowing
  32899. * rendering at a higher or lower resolution
  32900. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32901. * Check your browser for supported MIME types
  32902. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32903. * to the src parameter of an <img> to display it
  32904. */
  32905. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  32906. /**
  32907. * Generates an image screenshot from the specified camera.
  32908. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32909. * @param engine The engine to use for rendering
  32910. * @param camera The camera to use for rendering
  32911. * @param size This parameter can be set to a single number or to an object with the
  32912. * following (optional) properties: precision, width, height. If a single number is passed,
  32913. * it will be used for both width and height. If an object is passed, the screenshot size
  32914. * will be derived from the parameters. The precision property is a multiplier allowing
  32915. * rendering at a higher or lower resolution
  32916. * @param successCallback The callback receives a single parameter which contains the
  32917. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32918. * src parameter of an <img> to display it
  32919. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32920. * Check your browser for supported MIME types
  32921. * @param samples Texture samples (default: 1)
  32922. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32923. * @param fileName A name for for the downloaded file.
  32924. */
  32925. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32926. /**
  32927. * Generates an image screenshot from the specified camera.
  32928. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32929. * @param engine The engine to use for rendering
  32930. * @param camera The camera to use for rendering
  32931. * @param size This parameter can be set to a single number or to an object with the
  32932. * following (optional) properties: precision, width, height. If a single number is passed,
  32933. * it will be used for both width and height. If an object is passed, the screenshot size
  32934. * will be derived from the parameters. The precision property is a multiplier allowing
  32935. * rendering at a higher or lower resolution
  32936. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32937. * Check your browser for supported MIME types
  32938. * @param samples Texture samples (default: 1)
  32939. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32940. * @param fileName A name for for the downloaded file.
  32941. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32942. * to the src parameter of an <img> to display it
  32943. */
  32944. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  32945. /**
  32946. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32947. * Be aware Math.random() could cause collisions, but:
  32948. * "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"
  32949. * @returns a pseudo random id
  32950. */
  32951. static RandomId(): string;
  32952. /**
  32953. * Test if the given uri is a base64 string
  32954. * @param uri The uri to test
  32955. * @return True if the uri is a base64 string or false otherwise
  32956. */
  32957. static IsBase64(uri: string): boolean;
  32958. /**
  32959. * Decode the given base64 uri.
  32960. * @param uri The uri to decode
  32961. * @return The decoded base64 data.
  32962. */
  32963. static DecodeBase64(uri: string): ArrayBuffer;
  32964. /**
  32965. * Gets the absolute url.
  32966. * @param url the input url
  32967. * @return the absolute url
  32968. */
  32969. static GetAbsoluteUrl(url: string): string;
  32970. /**
  32971. * No log
  32972. */
  32973. static readonly NoneLogLevel: number;
  32974. /**
  32975. * Only message logs
  32976. */
  32977. static readonly MessageLogLevel: number;
  32978. /**
  32979. * Only warning logs
  32980. */
  32981. static readonly WarningLogLevel: number;
  32982. /**
  32983. * Only error logs
  32984. */
  32985. static readonly ErrorLogLevel: number;
  32986. /**
  32987. * All logs
  32988. */
  32989. static readonly AllLogLevel: number;
  32990. /**
  32991. * Gets a value indicating the number of loading errors
  32992. * @ignorenaming
  32993. */
  32994. static readonly errorsCount: number;
  32995. /**
  32996. * Callback called when a new log is added
  32997. */
  32998. static OnNewCacheEntry: (entry: string) => void;
  32999. /**
  33000. * Log a message to the console
  33001. * @param message defines the message to log
  33002. */
  33003. static Log(message: string): void;
  33004. /**
  33005. * Write a warning message to the console
  33006. * @param message defines the message to log
  33007. */
  33008. static Warn(message: string): void;
  33009. /**
  33010. * Write an error message to the console
  33011. * @param message defines the message to log
  33012. */
  33013. static Error(message: string): void;
  33014. /**
  33015. * Gets current log cache (list of logs)
  33016. */
  33017. static readonly LogCache: string;
  33018. /**
  33019. * Clears the log cache
  33020. */
  33021. static ClearLogCache(): void;
  33022. /**
  33023. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  33024. */
  33025. static LogLevels: number;
  33026. /**
  33027. * Checks if the window object exists
  33028. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  33029. */
  33030. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  33031. /**
  33032. * No performance log
  33033. */
  33034. static readonly PerformanceNoneLogLevel: number;
  33035. /**
  33036. * Use user marks to log performance
  33037. */
  33038. static readonly PerformanceUserMarkLogLevel: number;
  33039. /**
  33040. * Log performance to the console
  33041. */
  33042. static readonly PerformanceConsoleLogLevel: number;
  33043. private static _performance;
  33044. /**
  33045. * Sets the current performance log level
  33046. */
  33047. static PerformanceLogLevel: number;
  33048. private static _StartPerformanceCounterDisabled;
  33049. private static _EndPerformanceCounterDisabled;
  33050. private static _StartUserMark;
  33051. private static _EndUserMark;
  33052. private static _StartPerformanceConsole;
  33053. private static _EndPerformanceConsole;
  33054. /**
  33055. * Starts a performance counter
  33056. */
  33057. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33058. /**
  33059. * Ends a specific performance coutner
  33060. */
  33061. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33062. /**
  33063. * Gets either window.performance.now() if supported or Date.now() else
  33064. */
  33065. static readonly Now: number;
  33066. /**
  33067. * This method will return the name of the class used to create the instance of the given object.
  33068. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  33069. * @param object the object to get the class name from
  33070. * @param isType defines if the object is actually a type
  33071. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33072. */
  33073. static GetClassName(object: any, isType?: boolean): string;
  33074. /**
  33075. * Gets the first element of an array satisfying a given predicate
  33076. * @param array defines the array to browse
  33077. * @param predicate defines the predicate to use
  33078. * @returns null if not found or the element
  33079. */
  33080. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33081. /**
  33082. * This method will return the name of the full name of the class, including its owning module (if any).
  33083. * 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).
  33084. * @param object the object to get the class name from
  33085. * @param isType defines if the object is actually a type
  33086. * @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.
  33087. * @ignorenaming
  33088. */
  33089. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33090. /**
  33091. * Returns a promise that resolves after the given amount of time.
  33092. * @param delay Number of milliseconds to delay
  33093. * @returns Promise that resolves after the given amount of time
  33094. */
  33095. static DelayAsync(delay: number): Promise<void>;
  33096. }
  33097. /**
  33098. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33099. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33100. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33101. * @param name The name of the class, case should be preserved
  33102. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33103. */
  33104. export function className(name: string, module?: string): (target: Object) => void;
  33105. /**
  33106. * An implementation of a loop for asynchronous functions.
  33107. */
  33108. export class AsyncLoop {
  33109. /**
  33110. * Defines the number of iterations for the loop
  33111. */
  33112. iterations: number;
  33113. /**
  33114. * Defines the current index of the loop.
  33115. */
  33116. index: number;
  33117. private _done;
  33118. private _fn;
  33119. private _successCallback;
  33120. /**
  33121. * Constructor.
  33122. * @param iterations the number of iterations.
  33123. * @param func the function to run each iteration
  33124. * @param successCallback the callback that will be called upon succesful execution
  33125. * @param offset starting offset.
  33126. */
  33127. constructor(
  33128. /**
  33129. * Defines the number of iterations for the loop
  33130. */
  33131. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33132. /**
  33133. * Execute the next iteration. Must be called after the last iteration was finished.
  33134. */
  33135. executeNext(): void;
  33136. /**
  33137. * Break the loop and run the success callback.
  33138. */
  33139. breakLoop(): void;
  33140. /**
  33141. * Create and run an async loop.
  33142. * @param iterations the number of iterations.
  33143. * @param fn the function to run each iteration
  33144. * @param successCallback the callback that will be called upon succesful execution
  33145. * @param offset starting offset.
  33146. * @returns the created async loop object
  33147. */
  33148. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33149. /**
  33150. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33151. * @param iterations total number of iterations
  33152. * @param syncedIterations number of synchronous iterations in each async iteration.
  33153. * @param fn the function to call each iteration.
  33154. * @param callback a success call back that will be called when iterating stops.
  33155. * @param breakFunction a break condition (optional)
  33156. * @param timeout timeout settings for the setTimeout function. default - 0.
  33157. * @returns the created async loop object
  33158. */
  33159. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33160. }
  33161. }
  33162. declare module "babylonjs/Collisions/collisionCoordinator" {
  33163. import { Nullable } from "babylonjs/types";
  33164. import { Scene } from "babylonjs/scene";
  33165. import { Vector3 } from "babylonjs/Maths/math.vector";
  33166. import { Collider } from "babylonjs/Collisions/collider";
  33167. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33168. /** @hidden */
  33169. export interface ICollisionCoordinator {
  33170. createCollider(): Collider;
  33171. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33172. init(scene: Scene): void;
  33173. }
  33174. /** @hidden */
  33175. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33176. private _scene;
  33177. private _scaledPosition;
  33178. private _scaledVelocity;
  33179. private _finalPosition;
  33180. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33181. createCollider(): Collider;
  33182. init(scene: Scene): void;
  33183. private _collideWithWorld;
  33184. }
  33185. }
  33186. declare module "babylonjs/Inputs/scene.inputManager" {
  33187. import { Nullable } from "babylonjs/types";
  33188. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33189. import { Vector2 } from "babylonjs/Maths/math.vector";
  33190. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33191. import { Scene } from "babylonjs/scene";
  33192. /**
  33193. * Class used to manage all inputs for the scene.
  33194. */
  33195. export class InputManager {
  33196. /** The distance in pixel that you have to move to prevent some events */
  33197. static DragMovementThreshold: number;
  33198. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33199. static LongPressDelay: number;
  33200. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33201. static DoubleClickDelay: number;
  33202. /** If you need to check double click without raising a single click at first click, enable this flag */
  33203. static ExclusiveDoubleClickMode: boolean;
  33204. private _wheelEventName;
  33205. private _onPointerMove;
  33206. private _onPointerDown;
  33207. private _onPointerUp;
  33208. private _initClickEvent;
  33209. private _initActionManager;
  33210. private _delayedSimpleClick;
  33211. private _delayedSimpleClickTimeout;
  33212. private _previousDelayedSimpleClickTimeout;
  33213. private _meshPickProceed;
  33214. private _previousButtonPressed;
  33215. private _currentPickResult;
  33216. private _previousPickResult;
  33217. private _totalPointersPressed;
  33218. private _doubleClickOccured;
  33219. private _pointerOverMesh;
  33220. private _pickedDownMesh;
  33221. private _pickedUpMesh;
  33222. private _pointerX;
  33223. private _pointerY;
  33224. private _unTranslatedPointerX;
  33225. private _unTranslatedPointerY;
  33226. private _startingPointerPosition;
  33227. private _previousStartingPointerPosition;
  33228. private _startingPointerTime;
  33229. private _previousStartingPointerTime;
  33230. private _pointerCaptures;
  33231. private _onKeyDown;
  33232. private _onKeyUp;
  33233. private _onCanvasFocusObserver;
  33234. private _onCanvasBlurObserver;
  33235. private _scene;
  33236. /**
  33237. * Creates a new InputManager
  33238. * @param scene defines the hosting scene
  33239. */
  33240. constructor(scene: Scene);
  33241. /**
  33242. * Gets the mesh that is currently under the pointer
  33243. */
  33244. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33245. /**
  33246. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33247. */
  33248. readonly unTranslatedPointer: Vector2;
  33249. /**
  33250. * Gets or sets the current on-screen X position of the pointer
  33251. */
  33252. pointerX: number;
  33253. /**
  33254. * Gets or sets the current on-screen Y position of the pointer
  33255. */
  33256. pointerY: number;
  33257. private _updatePointerPosition;
  33258. private _processPointerMove;
  33259. private _setRayOnPointerInfo;
  33260. private _checkPrePointerObservable;
  33261. /**
  33262. * Use this method to simulate a pointer move on a mesh
  33263. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33264. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33265. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33266. */
  33267. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33268. /**
  33269. * Use this method to simulate a pointer down on a mesh
  33270. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33271. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33272. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33273. */
  33274. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33275. private _processPointerDown;
  33276. /** @hidden */
  33277. _isPointerSwiping(): boolean;
  33278. /**
  33279. * Use this method to simulate a pointer up on a mesh
  33280. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33281. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33282. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33283. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33284. */
  33285. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  33286. private _processPointerUp;
  33287. /**
  33288. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33289. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33290. * @returns true if the pointer was captured
  33291. */
  33292. isPointerCaptured(pointerId?: number): boolean;
  33293. /**
  33294. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33295. * @param attachUp defines if you want to attach events to pointerup
  33296. * @param attachDown defines if you want to attach events to pointerdown
  33297. * @param attachMove defines if you want to attach events to pointermove
  33298. */
  33299. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33300. /**
  33301. * Detaches all event handlers
  33302. */
  33303. detachControl(): void;
  33304. /**
  33305. * Force the value of meshUnderPointer
  33306. * @param mesh defines the mesh to use
  33307. */
  33308. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33309. /**
  33310. * Gets the mesh under the pointer
  33311. * @returns a Mesh or null if no mesh is under the pointer
  33312. */
  33313. getPointerOverMesh(): Nullable<AbstractMesh>;
  33314. }
  33315. }
  33316. declare module "babylonjs/Misc/uniqueIdGenerator" {
  33317. /**
  33318. * Helper class used to generate session unique ID
  33319. */
  33320. export class UniqueIdGenerator {
  33321. private static _UniqueIdCounter;
  33322. /**
  33323. * Gets an unique (relatively to the current scene) Id
  33324. */
  33325. static readonly UniqueId: number;
  33326. }
  33327. }
  33328. declare module "babylonjs/Animations/animationGroup" {
  33329. import { Animatable } from "babylonjs/Animations/animatable";
  33330. import { Animation } from "babylonjs/Animations/animation";
  33331. import { Scene, IDisposable } from "babylonjs/scene";
  33332. import { Observable } from "babylonjs/Misc/observable";
  33333. import { Nullable } from "babylonjs/types";
  33334. import "babylonjs/Animations/animatable";
  33335. /**
  33336. * This class defines the direct association between an animation and a target
  33337. */
  33338. export class TargetedAnimation {
  33339. /**
  33340. * Animation to perform
  33341. */
  33342. animation: Animation;
  33343. /**
  33344. * Target to animate
  33345. */
  33346. target: any;
  33347. /**
  33348. * Serialize the object
  33349. * @returns the JSON object representing the current entity
  33350. */
  33351. serialize(): any;
  33352. }
  33353. /**
  33354. * Use this class to create coordinated animations on multiple targets
  33355. */
  33356. export class AnimationGroup implements IDisposable {
  33357. /** The name of the animation group */
  33358. name: string;
  33359. private _scene;
  33360. private _targetedAnimations;
  33361. private _animatables;
  33362. private _from;
  33363. private _to;
  33364. private _isStarted;
  33365. private _isPaused;
  33366. private _speedRatio;
  33367. private _loopAnimation;
  33368. /**
  33369. * Gets or sets the unique id of the node
  33370. */
  33371. uniqueId: number;
  33372. /**
  33373. * This observable will notify when one animation have ended
  33374. */
  33375. onAnimationEndObservable: Observable<TargetedAnimation>;
  33376. /**
  33377. * Observer raised when one animation loops
  33378. */
  33379. onAnimationLoopObservable: Observable<TargetedAnimation>;
  33380. /**
  33381. * This observable will notify when all animations have ended.
  33382. */
  33383. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  33384. /**
  33385. * This observable will notify when all animations have paused.
  33386. */
  33387. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  33388. /**
  33389. * This observable will notify when all animations are playing.
  33390. */
  33391. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  33392. /**
  33393. * Gets the first frame
  33394. */
  33395. readonly from: number;
  33396. /**
  33397. * Gets the last frame
  33398. */
  33399. readonly to: number;
  33400. /**
  33401. * Define if the animations are started
  33402. */
  33403. readonly isStarted: boolean;
  33404. /**
  33405. * Gets a value indicating that the current group is playing
  33406. */
  33407. readonly isPlaying: boolean;
  33408. /**
  33409. * Gets or sets the speed ratio to use for all animations
  33410. */
  33411. /**
  33412. * Gets or sets the speed ratio to use for all animations
  33413. */
  33414. speedRatio: number;
  33415. /**
  33416. * Gets or sets if all animations should loop or not
  33417. */
  33418. loopAnimation: boolean;
  33419. /**
  33420. * Gets the targeted animations for this animation group
  33421. */
  33422. readonly targetedAnimations: Array<TargetedAnimation>;
  33423. /**
  33424. * returning the list of animatables controlled by this animation group.
  33425. */
  33426. readonly animatables: Array<Animatable>;
  33427. /**
  33428. * Instantiates a new Animation Group.
  33429. * This helps managing several animations at once.
  33430. * @see http://doc.babylonjs.com/how_to/group
  33431. * @param name Defines the name of the group
  33432. * @param scene Defines the scene the group belongs to
  33433. */
  33434. constructor(
  33435. /** The name of the animation group */
  33436. name: string, scene?: Nullable<Scene>);
  33437. /**
  33438. * Add an animation (with its target) in the group
  33439. * @param animation defines the animation we want to add
  33440. * @param target defines the target of the animation
  33441. * @returns the TargetedAnimation object
  33442. */
  33443. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  33444. /**
  33445. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  33446. * It can add constant keys at begin or end
  33447. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  33448. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  33449. * @returns the animation group
  33450. */
  33451. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  33452. /**
  33453. * Start all animations on given targets
  33454. * @param loop defines if animations must loop
  33455. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  33456. * @param from defines the from key (optional)
  33457. * @param to defines the to key (optional)
  33458. * @returns the current animation group
  33459. */
  33460. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  33461. /**
  33462. * Pause all animations
  33463. * @returns the animation group
  33464. */
  33465. pause(): AnimationGroup;
  33466. /**
  33467. * Play all animations to initial state
  33468. * This function will start() the animations if they were not started or will restart() them if they were paused
  33469. * @param loop defines if animations must loop
  33470. * @returns the animation group
  33471. */
  33472. play(loop?: boolean): AnimationGroup;
  33473. /**
  33474. * Reset all animations to initial state
  33475. * @returns the animation group
  33476. */
  33477. reset(): AnimationGroup;
  33478. /**
  33479. * Restart animations from key 0
  33480. * @returns the animation group
  33481. */
  33482. restart(): AnimationGroup;
  33483. /**
  33484. * Stop all animations
  33485. * @returns the animation group
  33486. */
  33487. stop(): AnimationGroup;
  33488. /**
  33489. * Set animation weight for all animatables
  33490. * @param weight defines the weight to use
  33491. * @return the animationGroup
  33492. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33493. */
  33494. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33495. /**
  33496. * Synchronize and normalize all animatables with a source animatable
  33497. * @param root defines the root animatable to synchronize with
  33498. * @return the animationGroup
  33499. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33500. */
  33501. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33502. /**
  33503. * Goes to a specific frame in this animation group
  33504. * @param frame the frame number to go to
  33505. * @return the animationGroup
  33506. */
  33507. goToFrame(frame: number): AnimationGroup;
  33508. /**
  33509. * Dispose all associated resources
  33510. */
  33511. dispose(): void;
  33512. private _checkAnimationGroupEnded;
  33513. /**
  33514. * Clone the current animation group and returns a copy
  33515. * @param newName defines the name of the new group
  33516. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33517. * @returns the new aniamtion group
  33518. */
  33519. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33520. /**
  33521. * Serializes the animationGroup to an object
  33522. * @returns Serialized object
  33523. */
  33524. serialize(): any;
  33525. /**
  33526. * Returns a new AnimationGroup object parsed from the source provided.
  33527. * @param parsedAnimationGroup defines the source
  33528. * @param scene defines the scene that will receive the animationGroup
  33529. * @returns a new AnimationGroup
  33530. */
  33531. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33532. /**
  33533. * Returns the string "AnimationGroup"
  33534. * @returns "AnimationGroup"
  33535. */
  33536. getClassName(): string;
  33537. /**
  33538. * Creates a detailled string about the object
  33539. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33540. * @returns a string representing the object
  33541. */
  33542. toString(fullDetails?: boolean): string;
  33543. }
  33544. }
  33545. declare module "babylonjs/scene" {
  33546. import { Nullable } from "babylonjs/types";
  33547. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33548. import { Observable } from "babylonjs/Misc/observable";
  33549. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  33550. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  33551. import { Geometry } from "babylonjs/Meshes/geometry";
  33552. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33553. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33554. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33555. import { Mesh } from "babylonjs/Meshes/mesh";
  33556. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33557. import { Bone } from "babylonjs/Bones/bone";
  33558. import { Skeleton } from "babylonjs/Bones/skeleton";
  33559. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33560. import { Camera } from "babylonjs/Cameras/camera";
  33561. import { AbstractScene } from "babylonjs/abstractScene";
  33562. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33563. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33564. import { Material } from "babylonjs/Materials/material";
  33565. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33566. import { Effect } from "babylonjs/Materials/effect";
  33567. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  33568. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33569. import { Light } from "babylonjs/Lights/light";
  33570. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33571. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  33572. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  33573. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  33574. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33575. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33576. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33577. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33578. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  33579. import { Engine } from "babylonjs/Engines/engine";
  33580. import { Node } from "babylonjs/node";
  33581. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33582. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33583. import { WebRequest } from "babylonjs/Misc/webRequest";
  33584. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  33585. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33586. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  33587. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  33588. import { Plane } from "babylonjs/Maths/math.plane";
  33589. import { Ray } from "babylonjs/Culling/ray";
  33590. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33591. import { Animation } from "babylonjs/Animations/animation";
  33592. import { Animatable } from "babylonjs/Animations/animatable";
  33593. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33594. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33595. import { Collider } from "babylonjs/Collisions/collider";
  33596. /**
  33597. * Define an interface for all classes that will hold resources
  33598. */
  33599. export interface IDisposable {
  33600. /**
  33601. * Releases all held resources
  33602. */
  33603. dispose(): void;
  33604. }
  33605. /** Interface defining initialization parameters for Scene class */
  33606. export interface SceneOptions {
  33607. /**
  33608. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33609. * It will improve performance when the number of geometries becomes important.
  33610. */
  33611. useGeometryUniqueIdsMap?: boolean;
  33612. /**
  33613. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33614. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33615. */
  33616. useMaterialMeshMap?: boolean;
  33617. /**
  33618. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33619. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33620. */
  33621. useClonedMeshhMap?: boolean;
  33622. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33623. virtual?: boolean;
  33624. }
  33625. /**
  33626. * Represents a scene to be rendered by the engine.
  33627. * @see http://doc.babylonjs.com/features/scene
  33628. */
  33629. export class Scene extends AbstractScene implements IAnimatable {
  33630. /** The fog is deactivated */
  33631. static readonly FOGMODE_NONE: number;
  33632. /** The fog density is following an exponential function */
  33633. static readonly FOGMODE_EXP: number;
  33634. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33635. static readonly FOGMODE_EXP2: number;
  33636. /** The fog density is following a linear function. */
  33637. static readonly FOGMODE_LINEAR: number;
  33638. /**
  33639. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33640. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33641. */
  33642. static MinDeltaTime: number;
  33643. /**
  33644. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33645. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33646. */
  33647. static MaxDeltaTime: number;
  33648. /**
  33649. * Factory used to create the default material.
  33650. * @param name The name of the material to create
  33651. * @param scene The scene to create the material for
  33652. * @returns The default material
  33653. */
  33654. static DefaultMaterialFactory(scene: Scene): Material;
  33655. /**
  33656. * Factory used to create the a collision coordinator.
  33657. * @returns The collision coordinator
  33658. */
  33659. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33660. /** @hidden */
  33661. _inputManager: InputManager;
  33662. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33663. cameraToUseForPointers: Nullable<Camera>;
  33664. /** @hidden */
  33665. readonly _isScene: boolean;
  33666. /**
  33667. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33668. */
  33669. autoClear: boolean;
  33670. /**
  33671. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33672. */
  33673. autoClearDepthAndStencil: boolean;
  33674. /**
  33675. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33676. */
  33677. clearColor: Color4;
  33678. /**
  33679. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33680. */
  33681. ambientColor: Color3;
  33682. /**
  33683. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33684. * It should only be one of the following (if not the default embedded one):
  33685. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33686. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33687. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33688. * The material properties need to be setup according to the type of texture in use.
  33689. */
  33690. environmentBRDFTexture: BaseTexture;
  33691. /** @hidden */
  33692. protected _environmentTexture: Nullable<BaseTexture>;
  33693. /**
  33694. * Texture used in all pbr material as the reflection texture.
  33695. * As in the majority of the scene they are the same (exception for multi room and so on),
  33696. * this is easier to reference from here than from all the materials.
  33697. */
  33698. /**
  33699. * Texture used in all pbr material as the reflection texture.
  33700. * As in the majority of the scene they are the same (exception for multi room and so on),
  33701. * this is easier to set here than in all the materials.
  33702. */
  33703. environmentTexture: Nullable<BaseTexture>;
  33704. /** @hidden */
  33705. protected _environmentIntensity: number;
  33706. /**
  33707. * Intensity of the environment in all pbr material.
  33708. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33709. * As in the majority of the scene they are the same (exception for multi room and so on),
  33710. * this is easier to reference from here than from all the materials.
  33711. */
  33712. /**
  33713. * Intensity of the environment in all pbr material.
  33714. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33715. * As in the majority of the scene they are the same (exception for multi room and so on),
  33716. * this is easier to set here than in all the materials.
  33717. */
  33718. environmentIntensity: number;
  33719. /** @hidden */
  33720. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33721. /**
  33722. * Default image processing configuration used either in the rendering
  33723. * Forward main pass or through the imageProcessingPostProcess if present.
  33724. * As in the majority of the scene they are the same (exception for multi camera),
  33725. * this is easier to reference from here than from all the materials and post process.
  33726. *
  33727. * No setter as we it is a shared configuration, you can set the values instead.
  33728. */
  33729. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33730. private _forceWireframe;
  33731. /**
  33732. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33733. */
  33734. forceWireframe: boolean;
  33735. private _forcePointsCloud;
  33736. /**
  33737. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33738. */
  33739. forcePointsCloud: boolean;
  33740. /**
  33741. * Gets or sets the active clipplane 1
  33742. */
  33743. clipPlane: Nullable<Plane>;
  33744. /**
  33745. * Gets or sets the active clipplane 2
  33746. */
  33747. clipPlane2: Nullable<Plane>;
  33748. /**
  33749. * Gets or sets the active clipplane 3
  33750. */
  33751. clipPlane3: Nullable<Plane>;
  33752. /**
  33753. * Gets or sets the active clipplane 4
  33754. */
  33755. clipPlane4: Nullable<Plane>;
  33756. /**
  33757. * Gets or sets a boolean indicating if animations are enabled
  33758. */
  33759. animationsEnabled: boolean;
  33760. private _animationPropertiesOverride;
  33761. /**
  33762. * Gets or sets the animation properties override
  33763. */
  33764. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33765. /**
  33766. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33767. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33768. */
  33769. useConstantAnimationDeltaTime: boolean;
  33770. /**
  33771. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33772. * Please note that it requires to run a ray cast through the scene on every frame
  33773. */
  33774. constantlyUpdateMeshUnderPointer: boolean;
  33775. /**
  33776. * Defines the HTML cursor to use when hovering over interactive elements
  33777. */
  33778. hoverCursor: string;
  33779. /**
  33780. * Defines the HTML default cursor to use (empty by default)
  33781. */
  33782. defaultCursor: string;
  33783. /**
  33784. * This is used to call preventDefault() on pointer down
  33785. * in order to block unwanted artifacts like system double clicks
  33786. */
  33787. preventDefaultOnPointerDown: boolean;
  33788. /**
  33789. * This is used to call preventDefault() on pointer up
  33790. * in order to block unwanted artifacts like system double clicks
  33791. */
  33792. preventDefaultOnPointerUp: boolean;
  33793. /**
  33794. * Gets or sets user defined metadata
  33795. */
  33796. metadata: any;
  33797. /**
  33798. * For internal use only. Please do not use.
  33799. */
  33800. reservedDataStore: any;
  33801. /**
  33802. * Gets the name of the plugin used to load this scene (null by default)
  33803. */
  33804. loadingPluginName: string;
  33805. /**
  33806. * Use this array to add regular expressions used to disable offline support for specific urls
  33807. */
  33808. disableOfflineSupportExceptionRules: RegExp[];
  33809. /**
  33810. * An event triggered when the scene is disposed.
  33811. */
  33812. onDisposeObservable: Observable<Scene>;
  33813. private _onDisposeObserver;
  33814. /** Sets a function to be executed when this scene is disposed. */
  33815. onDispose: () => void;
  33816. /**
  33817. * An event triggered before rendering the scene (right after animations and physics)
  33818. */
  33819. onBeforeRenderObservable: Observable<Scene>;
  33820. private _onBeforeRenderObserver;
  33821. /** Sets a function to be executed before rendering this scene */
  33822. beforeRender: Nullable<() => void>;
  33823. /**
  33824. * An event triggered after rendering the scene
  33825. */
  33826. onAfterRenderObservable: Observable<Scene>;
  33827. /**
  33828. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  33829. */
  33830. onAfterRenderCameraObservable: Observable<Camera>;
  33831. private _onAfterRenderObserver;
  33832. /** Sets a function to be executed after rendering this scene */
  33833. afterRender: Nullable<() => void>;
  33834. /**
  33835. * An event triggered before animating the scene
  33836. */
  33837. onBeforeAnimationsObservable: Observable<Scene>;
  33838. /**
  33839. * An event triggered after animations processing
  33840. */
  33841. onAfterAnimationsObservable: Observable<Scene>;
  33842. /**
  33843. * An event triggered before draw calls are ready to be sent
  33844. */
  33845. onBeforeDrawPhaseObservable: Observable<Scene>;
  33846. /**
  33847. * An event triggered after draw calls have been sent
  33848. */
  33849. onAfterDrawPhaseObservable: Observable<Scene>;
  33850. /**
  33851. * An event triggered when the scene is ready
  33852. */
  33853. onReadyObservable: Observable<Scene>;
  33854. /**
  33855. * An event triggered before rendering a camera
  33856. */
  33857. onBeforeCameraRenderObservable: Observable<Camera>;
  33858. private _onBeforeCameraRenderObserver;
  33859. /** Sets a function to be executed before rendering a camera*/
  33860. beforeCameraRender: () => void;
  33861. /**
  33862. * An event triggered after rendering a camera
  33863. */
  33864. onAfterCameraRenderObservable: Observable<Camera>;
  33865. private _onAfterCameraRenderObserver;
  33866. /** Sets a function to be executed after rendering a camera*/
  33867. afterCameraRender: () => void;
  33868. /**
  33869. * An event triggered when active meshes evaluation is about to start
  33870. */
  33871. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33872. /**
  33873. * An event triggered when active meshes evaluation is done
  33874. */
  33875. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33876. /**
  33877. * An event triggered when particles rendering is about to start
  33878. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33879. */
  33880. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33881. /**
  33882. * An event triggered when particles rendering is done
  33883. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33884. */
  33885. onAfterParticlesRenderingObservable: Observable<Scene>;
  33886. /**
  33887. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33888. */
  33889. onDataLoadedObservable: Observable<Scene>;
  33890. /**
  33891. * An event triggered when a camera is created
  33892. */
  33893. onNewCameraAddedObservable: Observable<Camera>;
  33894. /**
  33895. * An event triggered when a camera is removed
  33896. */
  33897. onCameraRemovedObservable: Observable<Camera>;
  33898. /**
  33899. * An event triggered when a light is created
  33900. */
  33901. onNewLightAddedObservable: Observable<Light>;
  33902. /**
  33903. * An event triggered when a light is removed
  33904. */
  33905. onLightRemovedObservable: Observable<Light>;
  33906. /**
  33907. * An event triggered when a geometry is created
  33908. */
  33909. onNewGeometryAddedObservable: Observable<Geometry>;
  33910. /**
  33911. * An event triggered when a geometry is removed
  33912. */
  33913. onGeometryRemovedObservable: Observable<Geometry>;
  33914. /**
  33915. * An event triggered when a transform node is created
  33916. */
  33917. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33918. /**
  33919. * An event triggered when a transform node is removed
  33920. */
  33921. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33922. /**
  33923. * An event triggered when a mesh is created
  33924. */
  33925. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33926. /**
  33927. * An event triggered when a mesh is removed
  33928. */
  33929. onMeshRemovedObservable: Observable<AbstractMesh>;
  33930. /**
  33931. * An event triggered when a skeleton is created
  33932. */
  33933. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33934. /**
  33935. * An event triggered when a skeleton is removed
  33936. */
  33937. onSkeletonRemovedObservable: Observable<Skeleton>;
  33938. /**
  33939. * An event triggered when a material is created
  33940. */
  33941. onNewMaterialAddedObservable: Observable<Material>;
  33942. /**
  33943. * An event triggered when a material is removed
  33944. */
  33945. onMaterialRemovedObservable: Observable<Material>;
  33946. /**
  33947. * An event triggered when a texture is created
  33948. */
  33949. onNewTextureAddedObservable: Observable<BaseTexture>;
  33950. /**
  33951. * An event triggered when a texture is removed
  33952. */
  33953. onTextureRemovedObservable: Observable<BaseTexture>;
  33954. /**
  33955. * An event triggered when render targets are about to be rendered
  33956. * Can happen multiple times per frame.
  33957. */
  33958. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33959. /**
  33960. * An event triggered when render targets were rendered.
  33961. * Can happen multiple times per frame.
  33962. */
  33963. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33964. /**
  33965. * An event triggered before calculating deterministic simulation step
  33966. */
  33967. onBeforeStepObservable: Observable<Scene>;
  33968. /**
  33969. * An event triggered after calculating deterministic simulation step
  33970. */
  33971. onAfterStepObservable: Observable<Scene>;
  33972. /**
  33973. * An event triggered when the activeCamera property is updated
  33974. */
  33975. onActiveCameraChanged: Observable<Scene>;
  33976. /**
  33977. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33978. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33979. * 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)
  33980. */
  33981. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33982. /**
  33983. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33984. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33985. * 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)
  33986. */
  33987. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33988. /**
  33989. * This Observable will when a mesh has been imported into the scene.
  33990. */
  33991. onMeshImportedObservable: Observable<AbstractMesh>;
  33992. /**
  33993. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33994. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33995. */
  33996. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33997. /** @hidden */
  33998. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33999. /**
  34000. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  34001. */
  34002. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  34003. /**
  34004. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  34005. */
  34006. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  34007. /**
  34008. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  34009. */
  34010. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  34011. /** Callback called when a pointer move is detected */
  34012. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34013. /** Callback called when a pointer down is detected */
  34014. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34015. /** Callback called when a pointer up is detected */
  34016. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  34017. /** Callback called when a pointer pick is detected */
  34018. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  34019. /**
  34020. * 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).
  34021. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  34022. */
  34023. onPrePointerObservable: Observable<PointerInfoPre>;
  34024. /**
  34025. * Observable event triggered each time an input event is received from the rendering canvas
  34026. */
  34027. onPointerObservable: Observable<PointerInfo>;
  34028. /**
  34029. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  34030. */
  34031. readonly unTranslatedPointer: Vector2;
  34032. /**
  34033. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  34034. */
  34035. static DragMovementThreshold: number;
  34036. /**
  34037. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  34038. */
  34039. static LongPressDelay: number;
  34040. /**
  34041. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  34042. */
  34043. static DoubleClickDelay: number;
  34044. /** If you need to check double click without raising a single click at first click, enable this flag */
  34045. static ExclusiveDoubleClickMode: boolean;
  34046. /** @hidden */
  34047. _mirroredCameraPosition: Nullable<Vector3>;
  34048. /**
  34049. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  34050. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  34051. */
  34052. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  34053. /**
  34054. * Observable event triggered each time an keyboard event is received from the hosting window
  34055. */
  34056. onKeyboardObservable: Observable<KeyboardInfo>;
  34057. private _useRightHandedSystem;
  34058. /**
  34059. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  34060. */
  34061. useRightHandedSystem: boolean;
  34062. private _timeAccumulator;
  34063. private _currentStepId;
  34064. private _currentInternalStep;
  34065. /**
  34066. * Sets the step Id used by deterministic lock step
  34067. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34068. * @param newStepId defines the step Id
  34069. */
  34070. setStepId(newStepId: number): void;
  34071. /**
  34072. * Gets the step Id used by deterministic lock step
  34073. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34074. * @returns the step Id
  34075. */
  34076. getStepId(): number;
  34077. /**
  34078. * Gets the internal step used by deterministic lock step
  34079. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34080. * @returns the internal step
  34081. */
  34082. getInternalStep(): number;
  34083. private _fogEnabled;
  34084. /**
  34085. * Gets or sets a boolean indicating if fog is enabled on this scene
  34086. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34087. * (Default is true)
  34088. */
  34089. fogEnabled: boolean;
  34090. private _fogMode;
  34091. /**
  34092. * Gets or sets the fog mode to use
  34093. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34094. * | mode | value |
  34095. * | --- | --- |
  34096. * | FOGMODE_NONE | 0 |
  34097. * | FOGMODE_EXP | 1 |
  34098. * | FOGMODE_EXP2 | 2 |
  34099. * | FOGMODE_LINEAR | 3 |
  34100. */
  34101. fogMode: number;
  34102. /**
  34103. * Gets or sets the fog color to use
  34104. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34105. * (Default is Color3(0.2, 0.2, 0.3))
  34106. */
  34107. fogColor: Color3;
  34108. /**
  34109. * Gets or sets the fog density to use
  34110. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34111. * (Default is 0.1)
  34112. */
  34113. fogDensity: number;
  34114. /**
  34115. * Gets or sets the fog start distance to use
  34116. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34117. * (Default is 0)
  34118. */
  34119. fogStart: number;
  34120. /**
  34121. * Gets or sets the fog end distance to use
  34122. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34123. * (Default is 1000)
  34124. */
  34125. fogEnd: number;
  34126. private _shadowsEnabled;
  34127. /**
  34128. * Gets or sets a boolean indicating if shadows are enabled on this scene
  34129. */
  34130. shadowsEnabled: boolean;
  34131. private _lightsEnabled;
  34132. /**
  34133. * Gets or sets a boolean indicating if lights are enabled on this scene
  34134. */
  34135. lightsEnabled: boolean;
  34136. /** All of the active cameras added to this scene. */
  34137. activeCameras: Camera[];
  34138. /** @hidden */
  34139. _activeCamera: Nullable<Camera>;
  34140. /** Gets or sets the current active camera */
  34141. activeCamera: Nullable<Camera>;
  34142. private _defaultMaterial;
  34143. /** The default material used on meshes when no material is affected */
  34144. /** The default material used on meshes when no material is affected */
  34145. defaultMaterial: Material;
  34146. private _texturesEnabled;
  34147. /**
  34148. * Gets or sets a boolean indicating if textures are enabled on this scene
  34149. */
  34150. texturesEnabled: boolean;
  34151. /**
  34152. * Gets or sets a boolean indicating if particles are enabled on this scene
  34153. */
  34154. particlesEnabled: boolean;
  34155. /**
  34156. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34157. */
  34158. spritesEnabled: boolean;
  34159. private _skeletonsEnabled;
  34160. /**
  34161. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34162. */
  34163. skeletonsEnabled: boolean;
  34164. /**
  34165. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34166. */
  34167. lensFlaresEnabled: boolean;
  34168. /**
  34169. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34170. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34171. */
  34172. collisionsEnabled: boolean;
  34173. private _collisionCoordinator;
  34174. /** @hidden */
  34175. readonly collisionCoordinator: ICollisionCoordinator;
  34176. /**
  34177. * Defines the gravity applied to this scene (used only for collisions)
  34178. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34179. */
  34180. gravity: Vector3;
  34181. /**
  34182. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  34183. */
  34184. postProcessesEnabled: boolean;
  34185. /**
  34186. * The list of postprocesses added to the scene
  34187. */
  34188. postProcesses: PostProcess[];
  34189. /**
  34190. * Gets the current postprocess manager
  34191. */
  34192. postProcessManager: PostProcessManager;
  34193. /**
  34194. * Gets or sets a boolean indicating if render targets are enabled on this scene
  34195. */
  34196. renderTargetsEnabled: boolean;
  34197. /**
  34198. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  34199. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34200. */
  34201. dumpNextRenderTargets: boolean;
  34202. /**
  34203. * The list of user defined render targets added to the scene
  34204. */
  34205. customRenderTargets: RenderTargetTexture[];
  34206. /**
  34207. * Defines if texture loading must be delayed
  34208. * If true, textures will only be loaded when they need to be rendered
  34209. */
  34210. useDelayedTextureLoading: boolean;
  34211. /**
  34212. * Gets the list of meshes imported to the scene through SceneLoader
  34213. */
  34214. importedMeshesFiles: String[];
  34215. /**
  34216. * Gets or sets a boolean indicating if probes are enabled on this scene
  34217. */
  34218. probesEnabled: boolean;
  34219. /**
  34220. * Gets or sets the current offline provider to use to store scene data
  34221. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  34222. */
  34223. offlineProvider: IOfflineProvider;
  34224. /**
  34225. * Gets or sets the action manager associated with the scene
  34226. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34227. */
  34228. actionManager: AbstractActionManager;
  34229. private _meshesForIntersections;
  34230. /**
  34231. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34232. */
  34233. proceduralTexturesEnabled: boolean;
  34234. private _engine;
  34235. private _totalVertices;
  34236. /** @hidden */
  34237. _activeIndices: PerfCounter;
  34238. /** @hidden */
  34239. _activeParticles: PerfCounter;
  34240. /** @hidden */
  34241. _activeBones: PerfCounter;
  34242. private _animationRatio;
  34243. /** @hidden */
  34244. _animationTimeLast: number;
  34245. /** @hidden */
  34246. _animationTime: number;
  34247. /**
  34248. * Gets or sets a general scale for animation speed
  34249. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  34250. */
  34251. animationTimeScale: number;
  34252. /** @hidden */
  34253. _cachedMaterial: Nullable<Material>;
  34254. /** @hidden */
  34255. _cachedEffect: Nullable<Effect>;
  34256. /** @hidden */
  34257. _cachedVisibility: Nullable<number>;
  34258. private _renderId;
  34259. private _frameId;
  34260. private _executeWhenReadyTimeoutId;
  34261. private _intermediateRendering;
  34262. private _viewUpdateFlag;
  34263. private _projectionUpdateFlag;
  34264. /** @hidden */
  34265. _toBeDisposed: Nullable<IDisposable>[];
  34266. private _activeRequests;
  34267. /** @hidden */
  34268. _pendingData: any[];
  34269. private _isDisposed;
  34270. /**
  34271. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  34272. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  34273. */
  34274. dispatchAllSubMeshesOfActiveMeshes: boolean;
  34275. private _activeMeshes;
  34276. private _processedMaterials;
  34277. private _renderTargets;
  34278. /** @hidden */
  34279. _activeParticleSystems: SmartArray<IParticleSystem>;
  34280. private _activeSkeletons;
  34281. private _softwareSkinnedMeshes;
  34282. private _renderingManager;
  34283. /** @hidden */
  34284. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  34285. private _transformMatrix;
  34286. private _sceneUbo;
  34287. /** @hidden */
  34288. _viewMatrix: Matrix;
  34289. private _projectionMatrix;
  34290. /** @hidden */
  34291. _forcedViewPosition: Nullable<Vector3>;
  34292. /** @hidden */
  34293. _frustumPlanes: Plane[];
  34294. /**
  34295. * Gets the list of frustum planes (built from the active camera)
  34296. */
  34297. readonly frustumPlanes: Plane[];
  34298. /**
  34299. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  34300. * This is useful if there are more lights that the maximum simulteanous authorized
  34301. */
  34302. requireLightSorting: boolean;
  34303. /** @hidden */
  34304. readonly useMaterialMeshMap: boolean;
  34305. /** @hidden */
  34306. readonly useClonedMeshhMap: boolean;
  34307. private _externalData;
  34308. private _uid;
  34309. /**
  34310. * @hidden
  34311. * Backing store of defined scene components.
  34312. */
  34313. _components: ISceneComponent[];
  34314. /**
  34315. * @hidden
  34316. * Backing store of defined scene components.
  34317. */
  34318. _serializableComponents: ISceneSerializableComponent[];
  34319. /**
  34320. * List of components to register on the next registration step.
  34321. */
  34322. private _transientComponents;
  34323. /**
  34324. * Registers the transient components if needed.
  34325. */
  34326. private _registerTransientComponents;
  34327. /**
  34328. * @hidden
  34329. * Add a component to the scene.
  34330. * Note that the ccomponent could be registered on th next frame if this is called after
  34331. * the register component stage.
  34332. * @param component Defines the component to add to the scene
  34333. */
  34334. _addComponent(component: ISceneComponent): void;
  34335. /**
  34336. * @hidden
  34337. * Gets a component from the scene.
  34338. * @param name defines the name of the component to retrieve
  34339. * @returns the component or null if not present
  34340. */
  34341. _getComponent(name: string): Nullable<ISceneComponent>;
  34342. /**
  34343. * @hidden
  34344. * Defines the actions happening before camera updates.
  34345. */
  34346. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  34347. /**
  34348. * @hidden
  34349. * Defines the actions happening before clear the canvas.
  34350. */
  34351. _beforeClearStage: Stage<SimpleStageAction>;
  34352. /**
  34353. * @hidden
  34354. * Defines the actions when collecting render targets for the frame.
  34355. */
  34356. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34357. /**
  34358. * @hidden
  34359. * Defines the actions happening for one camera in the frame.
  34360. */
  34361. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34362. /**
  34363. * @hidden
  34364. * Defines the actions happening during the per mesh ready checks.
  34365. */
  34366. _isReadyForMeshStage: Stage<MeshStageAction>;
  34367. /**
  34368. * @hidden
  34369. * Defines the actions happening before evaluate active mesh checks.
  34370. */
  34371. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  34372. /**
  34373. * @hidden
  34374. * Defines the actions happening during the evaluate sub mesh checks.
  34375. */
  34376. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  34377. /**
  34378. * @hidden
  34379. * Defines the actions happening during the active mesh stage.
  34380. */
  34381. _activeMeshStage: Stage<ActiveMeshStageAction>;
  34382. /**
  34383. * @hidden
  34384. * Defines the actions happening during the per camera render target step.
  34385. */
  34386. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  34387. /**
  34388. * @hidden
  34389. * Defines the actions happening just before the active camera is drawing.
  34390. */
  34391. _beforeCameraDrawStage: Stage<CameraStageAction>;
  34392. /**
  34393. * @hidden
  34394. * Defines the actions happening just before a render target is drawing.
  34395. */
  34396. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34397. /**
  34398. * @hidden
  34399. * Defines the actions happening just before a rendering group is drawing.
  34400. */
  34401. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34402. /**
  34403. * @hidden
  34404. * Defines the actions happening just before a mesh is drawing.
  34405. */
  34406. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34407. /**
  34408. * @hidden
  34409. * Defines the actions happening just after a mesh has been drawn.
  34410. */
  34411. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34412. /**
  34413. * @hidden
  34414. * Defines the actions happening just after a rendering group has been drawn.
  34415. */
  34416. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34417. /**
  34418. * @hidden
  34419. * Defines the actions happening just after the active camera has been drawn.
  34420. */
  34421. _afterCameraDrawStage: Stage<CameraStageAction>;
  34422. /**
  34423. * @hidden
  34424. * Defines the actions happening just after a render target has been drawn.
  34425. */
  34426. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34427. /**
  34428. * @hidden
  34429. * Defines the actions happening just after rendering all cameras and computing intersections.
  34430. */
  34431. _afterRenderStage: Stage<SimpleStageAction>;
  34432. /**
  34433. * @hidden
  34434. * Defines the actions happening when a pointer move event happens.
  34435. */
  34436. _pointerMoveStage: Stage<PointerMoveStageAction>;
  34437. /**
  34438. * @hidden
  34439. * Defines the actions happening when a pointer down event happens.
  34440. */
  34441. _pointerDownStage: Stage<PointerUpDownStageAction>;
  34442. /**
  34443. * @hidden
  34444. * Defines the actions happening when a pointer up event happens.
  34445. */
  34446. _pointerUpStage: Stage<PointerUpDownStageAction>;
  34447. /**
  34448. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  34449. */
  34450. private geometriesByUniqueId;
  34451. /**
  34452. * Creates a new Scene
  34453. * @param engine defines the engine to use to render this scene
  34454. * @param options defines the scene options
  34455. */
  34456. constructor(engine: Engine, options?: SceneOptions);
  34457. /**
  34458. * Gets a string idenfifying the name of the class
  34459. * @returns "Scene" string
  34460. */
  34461. getClassName(): string;
  34462. private _defaultMeshCandidates;
  34463. /**
  34464. * @hidden
  34465. */
  34466. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  34467. private _defaultSubMeshCandidates;
  34468. /**
  34469. * @hidden
  34470. */
  34471. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34472. /**
  34473. * Sets the default candidate providers for the scene.
  34474. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34475. * and getCollidingSubMeshCandidates to their default function
  34476. */
  34477. setDefaultCandidateProviders(): void;
  34478. /**
  34479. * Gets the mesh that is currently under the pointer
  34480. */
  34481. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34482. /**
  34483. * Gets or sets the current on-screen X position of the pointer
  34484. */
  34485. pointerX: number;
  34486. /**
  34487. * Gets or sets the current on-screen Y position of the pointer
  34488. */
  34489. pointerY: number;
  34490. /**
  34491. * Gets the cached material (ie. the latest rendered one)
  34492. * @returns the cached material
  34493. */
  34494. getCachedMaterial(): Nullable<Material>;
  34495. /**
  34496. * Gets the cached effect (ie. the latest rendered one)
  34497. * @returns the cached effect
  34498. */
  34499. getCachedEffect(): Nullable<Effect>;
  34500. /**
  34501. * Gets the cached visibility state (ie. the latest rendered one)
  34502. * @returns the cached visibility state
  34503. */
  34504. getCachedVisibility(): Nullable<number>;
  34505. /**
  34506. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34507. * @param material defines the current material
  34508. * @param effect defines the current effect
  34509. * @param visibility defines the current visibility state
  34510. * @returns true if one parameter is not cached
  34511. */
  34512. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34513. /**
  34514. * Gets the engine associated with the scene
  34515. * @returns an Engine
  34516. */
  34517. getEngine(): Engine;
  34518. /**
  34519. * Gets the total number of vertices rendered per frame
  34520. * @returns the total number of vertices rendered per frame
  34521. */
  34522. getTotalVertices(): number;
  34523. /**
  34524. * Gets the performance counter for total vertices
  34525. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34526. */
  34527. readonly totalVerticesPerfCounter: PerfCounter;
  34528. /**
  34529. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34530. * @returns the total number of active indices rendered per frame
  34531. */
  34532. getActiveIndices(): number;
  34533. /**
  34534. * Gets the performance counter for active indices
  34535. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34536. */
  34537. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34538. /**
  34539. * Gets the total number of active particles rendered per frame
  34540. * @returns the total number of active particles rendered per frame
  34541. */
  34542. getActiveParticles(): number;
  34543. /**
  34544. * Gets the performance counter for active particles
  34545. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34546. */
  34547. readonly activeParticlesPerfCounter: PerfCounter;
  34548. /**
  34549. * Gets the total number of active bones rendered per frame
  34550. * @returns the total number of active bones rendered per frame
  34551. */
  34552. getActiveBones(): number;
  34553. /**
  34554. * Gets the performance counter for active bones
  34555. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34556. */
  34557. readonly activeBonesPerfCounter: PerfCounter;
  34558. /**
  34559. * Gets the array of active meshes
  34560. * @returns an array of AbstractMesh
  34561. */
  34562. getActiveMeshes(): SmartArray<AbstractMesh>;
  34563. /**
  34564. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34565. * @returns a number
  34566. */
  34567. getAnimationRatio(): number;
  34568. /**
  34569. * Gets an unique Id for the current render phase
  34570. * @returns a number
  34571. */
  34572. getRenderId(): number;
  34573. /**
  34574. * Gets an unique Id for the current frame
  34575. * @returns a number
  34576. */
  34577. getFrameId(): number;
  34578. /** Call this function if you want to manually increment the render Id*/
  34579. incrementRenderId(): void;
  34580. private _createUbo;
  34581. /**
  34582. * Use this method to simulate a pointer move on a mesh
  34583. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34584. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34585. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34586. * @returns the current scene
  34587. */
  34588. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34589. /**
  34590. * Use this method to simulate a pointer down on a mesh
  34591. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34592. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34593. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34594. * @returns the current scene
  34595. */
  34596. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34597. /**
  34598. * Use this method to simulate a pointer up on a mesh
  34599. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34600. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34601. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34602. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34603. * @returns the current scene
  34604. */
  34605. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34606. /**
  34607. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34608. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34609. * @returns true if the pointer was captured
  34610. */
  34611. isPointerCaptured(pointerId?: number): boolean;
  34612. /**
  34613. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34614. * @param attachUp defines if you want to attach events to pointerup
  34615. * @param attachDown defines if you want to attach events to pointerdown
  34616. * @param attachMove defines if you want to attach events to pointermove
  34617. */
  34618. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34619. /** Detaches all event handlers*/
  34620. detachControl(): void;
  34621. /**
  34622. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34623. * Delay loaded resources are not taking in account
  34624. * @return true if all required resources are ready
  34625. */
  34626. isReady(): boolean;
  34627. /** Resets all cached information relative to material (including effect and visibility) */
  34628. resetCachedMaterial(): void;
  34629. /**
  34630. * Registers a function to be called before every frame render
  34631. * @param func defines the function to register
  34632. */
  34633. registerBeforeRender(func: () => void): void;
  34634. /**
  34635. * Unregisters a function called before every frame render
  34636. * @param func defines the function to unregister
  34637. */
  34638. unregisterBeforeRender(func: () => void): void;
  34639. /**
  34640. * Registers a function to be called after every frame render
  34641. * @param func defines the function to register
  34642. */
  34643. registerAfterRender(func: () => void): void;
  34644. /**
  34645. * Unregisters a function called after every frame render
  34646. * @param func defines the function to unregister
  34647. */
  34648. unregisterAfterRender(func: () => void): void;
  34649. private _executeOnceBeforeRender;
  34650. /**
  34651. * The provided function will run before render once and will be disposed afterwards.
  34652. * A timeout delay can be provided so that the function will be executed in N ms.
  34653. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34654. * @param func The function to be executed.
  34655. * @param timeout optional delay in ms
  34656. */
  34657. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34658. /** @hidden */
  34659. _addPendingData(data: any): void;
  34660. /** @hidden */
  34661. _removePendingData(data: any): void;
  34662. /**
  34663. * Returns the number of items waiting to be loaded
  34664. * @returns the number of items waiting to be loaded
  34665. */
  34666. getWaitingItemsCount(): number;
  34667. /**
  34668. * Returns a boolean indicating if the scene is still loading data
  34669. */
  34670. readonly isLoading: boolean;
  34671. /**
  34672. * Registers a function to be executed when the scene is ready
  34673. * @param {Function} func - the function to be executed
  34674. */
  34675. executeWhenReady(func: () => void): void;
  34676. /**
  34677. * Returns a promise that resolves when the scene is ready
  34678. * @returns A promise that resolves when the scene is ready
  34679. */
  34680. whenReadyAsync(): Promise<void>;
  34681. /** @hidden */
  34682. _checkIsReady(): void;
  34683. /**
  34684. * Gets all animatable attached to the scene
  34685. */
  34686. readonly animatables: Animatable[];
  34687. /**
  34688. * Resets the last animation time frame.
  34689. * Useful to override when animations start running when loading a scene for the first time.
  34690. */
  34691. resetLastAnimationTimeFrame(): void;
  34692. /**
  34693. * Gets the current view matrix
  34694. * @returns a Matrix
  34695. */
  34696. getViewMatrix(): Matrix;
  34697. /**
  34698. * Gets the current projection matrix
  34699. * @returns a Matrix
  34700. */
  34701. getProjectionMatrix(): Matrix;
  34702. /**
  34703. * Gets the current transform matrix
  34704. * @returns a Matrix made of View * Projection
  34705. */
  34706. getTransformMatrix(): Matrix;
  34707. /**
  34708. * Sets the current transform matrix
  34709. * @param viewL defines the View matrix to use
  34710. * @param projectionL defines the Projection matrix to use
  34711. * @param viewR defines the right View matrix to use (if provided)
  34712. * @param projectionR defines the right Projection matrix to use (if provided)
  34713. */
  34714. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34715. /**
  34716. * Gets the uniform buffer used to store scene data
  34717. * @returns a UniformBuffer
  34718. */
  34719. getSceneUniformBuffer(): UniformBuffer;
  34720. /**
  34721. * Gets an unique (relatively to the current scene) Id
  34722. * @returns an unique number for the scene
  34723. */
  34724. getUniqueId(): number;
  34725. /**
  34726. * Add a mesh to the list of scene's meshes
  34727. * @param newMesh defines the mesh to add
  34728. * @param recursive if all child meshes should also be added to the scene
  34729. */
  34730. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34731. /**
  34732. * Remove a mesh for the list of scene's meshes
  34733. * @param toRemove defines the mesh to remove
  34734. * @param recursive if all child meshes should also be removed from the scene
  34735. * @returns the index where the mesh was in the mesh list
  34736. */
  34737. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34738. /**
  34739. * Add a transform node to the list of scene's transform nodes
  34740. * @param newTransformNode defines the transform node to add
  34741. */
  34742. addTransformNode(newTransformNode: TransformNode): void;
  34743. /**
  34744. * Remove a transform node for the list of scene's transform nodes
  34745. * @param toRemove defines the transform node to remove
  34746. * @returns the index where the transform node was in the transform node list
  34747. */
  34748. removeTransformNode(toRemove: TransformNode): number;
  34749. /**
  34750. * Remove a skeleton for the list of scene's skeletons
  34751. * @param toRemove defines the skeleton to remove
  34752. * @returns the index where the skeleton was in the skeleton list
  34753. */
  34754. removeSkeleton(toRemove: Skeleton): number;
  34755. /**
  34756. * Remove a morph target for the list of scene's morph targets
  34757. * @param toRemove defines the morph target to remove
  34758. * @returns the index where the morph target was in the morph target list
  34759. */
  34760. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34761. /**
  34762. * Remove a light for the list of scene's lights
  34763. * @param toRemove defines the light to remove
  34764. * @returns the index where the light was in the light list
  34765. */
  34766. removeLight(toRemove: Light): number;
  34767. /**
  34768. * Remove a camera for the list of scene's cameras
  34769. * @param toRemove defines the camera to remove
  34770. * @returns the index where the camera was in the camera list
  34771. */
  34772. removeCamera(toRemove: Camera): number;
  34773. /**
  34774. * Remove a particle system for the list of scene's particle systems
  34775. * @param toRemove defines the particle system to remove
  34776. * @returns the index where the particle system was in the particle system list
  34777. */
  34778. removeParticleSystem(toRemove: IParticleSystem): number;
  34779. /**
  34780. * Remove a animation for the list of scene's animations
  34781. * @param toRemove defines the animation to remove
  34782. * @returns the index where the animation was in the animation list
  34783. */
  34784. removeAnimation(toRemove: Animation): number;
  34785. /**
  34786. * Will stop the animation of the given target
  34787. * @param target - the target
  34788. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34789. * @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)
  34790. */
  34791. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34792. /**
  34793. * Removes the given animation group from this scene.
  34794. * @param toRemove The animation group to remove
  34795. * @returns The index of the removed animation group
  34796. */
  34797. removeAnimationGroup(toRemove: AnimationGroup): number;
  34798. /**
  34799. * Removes the given multi-material from this scene.
  34800. * @param toRemove The multi-material to remove
  34801. * @returns The index of the removed multi-material
  34802. */
  34803. removeMultiMaterial(toRemove: MultiMaterial): number;
  34804. /**
  34805. * Removes the given material from this scene.
  34806. * @param toRemove The material to remove
  34807. * @returns The index of the removed material
  34808. */
  34809. removeMaterial(toRemove: Material): number;
  34810. /**
  34811. * Removes the given action manager from this scene.
  34812. * @param toRemove The action manager to remove
  34813. * @returns The index of the removed action manager
  34814. */
  34815. removeActionManager(toRemove: AbstractActionManager): number;
  34816. /**
  34817. * Removes the given texture from this scene.
  34818. * @param toRemove The texture to remove
  34819. * @returns The index of the removed texture
  34820. */
  34821. removeTexture(toRemove: BaseTexture): number;
  34822. /**
  34823. * Adds the given light to this scene
  34824. * @param newLight The light to add
  34825. */
  34826. addLight(newLight: Light): void;
  34827. /**
  34828. * Sorts the list list based on light priorities
  34829. */
  34830. sortLightsByPriority(): void;
  34831. /**
  34832. * Adds the given camera to this scene
  34833. * @param newCamera The camera to add
  34834. */
  34835. addCamera(newCamera: Camera): void;
  34836. /**
  34837. * Adds the given skeleton to this scene
  34838. * @param newSkeleton The skeleton to add
  34839. */
  34840. addSkeleton(newSkeleton: Skeleton): void;
  34841. /**
  34842. * Adds the given particle system to this scene
  34843. * @param newParticleSystem The particle system to add
  34844. */
  34845. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34846. /**
  34847. * Adds the given animation to this scene
  34848. * @param newAnimation The animation to add
  34849. */
  34850. addAnimation(newAnimation: Animation): void;
  34851. /**
  34852. * Adds the given animation group to this scene.
  34853. * @param newAnimationGroup The animation group to add
  34854. */
  34855. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34856. /**
  34857. * Adds the given multi-material to this scene
  34858. * @param newMultiMaterial The multi-material to add
  34859. */
  34860. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34861. /**
  34862. * Adds the given material to this scene
  34863. * @param newMaterial The material to add
  34864. */
  34865. addMaterial(newMaterial: Material): void;
  34866. /**
  34867. * Adds the given morph target to this scene
  34868. * @param newMorphTargetManager The morph target to add
  34869. */
  34870. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34871. /**
  34872. * Adds the given geometry to this scene
  34873. * @param newGeometry The geometry to add
  34874. */
  34875. addGeometry(newGeometry: Geometry): void;
  34876. /**
  34877. * Adds the given action manager to this scene
  34878. * @param newActionManager The action manager to add
  34879. */
  34880. addActionManager(newActionManager: AbstractActionManager): void;
  34881. /**
  34882. * Adds the given texture to this scene.
  34883. * @param newTexture The texture to add
  34884. */
  34885. addTexture(newTexture: BaseTexture): void;
  34886. /**
  34887. * Switch active camera
  34888. * @param newCamera defines the new active camera
  34889. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34890. */
  34891. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34892. /**
  34893. * sets the active camera of the scene using its ID
  34894. * @param id defines the camera's ID
  34895. * @return the new active camera or null if none found.
  34896. */
  34897. setActiveCameraByID(id: string): Nullable<Camera>;
  34898. /**
  34899. * sets the active camera of the scene using its name
  34900. * @param name defines the camera's name
  34901. * @returns the new active camera or null if none found.
  34902. */
  34903. setActiveCameraByName(name: string): Nullable<Camera>;
  34904. /**
  34905. * get an animation group using its name
  34906. * @param name defines the material's name
  34907. * @return the animation group or null if none found.
  34908. */
  34909. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34910. /**
  34911. * Get a material using its unique id
  34912. * @param uniqueId defines the material's unique id
  34913. * @return the material or null if none found.
  34914. */
  34915. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34916. /**
  34917. * get a material using its id
  34918. * @param id defines the material's ID
  34919. * @return the material or null if none found.
  34920. */
  34921. getMaterialByID(id: string): Nullable<Material>;
  34922. /**
  34923. * Gets a the last added material using a given id
  34924. * @param id defines the material's ID
  34925. * @return the last material with the given id or null if none found.
  34926. */
  34927. getLastMaterialByID(id: string): Nullable<Material>;
  34928. /**
  34929. * Gets a material using its name
  34930. * @param name defines the material's name
  34931. * @return the material or null if none found.
  34932. */
  34933. getMaterialByName(name: string): Nullable<Material>;
  34934. /**
  34935. * Get a texture using its unique id
  34936. * @param uniqueId defines the texture's unique id
  34937. * @return the texture or null if none found.
  34938. */
  34939. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  34940. /**
  34941. * Gets a camera using its id
  34942. * @param id defines the id to look for
  34943. * @returns the camera or null if not found
  34944. */
  34945. getCameraByID(id: string): Nullable<Camera>;
  34946. /**
  34947. * Gets a camera using its unique id
  34948. * @param uniqueId defines the unique id to look for
  34949. * @returns the camera or null if not found
  34950. */
  34951. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34952. /**
  34953. * Gets a camera using its name
  34954. * @param name defines the camera's name
  34955. * @return the camera or null if none found.
  34956. */
  34957. getCameraByName(name: string): Nullable<Camera>;
  34958. /**
  34959. * Gets a bone using its id
  34960. * @param id defines the bone's id
  34961. * @return the bone or null if not found
  34962. */
  34963. getBoneByID(id: string): Nullable<Bone>;
  34964. /**
  34965. * Gets a bone using its id
  34966. * @param name defines the bone's name
  34967. * @return the bone or null if not found
  34968. */
  34969. getBoneByName(name: string): Nullable<Bone>;
  34970. /**
  34971. * Gets a light node using its name
  34972. * @param name defines the the light's name
  34973. * @return the light or null if none found.
  34974. */
  34975. getLightByName(name: string): Nullable<Light>;
  34976. /**
  34977. * Gets a light node using its id
  34978. * @param id defines the light's id
  34979. * @return the light or null if none found.
  34980. */
  34981. getLightByID(id: string): Nullable<Light>;
  34982. /**
  34983. * Gets a light node using its scene-generated unique ID
  34984. * @param uniqueId defines the light's unique id
  34985. * @return the light or null if none found.
  34986. */
  34987. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34988. /**
  34989. * Gets a particle system by id
  34990. * @param id defines the particle system id
  34991. * @return the corresponding system or null if none found
  34992. */
  34993. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34994. /**
  34995. * Gets a geometry using its ID
  34996. * @param id defines the geometry's id
  34997. * @return the geometry or null if none found.
  34998. */
  34999. getGeometryByID(id: string): Nullable<Geometry>;
  35000. private _getGeometryByUniqueID;
  35001. /**
  35002. * Add a new geometry to this scene
  35003. * @param geometry defines the geometry to be added to the scene.
  35004. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  35005. * @return a boolean defining if the geometry was added or not
  35006. */
  35007. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  35008. /**
  35009. * Removes an existing geometry
  35010. * @param geometry defines the geometry to be removed from the scene
  35011. * @return a boolean defining if the geometry was removed or not
  35012. */
  35013. removeGeometry(geometry: Geometry): boolean;
  35014. /**
  35015. * Gets the list of geometries attached to the scene
  35016. * @returns an array of Geometry
  35017. */
  35018. getGeometries(): Geometry[];
  35019. /**
  35020. * Gets the first added mesh found of a given ID
  35021. * @param id defines the id to search for
  35022. * @return the mesh found or null if not found at all
  35023. */
  35024. getMeshByID(id: string): Nullable<AbstractMesh>;
  35025. /**
  35026. * Gets a list of meshes using their id
  35027. * @param id defines the id to search for
  35028. * @returns a list of meshes
  35029. */
  35030. getMeshesByID(id: string): Array<AbstractMesh>;
  35031. /**
  35032. * Gets the first added transform node found of a given ID
  35033. * @param id defines the id to search for
  35034. * @return the found transform node or null if not found at all.
  35035. */
  35036. getTransformNodeByID(id: string): Nullable<TransformNode>;
  35037. /**
  35038. * Gets a transform node with its auto-generated unique id
  35039. * @param uniqueId efines the unique id to search for
  35040. * @return the found transform node or null if not found at all.
  35041. */
  35042. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  35043. /**
  35044. * Gets a list of transform nodes using their id
  35045. * @param id defines the id to search for
  35046. * @returns a list of transform nodes
  35047. */
  35048. getTransformNodesByID(id: string): Array<TransformNode>;
  35049. /**
  35050. * Gets a mesh with its auto-generated unique id
  35051. * @param uniqueId defines the unique id to search for
  35052. * @return the found mesh or null if not found at all.
  35053. */
  35054. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  35055. /**
  35056. * Gets a the last added mesh using a given id
  35057. * @param id defines the id to search for
  35058. * @return the found mesh or null if not found at all.
  35059. */
  35060. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  35061. /**
  35062. * Gets a the last added node (Mesh, Camera, Light) using a given id
  35063. * @param id defines the id to search for
  35064. * @return the found node or null if not found at all
  35065. */
  35066. getLastEntryByID(id: string): Nullable<Node>;
  35067. /**
  35068. * Gets a node (Mesh, Camera, Light) using a given id
  35069. * @param id defines the id to search for
  35070. * @return the found node or null if not found at all
  35071. */
  35072. getNodeByID(id: string): Nullable<Node>;
  35073. /**
  35074. * Gets a node (Mesh, Camera, Light) using a given name
  35075. * @param name defines the name to search for
  35076. * @return the found node or null if not found at all.
  35077. */
  35078. getNodeByName(name: string): Nullable<Node>;
  35079. /**
  35080. * Gets a mesh using a given name
  35081. * @param name defines the name to search for
  35082. * @return the found mesh or null if not found at all.
  35083. */
  35084. getMeshByName(name: string): Nullable<AbstractMesh>;
  35085. /**
  35086. * Gets a transform node using a given name
  35087. * @param name defines the name to search for
  35088. * @return the found transform node or null if not found at all.
  35089. */
  35090. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35091. /**
  35092. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35093. * @param id defines the id to search for
  35094. * @return the found skeleton or null if not found at all.
  35095. */
  35096. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35097. /**
  35098. * Gets a skeleton using a given auto generated unique id
  35099. * @param uniqueId defines the unique id to search for
  35100. * @return the found skeleton or null if not found at all.
  35101. */
  35102. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35103. /**
  35104. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35105. * @param id defines the id to search for
  35106. * @return the found skeleton or null if not found at all.
  35107. */
  35108. getSkeletonById(id: string): Nullable<Skeleton>;
  35109. /**
  35110. * Gets a skeleton using a given name
  35111. * @param name defines the name to search for
  35112. * @return the found skeleton or null if not found at all.
  35113. */
  35114. getSkeletonByName(name: string): Nullable<Skeleton>;
  35115. /**
  35116. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35117. * @param id defines the id to search for
  35118. * @return the found morph target manager or null if not found at all.
  35119. */
  35120. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35121. /**
  35122. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35123. * @param id defines the id to search for
  35124. * @return the found morph target or null if not found at all.
  35125. */
  35126. getMorphTargetById(id: string): Nullable<MorphTarget>;
  35127. /**
  35128. * Gets a boolean indicating if the given mesh is active
  35129. * @param mesh defines the mesh to look for
  35130. * @returns true if the mesh is in the active list
  35131. */
  35132. isActiveMesh(mesh: AbstractMesh): boolean;
  35133. /**
  35134. * Return a unique id as a string which can serve as an identifier for the scene
  35135. */
  35136. readonly uid: string;
  35137. /**
  35138. * Add an externaly attached data from its key.
  35139. * This method call will fail and return false, if such key already exists.
  35140. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35141. * @param key the unique key that identifies the data
  35142. * @param data the data object to associate to the key for this Engine instance
  35143. * @return true if no such key were already present and the data was added successfully, false otherwise
  35144. */
  35145. addExternalData<T>(key: string, data: T): boolean;
  35146. /**
  35147. * Get an externaly attached data from its key
  35148. * @param key the unique key that identifies the data
  35149. * @return the associated data, if present (can be null), or undefined if not present
  35150. */
  35151. getExternalData<T>(key: string): Nullable<T>;
  35152. /**
  35153. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35154. * @param key the unique key that identifies the data
  35155. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35156. * @return the associated data, can be null if the factory returned null.
  35157. */
  35158. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35159. /**
  35160. * Remove an externaly attached data from the Engine instance
  35161. * @param key the unique key that identifies the data
  35162. * @return true if the data was successfully removed, false if it doesn't exist
  35163. */
  35164. removeExternalData(key: string): boolean;
  35165. private _evaluateSubMesh;
  35166. /**
  35167. * Clear the processed materials smart array preventing retention point in material dispose.
  35168. */
  35169. freeProcessedMaterials(): void;
  35170. private _preventFreeActiveMeshesAndRenderingGroups;
  35171. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  35172. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  35173. * when disposing several meshes in a row or a hierarchy of meshes.
  35174. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  35175. */
  35176. blockfreeActiveMeshesAndRenderingGroups: boolean;
  35177. /**
  35178. * Clear the active meshes smart array preventing retention point in mesh dispose.
  35179. */
  35180. freeActiveMeshes(): void;
  35181. /**
  35182. * Clear the info related to rendering groups preventing retention points during dispose.
  35183. */
  35184. freeRenderingGroups(): void;
  35185. /** @hidden */
  35186. _isInIntermediateRendering(): boolean;
  35187. /**
  35188. * Lambda returning the list of potentially active meshes.
  35189. */
  35190. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  35191. /**
  35192. * Lambda returning the list of potentially active sub meshes.
  35193. */
  35194. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  35195. /**
  35196. * Lambda returning the list of potentially intersecting sub meshes.
  35197. */
  35198. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  35199. /**
  35200. * Lambda returning the list of potentially colliding sub meshes.
  35201. */
  35202. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  35203. private _activeMeshesFrozen;
  35204. /**
  35205. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35206. * @returns the current scene
  35207. */
  35208. freezeActiveMeshes(): Scene;
  35209. /**
  35210. * Use this function to restart evaluating active meshes on every frame
  35211. * @returns the current scene
  35212. */
  35213. unfreezeActiveMeshes(): Scene;
  35214. private _evaluateActiveMeshes;
  35215. private _activeMesh;
  35216. /**
  35217. * Update the transform matrix to update from the current active camera
  35218. * @param force defines a boolean used to force the update even if cache is up to date
  35219. */
  35220. updateTransformMatrix(force?: boolean): void;
  35221. private _bindFrameBuffer;
  35222. /** @hidden */
  35223. _allowPostProcessClearColor: boolean;
  35224. /** @hidden */
  35225. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  35226. private _processSubCameras;
  35227. private _checkIntersections;
  35228. /** @hidden */
  35229. _advancePhysicsEngineStep(step: number): void;
  35230. /**
  35231. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35232. */
  35233. getDeterministicFrameTime: () => number;
  35234. /** @hidden */
  35235. _animate(): void;
  35236. /** Execute all animations (for a frame) */
  35237. animate(): void;
  35238. /**
  35239. * Render the scene
  35240. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  35241. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  35242. */
  35243. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  35244. /**
  35245. * Freeze all materials
  35246. * A frozen material will not be updatable but should be faster to render
  35247. */
  35248. freezeMaterials(): void;
  35249. /**
  35250. * Unfreeze all materials
  35251. * A frozen material will not be updatable but should be faster to render
  35252. */
  35253. unfreezeMaterials(): void;
  35254. /**
  35255. * Releases all held ressources
  35256. */
  35257. dispose(): void;
  35258. /**
  35259. * Gets if the scene is already disposed
  35260. */
  35261. readonly isDisposed: boolean;
  35262. /**
  35263. * Call this function to reduce memory footprint of the scene.
  35264. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  35265. */
  35266. clearCachedVertexData(): void;
  35267. /**
  35268. * This function will remove the local cached buffer data from texture.
  35269. * It will save memory but will prevent the texture from being rebuilt
  35270. */
  35271. cleanCachedTextureBuffer(): void;
  35272. /**
  35273. * Get the world extend vectors with an optional filter
  35274. *
  35275. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  35276. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  35277. */
  35278. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  35279. min: Vector3;
  35280. max: Vector3;
  35281. };
  35282. /**
  35283. * Creates a ray that can be used to pick in the scene
  35284. * @param x defines the x coordinate of the origin (on-screen)
  35285. * @param y defines the y coordinate of the origin (on-screen)
  35286. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35287. * @param camera defines the camera to use for the picking
  35288. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35289. * @returns a Ray
  35290. */
  35291. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  35292. /**
  35293. * Creates a ray that can be used to pick in the scene
  35294. * @param x defines the x coordinate of the origin (on-screen)
  35295. * @param y defines the y coordinate of the origin (on-screen)
  35296. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35297. * @param result defines the ray where to store the picking ray
  35298. * @param camera defines the camera to use for the picking
  35299. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35300. * @returns the current scene
  35301. */
  35302. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  35303. /**
  35304. * Creates a ray that can be used to pick in the scene
  35305. * @param x defines the x coordinate of the origin (on-screen)
  35306. * @param y defines the y coordinate of the origin (on-screen)
  35307. * @param camera defines the camera to use for the picking
  35308. * @returns a Ray
  35309. */
  35310. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  35311. /**
  35312. * Creates a ray that can be used to pick in the scene
  35313. * @param x defines the x coordinate of the origin (on-screen)
  35314. * @param y defines the y coordinate of the origin (on-screen)
  35315. * @param result defines the ray where to store the picking ray
  35316. * @param camera defines the camera to use for the picking
  35317. * @returns the current scene
  35318. */
  35319. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  35320. /** Launch a ray to try to pick a mesh in the scene
  35321. * @param x position on screen
  35322. * @param y position on screen
  35323. * @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
  35324. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35325. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35326. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35327. * @returns a PickingInfo
  35328. */
  35329. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35330. /** Use the given ray to pick a mesh in the scene
  35331. * @param ray The ray to use to pick meshes
  35332. * @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
  35333. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  35334. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35335. * @returns a PickingInfo
  35336. */
  35337. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35338. /**
  35339. * Launch a ray to try to pick a mesh in the scene
  35340. * @param x X position on screen
  35341. * @param y Y position on screen
  35342. * @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
  35343. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35344. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35345. * @returns an array of PickingInfo
  35346. */
  35347. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35348. /**
  35349. * Launch a ray to try to pick a mesh in the scene
  35350. * @param ray Ray to use
  35351. * @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
  35352. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35353. * @returns an array of PickingInfo
  35354. */
  35355. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35356. /**
  35357. * Force the value of meshUnderPointer
  35358. * @param mesh defines the mesh to use
  35359. */
  35360. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35361. /**
  35362. * Gets the mesh under the pointer
  35363. * @returns a Mesh or null if no mesh is under the pointer
  35364. */
  35365. getPointerOverMesh(): Nullable<AbstractMesh>;
  35366. /** @hidden */
  35367. _rebuildGeometries(): void;
  35368. /** @hidden */
  35369. _rebuildTextures(): void;
  35370. private _getByTags;
  35371. /**
  35372. * Get a list of meshes by tags
  35373. * @param tagsQuery defines the tags query to use
  35374. * @param forEach defines a predicate used to filter results
  35375. * @returns an array of Mesh
  35376. */
  35377. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  35378. /**
  35379. * Get a list of cameras by tags
  35380. * @param tagsQuery defines the tags query to use
  35381. * @param forEach defines a predicate used to filter results
  35382. * @returns an array of Camera
  35383. */
  35384. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  35385. /**
  35386. * Get a list of lights by tags
  35387. * @param tagsQuery defines the tags query to use
  35388. * @param forEach defines a predicate used to filter results
  35389. * @returns an array of Light
  35390. */
  35391. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  35392. /**
  35393. * Get a list of materials by tags
  35394. * @param tagsQuery defines the tags query to use
  35395. * @param forEach defines a predicate used to filter results
  35396. * @returns an array of Material
  35397. */
  35398. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  35399. /**
  35400. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35401. * This allowed control for front to back rendering or reversly depending of the special needs.
  35402. *
  35403. * @param renderingGroupId The rendering group id corresponding to its index
  35404. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35405. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35406. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35407. */
  35408. 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;
  35409. /**
  35410. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35411. *
  35412. * @param renderingGroupId The rendering group id corresponding to its index
  35413. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35414. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35415. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35416. */
  35417. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35418. /**
  35419. * Gets the current auto clear configuration for one rendering group of the rendering
  35420. * manager.
  35421. * @param index the rendering group index to get the information for
  35422. * @returns The auto clear setup for the requested rendering group
  35423. */
  35424. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35425. private _blockMaterialDirtyMechanism;
  35426. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  35427. blockMaterialDirtyMechanism: boolean;
  35428. /**
  35429. * Will flag all materials as dirty to trigger new shader compilation
  35430. * @param flag defines the flag used to specify which material part must be marked as dirty
  35431. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  35432. */
  35433. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  35434. /** @hidden */
  35435. _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;
  35436. /** @hidden */
  35437. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35438. }
  35439. }
  35440. declare module "babylonjs/assetContainer" {
  35441. import { AbstractScene } from "babylonjs/abstractScene";
  35442. import { Scene } from "babylonjs/scene";
  35443. import { Mesh } from "babylonjs/Meshes/mesh";
  35444. /**
  35445. * Set of assets to keep when moving a scene into an asset container.
  35446. */
  35447. export class KeepAssets extends AbstractScene {
  35448. }
  35449. /**
  35450. * Container with a set of assets that can be added or removed from a scene.
  35451. */
  35452. export class AssetContainer extends AbstractScene {
  35453. /**
  35454. * The scene the AssetContainer belongs to.
  35455. */
  35456. scene: Scene;
  35457. /**
  35458. * Instantiates an AssetContainer.
  35459. * @param scene The scene the AssetContainer belongs to.
  35460. */
  35461. constructor(scene: Scene);
  35462. /**
  35463. * Adds all the assets from the container to the scene.
  35464. */
  35465. addAllToScene(): void;
  35466. /**
  35467. * Removes all the assets in the container from the scene
  35468. */
  35469. removeAllFromScene(): void;
  35470. /**
  35471. * Disposes all the assets in the container
  35472. */
  35473. dispose(): void;
  35474. private _moveAssets;
  35475. /**
  35476. * Removes all the assets contained in the scene and adds them to the container.
  35477. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  35478. */
  35479. moveAllFromScene(keepAssets?: KeepAssets): void;
  35480. /**
  35481. * 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.
  35482. * @returns the root mesh
  35483. */
  35484. createRootMesh(): Mesh;
  35485. }
  35486. }
  35487. declare module "babylonjs/abstractScene" {
  35488. import { Scene } from "babylonjs/scene";
  35489. import { Nullable } from "babylonjs/types";
  35490. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35491. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35492. import { Geometry } from "babylonjs/Meshes/geometry";
  35493. import { Skeleton } from "babylonjs/Bones/skeleton";
  35494. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35495. import { AssetContainer } from "babylonjs/assetContainer";
  35496. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35497. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35498. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35499. import { Material } from "babylonjs/Materials/material";
  35500. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35501. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35502. import { Camera } from "babylonjs/Cameras/camera";
  35503. import { Light } from "babylonjs/Lights/light";
  35504. import { Node } from "babylonjs/node";
  35505. import { Animation } from "babylonjs/Animations/animation";
  35506. /**
  35507. * Defines how the parser contract is defined.
  35508. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35509. */
  35510. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35511. /**
  35512. * Defines how the individual parser contract is defined.
  35513. * These parser can parse an individual asset
  35514. */
  35515. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35516. /**
  35517. * Base class of the scene acting as a container for the different elements composing a scene.
  35518. * This class is dynamically extended by the different components of the scene increasing
  35519. * flexibility and reducing coupling
  35520. */
  35521. export abstract class AbstractScene {
  35522. /**
  35523. * Stores the list of available parsers in the application.
  35524. */
  35525. private static _BabylonFileParsers;
  35526. /**
  35527. * Stores the list of available individual parsers in the application.
  35528. */
  35529. private static _IndividualBabylonFileParsers;
  35530. /**
  35531. * Adds a parser in the list of available ones
  35532. * @param name Defines the name of the parser
  35533. * @param parser Defines the parser to add
  35534. */
  35535. static AddParser(name: string, parser: BabylonFileParser): void;
  35536. /**
  35537. * Gets a general parser from the list of avaialble ones
  35538. * @param name Defines the name of the parser
  35539. * @returns the requested parser or null
  35540. */
  35541. static GetParser(name: string): Nullable<BabylonFileParser>;
  35542. /**
  35543. * Adds n individual parser in the list of available ones
  35544. * @param name Defines the name of the parser
  35545. * @param parser Defines the parser to add
  35546. */
  35547. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35548. /**
  35549. * Gets an individual parser from the list of avaialble ones
  35550. * @param name Defines the name of the parser
  35551. * @returns the requested parser or null
  35552. */
  35553. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35554. /**
  35555. * Parser json data and populate both a scene and its associated container object
  35556. * @param jsonData Defines the data to parse
  35557. * @param scene Defines the scene to parse the data for
  35558. * @param container Defines the container attached to the parsing sequence
  35559. * @param rootUrl Defines the root url of the data
  35560. */
  35561. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35562. /**
  35563. * Gets the list of root nodes (ie. nodes with no parent)
  35564. */
  35565. rootNodes: Node[];
  35566. /** All of the cameras added to this scene
  35567. * @see http://doc.babylonjs.com/babylon101/cameras
  35568. */
  35569. cameras: Camera[];
  35570. /**
  35571. * All of the lights added to this scene
  35572. * @see http://doc.babylonjs.com/babylon101/lights
  35573. */
  35574. lights: Light[];
  35575. /**
  35576. * All of the (abstract) meshes added to this scene
  35577. */
  35578. meshes: AbstractMesh[];
  35579. /**
  35580. * The list of skeletons added to the scene
  35581. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35582. */
  35583. skeletons: Skeleton[];
  35584. /**
  35585. * All of the particle systems added to this scene
  35586. * @see http://doc.babylonjs.com/babylon101/particles
  35587. */
  35588. particleSystems: IParticleSystem[];
  35589. /**
  35590. * Gets a list of Animations associated with the scene
  35591. */
  35592. animations: Animation[];
  35593. /**
  35594. * All of the animation groups added to this scene
  35595. * @see http://doc.babylonjs.com/how_to/group
  35596. */
  35597. animationGroups: AnimationGroup[];
  35598. /**
  35599. * All of the multi-materials added to this scene
  35600. * @see http://doc.babylonjs.com/how_to/multi_materials
  35601. */
  35602. multiMaterials: MultiMaterial[];
  35603. /**
  35604. * All of the materials added to this scene
  35605. * In the context of a Scene, it is not supposed to be modified manually.
  35606. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  35607. * Note also that the order of the Material wihin the array is not significant and might change.
  35608. * @see http://doc.babylonjs.com/babylon101/materials
  35609. */
  35610. materials: Material[];
  35611. /**
  35612. * The list of morph target managers added to the scene
  35613. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35614. */
  35615. morphTargetManagers: MorphTargetManager[];
  35616. /**
  35617. * The list of geometries used in the scene.
  35618. */
  35619. geometries: Geometry[];
  35620. /**
  35621. * All of the tranform nodes added to this scene
  35622. * In the context of a Scene, it is not supposed to be modified manually.
  35623. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35624. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35625. * @see http://doc.babylonjs.com/how_to/transformnode
  35626. */
  35627. transformNodes: TransformNode[];
  35628. /**
  35629. * ActionManagers available on the scene.
  35630. */
  35631. actionManagers: AbstractActionManager[];
  35632. /**
  35633. * Textures to keep.
  35634. */
  35635. textures: BaseTexture[];
  35636. /**
  35637. * Environment texture for the scene
  35638. */
  35639. environmentTexture: Nullable<BaseTexture>;
  35640. }
  35641. }
  35642. declare module "babylonjs/Audio/sound" {
  35643. import { Observable } from "babylonjs/Misc/observable";
  35644. import { Vector3 } from "babylonjs/Maths/math.vector";
  35645. import { Nullable } from "babylonjs/types";
  35646. import { Scene } from "babylonjs/scene";
  35647. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35648. /**
  35649. * Interface used to define options for Sound class
  35650. */
  35651. export interface ISoundOptions {
  35652. /**
  35653. * Does the sound autoplay once loaded.
  35654. */
  35655. autoplay?: boolean;
  35656. /**
  35657. * Does the sound loop after it finishes playing once.
  35658. */
  35659. loop?: boolean;
  35660. /**
  35661. * Sound's volume
  35662. */
  35663. volume?: number;
  35664. /**
  35665. * Is it a spatial sound?
  35666. */
  35667. spatialSound?: boolean;
  35668. /**
  35669. * Maximum distance to hear that sound
  35670. */
  35671. maxDistance?: number;
  35672. /**
  35673. * Uses user defined attenuation function
  35674. */
  35675. useCustomAttenuation?: boolean;
  35676. /**
  35677. * Define the roll off factor of spatial sounds.
  35678. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35679. */
  35680. rolloffFactor?: number;
  35681. /**
  35682. * Define the reference distance the sound should be heard perfectly.
  35683. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35684. */
  35685. refDistance?: number;
  35686. /**
  35687. * Define the distance attenuation model the sound will follow.
  35688. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35689. */
  35690. distanceModel?: string;
  35691. /**
  35692. * Defines the playback speed (1 by default)
  35693. */
  35694. playbackRate?: number;
  35695. /**
  35696. * Defines if the sound is from a streaming source
  35697. */
  35698. streaming?: boolean;
  35699. /**
  35700. * Defines an optional length (in seconds) inside the sound file
  35701. */
  35702. length?: number;
  35703. /**
  35704. * Defines an optional offset (in seconds) inside the sound file
  35705. */
  35706. offset?: number;
  35707. /**
  35708. * If true, URLs will not be required to state the audio file codec to use.
  35709. */
  35710. skipCodecCheck?: boolean;
  35711. }
  35712. /**
  35713. * Defines a sound that can be played in the application.
  35714. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35715. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35716. */
  35717. export class Sound {
  35718. /**
  35719. * The name of the sound in the scene.
  35720. */
  35721. name: string;
  35722. /**
  35723. * Does the sound autoplay once loaded.
  35724. */
  35725. autoplay: boolean;
  35726. /**
  35727. * Does the sound loop after it finishes playing once.
  35728. */
  35729. loop: boolean;
  35730. /**
  35731. * Does the sound use a custom attenuation curve to simulate the falloff
  35732. * happening when the source gets further away from the camera.
  35733. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35734. */
  35735. useCustomAttenuation: boolean;
  35736. /**
  35737. * The sound track id this sound belongs to.
  35738. */
  35739. soundTrackId: number;
  35740. /**
  35741. * Is this sound currently played.
  35742. */
  35743. isPlaying: boolean;
  35744. /**
  35745. * Is this sound currently paused.
  35746. */
  35747. isPaused: boolean;
  35748. /**
  35749. * Does this sound enables spatial sound.
  35750. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35751. */
  35752. spatialSound: boolean;
  35753. /**
  35754. * Define the reference distance the sound should be heard perfectly.
  35755. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35756. */
  35757. refDistance: number;
  35758. /**
  35759. * Define the roll off factor of spatial sounds.
  35760. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35761. */
  35762. rolloffFactor: number;
  35763. /**
  35764. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35765. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35766. */
  35767. maxDistance: number;
  35768. /**
  35769. * Define the distance attenuation model the sound will follow.
  35770. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35771. */
  35772. distanceModel: string;
  35773. /**
  35774. * @hidden
  35775. * Back Compat
  35776. **/
  35777. onended: () => any;
  35778. /**
  35779. * Observable event when the current playing sound finishes.
  35780. */
  35781. onEndedObservable: Observable<Sound>;
  35782. private _panningModel;
  35783. private _playbackRate;
  35784. private _streaming;
  35785. private _startTime;
  35786. private _startOffset;
  35787. private _position;
  35788. /** @hidden */
  35789. _positionInEmitterSpace: boolean;
  35790. private _localDirection;
  35791. private _volume;
  35792. private _isReadyToPlay;
  35793. private _isDirectional;
  35794. private _readyToPlayCallback;
  35795. private _audioBuffer;
  35796. private _soundSource;
  35797. private _streamingSource;
  35798. private _soundPanner;
  35799. private _soundGain;
  35800. private _inputAudioNode;
  35801. private _outputAudioNode;
  35802. private _coneInnerAngle;
  35803. private _coneOuterAngle;
  35804. private _coneOuterGain;
  35805. private _scene;
  35806. private _connectedTransformNode;
  35807. private _customAttenuationFunction;
  35808. private _registerFunc;
  35809. private _isOutputConnected;
  35810. private _htmlAudioElement;
  35811. private _urlType;
  35812. private _length?;
  35813. private _offset?;
  35814. /** @hidden */
  35815. static _SceneComponentInitialization: (scene: Scene) => void;
  35816. /**
  35817. * Create a sound and attach it to a scene
  35818. * @param name Name of your sound
  35819. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35820. * @param scene defines the scene the sound belongs to
  35821. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35822. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35823. */
  35824. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  35825. /**
  35826. * Release the sound and its associated resources
  35827. */
  35828. dispose(): void;
  35829. /**
  35830. * Gets if the sounds is ready to be played or not.
  35831. * @returns true if ready, otherwise false
  35832. */
  35833. isReady(): boolean;
  35834. private _soundLoaded;
  35835. /**
  35836. * Sets the data of the sound from an audiobuffer
  35837. * @param audioBuffer The audioBuffer containing the data
  35838. */
  35839. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35840. /**
  35841. * Updates the current sounds options such as maxdistance, loop...
  35842. * @param options A JSON object containing values named as the object properties
  35843. */
  35844. updateOptions(options: ISoundOptions): void;
  35845. private _createSpatialParameters;
  35846. private _updateSpatialParameters;
  35847. /**
  35848. * Switch the panning model to HRTF:
  35849. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35850. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35851. */
  35852. switchPanningModelToHRTF(): void;
  35853. /**
  35854. * Switch the panning model to Equal Power:
  35855. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35856. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35857. */
  35858. switchPanningModelToEqualPower(): void;
  35859. private _switchPanningModel;
  35860. /**
  35861. * Connect this sound to a sound track audio node like gain...
  35862. * @param soundTrackAudioNode the sound track audio node to connect to
  35863. */
  35864. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35865. /**
  35866. * Transform this sound into a directional source
  35867. * @param coneInnerAngle Size of the inner cone in degree
  35868. * @param coneOuterAngle Size of the outer cone in degree
  35869. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35870. */
  35871. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35872. /**
  35873. * Gets or sets the inner angle for the directional cone.
  35874. */
  35875. /**
  35876. * Gets or sets the inner angle for the directional cone.
  35877. */
  35878. directionalConeInnerAngle: number;
  35879. /**
  35880. * Gets or sets the outer angle for the directional cone.
  35881. */
  35882. /**
  35883. * Gets or sets the outer angle for the directional cone.
  35884. */
  35885. directionalConeOuterAngle: number;
  35886. /**
  35887. * Sets the position of the emitter if spatial sound is enabled
  35888. * @param newPosition Defines the new posisiton
  35889. */
  35890. setPosition(newPosition: Vector3): void;
  35891. /**
  35892. * Sets the local direction of the emitter if spatial sound is enabled
  35893. * @param newLocalDirection Defines the new local direction
  35894. */
  35895. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35896. private _updateDirection;
  35897. /** @hidden */
  35898. updateDistanceFromListener(): void;
  35899. /**
  35900. * Sets a new custom attenuation function for the sound.
  35901. * @param callback Defines the function used for the attenuation
  35902. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35903. */
  35904. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35905. /**
  35906. * Play the sound
  35907. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35908. * @param offset (optional) Start the sound at a specific time in seconds
  35909. * @param length (optional) Sound duration (in seconds)
  35910. */
  35911. play(time?: number, offset?: number, length?: number): void;
  35912. private _onended;
  35913. /**
  35914. * Stop the sound
  35915. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35916. */
  35917. stop(time?: number): void;
  35918. /**
  35919. * Put the sound in pause
  35920. */
  35921. pause(): void;
  35922. /**
  35923. * Sets a dedicated volume for this sounds
  35924. * @param newVolume Define the new volume of the sound
  35925. * @param time Define time for gradual change to new volume
  35926. */
  35927. setVolume(newVolume: number, time?: number): void;
  35928. /**
  35929. * Set the sound play back rate
  35930. * @param newPlaybackRate Define the playback rate the sound should be played at
  35931. */
  35932. setPlaybackRate(newPlaybackRate: number): void;
  35933. /**
  35934. * Gets the volume of the sound.
  35935. * @returns the volume of the sound
  35936. */
  35937. getVolume(): number;
  35938. /**
  35939. * Attach the sound to a dedicated mesh
  35940. * @param transformNode The transform node to connect the sound with
  35941. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35942. */
  35943. attachToMesh(transformNode: TransformNode): void;
  35944. /**
  35945. * Detach the sound from the previously attached mesh
  35946. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35947. */
  35948. detachFromMesh(): void;
  35949. private _onRegisterAfterWorldMatrixUpdate;
  35950. /**
  35951. * Clone the current sound in the scene.
  35952. * @returns the new sound clone
  35953. */
  35954. clone(): Nullable<Sound>;
  35955. /**
  35956. * Gets the current underlying audio buffer containing the data
  35957. * @returns the audio buffer
  35958. */
  35959. getAudioBuffer(): Nullable<AudioBuffer>;
  35960. /**
  35961. * Serializes the Sound in a JSON representation
  35962. * @returns the JSON representation of the sound
  35963. */
  35964. serialize(): any;
  35965. /**
  35966. * Parse a JSON representation of a sound to innstantiate in a given scene
  35967. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35968. * @param scene Define the scene the new parsed sound should be created in
  35969. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35970. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35971. * @returns the newly parsed sound
  35972. */
  35973. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35974. }
  35975. }
  35976. declare module "babylonjs/Actions/directAudioActions" {
  35977. import { Action } from "babylonjs/Actions/action";
  35978. import { Condition } from "babylonjs/Actions/condition";
  35979. import { Sound } from "babylonjs/Audio/sound";
  35980. /**
  35981. * This defines an action helpful to play a defined sound on a triggered action.
  35982. */
  35983. export class PlaySoundAction extends Action {
  35984. private _sound;
  35985. /**
  35986. * Instantiate the action
  35987. * @param triggerOptions defines the trigger options
  35988. * @param sound defines the sound to play
  35989. * @param condition defines the trigger related conditions
  35990. */
  35991. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35992. /** @hidden */
  35993. _prepare(): void;
  35994. /**
  35995. * Execute the action and play the sound.
  35996. */
  35997. execute(): void;
  35998. /**
  35999. * Serializes the actions and its related information.
  36000. * @param parent defines the object to serialize in
  36001. * @returns the serialized object
  36002. */
  36003. serialize(parent: any): any;
  36004. }
  36005. /**
  36006. * This defines an action helpful to stop a defined sound on a triggered action.
  36007. */
  36008. export class StopSoundAction extends Action {
  36009. private _sound;
  36010. /**
  36011. * Instantiate the action
  36012. * @param triggerOptions defines the trigger options
  36013. * @param sound defines the sound to stop
  36014. * @param condition defines the trigger related conditions
  36015. */
  36016. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36017. /** @hidden */
  36018. _prepare(): void;
  36019. /**
  36020. * Execute the action and stop the sound.
  36021. */
  36022. execute(): void;
  36023. /**
  36024. * Serializes the actions and its related information.
  36025. * @param parent defines the object to serialize in
  36026. * @returns the serialized object
  36027. */
  36028. serialize(parent: any): any;
  36029. }
  36030. }
  36031. declare module "babylonjs/Actions/interpolateValueAction" {
  36032. import { Action } from "babylonjs/Actions/action";
  36033. import { Condition } from "babylonjs/Actions/condition";
  36034. import { Observable } from "babylonjs/Misc/observable";
  36035. /**
  36036. * This defines an action responsible to change the value of a property
  36037. * by interpolating between its current value and the newly set one once triggered.
  36038. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36039. */
  36040. export class InterpolateValueAction extends Action {
  36041. /**
  36042. * Defines the path of the property where the value should be interpolated
  36043. */
  36044. propertyPath: string;
  36045. /**
  36046. * Defines the target value at the end of the interpolation.
  36047. */
  36048. value: any;
  36049. /**
  36050. * Defines the time it will take for the property to interpolate to the value.
  36051. */
  36052. duration: number;
  36053. /**
  36054. * Defines if the other scene animations should be stopped when the action has been triggered
  36055. */
  36056. stopOtherAnimations?: boolean;
  36057. /**
  36058. * Defines a callback raised once the interpolation animation has been done.
  36059. */
  36060. onInterpolationDone?: () => void;
  36061. /**
  36062. * Observable triggered once the interpolation animation has been done.
  36063. */
  36064. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  36065. private _target;
  36066. private _effectiveTarget;
  36067. private _property;
  36068. /**
  36069. * Instantiate the action
  36070. * @param triggerOptions defines the trigger options
  36071. * @param target defines the object containing the value to interpolate
  36072. * @param propertyPath defines the path to the property in the target object
  36073. * @param value defines the target value at the end of the interpolation
  36074. * @param duration deines the time it will take for the property to interpolate to the value.
  36075. * @param condition defines the trigger related conditions
  36076. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36077. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36078. */
  36079. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36080. /** @hidden */
  36081. _prepare(): void;
  36082. /**
  36083. * Execute the action starts the value interpolation.
  36084. */
  36085. execute(): void;
  36086. /**
  36087. * Serializes the actions and its related information.
  36088. * @param parent defines the object to serialize in
  36089. * @returns the serialized object
  36090. */
  36091. serialize(parent: any): any;
  36092. }
  36093. }
  36094. declare module "babylonjs/Actions/index" {
  36095. export * from "babylonjs/Actions/abstractActionManager";
  36096. export * from "babylonjs/Actions/action";
  36097. export * from "babylonjs/Actions/actionEvent";
  36098. export * from "babylonjs/Actions/actionManager";
  36099. export * from "babylonjs/Actions/condition";
  36100. export * from "babylonjs/Actions/directActions";
  36101. export * from "babylonjs/Actions/directAudioActions";
  36102. export * from "babylonjs/Actions/interpolateValueAction";
  36103. }
  36104. declare module "babylonjs/Animations/index" {
  36105. export * from "babylonjs/Animations/animatable";
  36106. export * from "babylonjs/Animations/animation";
  36107. export * from "babylonjs/Animations/animationGroup";
  36108. export * from "babylonjs/Animations/animationPropertiesOverride";
  36109. export * from "babylonjs/Animations/easing";
  36110. export * from "babylonjs/Animations/runtimeAnimation";
  36111. export * from "babylonjs/Animations/animationEvent";
  36112. export * from "babylonjs/Animations/animationGroup";
  36113. export * from "babylonjs/Animations/animationKey";
  36114. export * from "babylonjs/Animations/animationRange";
  36115. export * from "babylonjs/Animations/animatable.interface";
  36116. }
  36117. declare module "babylonjs/Audio/soundTrack" {
  36118. import { Sound } from "babylonjs/Audio/sound";
  36119. import { Analyser } from "babylonjs/Audio/analyser";
  36120. import { Scene } from "babylonjs/scene";
  36121. /**
  36122. * Options allowed during the creation of a sound track.
  36123. */
  36124. export interface ISoundTrackOptions {
  36125. /**
  36126. * The volume the sound track should take during creation
  36127. */
  36128. volume?: number;
  36129. /**
  36130. * Define if the sound track is the main sound track of the scene
  36131. */
  36132. mainTrack?: boolean;
  36133. }
  36134. /**
  36135. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  36136. * It will be also used in a future release to apply effects on a specific track.
  36137. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36138. */
  36139. export class SoundTrack {
  36140. /**
  36141. * The unique identifier of the sound track in the scene.
  36142. */
  36143. id: number;
  36144. /**
  36145. * The list of sounds included in the sound track.
  36146. */
  36147. soundCollection: Array<Sound>;
  36148. private _outputAudioNode;
  36149. private _scene;
  36150. private _isMainTrack;
  36151. private _connectedAnalyser;
  36152. private _options;
  36153. private _isInitialized;
  36154. /**
  36155. * Creates a new sound track.
  36156. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36157. * @param scene Define the scene the sound track belongs to
  36158. * @param options
  36159. */
  36160. constructor(scene: Scene, options?: ISoundTrackOptions);
  36161. private _initializeSoundTrackAudioGraph;
  36162. /**
  36163. * Release the sound track and its associated resources
  36164. */
  36165. dispose(): void;
  36166. /**
  36167. * Adds a sound to this sound track
  36168. * @param sound define the cound to add
  36169. * @ignoreNaming
  36170. */
  36171. AddSound(sound: Sound): void;
  36172. /**
  36173. * Removes a sound to this sound track
  36174. * @param sound define the cound to remove
  36175. * @ignoreNaming
  36176. */
  36177. RemoveSound(sound: Sound): void;
  36178. /**
  36179. * Set a global volume for the full sound track.
  36180. * @param newVolume Define the new volume of the sound track
  36181. */
  36182. setVolume(newVolume: number): void;
  36183. /**
  36184. * Switch the panning model to HRTF:
  36185. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36186. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36187. */
  36188. switchPanningModelToHRTF(): void;
  36189. /**
  36190. * Switch the panning model to Equal Power:
  36191. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36192. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36193. */
  36194. switchPanningModelToEqualPower(): void;
  36195. /**
  36196. * Connect the sound track to an audio analyser allowing some amazing
  36197. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36198. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36199. * @param analyser The analyser to connect to the engine
  36200. */
  36201. connectToAnalyser(analyser: Analyser): void;
  36202. }
  36203. }
  36204. declare module "babylonjs/Audio/audioSceneComponent" {
  36205. import { Sound } from "babylonjs/Audio/sound";
  36206. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  36207. import { Nullable } from "babylonjs/types";
  36208. import { Vector3 } from "babylonjs/Maths/math.vector";
  36209. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  36210. import { Scene } from "babylonjs/scene";
  36211. import { AbstractScene } from "babylonjs/abstractScene";
  36212. import "babylonjs/Audio/audioEngine";
  36213. module "babylonjs/abstractScene" {
  36214. interface AbstractScene {
  36215. /**
  36216. * The list of sounds used in the scene.
  36217. */
  36218. sounds: Nullable<Array<Sound>>;
  36219. }
  36220. }
  36221. module "babylonjs/scene" {
  36222. interface Scene {
  36223. /**
  36224. * @hidden
  36225. * Backing field
  36226. */
  36227. _mainSoundTrack: SoundTrack;
  36228. /**
  36229. * The main sound track played by the scene.
  36230. * It cotains your primary collection of sounds.
  36231. */
  36232. mainSoundTrack: SoundTrack;
  36233. /**
  36234. * The list of sound tracks added to the scene
  36235. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36236. */
  36237. soundTracks: Nullable<Array<SoundTrack>>;
  36238. /**
  36239. * Gets a sound using a given name
  36240. * @param name defines the name to search for
  36241. * @return the found sound or null if not found at all.
  36242. */
  36243. getSoundByName(name: string): Nullable<Sound>;
  36244. /**
  36245. * Gets or sets if audio support is enabled
  36246. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36247. */
  36248. audioEnabled: boolean;
  36249. /**
  36250. * Gets or sets if audio will be output to headphones
  36251. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36252. */
  36253. headphone: boolean;
  36254. /**
  36255. * Gets or sets custom audio listener position provider
  36256. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36257. */
  36258. audioListenerPositionProvider: Nullable<() => Vector3>;
  36259. }
  36260. }
  36261. /**
  36262. * Defines the sound scene component responsible to manage any sounds
  36263. * in a given scene.
  36264. */
  36265. export class AudioSceneComponent implements ISceneSerializableComponent {
  36266. /**
  36267. * The component name helpfull to identify the component in the list of scene components.
  36268. */
  36269. readonly name: string;
  36270. /**
  36271. * The scene the component belongs to.
  36272. */
  36273. scene: Scene;
  36274. private _audioEnabled;
  36275. /**
  36276. * Gets whether audio is enabled or not.
  36277. * Please use related enable/disable method to switch state.
  36278. */
  36279. readonly audioEnabled: boolean;
  36280. private _headphone;
  36281. /**
  36282. * Gets whether audio is outputing to headphone or not.
  36283. * Please use the according Switch methods to change output.
  36284. */
  36285. readonly headphone: boolean;
  36286. private _audioListenerPositionProvider;
  36287. /**
  36288. * Gets the current audio listener position provider
  36289. */
  36290. /**
  36291. * Sets a custom listener position for all sounds in the scene
  36292. * By default, this is the position of the first active camera
  36293. */
  36294. audioListenerPositionProvider: Nullable<() => Vector3>;
  36295. /**
  36296. * Creates a new instance of the component for the given scene
  36297. * @param scene Defines the scene to register the component in
  36298. */
  36299. constructor(scene: Scene);
  36300. /**
  36301. * Registers the component in a given scene
  36302. */
  36303. register(): void;
  36304. /**
  36305. * Rebuilds the elements related to this component in case of
  36306. * context lost for instance.
  36307. */
  36308. rebuild(): void;
  36309. /**
  36310. * Serializes the component data to the specified json object
  36311. * @param serializationObject The object to serialize to
  36312. */
  36313. serialize(serializationObject: any): void;
  36314. /**
  36315. * Adds all the elements from the container to the scene
  36316. * @param container the container holding the elements
  36317. */
  36318. addFromContainer(container: AbstractScene): void;
  36319. /**
  36320. * Removes all the elements in the container from the scene
  36321. * @param container contains the elements to remove
  36322. * @param dispose if the removed element should be disposed (default: false)
  36323. */
  36324. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  36325. /**
  36326. * Disposes the component and the associated ressources.
  36327. */
  36328. dispose(): void;
  36329. /**
  36330. * Disables audio in the associated scene.
  36331. */
  36332. disableAudio(): void;
  36333. /**
  36334. * Enables audio in the associated scene.
  36335. */
  36336. enableAudio(): void;
  36337. /**
  36338. * Switch audio to headphone output.
  36339. */
  36340. switchAudioModeForHeadphones(): void;
  36341. /**
  36342. * Switch audio to normal speakers.
  36343. */
  36344. switchAudioModeForNormalSpeakers(): void;
  36345. private _afterRender;
  36346. }
  36347. }
  36348. declare module "babylonjs/Audio/weightedsound" {
  36349. import { Sound } from "babylonjs/Audio/sound";
  36350. /**
  36351. * Wraps one or more Sound objects and selects one with random weight for playback.
  36352. */
  36353. export class WeightedSound {
  36354. /** When true a Sound will be selected and played when the current playing Sound completes. */
  36355. loop: boolean;
  36356. private _coneInnerAngle;
  36357. private _coneOuterAngle;
  36358. private _volume;
  36359. /** A Sound is currently playing. */
  36360. isPlaying: boolean;
  36361. /** A Sound is currently paused. */
  36362. isPaused: boolean;
  36363. private _sounds;
  36364. private _weights;
  36365. private _currentIndex?;
  36366. /**
  36367. * Creates a new WeightedSound from the list of sounds given.
  36368. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  36369. * @param sounds Array of Sounds that will be selected from.
  36370. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  36371. */
  36372. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  36373. /**
  36374. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  36375. */
  36376. /**
  36377. * The size of cone in degress for a directional sound in which there will be no attenuation.
  36378. */
  36379. directionalConeInnerAngle: number;
  36380. /**
  36381. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36382. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36383. */
  36384. /**
  36385. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36386. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36387. */
  36388. directionalConeOuterAngle: number;
  36389. /**
  36390. * Playback volume.
  36391. */
  36392. /**
  36393. * Playback volume.
  36394. */
  36395. volume: number;
  36396. private _onended;
  36397. /**
  36398. * Suspend playback
  36399. */
  36400. pause(): void;
  36401. /**
  36402. * Stop playback
  36403. */
  36404. stop(): void;
  36405. /**
  36406. * Start playback.
  36407. * @param startOffset Position the clip head at a specific time in seconds.
  36408. */
  36409. play(startOffset?: number): void;
  36410. }
  36411. }
  36412. declare module "babylonjs/Audio/index" {
  36413. export * from "babylonjs/Audio/analyser";
  36414. export * from "babylonjs/Audio/audioEngine";
  36415. export * from "babylonjs/Audio/audioSceneComponent";
  36416. export * from "babylonjs/Audio/sound";
  36417. export * from "babylonjs/Audio/soundTrack";
  36418. export * from "babylonjs/Audio/weightedsound";
  36419. }
  36420. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  36421. import { Behavior } from "babylonjs/Behaviors/behavior";
  36422. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36423. import { BackEase } from "babylonjs/Animations/easing";
  36424. /**
  36425. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  36426. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36427. */
  36428. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  36429. /**
  36430. * Gets the name of the behavior.
  36431. */
  36432. readonly name: string;
  36433. /**
  36434. * The easing function used by animations
  36435. */
  36436. static EasingFunction: BackEase;
  36437. /**
  36438. * The easing mode used by animations
  36439. */
  36440. static EasingMode: number;
  36441. /**
  36442. * The duration of the animation, in milliseconds
  36443. */
  36444. transitionDuration: number;
  36445. /**
  36446. * Length of the distance animated by the transition when lower radius is reached
  36447. */
  36448. lowerRadiusTransitionRange: number;
  36449. /**
  36450. * Length of the distance animated by the transition when upper radius is reached
  36451. */
  36452. upperRadiusTransitionRange: number;
  36453. private _autoTransitionRange;
  36454. /**
  36455. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36456. */
  36457. /**
  36458. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36459. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  36460. */
  36461. autoTransitionRange: boolean;
  36462. private _attachedCamera;
  36463. private _onAfterCheckInputsObserver;
  36464. private _onMeshTargetChangedObserver;
  36465. /**
  36466. * Initializes the behavior.
  36467. */
  36468. init(): void;
  36469. /**
  36470. * Attaches the behavior to its arc rotate camera.
  36471. * @param camera Defines the camera to attach the behavior to
  36472. */
  36473. attach(camera: ArcRotateCamera): void;
  36474. /**
  36475. * Detaches the behavior from its current arc rotate camera.
  36476. */
  36477. detach(): void;
  36478. private _radiusIsAnimating;
  36479. private _radiusBounceTransition;
  36480. private _animatables;
  36481. private _cachedWheelPrecision;
  36482. /**
  36483. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  36484. * @param radiusLimit The limit to check against.
  36485. * @return Bool to indicate if at limit.
  36486. */
  36487. private _isRadiusAtLimit;
  36488. /**
  36489. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  36490. * @param radiusDelta The delta by which to animate to. Can be negative.
  36491. */
  36492. private _applyBoundRadiusAnimation;
  36493. /**
  36494. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  36495. */
  36496. protected _clearAnimationLocks(): void;
  36497. /**
  36498. * Stops and removes all animations that have been applied to the camera
  36499. */
  36500. stopAllAnimations(): void;
  36501. }
  36502. }
  36503. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  36504. import { Behavior } from "babylonjs/Behaviors/behavior";
  36505. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36506. import { ExponentialEase } from "babylonjs/Animations/easing";
  36507. import { Nullable } from "babylonjs/types";
  36508. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36509. import { Vector3 } from "babylonjs/Maths/math.vector";
  36510. /**
  36511. * 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.
  36512. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36513. */
  36514. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36515. /**
  36516. * Gets the name of the behavior.
  36517. */
  36518. readonly name: string;
  36519. private _mode;
  36520. private _radiusScale;
  36521. private _positionScale;
  36522. private _defaultElevation;
  36523. private _elevationReturnTime;
  36524. private _elevationReturnWaitTime;
  36525. private _zoomStopsAnimation;
  36526. private _framingTime;
  36527. /**
  36528. * The easing function used by animations
  36529. */
  36530. static EasingFunction: ExponentialEase;
  36531. /**
  36532. * The easing mode used by animations
  36533. */
  36534. static EasingMode: number;
  36535. /**
  36536. * Sets the current mode used by the behavior
  36537. */
  36538. /**
  36539. * Gets current mode used by the behavior.
  36540. */
  36541. mode: number;
  36542. /**
  36543. * Sets the scale applied to the radius (1 by default)
  36544. */
  36545. /**
  36546. * Gets the scale applied to the radius
  36547. */
  36548. radiusScale: number;
  36549. /**
  36550. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36551. */
  36552. /**
  36553. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36554. */
  36555. positionScale: number;
  36556. /**
  36557. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36558. * behaviour is triggered, in radians.
  36559. */
  36560. /**
  36561. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36562. * behaviour is triggered, in radians.
  36563. */
  36564. defaultElevation: number;
  36565. /**
  36566. * Sets the time (in milliseconds) taken to return to the default beta position.
  36567. * Negative value indicates camera should not return to default.
  36568. */
  36569. /**
  36570. * Gets the time (in milliseconds) taken to return to the default beta position.
  36571. * Negative value indicates camera should not return to default.
  36572. */
  36573. elevationReturnTime: number;
  36574. /**
  36575. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36576. */
  36577. /**
  36578. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36579. */
  36580. elevationReturnWaitTime: number;
  36581. /**
  36582. * Sets the flag that indicates if user zooming should stop animation.
  36583. */
  36584. /**
  36585. * Gets the flag that indicates if user zooming should stop animation.
  36586. */
  36587. zoomStopsAnimation: boolean;
  36588. /**
  36589. * Sets the transition time when framing the mesh, in milliseconds
  36590. */
  36591. /**
  36592. * Gets the transition time when framing the mesh, in milliseconds
  36593. */
  36594. framingTime: number;
  36595. /**
  36596. * Define if the behavior should automatically change the configured
  36597. * camera limits and sensibilities.
  36598. */
  36599. autoCorrectCameraLimitsAndSensibility: boolean;
  36600. private _onPrePointerObservableObserver;
  36601. private _onAfterCheckInputsObserver;
  36602. private _onMeshTargetChangedObserver;
  36603. private _attachedCamera;
  36604. private _isPointerDown;
  36605. private _lastInteractionTime;
  36606. /**
  36607. * Initializes the behavior.
  36608. */
  36609. init(): void;
  36610. /**
  36611. * Attaches the behavior to its arc rotate camera.
  36612. * @param camera Defines the camera to attach the behavior to
  36613. */
  36614. attach(camera: ArcRotateCamera): void;
  36615. /**
  36616. * Detaches the behavior from its current arc rotate camera.
  36617. */
  36618. detach(): void;
  36619. private _animatables;
  36620. private _betaIsAnimating;
  36621. private _betaTransition;
  36622. private _radiusTransition;
  36623. private _vectorTransition;
  36624. /**
  36625. * Targets the given mesh and updates zoom level accordingly.
  36626. * @param mesh The mesh to target.
  36627. * @param radius Optional. If a cached radius position already exists, overrides default.
  36628. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36629. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36630. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36631. */
  36632. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36633. /**
  36634. * Targets the given mesh with its children and updates zoom level accordingly.
  36635. * @param mesh The mesh to target.
  36636. * @param radius Optional. If a cached radius position already exists, overrides default.
  36637. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36638. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36639. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36640. */
  36641. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36642. /**
  36643. * Targets the given meshes with their children and updates zoom level accordingly.
  36644. * @param meshes The mesh to target.
  36645. * @param radius Optional. If a cached radius position already exists, overrides default.
  36646. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36647. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36648. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36649. */
  36650. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36651. /**
  36652. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  36653. * @param minimumWorld Determines the smaller position of the bounding box extend
  36654. * @param maximumWorld Determines the bigger position of the bounding box extend
  36655. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36656. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36657. */
  36658. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36659. /**
  36660. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  36661. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  36662. * frustum width.
  36663. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  36664. * to fully enclose the mesh in the viewing frustum.
  36665. */
  36666. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  36667. /**
  36668. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  36669. * is automatically returned to its default position (expected to be above ground plane).
  36670. */
  36671. private _maintainCameraAboveGround;
  36672. /**
  36673. * Returns the frustum slope based on the canvas ratio and camera FOV
  36674. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  36675. */
  36676. private _getFrustumSlope;
  36677. /**
  36678. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  36679. */
  36680. private _clearAnimationLocks;
  36681. /**
  36682. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36683. */
  36684. private _applyUserInteraction;
  36685. /**
  36686. * Stops and removes all animations that have been applied to the camera
  36687. */
  36688. stopAllAnimations(): void;
  36689. /**
  36690. * Gets a value indicating if the user is moving the camera
  36691. */
  36692. readonly isUserIsMoving: boolean;
  36693. /**
  36694. * The camera can move all the way towards the mesh.
  36695. */
  36696. static IgnoreBoundsSizeMode: number;
  36697. /**
  36698. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36699. */
  36700. static FitFrustumSidesMode: number;
  36701. }
  36702. }
  36703. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  36704. import { Nullable } from "babylonjs/types";
  36705. import { Camera } from "babylonjs/Cameras/camera";
  36706. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36707. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36708. /**
  36709. * Base class for Camera Pointer Inputs.
  36710. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  36711. * for example usage.
  36712. */
  36713. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  36714. /**
  36715. * Defines the camera the input is attached to.
  36716. */
  36717. abstract camera: Camera;
  36718. /**
  36719. * Whether keyboard modifier keys are pressed at time of last mouse event.
  36720. */
  36721. protected _altKey: boolean;
  36722. protected _ctrlKey: boolean;
  36723. protected _metaKey: boolean;
  36724. protected _shiftKey: boolean;
  36725. /**
  36726. * Which mouse buttons were pressed at time of last mouse event.
  36727. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  36728. */
  36729. protected _buttonsPressed: number;
  36730. /**
  36731. * Defines the buttons associated with the input to handle camera move.
  36732. */
  36733. buttons: number[];
  36734. /**
  36735. * Attach the input controls to a specific dom element to get the input from.
  36736. * @param element Defines the element the controls should be listened from
  36737. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36738. */
  36739. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36740. /**
  36741. * Detach the current controls from the specified dom element.
  36742. * @param element Defines the element to stop listening the inputs from
  36743. */
  36744. detachControl(element: Nullable<HTMLElement>): void;
  36745. /**
  36746. * Gets the class name of the current input.
  36747. * @returns the class name
  36748. */
  36749. getClassName(): string;
  36750. /**
  36751. * Get the friendly name associated with the input class.
  36752. * @returns the input friendly name
  36753. */
  36754. getSimpleName(): string;
  36755. /**
  36756. * Called on pointer POINTERDOUBLETAP event.
  36757. * Override this method to provide functionality on POINTERDOUBLETAP event.
  36758. */
  36759. protected onDoubleTap(type: string): void;
  36760. /**
  36761. * Called on pointer POINTERMOVE event if only a single touch is active.
  36762. * Override this method to provide functionality.
  36763. */
  36764. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36765. /**
  36766. * Called on pointer POINTERMOVE event if multiple touches are active.
  36767. * Override this method to provide functionality.
  36768. */
  36769. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36770. /**
  36771. * Called on JS contextmenu event.
  36772. * Override this method to provide functionality.
  36773. */
  36774. protected onContextMenu(evt: PointerEvent): void;
  36775. /**
  36776. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36777. * press.
  36778. * Override this method to provide functionality.
  36779. */
  36780. protected onButtonDown(evt: PointerEvent): void;
  36781. /**
  36782. * Called each time a new POINTERUP event occurs. Ie, for each button
  36783. * release.
  36784. * Override this method to provide functionality.
  36785. */
  36786. protected onButtonUp(evt: PointerEvent): void;
  36787. /**
  36788. * Called when window becomes inactive.
  36789. * Override this method to provide functionality.
  36790. */
  36791. protected onLostFocus(): void;
  36792. private _pointerInput;
  36793. private _observer;
  36794. private _onLostFocus;
  36795. private pointA;
  36796. private pointB;
  36797. }
  36798. }
  36799. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  36800. import { Nullable } from "babylonjs/types";
  36801. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36802. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  36803. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36804. /**
  36805. * Manage the pointers inputs to control an arc rotate camera.
  36806. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36807. */
  36808. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36809. /**
  36810. * Defines the camera the input is attached to.
  36811. */
  36812. camera: ArcRotateCamera;
  36813. /**
  36814. * Gets the class name of the current input.
  36815. * @returns the class name
  36816. */
  36817. getClassName(): string;
  36818. /**
  36819. * Defines the buttons associated with the input to handle camera move.
  36820. */
  36821. buttons: number[];
  36822. /**
  36823. * Defines the pointer angular sensibility along the X axis or how fast is
  36824. * the camera rotating.
  36825. */
  36826. angularSensibilityX: number;
  36827. /**
  36828. * Defines the pointer angular sensibility along the Y axis or how fast is
  36829. * the camera rotating.
  36830. */
  36831. angularSensibilityY: number;
  36832. /**
  36833. * Defines the pointer pinch precision or how fast is the camera zooming.
  36834. */
  36835. pinchPrecision: number;
  36836. /**
  36837. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36838. * from 0.
  36839. * It defines the percentage of current camera.radius to use as delta when
  36840. * pinch zoom is used.
  36841. */
  36842. pinchDeltaPercentage: number;
  36843. /**
  36844. * Defines the pointer panning sensibility or how fast is the camera moving.
  36845. */
  36846. panningSensibility: number;
  36847. /**
  36848. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36849. */
  36850. multiTouchPanning: boolean;
  36851. /**
  36852. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  36853. * zoom (pinch) through multitouch.
  36854. */
  36855. multiTouchPanAndZoom: boolean;
  36856. /**
  36857. * Revers pinch action direction.
  36858. */
  36859. pinchInwards: boolean;
  36860. private _isPanClick;
  36861. private _twoFingerActivityCount;
  36862. private _isPinching;
  36863. /**
  36864. * Called on pointer POINTERMOVE event if only a single touch is active.
  36865. */
  36866. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36867. /**
  36868. * Called on pointer POINTERDOUBLETAP event.
  36869. */
  36870. protected onDoubleTap(type: string): void;
  36871. /**
  36872. * Called on pointer POINTERMOVE event if multiple touches are active.
  36873. */
  36874. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36875. /**
  36876. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36877. * press.
  36878. */
  36879. protected onButtonDown(evt: PointerEvent): void;
  36880. /**
  36881. * Called each time a new POINTERUP event occurs. Ie, for each button
  36882. * release.
  36883. */
  36884. protected onButtonUp(evt: PointerEvent): void;
  36885. /**
  36886. * Called when window becomes inactive.
  36887. */
  36888. protected onLostFocus(): void;
  36889. }
  36890. }
  36891. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  36892. import { Nullable } from "babylonjs/types";
  36893. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36894. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36895. /**
  36896. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  36897. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36898. */
  36899. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  36900. /**
  36901. * Defines the camera the input is attached to.
  36902. */
  36903. camera: ArcRotateCamera;
  36904. /**
  36905. * Defines the list of key codes associated with the up action (increase alpha)
  36906. */
  36907. keysUp: number[];
  36908. /**
  36909. * Defines the list of key codes associated with the down action (decrease alpha)
  36910. */
  36911. keysDown: number[];
  36912. /**
  36913. * Defines the list of key codes associated with the left action (increase beta)
  36914. */
  36915. keysLeft: number[];
  36916. /**
  36917. * Defines the list of key codes associated with the right action (decrease beta)
  36918. */
  36919. keysRight: number[];
  36920. /**
  36921. * Defines the list of key codes associated with the reset action.
  36922. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36923. */
  36924. keysReset: number[];
  36925. /**
  36926. * Defines the panning sensibility of the inputs.
  36927. * (How fast is the camera paning)
  36928. */
  36929. panningSensibility: number;
  36930. /**
  36931. * Defines the zooming sensibility of the inputs.
  36932. * (How fast is the camera zooming)
  36933. */
  36934. zoomingSensibility: number;
  36935. /**
  36936. * Defines wether maintaining the alt key down switch the movement mode from
  36937. * orientation to zoom.
  36938. */
  36939. useAltToZoom: boolean;
  36940. /**
  36941. * Rotation speed of the camera
  36942. */
  36943. angularSpeed: number;
  36944. private _keys;
  36945. private _ctrlPressed;
  36946. private _altPressed;
  36947. private _onCanvasBlurObserver;
  36948. private _onKeyboardObserver;
  36949. private _engine;
  36950. private _scene;
  36951. /**
  36952. * Attach the input controls to a specific dom element to get the input from.
  36953. * @param element Defines the element the controls should be listened from
  36954. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36955. */
  36956. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36957. /**
  36958. * Detach the current controls from the specified dom element.
  36959. * @param element Defines the element to stop listening the inputs from
  36960. */
  36961. detachControl(element: Nullable<HTMLElement>): void;
  36962. /**
  36963. * Update the current camera state depending on the inputs that have been used this frame.
  36964. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36965. */
  36966. checkInputs(): void;
  36967. /**
  36968. * Gets the class name of the current intput.
  36969. * @returns the class name
  36970. */
  36971. getClassName(): string;
  36972. /**
  36973. * Get the friendly name associated with the input class.
  36974. * @returns the input friendly name
  36975. */
  36976. getSimpleName(): string;
  36977. }
  36978. }
  36979. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  36980. import { Nullable } from "babylonjs/types";
  36981. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36982. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36983. /**
  36984. * Manage the mouse wheel inputs to control an arc rotate camera.
  36985. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36986. */
  36987. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36988. /**
  36989. * Defines the camera the input is attached to.
  36990. */
  36991. camera: ArcRotateCamera;
  36992. /**
  36993. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36994. */
  36995. wheelPrecision: number;
  36996. /**
  36997. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36998. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36999. */
  37000. wheelDeltaPercentage: number;
  37001. private _wheel;
  37002. private _observer;
  37003. private computeDeltaFromMouseWheelLegacyEvent;
  37004. /**
  37005. * Attach the input controls to a specific dom element to get the input from.
  37006. * @param element Defines the element the controls should be listened from
  37007. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37008. */
  37009. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37010. /**
  37011. * Detach the current controls from the specified dom element.
  37012. * @param element Defines the element to stop listening the inputs from
  37013. */
  37014. detachControl(element: Nullable<HTMLElement>): void;
  37015. /**
  37016. * Gets the class name of the current intput.
  37017. * @returns the class name
  37018. */
  37019. getClassName(): string;
  37020. /**
  37021. * Get the friendly name associated with the input class.
  37022. * @returns the input friendly name
  37023. */
  37024. getSimpleName(): string;
  37025. }
  37026. }
  37027. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37028. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37029. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37030. /**
  37031. * Default Inputs manager for the ArcRotateCamera.
  37032. * It groups all the default supported inputs for ease of use.
  37033. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37034. */
  37035. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  37036. /**
  37037. * Instantiates a new ArcRotateCameraInputsManager.
  37038. * @param camera Defines the camera the inputs belong to
  37039. */
  37040. constructor(camera: ArcRotateCamera);
  37041. /**
  37042. * Add mouse wheel input support to the input manager.
  37043. * @returns the current input manager
  37044. */
  37045. addMouseWheel(): ArcRotateCameraInputsManager;
  37046. /**
  37047. * Add pointers input support to the input manager.
  37048. * @returns the current input manager
  37049. */
  37050. addPointers(): ArcRotateCameraInputsManager;
  37051. /**
  37052. * Add keyboard input support to the input manager.
  37053. * @returns the current input manager
  37054. */
  37055. addKeyboard(): ArcRotateCameraInputsManager;
  37056. }
  37057. }
  37058. declare module "babylonjs/Cameras/arcRotateCamera" {
  37059. import { Observable } from "babylonjs/Misc/observable";
  37060. import { Nullable } from "babylonjs/types";
  37061. import { Scene } from "babylonjs/scene";
  37062. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  37063. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37064. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37065. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37066. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  37067. import { Camera } from "babylonjs/Cameras/camera";
  37068. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37069. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  37070. import { Collider } from "babylonjs/Collisions/collider";
  37071. /**
  37072. * This represents an orbital type of camera.
  37073. *
  37074. * 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.
  37075. * 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.
  37076. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  37077. */
  37078. export class ArcRotateCamera extends TargetCamera {
  37079. /**
  37080. * Defines the rotation angle of the camera along the longitudinal axis.
  37081. */
  37082. alpha: number;
  37083. /**
  37084. * Defines the rotation angle of the camera along the latitudinal axis.
  37085. */
  37086. beta: number;
  37087. /**
  37088. * Defines the radius of the camera from it s target point.
  37089. */
  37090. radius: number;
  37091. protected _target: Vector3;
  37092. protected _targetHost: Nullable<AbstractMesh>;
  37093. /**
  37094. * Defines the target point of the camera.
  37095. * The camera looks towards it form the radius distance.
  37096. */
  37097. target: Vector3;
  37098. /**
  37099. * Define the current local position of the camera in the scene
  37100. */
  37101. position: Vector3;
  37102. protected _upVector: Vector3;
  37103. protected _upToYMatrix: Matrix;
  37104. protected _YToUpMatrix: Matrix;
  37105. /**
  37106. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37107. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37108. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37109. */
  37110. upVector: Vector3;
  37111. /**
  37112. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37113. */
  37114. setMatUp(): void;
  37115. /**
  37116. * Current inertia value on the longitudinal axis.
  37117. * The bigger this number the longer it will take for the camera to stop.
  37118. */
  37119. inertialAlphaOffset: number;
  37120. /**
  37121. * Current inertia value on the latitudinal axis.
  37122. * The bigger this number the longer it will take for the camera to stop.
  37123. */
  37124. inertialBetaOffset: number;
  37125. /**
  37126. * Current inertia value on the radius axis.
  37127. * The bigger this number the longer it will take for the camera to stop.
  37128. */
  37129. inertialRadiusOffset: number;
  37130. /**
  37131. * Minimum allowed angle on the longitudinal axis.
  37132. * This can help limiting how the Camera is able to move in the scene.
  37133. */
  37134. lowerAlphaLimit: Nullable<number>;
  37135. /**
  37136. * Maximum allowed angle on the longitudinal axis.
  37137. * This can help limiting how the Camera is able to move in the scene.
  37138. */
  37139. upperAlphaLimit: Nullable<number>;
  37140. /**
  37141. * Minimum allowed angle on the latitudinal axis.
  37142. * This can help limiting how the Camera is able to move in the scene.
  37143. */
  37144. lowerBetaLimit: number;
  37145. /**
  37146. * Maximum allowed angle on the latitudinal axis.
  37147. * This can help limiting how the Camera is able to move in the scene.
  37148. */
  37149. upperBetaLimit: number;
  37150. /**
  37151. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37152. * This can help limiting how the Camera is able to move in the scene.
  37153. */
  37154. lowerRadiusLimit: Nullable<number>;
  37155. /**
  37156. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37157. * This can help limiting how the Camera is able to move in the scene.
  37158. */
  37159. upperRadiusLimit: Nullable<number>;
  37160. /**
  37161. * Defines the current inertia value used during panning of the camera along the X axis.
  37162. */
  37163. inertialPanningX: number;
  37164. /**
  37165. * Defines the current inertia value used during panning of the camera along the Y axis.
  37166. */
  37167. inertialPanningY: number;
  37168. /**
  37169. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37170. * Basically if your fingers moves away from more than this distance you will be considered
  37171. * in pinch mode.
  37172. */
  37173. pinchToPanMaxDistance: number;
  37174. /**
  37175. * Defines the maximum distance the camera can pan.
  37176. * This could help keeping the cammera always in your scene.
  37177. */
  37178. panningDistanceLimit: Nullable<number>;
  37179. /**
  37180. * Defines the target of the camera before paning.
  37181. */
  37182. panningOriginTarget: Vector3;
  37183. /**
  37184. * Defines the value of the inertia used during panning.
  37185. * 0 would mean stop inertia and one would mean no decelleration at all.
  37186. */
  37187. panningInertia: number;
  37188. /**
  37189. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  37190. */
  37191. angularSensibilityX: number;
  37192. /**
  37193. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  37194. */
  37195. angularSensibilityY: number;
  37196. /**
  37197. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  37198. */
  37199. pinchPrecision: number;
  37200. /**
  37201. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  37202. * It will be used instead of pinchDeltaPrecision if different from 0.
  37203. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37204. */
  37205. pinchDeltaPercentage: number;
  37206. /**
  37207. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  37208. */
  37209. panningSensibility: number;
  37210. /**
  37211. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  37212. */
  37213. keysUp: number[];
  37214. /**
  37215. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  37216. */
  37217. keysDown: number[];
  37218. /**
  37219. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  37220. */
  37221. keysLeft: number[];
  37222. /**
  37223. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  37224. */
  37225. keysRight: number[];
  37226. /**
  37227. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37228. */
  37229. wheelPrecision: number;
  37230. /**
  37231. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  37232. * It will be used instead of pinchDeltaPrecision if different from 0.
  37233. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37234. */
  37235. wheelDeltaPercentage: number;
  37236. /**
  37237. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  37238. */
  37239. zoomOnFactor: number;
  37240. /**
  37241. * Defines a screen offset for the camera position.
  37242. */
  37243. targetScreenOffset: Vector2;
  37244. /**
  37245. * Allows the camera to be completely reversed.
  37246. * If false the camera can not arrive upside down.
  37247. */
  37248. allowUpsideDown: boolean;
  37249. /**
  37250. * Define if double tap/click is used to restore the previously saved state of the camera.
  37251. */
  37252. useInputToRestoreState: boolean;
  37253. /** @hidden */
  37254. _viewMatrix: Matrix;
  37255. /** @hidden */
  37256. _useCtrlForPanning: boolean;
  37257. /** @hidden */
  37258. _panningMouseButton: number;
  37259. /**
  37260. * Defines the input associated to the camera.
  37261. */
  37262. inputs: ArcRotateCameraInputsManager;
  37263. /** @hidden */
  37264. _reset: () => void;
  37265. /**
  37266. * Defines the allowed panning axis.
  37267. */
  37268. panningAxis: Vector3;
  37269. protected _localDirection: Vector3;
  37270. protected _transformedDirection: Vector3;
  37271. private _bouncingBehavior;
  37272. /**
  37273. * Gets the bouncing behavior of the camera if it has been enabled.
  37274. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37275. */
  37276. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  37277. /**
  37278. * Defines if the bouncing behavior of the camera is enabled on the camera.
  37279. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37280. */
  37281. useBouncingBehavior: boolean;
  37282. private _framingBehavior;
  37283. /**
  37284. * Gets the framing behavior of the camera if it has been enabled.
  37285. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37286. */
  37287. readonly framingBehavior: Nullable<FramingBehavior>;
  37288. /**
  37289. * Defines if the framing behavior of the camera is enabled on the camera.
  37290. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37291. */
  37292. useFramingBehavior: boolean;
  37293. private _autoRotationBehavior;
  37294. /**
  37295. * Gets the auto rotation behavior of the camera if it has been enabled.
  37296. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37297. */
  37298. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  37299. /**
  37300. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  37301. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37302. */
  37303. useAutoRotationBehavior: boolean;
  37304. /**
  37305. * Observable triggered when the mesh target has been changed on the camera.
  37306. */
  37307. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  37308. /**
  37309. * Event raised when the camera is colliding with a mesh.
  37310. */
  37311. onCollide: (collidedMesh: AbstractMesh) => void;
  37312. /**
  37313. * Defines whether the camera should check collision with the objects oh the scene.
  37314. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  37315. */
  37316. checkCollisions: boolean;
  37317. /**
  37318. * Defines the collision radius of the camera.
  37319. * This simulates a sphere around the camera.
  37320. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37321. */
  37322. collisionRadius: Vector3;
  37323. protected _collider: Collider;
  37324. protected _previousPosition: Vector3;
  37325. protected _collisionVelocity: Vector3;
  37326. protected _newPosition: Vector3;
  37327. protected _previousAlpha: number;
  37328. protected _previousBeta: number;
  37329. protected _previousRadius: number;
  37330. protected _collisionTriggered: boolean;
  37331. protected _targetBoundingCenter: Nullable<Vector3>;
  37332. private _computationVector;
  37333. /**
  37334. * Instantiates a new ArcRotateCamera in a given scene
  37335. * @param name Defines the name of the camera
  37336. * @param alpha Defines the camera rotation along the logitudinal axis
  37337. * @param beta Defines the camera rotation along the latitudinal axis
  37338. * @param radius Defines the camera distance from its target
  37339. * @param target Defines the camera target
  37340. * @param scene Defines the scene the camera belongs to
  37341. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  37342. */
  37343. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37344. /** @hidden */
  37345. _initCache(): void;
  37346. /** @hidden */
  37347. _updateCache(ignoreParentClass?: boolean): void;
  37348. protected _getTargetPosition(): Vector3;
  37349. private _storedAlpha;
  37350. private _storedBeta;
  37351. private _storedRadius;
  37352. private _storedTarget;
  37353. private _storedTargetScreenOffset;
  37354. /**
  37355. * Stores the current state of the camera (alpha, beta, radius and target)
  37356. * @returns the camera itself
  37357. */
  37358. storeState(): Camera;
  37359. /**
  37360. * @hidden
  37361. * Restored camera state. You must call storeState() first
  37362. */
  37363. _restoreStateValues(): boolean;
  37364. /** @hidden */
  37365. _isSynchronizedViewMatrix(): boolean;
  37366. /**
  37367. * Attached controls to the current camera.
  37368. * @param element Defines the element the controls should be listened from
  37369. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37370. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  37371. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  37372. */
  37373. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  37374. /**
  37375. * Detach the current controls from the camera.
  37376. * The camera will stop reacting to inputs.
  37377. * @param element Defines the element to stop listening the inputs from
  37378. */
  37379. detachControl(element: HTMLElement): void;
  37380. /** @hidden */
  37381. _checkInputs(): void;
  37382. protected _checkLimits(): void;
  37383. /**
  37384. * Rebuilds angles (alpha, beta) and radius from the give position and target
  37385. */
  37386. rebuildAnglesAndRadius(): void;
  37387. /**
  37388. * Use a position to define the current camera related information like aplha, beta and radius
  37389. * @param position Defines the position to set the camera at
  37390. */
  37391. setPosition(position: Vector3): void;
  37392. /**
  37393. * Defines the target the camera should look at.
  37394. * This will automatically adapt alpha beta and radius to fit within the new target.
  37395. * @param target Defines the new target as a Vector or a mesh
  37396. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  37397. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  37398. */
  37399. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  37400. /** @hidden */
  37401. _getViewMatrix(): Matrix;
  37402. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  37403. /**
  37404. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  37405. * @param meshes Defines the mesh to zoom on
  37406. * @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)
  37407. */
  37408. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  37409. /**
  37410. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  37411. * The target will be changed but the radius
  37412. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  37413. * @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)
  37414. */
  37415. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  37416. min: Vector3;
  37417. max: Vector3;
  37418. distance: number;
  37419. }, doNotUpdateMaxZ?: boolean): void;
  37420. /**
  37421. * @override
  37422. * Override Camera.createRigCamera
  37423. */
  37424. createRigCamera(name: string, cameraIndex: number): Camera;
  37425. /**
  37426. * @hidden
  37427. * @override
  37428. * Override Camera._updateRigCameras
  37429. */
  37430. _updateRigCameras(): void;
  37431. /**
  37432. * Destroy the camera and release the current resources hold by it.
  37433. */
  37434. dispose(): void;
  37435. /**
  37436. * Gets the current object class name.
  37437. * @return the class name
  37438. */
  37439. getClassName(): string;
  37440. }
  37441. }
  37442. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  37443. import { Behavior } from "babylonjs/Behaviors/behavior";
  37444. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37445. /**
  37446. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  37447. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37448. */
  37449. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  37450. /**
  37451. * Gets the name of the behavior.
  37452. */
  37453. readonly name: string;
  37454. private _zoomStopsAnimation;
  37455. private _idleRotationSpeed;
  37456. private _idleRotationWaitTime;
  37457. private _idleRotationSpinupTime;
  37458. /**
  37459. * Sets the flag that indicates if user zooming should stop animation.
  37460. */
  37461. /**
  37462. * Gets the flag that indicates if user zooming should stop animation.
  37463. */
  37464. zoomStopsAnimation: boolean;
  37465. /**
  37466. * Sets the default speed at which the camera rotates around the model.
  37467. */
  37468. /**
  37469. * Gets the default speed at which the camera rotates around the model.
  37470. */
  37471. idleRotationSpeed: number;
  37472. /**
  37473. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  37474. */
  37475. /**
  37476. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  37477. */
  37478. idleRotationWaitTime: number;
  37479. /**
  37480. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37481. */
  37482. /**
  37483. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37484. */
  37485. idleRotationSpinupTime: number;
  37486. /**
  37487. * Gets a value indicating if the camera is currently rotating because of this behavior
  37488. */
  37489. readonly rotationInProgress: boolean;
  37490. private _onPrePointerObservableObserver;
  37491. private _onAfterCheckInputsObserver;
  37492. private _attachedCamera;
  37493. private _isPointerDown;
  37494. private _lastFrameTime;
  37495. private _lastInteractionTime;
  37496. private _cameraRotationSpeed;
  37497. /**
  37498. * Initializes the behavior.
  37499. */
  37500. init(): void;
  37501. /**
  37502. * Attaches the behavior to its arc rotate camera.
  37503. * @param camera Defines the camera to attach the behavior to
  37504. */
  37505. attach(camera: ArcRotateCamera): void;
  37506. /**
  37507. * Detaches the behavior from its current arc rotate camera.
  37508. */
  37509. detach(): void;
  37510. /**
  37511. * Returns true if user is scrolling.
  37512. * @return true if user is scrolling.
  37513. */
  37514. private _userIsZooming;
  37515. private _lastFrameRadius;
  37516. private _shouldAnimationStopForInteraction;
  37517. /**
  37518. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37519. */
  37520. private _applyUserInteraction;
  37521. private _userIsMoving;
  37522. }
  37523. }
  37524. declare module "babylonjs/Behaviors/Cameras/index" {
  37525. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37526. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37527. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  37528. }
  37529. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  37530. import { Mesh } from "babylonjs/Meshes/mesh";
  37531. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37532. import { Behavior } from "babylonjs/Behaviors/behavior";
  37533. /**
  37534. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  37535. */
  37536. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37537. private ui;
  37538. /**
  37539. * The name of the behavior
  37540. */
  37541. name: string;
  37542. /**
  37543. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37544. */
  37545. distanceAwayFromFace: number;
  37546. /**
  37547. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37548. */
  37549. distanceAwayFromBottomOfFace: number;
  37550. private _faceVectors;
  37551. private _target;
  37552. private _scene;
  37553. private _onRenderObserver;
  37554. private _tmpMatrix;
  37555. private _tmpVector;
  37556. /**
  37557. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37558. * @param ui The transform node that should be attched to the mesh
  37559. */
  37560. constructor(ui: TransformNode);
  37561. /**
  37562. * Initializes the behavior
  37563. */
  37564. init(): void;
  37565. private _closestFace;
  37566. private _zeroVector;
  37567. private _lookAtTmpMatrix;
  37568. private _lookAtToRef;
  37569. /**
  37570. * Attaches the AttachToBoxBehavior to the passed in mesh
  37571. * @param target The mesh that the specified node will be attached to
  37572. */
  37573. attach(target: Mesh): void;
  37574. /**
  37575. * Detaches the behavior from the mesh
  37576. */
  37577. detach(): void;
  37578. }
  37579. }
  37580. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  37581. import { Behavior } from "babylonjs/Behaviors/behavior";
  37582. import { Mesh } from "babylonjs/Meshes/mesh";
  37583. /**
  37584. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37585. */
  37586. export class FadeInOutBehavior implements Behavior<Mesh> {
  37587. /**
  37588. * Time in milliseconds to delay before fading in (Default: 0)
  37589. */
  37590. delay: number;
  37591. /**
  37592. * Time in milliseconds for the mesh to fade in (Default: 300)
  37593. */
  37594. fadeInTime: number;
  37595. private _millisecondsPerFrame;
  37596. private _hovered;
  37597. private _hoverValue;
  37598. private _ownerNode;
  37599. /**
  37600. * Instatiates the FadeInOutBehavior
  37601. */
  37602. constructor();
  37603. /**
  37604. * The name of the behavior
  37605. */
  37606. readonly name: string;
  37607. /**
  37608. * Initializes the behavior
  37609. */
  37610. init(): void;
  37611. /**
  37612. * Attaches the fade behavior on the passed in mesh
  37613. * @param ownerNode The mesh that will be faded in/out once attached
  37614. */
  37615. attach(ownerNode: Mesh): void;
  37616. /**
  37617. * Detaches the behavior from the mesh
  37618. */
  37619. detach(): void;
  37620. /**
  37621. * Triggers the mesh to begin fading in or out
  37622. * @param value if the object should fade in or out (true to fade in)
  37623. */
  37624. fadeIn(value: boolean): void;
  37625. private _update;
  37626. private _setAllVisibility;
  37627. }
  37628. }
  37629. declare module "babylonjs/Misc/pivotTools" {
  37630. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37631. /**
  37632. * Class containing a set of static utilities functions for managing Pivots
  37633. * @hidden
  37634. */
  37635. export class PivotTools {
  37636. private static _PivotCached;
  37637. private static _OldPivotPoint;
  37638. private static _PivotTranslation;
  37639. private static _PivotTmpVector;
  37640. /** @hidden */
  37641. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  37642. /** @hidden */
  37643. static _RestorePivotPoint(mesh: AbstractMesh): void;
  37644. }
  37645. }
  37646. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  37647. import { Scene } from "babylonjs/scene";
  37648. import { Vector4 } from "babylonjs/Maths/math.vector";
  37649. import { Mesh } from "babylonjs/Meshes/mesh";
  37650. import { Nullable } from "babylonjs/types";
  37651. import { Plane } from "babylonjs/Maths/math.plane";
  37652. /**
  37653. * Class containing static functions to help procedurally build meshes
  37654. */
  37655. export class PlaneBuilder {
  37656. /**
  37657. * Creates a plane mesh
  37658. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  37659. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  37660. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  37661. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  37662. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  37663. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  37664. * @param name defines the name of the mesh
  37665. * @param options defines the options used to create the mesh
  37666. * @param scene defines the hosting scene
  37667. * @returns the plane mesh
  37668. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  37669. */
  37670. static CreatePlane(name: string, options: {
  37671. size?: number;
  37672. width?: number;
  37673. height?: number;
  37674. sideOrientation?: number;
  37675. frontUVs?: Vector4;
  37676. backUVs?: Vector4;
  37677. updatable?: boolean;
  37678. sourcePlane?: Plane;
  37679. }, scene?: Nullable<Scene>): Mesh;
  37680. }
  37681. }
  37682. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  37683. import { Behavior } from "babylonjs/Behaviors/behavior";
  37684. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37685. import { Observable } from "babylonjs/Misc/observable";
  37686. import { Vector3 } from "babylonjs/Maths/math.vector";
  37687. import { Ray } from "babylonjs/Culling/ray";
  37688. import "babylonjs/Meshes/Builders/planeBuilder";
  37689. /**
  37690. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  37691. */
  37692. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  37693. private static _AnyMouseID;
  37694. /**
  37695. * Abstract mesh the behavior is set on
  37696. */
  37697. attachedNode: AbstractMesh;
  37698. private _dragPlane;
  37699. private _scene;
  37700. private _pointerObserver;
  37701. private _beforeRenderObserver;
  37702. private static _planeScene;
  37703. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  37704. /**
  37705. * 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)
  37706. */
  37707. maxDragAngle: number;
  37708. /**
  37709. * @hidden
  37710. */
  37711. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  37712. /**
  37713. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37714. */
  37715. currentDraggingPointerID: number;
  37716. /**
  37717. * The last position where the pointer hit the drag plane in world space
  37718. */
  37719. lastDragPosition: Vector3;
  37720. /**
  37721. * If the behavior is currently in a dragging state
  37722. */
  37723. dragging: boolean;
  37724. /**
  37725. * 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)
  37726. */
  37727. dragDeltaRatio: number;
  37728. /**
  37729. * If the drag plane orientation should be updated during the dragging (Default: true)
  37730. */
  37731. updateDragPlane: boolean;
  37732. private _debugMode;
  37733. private _moving;
  37734. /**
  37735. * Fires each time the attached mesh is dragged with the pointer
  37736. * * delta between last drag position and current drag position in world space
  37737. * * dragDistance along the drag axis
  37738. * * dragPlaneNormal normal of the current drag plane used during the drag
  37739. * * dragPlanePoint in world space where the drag intersects the drag plane
  37740. */
  37741. onDragObservable: Observable<{
  37742. delta: Vector3;
  37743. dragPlanePoint: Vector3;
  37744. dragPlaneNormal: Vector3;
  37745. dragDistance: number;
  37746. pointerId: number;
  37747. }>;
  37748. /**
  37749. * Fires each time a drag begins (eg. mouse down on mesh)
  37750. */
  37751. onDragStartObservable: Observable<{
  37752. dragPlanePoint: Vector3;
  37753. pointerId: number;
  37754. }>;
  37755. /**
  37756. * Fires each time a drag ends (eg. mouse release after drag)
  37757. */
  37758. onDragEndObservable: Observable<{
  37759. dragPlanePoint: Vector3;
  37760. pointerId: number;
  37761. }>;
  37762. /**
  37763. * If the attached mesh should be moved when dragged
  37764. */
  37765. moveAttached: boolean;
  37766. /**
  37767. * If the drag behavior will react to drag events (Default: true)
  37768. */
  37769. enabled: boolean;
  37770. /**
  37771. * If pointer events should start and release the drag (Default: true)
  37772. */
  37773. startAndReleaseDragOnPointerEvents: boolean;
  37774. /**
  37775. * If camera controls should be detached during the drag
  37776. */
  37777. detachCameraControls: boolean;
  37778. /**
  37779. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  37780. */
  37781. useObjectOrienationForDragging: boolean;
  37782. private _options;
  37783. /**
  37784. * Creates a pointer drag behavior that can be attached to a mesh
  37785. * @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)
  37786. */
  37787. constructor(options?: {
  37788. dragAxis?: Vector3;
  37789. dragPlaneNormal?: Vector3;
  37790. });
  37791. /**
  37792. * Predicate to determine if it is valid to move the object to a new position when it is moved
  37793. */
  37794. validateDrag: (targetPosition: Vector3) => boolean;
  37795. /**
  37796. * The name of the behavior
  37797. */
  37798. readonly name: string;
  37799. /**
  37800. * Initializes the behavior
  37801. */
  37802. init(): void;
  37803. private _tmpVector;
  37804. private _alternatePickedPoint;
  37805. private _worldDragAxis;
  37806. private _targetPosition;
  37807. private _attachedElement;
  37808. /**
  37809. * Attaches the drag behavior the passed in mesh
  37810. * @param ownerNode The mesh that will be dragged around once attached
  37811. */
  37812. attach(ownerNode: AbstractMesh): void;
  37813. /**
  37814. * Force relase the drag action by code.
  37815. */
  37816. releaseDrag(): void;
  37817. private _startDragRay;
  37818. private _lastPointerRay;
  37819. /**
  37820. * Simulates the start of a pointer drag event on the behavior
  37821. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37822. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  37823. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  37824. */
  37825. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  37826. private _startDrag;
  37827. private _dragDelta;
  37828. private _moveDrag;
  37829. private _pickWithRayOnDragPlane;
  37830. private _pointA;
  37831. private _pointB;
  37832. private _pointC;
  37833. private _lineA;
  37834. private _lineB;
  37835. private _localAxis;
  37836. private _lookAt;
  37837. private _updateDragPlanePosition;
  37838. /**
  37839. * Detaches the behavior from the mesh
  37840. */
  37841. detach(): void;
  37842. }
  37843. }
  37844. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  37845. import { Mesh } from "babylonjs/Meshes/mesh";
  37846. import { Behavior } from "babylonjs/Behaviors/behavior";
  37847. /**
  37848. * A behavior that when attached to a mesh will allow the mesh to be scaled
  37849. */
  37850. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  37851. private _dragBehaviorA;
  37852. private _dragBehaviorB;
  37853. private _startDistance;
  37854. private _initialScale;
  37855. private _targetScale;
  37856. private _ownerNode;
  37857. private _sceneRenderObserver;
  37858. /**
  37859. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  37860. */
  37861. constructor();
  37862. /**
  37863. * The name of the behavior
  37864. */
  37865. readonly name: string;
  37866. /**
  37867. * Initializes the behavior
  37868. */
  37869. init(): void;
  37870. private _getCurrentDistance;
  37871. /**
  37872. * Attaches the scale behavior the passed in mesh
  37873. * @param ownerNode The mesh that will be scaled around once attached
  37874. */
  37875. attach(ownerNode: Mesh): void;
  37876. /**
  37877. * Detaches the behavior from the mesh
  37878. */
  37879. detach(): void;
  37880. }
  37881. }
  37882. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  37883. import { Behavior } from "babylonjs/Behaviors/behavior";
  37884. import { Mesh } from "babylonjs/Meshes/mesh";
  37885. import { Observable } from "babylonjs/Misc/observable";
  37886. /**
  37887. * 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
  37888. */
  37889. export class SixDofDragBehavior implements Behavior<Mesh> {
  37890. private static _virtualScene;
  37891. private _ownerNode;
  37892. private _sceneRenderObserver;
  37893. private _scene;
  37894. private _targetPosition;
  37895. private _virtualOriginMesh;
  37896. private _virtualDragMesh;
  37897. private _pointerObserver;
  37898. private _moving;
  37899. private _startingOrientation;
  37900. /**
  37901. * 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)
  37902. */
  37903. private zDragFactor;
  37904. /**
  37905. * If the object should rotate to face the drag origin
  37906. */
  37907. rotateDraggedObject: boolean;
  37908. /**
  37909. * If the behavior is currently in a dragging state
  37910. */
  37911. dragging: boolean;
  37912. /**
  37913. * 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)
  37914. */
  37915. dragDeltaRatio: number;
  37916. /**
  37917. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37918. */
  37919. currentDraggingPointerID: number;
  37920. /**
  37921. * If camera controls should be detached during the drag
  37922. */
  37923. detachCameraControls: boolean;
  37924. /**
  37925. * Fires each time a drag starts
  37926. */
  37927. onDragStartObservable: Observable<{}>;
  37928. /**
  37929. * Fires each time a drag ends (eg. mouse release after drag)
  37930. */
  37931. onDragEndObservable: Observable<{}>;
  37932. /**
  37933. * 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
  37934. */
  37935. constructor();
  37936. /**
  37937. * The name of the behavior
  37938. */
  37939. readonly name: string;
  37940. /**
  37941. * Initializes the behavior
  37942. */
  37943. init(): void;
  37944. /**
  37945. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  37946. */
  37947. private readonly _pointerCamera;
  37948. /**
  37949. * Attaches the scale behavior the passed in mesh
  37950. * @param ownerNode The mesh that will be scaled around once attached
  37951. */
  37952. attach(ownerNode: Mesh): void;
  37953. /**
  37954. * Detaches the behavior from the mesh
  37955. */
  37956. detach(): void;
  37957. }
  37958. }
  37959. declare module "babylonjs/Behaviors/Meshes/index" {
  37960. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  37961. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  37962. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  37963. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  37964. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  37965. }
  37966. declare module "babylonjs/Behaviors/index" {
  37967. export * from "babylonjs/Behaviors/behavior";
  37968. export * from "babylonjs/Behaviors/Cameras/index";
  37969. export * from "babylonjs/Behaviors/Meshes/index";
  37970. }
  37971. declare module "babylonjs/Bones/boneIKController" {
  37972. import { Bone } from "babylonjs/Bones/bone";
  37973. import { Vector3 } from "babylonjs/Maths/math.vector";
  37974. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37975. import { Nullable } from "babylonjs/types";
  37976. /**
  37977. * Class used to apply inverse kinematics to bones
  37978. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  37979. */
  37980. export class BoneIKController {
  37981. private static _tmpVecs;
  37982. private static _tmpQuat;
  37983. private static _tmpMats;
  37984. /**
  37985. * Gets or sets the target mesh
  37986. */
  37987. targetMesh: AbstractMesh;
  37988. /** Gets or sets the mesh used as pole */
  37989. poleTargetMesh: AbstractMesh;
  37990. /**
  37991. * Gets or sets the bone used as pole
  37992. */
  37993. poleTargetBone: Nullable<Bone>;
  37994. /**
  37995. * Gets or sets the target position
  37996. */
  37997. targetPosition: Vector3;
  37998. /**
  37999. * Gets or sets the pole target position
  38000. */
  38001. poleTargetPosition: Vector3;
  38002. /**
  38003. * Gets or sets the pole target local offset
  38004. */
  38005. poleTargetLocalOffset: Vector3;
  38006. /**
  38007. * Gets or sets the pole angle
  38008. */
  38009. poleAngle: number;
  38010. /**
  38011. * Gets or sets the mesh associated with the controller
  38012. */
  38013. mesh: AbstractMesh;
  38014. /**
  38015. * 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)
  38016. */
  38017. slerpAmount: number;
  38018. private _bone1Quat;
  38019. private _bone1Mat;
  38020. private _bone2Ang;
  38021. private _bone1;
  38022. private _bone2;
  38023. private _bone1Length;
  38024. private _bone2Length;
  38025. private _maxAngle;
  38026. private _maxReach;
  38027. private _rightHandedSystem;
  38028. private _bendAxis;
  38029. private _slerping;
  38030. private _adjustRoll;
  38031. /**
  38032. * Gets or sets maximum allowed angle
  38033. */
  38034. maxAngle: number;
  38035. /**
  38036. * Creates a new BoneIKController
  38037. * @param mesh defines the mesh to control
  38038. * @param bone defines the bone to control
  38039. * @param options defines options to set up the controller
  38040. */
  38041. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  38042. targetMesh?: AbstractMesh;
  38043. poleTargetMesh?: AbstractMesh;
  38044. poleTargetBone?: Bone;
  38045. poleTargetLocalOffset?: Vector3;
  38046. poleAngle?: number;
  38047. bendAxis?: Vector3;
  38048. maxAngle?: number;
  38049. slerpAmount?: number;
  38050. });
  38051. private _setMaxAngle;
  38052. /**
  38053. * Force the controller to update the bones
  38054. */
  38055. update(): void;
  38056. }
  38057. }
  38058. declare module "babylonjs/Bones/boneLookController" {
  38059. import { Vector3 } from "babylonjs/Maths/math.vector";
  38060. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38061. import { Bone } from "babylonjs/Bones/bone";
  38062. import { Space } from "babylonjs/Maths/math.axis";
  38063. /**
  38064. * Class used to make a bone look toward a point in space
  38065. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  38066. */
  38067. export class BoneLookController {
  38068. private static _tmpVecs;
  38069. private static _tmpQuat;
  38070. private static _tmpMats;
  38071. /**
  38072. * The target Vector3 that the bone will look at
  38073. */
  38074. target: Vector3;
  38075. /**
  38076. * The mesh that the bone is attached to
  38077. */
  38078. mesh: AbstractMesh;
  38079. /**
  38080. * The bone that will be looking to the target
  38081. */
  38082. bone: Bone;
  38083. /**
  38084. * The up axis of the coordinate system that is used when the bone is rotated
  38085. */
  38086. upAxis: Vector3;
  38087. /**
  38088. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38089. */
  38090. upAxisSpace: Space;
  38091. /**
  38092. * Used to make an adjustment to the yaw of the bone
  38093. */
  38094. adjustYaw: number;
  38095. /**
  38096. * Used to make an adjustment to the pitch of the bone
  38097. */
  38098. adjustPitch: number;
  38099. /**
  38100. * Used to make an adjustment to the roll of the bone
  38101. */
  38102. adjustRoll: number;
  38103. /**
  38104. * 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)
  38105. */
  38106. slerpAmount: number;
  38107. private _minYaw;
  38108. private _maxYaw;
  38109. private _minPitch;
  38110. private _maxPitch;
  38111. private _minYawSin;
  38112. private _minYawCos;
  38113. private _maxYawSin;
  38114. private _maxYawCos;
  38115. private _midYawConstraint;
  38116. private _minPitchTan;
  38117. private _maxPitchTan;
  38118. private _boneQuat;
  38119. private _slerping;
  38120. private _transformYawPitch;
  38121. private _transformYawPitchInv;
  38122. private _firstFrameSkipped;
  38123. private _yawRange;
  38124. private _fowardAxis;
  38125. /**
  38126. * Gets or sets the minimum yaw angle that the bone can look to
  38127. */
  38128. minYaw: number;
  38129. /**
  38130. * Gets or sets the maximum yaw angle that the bone can look to
  38131. */
  38132. maxYaw: number;
  38133. /**
  38134. * Gets or sets the minimum pitch angle that the bone can look to
  38135. */
  38136. minPitch: number;
  38137. /**
  38138. * Gets or sets the maximum pitch angle that the bone can look to
  38139. */
  38140. maxPitch: number;
  38141. /**
  38142. * Create a BoneLookController
  38143. * @param mesh the mesh that the bone belongs to
  38144. * @param bone the bone that will be looking to the target
  38145. * @param target the target Vector3 to look at
  38146. * @param options optional settings:
  38147. * * maxYaw: the maximum angle the bone will yaw to
  38148. * * minYaw: the minimum angle the bone will yaw to
  38149. * * maxPitch: the maximum angle the bone will pitch to
  38150. * * minPitch: the minimum angle the bone will yaw to
  38151. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38152. * * upAxis: the up axis of the coordinate system
  38153. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38154. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38155. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38156. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38157. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38158. * * adjustRoll: used to make an adjustment to the roll of the bone
  38159. **/
  38160. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38161. maxYaw?: number;
  38162. minYaw?: number;
  38163. maxPitch?: number;
  38164. minPitch?: number;
  38165. slerpAmount?: number;
  38166. upAxis?: Vector3;
  38167. upAxisSpace?: Space;
  38168. yawAxis?: Vector3;
  38169. pitchAxis?: Vector3;
  38170. adjustYaw?: number;
  38171. adjustPitch?: number;
  38172. adjustRoll?: number;
  38173. });
  38174. /**
  38175. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38176. */
  38177. update(): void;
  38178. private _getAngleDiff;
  38179. private _getAngleBetween;
  38180. private _isAngleBetween;
  38181. }
  38182. }
  38183. declare module "babylonjs/Bones/index" {
  38184. export * from "babylonjs/Bones/bone";
  38185. export * from "babylonjs/Bones/boneIKController";
  38186. export * from "babylonjs/Bones/boneLookController";
  38187. export * from "babylonjs/Bones/skeleton";
  38188. }
  38189. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  38190. import { Nullable } from "babylonjs/types";
  38191. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38192. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38193. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38194. /**
  38195. * Manage the gamepad inputs to control an arc rotate camera.
  38196. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38197. */
  38198. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38199. /**
  38200. * Defines the camera the input is attached to.
  38201. */
  38202. camera: ArcRotateCamera;
  38203. /**
  38204. * Defines the gamepad the input is gathering event from.
  38205. */
  38206. gamepad: Nullable<Gamepad>;
  38207. /**
  38208. * Defines the gamepad rotation sensiblity.
  38209. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38210. */
  38211. gamepadRotationSensibility: number;
  38212. /**
  38213. * Defines the gamepad move sensiblity.
  38214. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38215. */
  38216. gamepadMoveSensibility: number;
  38217. private _onGamepadConnectedObserver;
  38218. private _onGamepadDisconnectedObserver;
  38219. /**
  38220. * Attach the input controls to a specific dom element to get the input from.
  38221. * @param element Defines the element the controls should be listened from
  38222. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38223. */
  38224. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38225. /**
  38226. * Detach the current controls from the specified dom element.
  38227. * @param element Defines the element to stop listening the inputs from
  38228. */
  38229. detachControl(element: Nullable<HTMLElement>): void;
  38230. /**
  38231. * Update the current camera state depending on the inputs that have been used this frame.
  38232. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38233. */
  38234. checkInputs(): void;
  38235. /**
  38236. * Gets the class name of the current intput.
  38237. * @returns the class name
  38238. */
  38239. getClassName(): string;
  38240. /**
  38241. * Get the friendly name associated with the input class.
  38242. * @returns the input friendly name
  38243. */
  38244. getSimpleName(): string;
  38245. }
  38246. }
  38247. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  38248. import { Nullable } from "babylonjs/types";
  38249. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38250. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38251. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38252. interface ArcRotateCameraInputsManager {
  38253. /**
  38254. * Add orientation input support to the input manager.
  38255. * @returns the current input manager
  38256. */
  38257. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  38258. }
  38259. }
  38260. /**
  38261. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  38262. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38263. */
  38264. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  38265. /**
  38266. * Defines the camera the input is attached to.
  38267. */
  38268. camera: ArcRotateCamera;
  38269. /**
  38270. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  38271. */
  38272. alphaCorrection: number;
  38273. /**
  38274. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  38275. */
  38276. gammaCorrection: number;
  38277. private _alpha;
  38278. private _gamma;
  38279. private _dirty;
  38280. private _deviceOrientationHandler;
  38281. /**
  38282. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  38283. */
  38284. constructor();
  38285. /**
  38286. * Attach the input controls to a specific dom element to get the input from.
  38287. * @param element Defines the element the controls should be listened from
  38288. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38289. */
  38290. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38291. /** @hidden */
  38292. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  38293. /**
  38294. * Update the current camera state depending on the inputs that have been used this frame.
  38295. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38296. */
  38297. checkInputs(): void;
  38298. /**
  38299. * Detach the current controls from the specified dom element.
  38300. * @param element Defines the element to stop listening the inputs from
  38301. */
  38302. detachControl(element: Nullable<HTMLElement>): void;
  38303. /**
  38304. * Gets the class name of the current intput.
  38305. * @returns the class name
  38306. */
  38307. getClassName(): string;
  38308. /**
  38309. * Get the friendly name associated with the input class.
  38310. * @returns the input friendly name
  38311. */
  38312. getSimpleName(): string;
  38313. }
  38314. }
  38315. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  38316. import { Nullable } from "babylonjs/types";
  38317. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38318. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38319. /**
  38320. * Listen to mouse events to control the camera.
  38321. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38322. */
  38323. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  38324. /**
  38325. * Defines the camera the input is attached to.
  38326. */
  38327. camera: FlyCamera;
  38328. /**
  38329. * Defines if touch is enabled. (Default is true.)
  38330. */
  38331. touchEnabled: boolean;
  38332. /**
  38333. * Defines the buttons associated with the input to handle camera rotation.
  38334. */
  38335. buttons: number[];
  38336. /**
  38337. * Assign buttons for Yaw control.
  38338. */
  38339. buttonsYaw: number[];
  38340. /**
  38341. * Assign buttons for Pitch control.
  38342. */
  38343. buttonsPitch: number[];
  38344. /**
  38345. * Assign buttons for Roll control.
  38346. */
  38347. buttonsRoll: number[];
  38348. /**
  38349. * Detect if any button is being pressed while mouse is moved.
  38350. * -1 = Mouse locked.
  38351. * 0 = Left button.
  38352. * 1 = Middle Button.
  38353. * 2 = Right Button.
  38354. */
  38355. activeButton: number;
  38356. /**
  38357. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  38358. * Higher values reduce its sensitivity.
  38359. */
  38360. angularSensibility: number;
  38361. private _mousemoveCallback;
  38362. private _observer;
  38363. private _rollObserver;
  38364. private previousPosition;
  38365. private noPreventDefault;
  38366. private element;
  38367. /**
  38368. * Listen to mouse events to control the camera.
  38369. * @param touchEnabled Define if touch is enabled. (Default is true.)
  38370. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38371. */
  38372. constructor(touchEnabled?: boolean);
  38373. /**
  38374. * Attach the mouse control to the HTML DOM element.
  38375. * @param element Defines the element that listens to the input events.
  38376. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  38377. */
  38378. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38379. /**
  38380. * Detach the current controls from the specified dom element.
  38381. * @param element Defines the element to stop listening the inputs from
  38382. */
  38383. detachControl(element: Nullable<HTMLElement>): void;
  38384. /**
  38385. * Gets the class name of the current input.
  38386. * @returns the class name.
  38387. */
  38388. getClassName(): string;
  38389. /**
  38390. * Get the friendly name associated with the input class.
  38391. * @returns the input's friendly name.
  38392. */
  38393. getSimpleName(): string;
  38394. private _pointerInput;
  38395. private _onMouseMove;
  38396. /**
  38397. * Rotate camera by mouse offset.
  38398. */
  38399. private rotateCamera;
  38400. }
  38401. }
  38402. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  38403. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38404. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38405. /**
  38406. * Default Inputs manager for the FlyCamera.
  38407. * It groups all the default supported inputs for ease of use.
  38408. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38409. */
  38410. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  38411. /**
  38412. * Instantiates a new FlyCameraInputsManager.
  38413. * @param camera Defines the camera the inputs belong to.
  38414. */
  38415. constructor(camera: FlyCamera);
  38416. /**
  38417. * Add keyboard input support to the input manager.
  38418. * @returns the new FlyCameraKeyboardMoveInput().
  38419. */
  38420. addKeyboard(): FlyCameraInputsManager;
  38421. /**
  38422. * Add mouse input support to the input manager.
  38423. * @param touchEnabled Enable touch screen support.
  38424. * @returns the new FlyCameraMouseInput().
  38425. */
  38426. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  38427. }
  38428. }
  38429. declare module "babylonjs/Cameras/flyCamera" {
  38430. import { Scene } from "babylonjs/scene";
  38431. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  38432. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38433. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38434. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  38435. /**
  38436. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38437. * such as in a 3D Space Shooter or a Flight Simulator.
  38438. */
  38439. export class FlyCamera extends TargetCamera {
  38440. /**
  38441. * Define the collision ellipsoid of the camera.
  38442. * This is helpful for simulating a camera body, like a player's body.
  38443. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38444. */
  38445. ellipsoid: Vector3;
  38446. /**
  38447. * Define an offset for the position of the ellipsoid around the camera.
  38448. * This can be helpful if the camera is attached away from the player's body center,
  38449. * such as at its head.
  38450. */
  38451. ellipsoidOffset: Vector3;
  38452. /**
  38453. * Enable or disable collisions of the camera with the rest of the scene objects.
  38454. */
  38455. checkCollisions: boolean;
  38456. /**
  38457. * Enable or disable gravity on the camera.
  38458. */
  38459. applyGravity: boolean;
  38460. /**
  38461. * Define the current direction the camera is moving to.
  38462. */
  38463. cameraDirection: Vector3;
  38464. /**
  38465. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  38466. * This overrides and empties cameraRotation.
  38467. */
  38468. rotationQuaternion: Quaternion;
  38469. /**
  38470. * Track Roll to maintain the wanted Rolling when looking around.
  38471. */
  38472. _trackRoll: number;
  38473. /**
  38474. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  38475. */
  38476. rollCorrect: number;
  38477. /**
  38478. * Mimic a banked turn, Rolling the camera when Yawing.
  38479. * It's recommended to use rollCorrect = 10 for faster banking correction.
  38480. */
  38481. bankedTurn: boolean;
  38482. /**
  38483. * Limit in radians for how much Roll banking will add. (Default: 90°)
  38484. */
  38485. bankedTurnLimit: number;
  38486. /**
  38487. * Value of 0 disables the banked Roll.
  38488. * Value of 1 is equal to the Yaw angle in radians.
  38489. */
  38490. bankedTurnMultiplier: number;
  38491. /**
  38492. * The inputs manager loads all the input sources, such as keyboard and mouse.
  38493. */
  38494. inputs: FlyCameraInputsManager;
  38495. /**
  38496. * Gets the input sensibility for mouse input.
  38497. * Higher values reduce sensitivity.
  38498. */
  38499. /**
  38500. * Sets the input sensibility for a mouse input.
  38501. * Higher values reduce sensitivity.
  38502. */
  38503. angularSensibility: number;
  38504. /**
  38505. * Get the keys for camera movement forward.
  38506. */
  38507. /**
  38508. * Set the keys for camera movement forward.
  38509. */
  38510. keysForward: number[];
  38511. /**
  38512. * Get the keys for camera movement backward.
  38513. */
  38514. keysBackward: number[];
  38515. /**
  38516. * Get the keys for camera movement up.
  38517. */
  38518. /**
  38519. * Set the keys for camera movement up.
  38520. */
  38521. keysUp: number[];
  38522. /**
  38523. * Get the keys for camera movement down.
  38524. */
  38525. /**
  38526. * Set the keys for camera movement down.
  38527. */
  38528. keysDown: number[];
  38529. /**
  38530. * Get the keys for camera movement left.
  38531. */
  38532. /**
  38533. * Set the keys for camera movement left.
  38534. */
  38535. keysLeft: number[];
  38536. /**
  38537. * Set the keys for camera movement right.
  38538. */
  38539. /**
  38540. * Set the keys for camera movement right.
  38541. */
  38542. keysRight: number[];
  38543. /**
  38544. * Event raised when the camera collides with a mesh in the scene.
  38545. */
  38546. onCollide: (collidedMesh: AbstractMesh) => void;
  38547. private _collider;
  38548. private _needMoveForGravity;
  38549. private _oldPosition;
  38550. private _diffPosition;
  38551. private _newPosition;
  38552. /** @hidden */
  38553. _localDirection: Vector3;
  38554. /** @hidden */
  38555. _transformedDirection: Vector3;
  38556. /**
  38557. * Instantiates a FlyCamera.
  38558. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38559. * such as in a 3D Space Shooter or a Flight Simulator.
  38560. * @param name Define the name of the camera in the scene.
  38561. * @param position Define the starting position of the camera in the scene.
  38562. * @param scene Define the scene the camera belongs to.
  38563. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  38564. */
  38565. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38566. /**
  38567. * Attach a control to the HTML DOM element.
  38568. * @param element Defines the element that listens to the input events.
  38569. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  38570. */
  38571. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38572. /**
  38573. * Detach a control from the HTML DOM element.
  38574. * The camera will stop reacting to that input.
  38575. * @param element Defines the element that listens to the input events.
  38576. */
  38577. detachControl(element: HTMLElement): void;
  38578. private _collisionMask;
  38579. /**
  38580. * Get the mask that the camera ignores in collision events.
  38581. */
  38582. /**
  38583. * Set the mask that the camera ignores in collision events.
  38584. */
  38585. collisionMask: number;
  38586. /** @hidden */
  38587. _collideWithWorld(displacement: Vector3): void;
  38588. /** @hidden */
  38589. private _onCollisionPositionChange;
  38590. /** @hidden */
  38591. _checkInputs(): void;
  38592. /** @hidden */
  38593. _decideIfNeedsToMove(): boolean;
  38594. /** @hidden */
  38595. _updatePosition(): void;
  38596. /**
  38597. * Restore the Roll to its target value at the rate specified.
  38598. * @param rate - Higher means slower restoring.
  38599. * @hidden
  38600. */
  38601. restoreRoll(rate: number): void;
  38602. /**
  38603. * Destroy the camera and release the current resources held by it.
  38604. */
  38605. dispose(): void;
  38606. /**
  38607. * Get the current object class name.
  38608. * @returns the class name.
  38609. */
  38610. getClassName(): string;
  38611. }
  38612. }
  38613. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  38614. import { Nullable } from "babylonjs/types";
  38615. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38616. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38617. /**
  38618. * Listen to keyboard events to control the camera.
  38619. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38620. */
  38621. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  38622. /**
  38623. * Defines the camera the input is attached to.
  38624. */
  38625. camera: FlyCamera;
  38626. /**
  38627. * The list of keyboard keys used to control the forward move of the camera.
  38628. */
  38629. keysForward: number[];
  38630. /**
  38631. * The list of keyboard keys used to control the backward move of the camera.
  38632. */
  38633. keysBackward: number[];
  38634. /**
  38635. * The list of keyboard keys used to control the forward move of the camera.
  38636. */
  38637. keysUp: number[];
  38638. /**
  38639. * The list of keyboard keys used to control the backward move of the camera.
  38640. */
  38641. keysDown: number[];
  38642. /**
  38643. * The list of keyboard keys used to control the right strafe move of the camera.
  38644. */
  38645. keysRight: number[];
  38646. /**
  38647. * The list of keyboard keys used to control the left strafe move of the camera.
  38648. */
  38649. keysLeft: number[];
  38650. private _keys;
  38651. private _onCanvasBlurObserver;
  38652. private _onKeyboardObserver;
  38653. private _engine;
  38654. private _scene;
  38655. /**
  38656. * Attach the input controls to a specific dom element to get the input from.
  38657. * @param element Defines the element the controls should be listened from
  38658. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38659. */
  38660. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38661. /**
  38662. * Detach the current controls from the specified dom element.
  38663. * @param element Defines the element to stop listening the inputs from
  38664. */
  38665. detachControl(element: Nullable<HTMLElement>): void;
  38666. /**
  38667. * Gets the class name of the current intput.
  38668. * @returns the class name
  38669. */
  38670. getClassName(): string;
  38671. /** @hidden */
  38672. _onLostFocus(e: FocusEvent): void;
  38673. /**
  38674. * Get the friendly name associated with the input class.
  38675. * @returns the input friendly name
  38676. */
  38677. getSimpleName(): string;
  38678. /**
  38679. * Update the current camera state depending on the inputs that have been used this frame.
  38680. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38681. */
  38682. checkInputs(): void;
  38683. }
  38684. }
  38685. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  38686. import { Nullable } from "babylonjs/types";
  38687. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38688. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38689. /**
  38690. * Manage the mouse wheel inputs to control a follow camera.
  38691. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38692. */
  38693. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  38694. /**
  38695. * Defines the camera the input is attached to.
  38696. */
  38697. camera: FollowCamera;
  38698. /**
  38699. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  38700. */
  38701. axisControlRadius: boolean;
  38702. /**
  38703. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  38704. */
  38705. axisControlHeight: boolean;
  38706. /**
  38707. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  38708. */
  38709. axisControlRotation: boolean;
  38710. /**
  38711. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  38712. * relation to mouseWheel events.
  38713. */
  38714. wheelPrecision: number;
  38715. /**
  38716. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38717. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38718. */
  38719. wheelDeltaPercentage: number;
  38720. private _wheel;
  38721. private _observer;
  38722. /**
  38723. * Attach the input controls to a specific dom element to get the input from.
  38724. * @param element Defines the element the controls should be listened from
  38725. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38726. */
  38727. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38728. /**
  38729. * Detach the current controls from the specified dom element.
  38730. * @param element Defines the element to stop listening the inputs from
  38731. */
  38732. detachControl(element: Nullable<HTMLElement>): void;
  38733. /**
  38734. * Gets the class name of the current intput.
  38735. * @returns the class name
  38736. */
  38737. getClassName(): string;
  38738. /**
  38739. * Get the friendly name associated with the input class.
  38740. * @returns the input friendly name
  38741. */
  38742. getSimpleName(): string;
  38743. }
  38744. }
  38745. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  38746. import { Nullable } from "babylonjs/types";
  38747. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38748. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  38749. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  38750. /**
  38751. * Manage the pointers inputs to control an follow camera.
  38752. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38753. */
  38754. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  38755. /**
  38756. * Defines the camera the input is attached to.
  38757. */
  38758. camera: FollowCamera;
  38759. /**
  38760. * Gets the class name of the current input.
  38761. * @returns the class name
  38762. */
  38763. getClassName(): string;
  38764. /**
  38765. * Defines the pointer angular sensibility along the X axis or how fast is
  38766. * the camera rotating.
  38767. * A negative number will reverse the axis direction.
  38768. */
  38769. angularSensibilityX: number;
  38770. /**
  38771. * Defines the pointer angular sensibility along the Y axis or how fast is
  38772. * the camera rotating.
  38773. * A negative number will reverse the axis direction.
  38774. */
  38775. angularSensibilityY: number;
  38776. /**
  38777. * Defines the pointer pinch precision or how fast is the camera zooming.
  38778. * A negative number will reverse the axis direction.
  38779. */
  38780. pinchPrecision: number;
  38781. /**
  38782. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38783. * from 0.
  38784. * It defines the percentage of current camera.radius to use as delta when
  38785. * pinch zoom is used.
  38786. */
  38787. pinchDeltaPercentage: number;
  38788. /**
  38789. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  38790. */
  38791. axisXControlRadius: boolean;
  38792. /**
  38793. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  38794. */
  38795. axisXControlHeight: boolean;
  38796. /**
  38797. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  38798. */
  38799. axisXControlRotation: boolean;
  38800. /**
  38801. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  38802. */
  38803. axisYControlRadius: boolean;
  38804. /**
  38805. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  38806. */
  38807. axisYControlHeight: boolean;
  38808. /**
  38809. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  38810. */
  38811. axisYControlRotation: boolean;
  38812. /**
  38813. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  38814. */
  38815. axisPinchControlRadius: boolean;
  38816. /**
  38817. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  38818. */
  38819. axisPinchControlHeight: boolean;
  38820. /**
  38821. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  38822. */
  38823. axisPinchControlRotation: boolean;
  38824. /**
  38825. * Log error messages if basic misconfiguration has occurred.
  38826. */
  38827. warningEnable: boolean;
  38828. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38829. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38830. private _warningCounter;
  38831. private _warning;
  38832. }
  38833. }
  38834. declare module "babylonjs/Cameras/followCameraInputsManager" {
  38835. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38836. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38837. /**
  38838. * Default Inputs manager for the FollowCamera.
  38839. * It groups all the default supported inputs for ease of use.
  38840. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38841. */
  38842. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  38843. /**
  38844. * Instantiates a new FollowCameraInputsManager.
  38845. * @param camera Defines the camera the inputs belong to
  38846. */
  38847. constructor(camera: FollowCamera);
  38848. /**
  38849. * Add keyboard input support to the input manager.
  38850. * @returns the current input manager
  38851. */
  38852. addKeyboard(): FollowCameraInputsManager;
  38853. /**
  38854. * Add mouse wheel input support to the input manager.
  38855. * @returns the current input manager
  38856. */
  38857. addMouseWheel(): FollowCameraInputsManager;
  38858. /**
  38859. * Add pointers input support to the input manager.
  38860. * @returns the current input manager
  38861. */
  38862. addPointers(): FollowCameraInputsManager;
  38863. /**
  38864. * Add orientation input support to the input manager.
  38865. * @returns the current input manager
  38866. */
  38867. addVRDeviceOrientation(): FollowCameraInputsManager;
  38868. }
  38869. }
  38870. declare module "babylonjs/Cameras/followCamera" {
  38871. import { Nullable } from "babylonjs/types";
  38872. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38873. import { Scene } from "babylonjs/scene";
  38874. import { Vector3 } from "babylonjs/Maths/math.vector";
  38875. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38876. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  38877. /**
  38878. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  38879. * an arc rotate version arcFollowCamera are available.
  38880. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38881. */
  38882. export class FollowCamera extends TargetCamera {
  38883. /**
  38884. * Distance the follow camera should follow an object at
  38885. */
  38886. radius: number;
  38887. /**
  38888. * Minimum allowed distance of the camera to the axis of rotation
  38889. * (The camera can not get closer).
  38890. * This can help limiting how the Camera is able to move in the scene.
  38891. */
  38892. lowerRadiusLimit: Nullable<number>;
  38893. /**
  38894. * Maximum allowed distance of the camera to the axis of rotation
  38895. * (The camera can not get further).
  38896. * This can help limiting how the Camera is able to move in the scene.
  38897. */
  38898. upperRadiusLimit: Nullable<number>;
  38899. /**
  38900. * Define a rotation offset between the camera and the object it follows
  38901. */
  38902. rotationOffset: number;
  38903. /**
  38904. * Minimum allowed angle to camera position relative to target object.
  38905. * This can help limiting how the Camera is able to move in the scene.
  38906. */
  38907. lowerRotationOffsetLimit: Nullable<number>;
  38908. /**
  38909. * Maximum allowed angle to camera position relative to target object.
  38910. * This can help limiting how the Camera is able to move in the scene.
  38911. */
  38912. upperRotationOffsetLimit: Nullable<number>;
  38913. /**
  38914. * Define a height offset between the camera and the object it follows.
  38915. * It can help following an object from the top (like a car chaing a plane)
  38916. */
  38917. heightOffset: number;
  38918. /**
  38919. * Minimum allowed height of camera position relative to target object.
  38920. * This can help limiting how the Camera is able to move in the scene.
  38921. */
  38922. lowerHeightOffsetLimit: Nullable<number>;
  38923. /**
  38924. * Maximum allowed height of camera position relative to target object.
  38925. * This can help limiting how the Camera is able to move in the scene.
  38926. */
  38927. upperHeightOffsetLimit: Nullable<number>;
  38928. /**
  38929. * Define how fast the camera can accelerate to follow it s target.
  38930. */
  38931. cameraAcceleration: number;
  38932. /**
  38933. * Define the speed limit of the camera following an object.
  38934. */
  38935. maxCameraSpeed: number;
  38936. /**
  38937. * Define the target of the camera.
  38938. */
  38939. lockedTarget: Nullable<AbstractMesh>;
  38940. /**
  38941. * Defines the input associated with the camera.
  38942. */
  38943. inputs: FollowCameraInputsManager;
  38944. /**
  38945. * Instantiates the follow camera.
  38946. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38947. * @param name Define the name of the camera in the scene
  38948. * @param position Define the position of the camera
  38949. * @param scene Define the scene the camera belong to
  38950. * @param lockedTarget Define the target of the camera
  38951. */
  38952. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  38953. private _follow;
  38954. /**
  38955. * Attached controls to the current camera.
  38956. * @param element Defines the element the controls should be listened from
  38957. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38958. */
  38959. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38960. /**
  38961. * Detach the current controls from the camera.
  38962. * The camera will stop reacting to inputs.
  38963. * @param element Defines the element to stop listening the inputs from
  38964. */
  38965. detachControl(element: HTMLElement): void;
  38966. /** @hidden */
  38967. _checkInputs(): void;
  38968. private _checkLimits;
  38969. /**
  38970. * Gets the camera class name.
  38971. * @returns the class name
  38972. */
  38973. getClassName(): string;
  38974. }
  38975. /**
  38976. * Arc Rotate version of the follow camera.
  38977. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  38978. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38979. */
  38980. export class ArcFollowCamera extends TargetCamera {
  38981. /** The longitudinal angle of the camera */
  38982. alpha: number;
  38983. /** The latitudinal angle of the camera */
  38984. beta: number;
  38985. /** The radius of the camera from its target */
  38986. radius: number;
  38987. /** Define the camera target (the messh it should follow) */
  38988. target: Nullable<AbstractMesh>;
  38989. private _cartesianCoordinates;
  38990. /**
  38991. * Instantiates a new ArcFollowCamera
  38992. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38993. * @param name Define the name of the camera
  38994. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38995. * @param beta Define the rotation angle of the camera around the elevation axis
  38996. * @param radius Define the radius of the camera from its target point
  38997. * @param target Define the target of the camera
  38998. * @param scene Define the scene the camera belongs to
  38999. */
  39000. constructor(name: string,
  39001. /** The longitudinal angle of the camera */
  39002. alpha: number,
  39003. /** The latitudinal angle of the camera */
  39004. beta: number,
  39005. /** The radius of the camera from its target */
  39006. radius: number,
  39007. /** Define the camera target (the messh it should follow) */
  39008. target: Nullable<AbstractMesh>, scene: Scene);
  39009. private _follow;
  39010. /** @hidden */
  39011. _checkInputs(): void;
  39012. /**
  39013. * Returns the class name of the object.
  39014. * It is mostly used internally for serialization purposes.
  39015. */
  39016. getClassName(): string;
  39017. }
  39018. }
  39019. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  39020. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39021. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39022. import { Nullable } from "babylonjs/types";
  39023. /**
  39024. * Manage the keyboard inputs to control the movement of a follow camera.
  39025. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39026. */
  39027. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  39028. /**
  39029. * Defines the camera the input is attached to.
  39030. */
  39031. camera: FollowCamera;
  39032. /**
  39033. * Defines the list of key codes associated with the up action (increase heightOffset)
  39034. */
  39035. keysHeightOffsetIncr: number[];
  39036. /**
  39037. * Defines the list of key codes associated with the down action (decrease heightOffset)
  39038. */
  39039. keysHeightOffsetDecr: number[];
  39040. /**
  39041. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  39042. */
  39043. keysHeightOffsetModifierAlt: boolean;
  39044. /**
  39045. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  39046. */
  39047. keysHeightOffsetModifierCtrl: boolean;
  39048. /**
  39049. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  39050. */
  39051. keysHeightOffsetModifierShift: boolean;
  39052. /**
  39053. * Defines the list of key codes associated with the left action (increase rotationOffset)
  39054. */
  39055. keysRotationOffsetIncr: number[];
  39056. /**
  39057. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  39058. */
  39059. keysRotationOffsetDecr: number[];
  39060. /**
  39061. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  39062. */
  39063. keysRotationOffsetModifierAlt: boolean;
  39064. /**
  39065. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  39066. */
  39067. keysRotationOffsetModifierCtrl: boolean;
  39068. /**
  39069. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  39070. */
  39071. keysRotationOffsetModifierShift: boolean;
  39072. /**
  39073. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  39074. */
  39075. keysRadiusIncr: number[];
  39076. /**
  39077. * Defines the list of key codes associated with the zoom-out action (increase radius)
  39078. */
  39079. keysRadiusDecr: number[];
  39080. /**
  39081. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  39082. */
  39083. keysRadiusModifierAlt: boolean;
  39084. /**
  39085. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  39086. */
  39087. keysRadiusModifierCtrl: boolean;
  39088. /**
  39089. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  39090. */
  39091. keysRadiusModifierShift: boolean;
  39092. /**
  39093. * Defines the rate of change of heightOffset.
  39094. */
  39095. heightSensibility: number;
  39096. /**
  39097. * Defines the rate of change of rotationOffset.
  39098. */
  39099. rotationSensibility: number;
  39100. /**
  39101. * Defines the rate of change of radius.
  39102. */
  39103. radiusSensibility: number;
  39104. private _keys;
  39105. private _ctrlPressed;
  39106. private _altPressed;
  39107. private _shiftPressed;
  39108. private _onCanvasBlurObserver;
  39109. private _onKeyboardObserver;
  39110. private _engine;
  39111. private _scene;
  39112. /**
  39113. * Attach the input controls to a specific dom element to get the input from.
  39114. * @param element Defines the element the controls should be listened from
  39115. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39116. */
  39117. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39118. /**
  39119. * Detach the current controls from the specified dom element.
  39120. * @param element Defines the element to stop listening the inputs from
  39121. */
  39122. detachControl(element: Nullable<HTMLElement>): void;
  39123. /**
  39124. * Update the current camera state depending on the inputs that have been used this frame.
  39125. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39126. */
  39127. checkInputs(): void;
  39128. /**
  39129. * Gets the class name of the current input.
  39130. * @returns the class name
  39131. */
  39132. getClassName(): string;
  39133. /**
  39134. * Get the friendly name associated with the input class.
  39135. * @returns the input friendly name
  39136. */
  39137. getSimpleName(): string;
  39138. /**
  39139. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39140. * allow modification of the heightOffset value.
  39141. */
  39142. private _modifierHeightOffset;
  39143. /**
  39144. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39145. * allow modification of the rotationOffset value.
  39146. */
  39147. private _modifierRotationOffset;
  39148. /**
  39149. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39150. * allow modification of the radius value.
  39151. */
  39152. private _modifierRadius;
  39153. }
  39154. }
  39155. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  39156. import { Nullable } from "babylonjs/types";
  39157. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39158. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39159. import { Observable } from "babylonjs/Misc/observable";
  39160. module "babylonjs/Cameras/freeCameraInputsManager" {
  39161. interface FreeCameraInputsManager {
  39162. /**
  39163. * @hidden
  39164. */
  39165. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39166. /**
  39167. * Add orientation input support to the input manager.
  39168. * @returns the current input manager
  39169. */
  39170. addDeviceOrientation(): FreeCameraInputsManager;
  39171. }
  39172. }
  39173. /**
  39174. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39175. * Screen rotation is taken into account.
  39176. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39177. */
  39178. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39179. private _camera;
  39180. private _screenOrientationAngle;
  39181. private _constantTranform;
  39182. private _screenQuaternion;
  39183. private _alpha;
  39184. private _beta;
  39185. private _gamma;
  39186. /**
  39187. * Can be used to detect if a device orientation sensor is availible on a device
  39188. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  39189. * @returns a promise that will resolve on orientation change
  39190. */
  39191. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  39192. /**
  39193. * @hidden
  39194. */
  39195. _onDeviceOrientationChangedObservable: Observable<void>;
  39196. /**
  39197. * Instantiates a new input
  39198. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39199. */
  39200. constructor();
  39201. /**
  39202. * Define the camera controlled by the input.
  39203. */
  39204. camera: FreeCamera;
  39205. /**
  39206. * Attach the input controls to a specific dom element to get the input from.
  39207. * @param element Defines the element the controls should be listened from
  39208. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39209. */
  39210. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39211. private _orientationChanged;
  39212. private _deviceOrientation;
  39213. /**
  39214. * Detach the current controls from the specified dom element.
  39215. * @param element Defines the element to stop listening the inputs from
  39216. */
  39217. detachControl(element: Nullable<HTMLElement>): void;
  39218. /**
  39219. * Update the current camera state depending on the inputs that have been used this frame.
  39220. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39221. */
  39222. checkInputs(): void;
  39223. /**
  39224. * Gets the class name of the current intput.
  39225. * @returns the class name
  39226. */
  39227. getClassName(): string;
  39228. /**
  39229. * Get the friendly name associated with the input class.
  39230. * @returns the input friendly name
  39231. */
  39232. getSimpleName(): string;
  39233. }
  39234. }
  39235. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  39236. import { Nullable } from "babylonjs/types";
  39237. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39238. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39239. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39240. /**
  39241. * Manage the gamepad inputs to control a free camera.
  39242. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39243. */
  39244. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39245. /**
  39246. * Define the camera the input is attached to.
  39247. */
  39248. camera: FreeCamera;
  39249. /**
  39250. * Define the Gamepad controlling the input
  39251. */
  39252. gamepad: Nullable<Gamepad>;
  39253. /**
  39254. * Defines the gamepad rotation sensiblity.
  39255. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39256. */
  39257. gamepadAngularSensibility: number;
  39258. /**
  39259. * Defines the gamepad move sensiblity.
  39260. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39261. */
  39262. gamepadMoveSensibility: number;
  39263. private _onGamepadConnectedObserver;
  39264. private _onGamepadDisconnectedObserver;
  39265. private _cameraTransform;
  39266. private _deltaTransform;
  39267. private _vector3;
  39268. private _vector2;
  39269. /**
  39270. * Attach the input controls to a specific dom element to get the input from.
  39271. * @param element Defines the element the controls should be listened from
  39272. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39273. */
  39274. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39275. /**
  39276. * Detach the current controls from the specified dom element.
  39277. * @param element Defines the element to stop listening the inputs from
  39278. */
  39279. detachControl(element: Nullable<HTMLElement>): void;
  39280. /**
  39281. * Update the current camera state depending on the inputs that have been used this frame.
  39282. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39283. */
  39284. checkInputs(): void;
  39285. /**
  39286. * Gets the class name of the current intput.
  39287. * @returns the class name
  39288. */
  39289. getClassName(): string;
  39290. /**
  39291. * Get the friendly name associated with the input class.
  39292. * @returns the input friendly name
  39293. */
  39294. getSimpleName(): string;
  39295. }
  39296. }
  39297. declare module "babylonjs/Misc/virtualJoystick" {
  39298. import { Nullable } from "babylonjs/types";
  39299. import { Vector3 } from "babylonjs/Maths/math.vector";
  39300. /**
  39301. * Defines the potential axis of a Joystick
  39302. */
  39303. export enum JoystickAxis {
  39304. /** X axis */
  39305. X = 0,
  39306. /** Y axis */
  39307. Y = 1,
  39308. /** Z axis */
  39309. Z = 2
  39310. }
  39311. /**
  39312. * Class used to define virtual joystick (used in touch mode)
  39313. */
  39314. export class VirtualJoystick {
  39315. /**
  39316. * Gets or sets a boolean indicating that left and right values must be inverted
  39317. */
  39318. reverseLeftRight: boolean;
  39319. /**
  39320. * Gets or sets a boolean indicating that up and down values must be inverted
  39321. */
  39322. reverseUpDown: boolean;
  39323. /**
  39324. * Gets the offset value for the position (ie. the change of the position value)
  39325. */
  39326. deltaPosition: Vector3;
  39327. /**
  39328. * Gets a boolean indicating if the virtual joystick was pressed
  39329. */
  39330. pressed: boolean;
  39331. /**
  39332. * Canvas the virtual joystick will render onto, default z-index of this is 5
  39333. */
  39334. static Canvas: Nullable<HTMLCanvasElement>;
  39335. private static _globalJoystickIndex;
  39336. private static vjCanvasContext;
  39337. private static vjCanvasWidth;
  39338. private static vjCanvasHeight;
  39339. private static halfWidth;
  39340. private _action;
  39341. private _axisTargetedByLeftAndRight;
  39342. private _axisTargetedByUpAndDown;
  39343. private _joystickSensibility;
  39344. private _inversedSensibility;
  39345. private _joystickPointerID;
  39346. private _joystickColor;
  39347. private _joystickPointerPos;
  39348. private _joystickPreviousPointerPos;
  39349. private _joystickPointerStartPos;
  39350. private _deltaJoystickVector;
  39351. private _leftJoystick;
  39352. private _touches;
  39353. private _onPointerDownHandlerRef;
  39354. private _onPointerMoveHandlerRef;
  39355. private _onPointerUpHandlerRef;
  39356. private _onResize;
  39357. /**
  39358. * Creates a new virtual joystick
  39359. * @param leftJoystick defines that the joystick is for left hand (false by default)
  39360. */
  39361. constructor(leftJoystick?: boolean);
  39362. /**
  39363. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  39364. * @param newJoystickSensibility defines the new sensibility
  39365. */
  39366. setJoystickSensibility(newJoystickSensibility: number): void;
  39367. private _onPointerDown;
  39368. private _onPointerMove;
  39369. private _onPointerUp;
  39370. /**
  39371. * Change the color of the virtual joystick
  39372. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  39373. */
  39374. setJoystickColor(newColor: string): void;
  39375. /**
  39376. * Defines a callback to call when the joystick is touched
  39377. * @param action defines the callback
  39378. */
  39379. setActionOnTouch(action: () => any): void;
  39380. /**
  39381. * Defines which axis you'd like to control for left & right
  39382. * @param axis defines the axis to use
  39383. */
  39384. setAxisForLeftRight(axis: JoystickAxis): void;
  39385. /**
  39386. * Defines which axis you'd like to control for up & down
  39387. * @param axis defines the axis to use
  39388. */
  39389. setAxisForUpDown(axis: JoystickAxis): void;
  39390. private _drawVirtualJoystick;
  39391. /**
  39392. * Release internal HTML canvas
  39393. */
  39394. releaseCanvas(): void;
  39395. }
  39396. }
  39397. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  39398. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  39399. import { Nullable } from "babylonjs/types";
  39400. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39401. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39402. module "babylonjs/Cameras/freeCameraInputsManager" {
  39403. interface FreeCameraInputsManager {
  39404. /**
  39405. * Add virtual joystick input support to the input manager.
  39406. * @returns the current input manager
  39407. */
  39408. addVirtualJoystick(): FreeCameraInputsManager;
  39409. }
  39410. }
  39411. /**
  39412. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  39413. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39414. */
  39415. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  39416. /**
  39417. * Defines the camera the input is attached to.
  39418. */
  39419. camera: FreeCamera;
  39420. private _leftjoystick;
  39421. private _rightjoystick;
  39422. /**
  39423. * Gets the left stick of the virtual joystick.
  39424. * @returns The virtual Joystick
  39425. */
  39426. getLeftJoystick(): VirtualJoystick;
  39427. /**
  39428. * Gets the right stick of the virtual joystick.
  39429. * @returns The virtual Joystick
  39430. */
  39431. getRightJoystick(): VirtualJoystick;
  39432. /**
  39433. * Update the current camera state depending on the inputs that have been used this frame.
  39434. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39435. */
  39436. checkInputs(): void;
  39437. /**
  39438. * Attach the input controls to a specific dom element to get the input from.
  39439. * @param element Defines the element the controls should be listened from
  39440. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39441. */
  39442. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39443. /**
  39444. * Detach the current controls from the specified dom element.
  39445. * @param element Defines the element to stop listening the inputs from
  39446. */
  39447. detachControl(element: Nullable<HTMLElement>): void;
  39448. /**
  39449. * Gets the class name of the current intput.
  39450. * @returns the class name
  39451. */
  39452. getClassName(): string;
  39453. /**
  39454. * Get the friendly name associated with the input class.
  39455. * @returns the input friendly name
  39456. */
  39457. getSimpleName(): string;
  39458. }
  39459. }
  39460. declare module "babylonjs/Cameras/Inputs/index" {
  39461. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  39462. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  39463. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  39464. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  39465. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39466. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  39467. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  39468. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  39469. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  39470. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  39471. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39472. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  39473. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  39474. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  39475. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  39476. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39477. }
  39478. declare module "babylonjs/Cameras/touchCamera" {
  39479. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39480. import { Scene } from "babylonjs/scene";
  39481. import { Vector3 } from "babylonjs/Maths/math.vector";
  39482. /**
  39483. * This represents a FPS type of camera controlled by touch.
  39484. * This is like a universal camera minus the Gamepad controls.
  39485. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39486. */
  39487. export class TouchCamera extends FreeCamera {
  39488. /**
  39489. * Defines the touch sensibility for rotation.
  39490. * The higher the faster.
  39491. */
  39492. touchAngularSensibility: number;
  39493. /**
  39494. * Defines the touch sensibility for move.
  39495. * The higher the faster.
  39496. */
  39497. touchMoveSensibility: number;
  39498. /**
  39499. * Instantiates a new touch camera.
  39500. * This represents a FPS type of camera controlled by touch.
  39501. * This is like a universal camera minus the Gamepad controls.
  39502. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39503. * @param name Define the name of the camera in the scene
  39504. * @param position Define the start position of the camera in the scene
  39505. * @param scene Define the scene the camera belongs to
  39506. */
  39507. constructor(name: string, position: Vector3, scene: Scene);
  39508. /**
  39509. * Gets the current object class name.
  39510. * @return the class name
  39511. */
  39512. getClassName(): string;
  39513. /** @hidden */
  39514. _setupInputs(): void;
  39515. }
  39516. }
  39517. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  39518. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39519. import { Scene } from "babylonjs/scene";
  39520. import { Vector3 } from "babylonjs/Maths/math.vector";
  39521. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39522. import { Axis } from "babylonjs/Maths/math.axis";
  39523. /**
  39524. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  39525. * being tilted forward or back and left or right.
  39526. */
  39527. export class DeviceOrientationCamera extends FreeCamera {
  39528. private _initialQuaternion;
  39529. private _quaternionCache;
  39530. private _tmpDragQuaternion;
  39531. private _disablePointerInputWhenUsingDeviceOrientation;
  39532. /**
  39533. * Creates a new device orientation camera
  39534. * @param name The name of the camera
  39535. * @param position The start position camera
  39536. * @param scene The scene the camera belongs to
  39537. */
  39538. constructor(name: string, position: Vector3, scene: Scene);
  39539. /**
  39540. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  39541. */
  39542. disablePointerInputWhenUsingDeviceOrientation: boolean;
  39543. private _dragFactor;
  39544. /**
  39545. * Enabled turning on the y axis when the orientation sensor is active
  39546. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  39547. */
  39548. enableHorizontalDragging(dragFactor?: number): void;
  39549. /**
  39550. * Gets the current instance class name ("DeviceOrientationCamera").
  39551. * This helps avoiding instanceof at run time.
  39552. * @returns the class name
  39553. */
  39554. getClassName(): string;
  39555. /**
  39556. * @hidden
  39557. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  39558. */
  39559. _checkInputs(): void;
  39560. /**
  39561. * Reset the camera to its default orientation on the specified axis only.
  39562. * @param axis The axis to reset
  39563. */
  39564. resetToCurrentRotation(axis?: Axis): void;
  39565. }
  39566. }
  39567. declare module "babylonjs/Gamepads/xboxGamepad" {
  39568. import { Observable } from "babylonjs/Misc/observable";
  39569. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39570. /**
  39571. * Defines supported buttons for XBox360 compatible gamepads
  39572. */
  39573. export enum Xbox360Button {
  39574. /** A */
  39575. A = 0,
  39576. /** B */
  39577. B = 1,
  39578. /** X */
  39579. X = 2,
  39580. /** Y */
  39581. Y = 3,
  39582. /** Start */
  39583. Start = 4,
  39584. /** Back */
  39585. Back = 5,
  39586. /** Left button */
  39587. LB = 6,
  39588. /** Right button */
  39589. RB = 7,
  39590. /** Left stick */
  39591. LeftStick = 8,
  39592. /** Right stick */
  39593. RightStick = 9
  39594. }
  39595. /** Defines values for XBox360 DPad */
  39596. export enum Xbox360Dpad {
  39597. /** Up */
  39598. Up = 0,
  39599. /** Down */
  39600. Down = 1,
  39601. /** Left */
  39602. Left = 2,
  39603. /** Right */
  39604. Right = 3
  39605. }
  39606. /**
  39607. * Defines a XBox360 gamepad
  39608. */
  39609. export class Xbox360Pad extends Gamepad {
  39610. private _leftTrigger;
  39611. private _rightTrigger;
  39612. private _onlefttriggerchanged;
  39613. private _onrighttriggerchanged;
  39614. private _onbuttondown;
  39615. private _onbuttonup;
  39616. private _ondpaddown;
  39617. private _ondpadup;
  39618. /** Observable raised when a button is pressed */
  39619. onButtonDownObservable: Observable<Xbox360Button>;
  39620. /** Observable raised when a button is released */
  39621. onButtonUpObservable: Observable<Xbox360Button>;
  39622. /** Observable raised when a pad is pressed */
  39623. onPadDownObservable: Observable<Xbox360Dpad>;
  39624. /** Observable raised when a pad is released */
  39625. onPadUpObservable: Observable<Xbox360Dpad>;
  39626. private _buttonA;
  39627. private _buttonB;
  39628. private _buttonX;
  39629. private _buttonY;
  39630. private _buttonBack;
  39631. private _buttonStart;
  39632. private _buttonLB;
  39633. private _buttonRB;
  39634. private _buttonLeftStick;
  39635. private _buttonRightStick;
  39636. private _dPadUp;
  39637. private _dPadDown;
  39638. private _dPadLeft;
  39639. private _dPadRight;
  39640. private _isXboxOnePad;
  39641. /**
  39642. * Creates a new XBox360 gamepad object
  39643. * @param id defines the id of this gamepad
  39644. * @param index defines its index
  39645. * @param gamepad defines the internal HTML gamepad object
  39646. * @param xboxOne defines if it is a XBox One gamepad
  39647. */
  39648. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39649. /**
  39650. * Defines the callback to call when left trigger is pressed
  39651. * @param callback defines the callback to use
  39652. */
  39653. onlefttriggerchanged(callback: (value: number) => void): void;
  39654. /**
  39655. * Defines the callback to call when right trigger is pressed
  39656. * @param callback defines the callback to use
  39657. */
  39658. onrighttriggerchanged(callback: (value: number) => void): void;
  39659. /**
  39660. * Gets the left trigger value
  39661. */
  39662. /**
  39663. * Sets the left trigger value
  39664. */
  39665. leftTrigger: number;
  39666. /**
  39667. * Gets the right trigger value
  39668. */
  39669. /**
  39670. * Sets the right trigger value
  39671. */
  39672. rightTrigger: number;
  39673. /**
  39674. * Defines the callback to call when a button is pressed
  39675. * @param callback defines the callback to use
  39676. */
  39677. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39678. /**
  39679. * Defines the callback to call when a button is released
  39680. * @param callback defines the callback to use
  39681. */
  39682. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39683. /**
  39684. * Defines the callback to call when a pad is pressed
  39685. * @param callback defines the callback to use
  39686. */
  39687. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39688. /**
  39689. * Defines the callback to call when a pad is released
  39690. * @param callback defines the callback to use
  39691. */
  39692. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39693. private _setButtonValue;
  39694. private _setDPadValue;
  39695. /**
  39696. * Gets the value of the `A` button
  39697. */
  39698. /**
  39699. * Sets the value of the `A` button
  39700. */
  39701. buttonA: number;
  39702. /**
  39703. * Gets the value of the `B` button
  39704. */
  39705. /**
  39706. * Sets the value of the `B` button
  39707. */
  39708. buttonB: number;
  39709. /**
  39710. * Gets the value of the `X` button
  39711. */
  39712. /**
  39713. * Sets the value of the `X` button
  39714. */
  39715. buttonX: number;
  39716. /**
  39717. * Gets the value of the `Y` button
  39718. */
  39719. /**
  39720. * Sets the value of the `Y` button
  39721. */
  39722. buttonY: number;
  39723. /**
  39724. * Gets the value of the `Start` button
  39725. */
  39726. /**
  39727. * Sets the value of the `Start` button
  39728. */
  39729. buttonStart: number;
  39730. /**
  39731. * Gets the value of the `Back` button
  39732. */
  39733. /**
  39734. * Sets the value of the `Back` button
  39735. */
  39736. buttonBack: number;
  39737. /**
  39738. * Gets the value of the `Left` button
  39739. */
  39740. /**
  39741. * Sets the value of the `Left` button
  39742. */
  39743. buttonLB: number;
  39744. /**
  39745. * Gets the value of the `Right` button
  39746. */
  39747. /**
  39748. * Sets the value of the `Right` button
  39749. */
  39750. buttonRB: number;
  39751. /**
  39752. * Gets the value of the Left joystick
  39753. */
  39754. /**
  39755. * Sets the value of the Left joystick
  39756. */
  39757. buttonLeftStick: number;
  39758. /**
  39759. * Gets the value of the Right joystick
  39760. */
  39761. /**
  39762. * Sets the value of the Right joystick
  39763. */
  39764. buttonRightStick: number;
  39765. /**
  39766. * Gets the value of D-pad up
  39767. */
  39768. /**
  39769. * Sets the value of D-pad up
  39770. */
  39771. dPadUp: number;
  39772. /**
  39773. * Gets the value of D-pad down
  39774. */
  39775. /**
  39776. * Sets the value of D-pad down
  39777. */
  39778. dPadDown: number;
  39779. /**
  39780. * Gets the value of D-pad left
  39781. */
  39782. /**
  39783. * Sets the value of D-pad left
  39784. */
  39785. dPadLeft: number;
  39786. /**
  39787. * Gets the value of D-pad right
  39788. */
  39789. /**
  39790. * Sets the value of D-pad right
  39791. */
  39792. dPadRight: number;
  39793. /**
  39794. * Force the gamepad to synchronize with device values
  39795. */
  39796. update(): void;
  39797. /**
  39798. * Disposes the gamepad
  39799. */
  39800. dispose(): void;
  39801. }
  39802. }
  39803. declare module "babylonjs/Gamepads/dualShockGamepad" {
  39804. import { Observable } from "babylonjs/Misc/observable";
  39805. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39806. /**
  39807. * Defines supported buttons for DualShock compatible gamepads
  39808. */
  39809. export enum DualShockButton {
  39810. /** Cross */
  39811. Cross = 0,
  39812. /** Circle */
  39813. Circle = 1,
  39814. /** Square */
  39815. Square = 2,
  39816. /** Triangle */
  39817. Triangle = 3,
  39818. /** Options */
  39819. Options = 4,
  39820. /** Share */
  39821. Share = 5,
  39822. /** L1 */
  39823. L1 = 6,
  39824. /** R1 */
  39825. R1 = 7,
  39826. /** Left stick */
  39827. LeftStick = 8,
  39828. /** Right stick */
  39829. RightStick = 9
  39830. }
  39831. /** Defines values for DualShock DPad */
  39832. export enum DualShockDpad {
  39833. /** Up */
  39834. Up = 0,
  39835. /** Down */
  39836. Down = 1,
  39837. /** Left */
  39838. Left = 2,
  39839. /** Right */
  39840. Right = 3
  39841. }
  39842. /**
  39843. * Defines a DualShock gamepad
  39844. */
  39845. export class DualShockPad extends Gamepad {
  39846. private _leftTrigger;
  39847. private _rightTrigger;
  39848. private _onlefttriggerchanged;
  39849. private _onrighttriggerchanged;
  39850. private _onbuttondown;
  39851. private _onbuttonup;
  39852. private _ondpaddown;
  39853. private _ondpadup;
  39854. /** Observable raised when a button is pressed */
  39855. onButtonDownObservable: Observable<DualShockButton>;
  39856. /** Observable raised when a button is released */
  39857. onButtonUpObservable: Observable<DualShockButton>;
  39858. /** Observable raised when a pad is pressed */
  39859. onPadDownObservable: Observable<DualShockDpad>;
  39860. /** Observable raised when a pad is released */
  39861. onPadUpObservable: Observable<DualShockDpad>;
  39862. private _buttonCross;
  39863. private _buttonCircle;
  39864. private _buttonSquare;
  39865. private _buttonTriangle;
  39866. private _buttonShare;
  39867. private _buttonOptions;
  39868. private _buttonL1;
  39869. private _buttonR1;
  39870. private _buttonLeftStick;
  39871. private _buttonRightStick;
  39872. private _dPadUp;
  39873. private _dPadDown;
  39874. private _dPadLeft;
  39875. private _dPadRight;
  39876. /**
  39877. * Creates a new DualShock gamepad object
  39878. * @param id defines the id of this gamepad
  39879. * @param index defines its index
  39880. * @param gamepad defines the internal HTML gamepad object
  39881. */
  39882. constructor(id: string, index: number, gamepad: any);
  39883. /**
  39884. * Defines the callback to call when left trigger is pressed
  39885. * @param callback defines the callback to use
  39886. */
  39887. onlefttriggerchanged(callback: (value: number) => void): void;
  39888. /**
  39889. * Defines the callback to call when right trigger is pressed
  39890. * @param callback defines the callback to use
  39891. */
  39892. onrighttriggerchanged(callback: (value: number) => void): void;
  39893. /**
  39894. * Gets the left trigger value
  39895. */
  39896. /**
  39897. * Sets the left trigger value
  39898. */
  39899. leftTrigger: number;
  39900. /**
  39901. * Gets the right trigger value
  39902. */
  39903. /**
  39904. * Sets the right trigger value
  39905. */
  39906. rightTrigger: number;
  39907. /**
  39908. * Defines the callback to call when a button is pressed
  39909. * @param callback defines the callback to use
  39910. */
  39911. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  39912. /**
  39913. * Defines the callback to call when a button is released
  39914. * @param callback defines the callback to use
  39915. */
  39916. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  39917. /**
  39918. * Defines the callback to call when a pad is pressed
  39919. * @param callback defines the callback to use
  39920. */
  39921. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  39922. /**
  39923. * Defines the callback to call when a pad is released
  39924. * @param callback defines the callback to use
  39925. */
  39926. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  39927. private _setButtonValue;
  39928. private _setDPadValue;
  39929. /**
  39930. * Gets the value of the `Cross` button
  39931. */
  39932. /**
  39933. * Sets the value of the `Cross` button
  39934. */
  39935. buttonCross: number;
  39936. /**
  39937. * Gets the value of the `Circle` button
  39938. */
  39939. /**
  39940. * Sets the value of the `Circle` button
  39941. */
  39942. buttonCircle: number;
  39943. /**
  39944. * Gets the value of the `Square` button
  39945. */
  39946. /**
  39947. * Sets the value of the `Square` button
  39948. */
  39949. buttonSquare: number;
  39950. /**
  39951. * Gets the value of the `Triangle` button
  39952. */
  39953. /**
  39954. * Sets the value of the `Triangle` button
  39955. */
  39956. buttonTriangle: number;
  39957. /**
  39958. * Gets the value of the `Options` button
  39959. */
  39960. /**
  39961. * Sets the value of the `Options` button
  39962. */
  39963. buttonOptions: number;
  39964. /**
  39965. * Gets the value of the `Share` button
  39966. */
  39967. /**
  39968. * Sets the value of the `Share` button
  39969. */
  39970. buttonShare: number;
  39971. /**
  39972. * Gets the value of the `L1` button
  39973. */
  39974. /**
  39975. * Sets the value of the `L1` button
  39976. */
  39977. buttonL1: number;
  39978. /**
  39979. * Gets the value of the `R1` button
  39980. */
  39981. /**
  39982. * Sets the value of the `R1` button
  39983. */
  39984. buttonR1: number;
  39985. /**
  39986. * Gets the value of the Left joystick
  39987. */
  39988. /**
  39989. * Sets the value of the Left joystick
  39990. */
  39991. buttonLeftStick: number;
  39992. /**
  39993. * Gets the value of the Right joystick
  39994. */
  39995. /**
  39996. * Sets the value of the Right joystick
  39997. */
  39998. buttonRightStick: number;
  39999. /**
  40000. * Gets the value of D-pad up
  40001. */
  40002. /**
  40003. * Sets the value of D-pad up
  40004. */
  40005. dPadUp: number;
  40006. /**
  40007. * Gets the value of D-pad down
  40008. */
  40009. /**
  40010. * Sets the value of D-pad down
  40011. */
  40012. dPadDown: number;
  40013. /**
  40014. * Gets the value of D-pad left
  40015. */
  40016. /**
  40017. * Sets the value of D-pad left
  40018. */
  40019. dPadLeft: number;
  40020. /**
  40021. * Gets the value of D-pad right
  40022. */
  40023. /**
  40024. * Sets the value of D-pad right
  40025. */
  40026. dPadRight: number;
  40027. /**
  40028. * Force the gamepad to synchronize with device values
  40029. */
  40030. update(): void;
  40031. /**
  40032. * Disposes the gamepad
  40033. */
  40034. dispose(): void;
  40035. }
  40036. }
  40037. declare module "babylonjs/Gamepads/gamepadManager" {
  40038. import { Observable } from "babylonjs/Misc/observable";
  40039. import { Nullable } from "babylonjs/types";
  40040. import { Scene } from "babylonjs/scene";
  40041. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40042. /**
  40043. * Manager for handling gamepads
  40044. */
  40045. export class GamepadManager {
  40046. private _scene?;
  40047. private _babylonGamepads;
  40048. private _oneGamepadConnected;
  40049. /** @hidden */
  40050. _isMonitoring: boolean;
  40051. private _gamepadEventSupported;
  40052. private _gamepadSupport;
  40053. /**
  40054. * observable to be triggered when the gamepad controller has been connected
  40055. */
  40056. onGamepadConnectedObservable: Observable<Gamepad>;
  40057. /**
  40058. * observable to be triggered when the gamepad controller has been disconnected
  40059. */
  40060. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40061. private _onGamepadConnectedEvent;
  40062. private _onGamepadDisconnectedEvent;
  40063. /**
  40064. * Initializes the gamepad manager
  40065. * @param _scene BabylonJS scene
  40066. */
  40067. constructor(_scene?: Scene | undefined);
  40068. /**
  40069. * The gamepads in the game pad manager
  40070. */
  40071. readonly gamepads: Gamepad[];
  40072. /**
  40073. * Get the gamepad controllers based on type
  40074. * @param type The type of gamepad controller
  40075. * @returns Nullable gamepad
  40076. */
  40077. getGamepadByType(type?: number): Nullable<Gamepad>;
  40078. /**
  40079. * Disposes the gamepad manager
  40080. */
  40081. dispose(): void;
  40082. private _addNewGamepad;
  40083. private _startMonitoringGamepads;
  40084. private _stopMonitoringGamepads;
  40085. /** @hidden */
  40086. _checkGamepadsStatus(): void;
  40087. private _updateGamepadObjects;
  40088. }
  40089. }
  40090. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40091. import { Nullable } from "babylonjs/types";
  40092. import { Scene } from "babylonjs/scene";
  40093. import { ISceneComponent } from "babylonjs/sceneComponent";
  40094. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40095. module "babylonjs/scene" {
  40096. interface Scene {
  40097. /** @hidden */
  40098. _gamepadManager: Nullable<GamepadManager>;
  40099. /**
  40100. * Gets the gamepad manager associated with the scene
  40101. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40102. */
  40103. gamepadManager: GamepadManager;
  40104. }
  40105. }
  40106. module "babylonjs/Cameras/freeCameraInputsManager" {
  40107. /**
  40108. * Interface representing a free camera inputs manager
  40109. */
  40110. interface FreeCameraInputsManager {
  40111. /**
  40112. * Adds gamepad input support to the FreeCameraInputsManager.
  40113. * @returns the FreeCameraInputsManager
  40114. */
  40115. addGamepad(): FreeCameraInputsManager;
  40116. }
  40117. }
  40118. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40119. /**
  40120. * Interface representing an arc rotate camera inputs manager
  40121. */
  40122. interface ArcRotateCameraInputsManager {
  40123. /**
  40124. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40125. * @returns the camera inputs manager
  40126. */
  40127. addGamepad(): ArcRotateCameraInputsManager;
  40128. }
  40129. }
  40130. /**
  40131. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40132. */
  40133. export class GamepadSystemSceneComponent implements ISceneComponent {
  40134. /**
  40135. * The component name helpfull to identify the component in the list of scene components.
  40136. */
  40137. readonly name: string;
  40138. /**
  40139. * The scene the component belongs to.
  40140. */
  40141. scene: Scene;
  40142. /**
  40143. * Creates a new instance of the component for the given scene
  40144. * @param scene Defines the scene to register the component in
  40145. */
  40146. constructor(scene: Scene);
  40147. /**
  40148. * Registers the component in a given scene
  40149. */
  40150. register(): void;
  40151. /**
  40152. * Rebuilds the elements related to this component in case of
  40153. * context lost for instance.
  40154. */
  40155. rebuild(): void;
  40156. /**
  40157. * Disposes the component and the associated ressources
  40158. */
  40159. dispose(): void;
  40160. private _beforeCameraUpdate;
  40161. }
  40162. }
  40163. declare module "babylonjs/Cameras/universalCamera" {
  40164. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  40165. import { Scene } from "babylonjs/scene";
  40166. import { Vector3 } from "babylonjs/Maths/math.vector";
  40167. import "babylonjs/Gamepads/gamepadSceneComponent";
  40168. /**
  40169. * 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,
  40170. * which still works and will still be found in many Playgrounds.
  40171. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40172. */
  40173. export class UniversalCamera extends TouchCamera {
  40174. /**
  40175. * Defines the gamepad rotation sensiblity.
  40176. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40177. */
  40178. gamepadAngularSensibility: number;
  40179. /**
  40180. * Defines the gamepad move sensiblity.
  40181. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40182. */
  40183. gamepadMoveSensibility: number;
  40184. /**
  40185. * 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,
  40186. * which still works and will still be found in many Playgrounds.
  40187. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40188. * @param name Define the name of the camera in the scene
  40189. * @param position Define the start position of the camera in the scene
  40190. * @param scene Define the scene the camera belongs to
  40191. */
  40192. constructor(name: string, position: Vector3, scene: Scene);
  40193. /**
  40194. * Gets the current object class name.
  40195. * @return the class name
  40196. */
  40197. getClassName(): string;
  40198. }
  40199. }
  40200. declare module "babylonjs/Cameras/gamepadCamera" {
  40201. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40202. import { Scene } from "babylonjs/scene";
  40203. import { Vector3 } from "babylonjs/Maths/math.vector";
  40204. /**
  40205. * This represents a FPS type of camera. This is only here for back compat purpose.
  40206. * Please use the UniversalCamera instead as both are identical.
  40207. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40208. */
  40209. export class GamepadCamera extends UniversalCamera {
  40210. /**
  40211. * Instantiates a new Gamepad Camera
  40212. * This represents a FPS type of camera. This is only here for back compat purpose.
  40213. * Please use the UniversalCamera instead as both are identical.
  40214. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40215. * @param name Define the name of the camera in the scene
  40216. * @param position Define the start position of the camera in the scene
  40217. * @param scene Define the scene the camera belongs to
  40218. */
  40219. constructor(name: string, position: Vector3, scene: Scene);
  40220. /**
  40221. * Gets the current object class name.
  40222. * @return the class name
  40223. */
  40224. getClassName(): string;
  40225. }
  40226. }
  40227. declare module "babylonjs/Shaders/pass.fragment" {
  40228. /** @hidden */
  40229. export var passPixelShader: {
  40230. name: string;
  40231. shader: string;
  40232. };
  40233. }
  40234. declare module "babylonjs/Shaders/passCube.fragment" {
  40235. /** @hidden */
  40236. export var passCubePixelShader: {
  40237. name: string;
  40238. shader: string;
  40239. };
  40240. }
  40241. declare module "babylonjs/PostProcesses/passPostProcess" {
  40242. import { Nullable } from "babylonjs/types";
  40243. import { Camera } from "babylonjs/Cameras/camera";
  40244. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40245. import { Engine } from "babylonjs/Engines/engine";
  40246. import "babylonjs/Shaders/pass.fragment";
  40247. import "babylonjs/Shaders/passCube.fragment";
  40248. /**
  40249. * PassPostProcess which produces an output the same as it's input
  40250. */
  40251. export class PassPostProcess extends PostProcess {
  40252. /**
  40253. * Creates the PassPostProcess
  40254. * @param name The name of the effect.
  40255. * @param options The required width/height ratio to downsize to before computing the render pass.
  40256. * @param camera The camera to apply the render pass to.
  40257. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40258. * @param engine The engine which the post process will be applied. (default: current engine)
  40259. * @param reusable If the post process can be reused on the same frame. (default: false)
  40260. * @param textureType The type of texture to be used when performing the post processing.
  40261. * @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)
  40262. */
  40263. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40264. }
  40265. /**
  40266. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  40267. */
  40268. export class PassCubePostProcess extends PostProcess {
  40269. private _face;
  40270. /**
  40271. * Gets or sets the cube face to display.
  40272. * * 0 is +X
  40273. * * 1 is -X
  40274. * * 2 is +Y
  40275. * * 3 is -Y
  40276. * * 4 is +Z
  40277. * * 5 is -Z
  40278. */
  40279. face: number;
  40280. /**
  40281. * Creates the PassCubePostProcess
  40282. * @param name The name of the effect.
  40283. * @param options The required width/height ratio to downsize to before computing the render pass.
  40284. * @param camera The camera to apply the render pass to.
  40285. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40286. * @param engine The engine which the post process will be applied. (default: current engine)
  40287. * @param reusable If the post process can be reused on the same frame. (default: false)
  40288. * @param textureType The type of texture to be used when performing the post processing.
  40289. * @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)
  40290. */
  40291. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40292. }
  40293. }
  40294. declare module "babylonjs/Shaders/anaglyph.fragment" {
  40295. /** @hidden */
  40296. export var anaglyphPixelShader: {
  40297. name: string;
  40298. shader: string;
  40299. };
  40300. }
  40301. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  40302. import { Engine } from "babylonjs/Engines/engine";
  40303. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40304. import { Camera } from "babylonjs/Cameras/camera";
  40305. import "babylonjs/Shaders/anaglyph.fragment";
  40306. /**
  40307. * Postprocess used to generate anaglyphic rendering
  40308. */
  40309. export class AnaglyphPostProcess extends PostProcess {
  40310. private _passedProcess;
  40311. /**
  40312. * Creates a new AnaglyphPostProcess
  40313. * @param name defines postprocess name
  40314. * @param options defines creation options or target ratio scale
  40315. * @param rigCameras defines cameras using this postprocess
  40316. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  40317. * @param engine defines hosting engine
  40318. * @param reusable defines if the postprocess will be reused multiple times per frame
  40319. */
  40320. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  40321. }
  40322. }
  40323. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  40324. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  40325. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40326. import { Scene } from "babylonjs/scene";
  40327. import { Vector3 } from "babylonjs/Maths/math.vector";
  40328. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40329. /**
  40330. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  40331. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40332. */
  40333. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  40334. /**
  40335. * Creates a new AnaglyphArcRotateCamera
  40336. * @param name defines camera name
  40337. * @param alpha defines alpha angle (in radians)
  40338. * @param beta defines beta angle (in radians)
  40339. * @param radius defines radius
  40340. * @param target defines camera target
  40341. * @param interaxialDistance defines distance between each color axis
  40342. * @param scene defines the hosting scene
  40343. */
  40344. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  40345. /**
  40346. * Gets camera class name
  40347. * @returns AnaglyphArcRotateCamera
  40348. */
  40349. getClassName(): string;
  40350. }
  40351. }
  40352. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  40353. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40354. import { Scene } from "babylonjs/scene";
  40355. import { Vector3 } from "babylonjs/Maths/math.vector";
  40356. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40357. /**
  40358. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  40359. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40360. */
  40361. export class AnaglyphFreeCamera extends FreeCamera {
  40362. /**
  40363. * Creates a new AnaglyphFreeCamera
  40364. * @param name defines camera name
  40365. * @param position defines initial position
  40366. * @param interaxialDistance defines distance between each color axis
  40367. * @param scene defines the hosting scene
  40368. */
  40369. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40370. /**
  40371. * Gets camera class name
  40372. * @returns AnaglyphFreeCamera
  40373. */
  40374. getClassName(): string;
  40375. }
  40376. }
  40377. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  40378. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40379. import { Scene } from "babylonjs/scene";
  40380. import { Vector3 } from "babylonjs/Maths/math.vector";
  40381. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40382. /**
  40383. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  40384. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40385. */
  40386. export class AnaglyphGamepadCamera extends GamepadCamera {
  40387. /**
  40388. * Creates a new AnaglyphGamepadCamera
  40389. * @param name defines camera name
  40390. * @param position defines initial position
  40391. * @param interaxialDistance defines distance between each color axis
  40392. * @param scene defines the hosting scene
  40393. */
  40394. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40395. /**
  40396. * Gets camera class name
  40397. * @returns AnaglyphGamepadCamera
  40398. */
  40399. getClassName(): string;
  40400. }
  40401. }
  40402. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  40403. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40404. import { Scene } from "babylonjs/scene";
  40405. import { Vector3 } from "babylonjs/Maths/math.vector";
  40406. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40407. /**
  40408. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  40409. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40410. */
  40411. export class AnaglyphUniversalCamera extends UniversalCamera {
  40412. /**
  40413. * Creates a new AnaglyphUniversalCamera
  40414. * @param name defines camera name
  40415. * @param position defines initial position
  40416. * @param interaxialDistance defines distance between each color axis
  40417. * @param scene defines the hosting scene
  40418. */
  40419. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40420. /**
  40421. * Gets camera class name
  40422. * @returns AnaglyphUniversalCamera
  40423. */
  40424. getClassName(): string;
  40425. }
  40426. }
  40427. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  40428. /** @hidden */
  40429. export var stereoscopicInterlacePixelShader: {
  40430. name: string;
  40431. shader: string;
  40432. };
  40433. }
  40434. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  40435. import { Camera } from "babylonjs/Cameras/camera";
  40436. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40437. import { Engine } from "babylonjs/Engines/engine";
  40438. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  40439. /**
  40440. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  40441. */
  40442. export class StereoscopicInterlacePostProcess extends PostProcess {
  40443. private _stepSize;
  40444. private _passedProcess;
  40445. /**
  40446. * Initializes a StereoscopicInterlacePostProcess
  40447. * @param name The name of the effect.
  40448. * @param rigCameras The rig cameras to be appled to the post process
  40449. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  40450. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40451. * @param engine The engine which the post process will be applied. (default: current engine)
  40452. * @param reusable If the post process can be reused on the same frame. (default: false)
  40453. */
  40454. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  40455. }
  40456. }
  40457. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  40458. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  40459. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40460. import { Scene } from "babylonjs/scene";
  40461. import { Vector3 } from "babylonjs/Maths/math.vector";
  40462. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40463. /**
  40464. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  40465. * @see http://doc.babylonjs.com/features/cameras
  40466. */
  40467. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  40468. /**
  40469. * Creates a new StereoscopicArcRotateCamera
  40470. * @param name defines camera name
  40471. * @param alpha defines alpha angle (in radians)
  40472. * @param beta defines beta angle (in radians)
  40473. * @param radius defines radius
  40474. * @param target defines camera target
  40475. * @param interaxialDistance defines distance between each color axis
  40476. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40477. * @param scene defines the hosting scene
  40478. */
  40479. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40480. /**
  40481. * Gets camera class name
  40482. * @returns StereoscopicArcRotateCamera
  40483. */
  40484. getClassName(): string;
  40485. }
  40486. }
  40487. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  40488. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40489. import { Scene } from "babylonjs/scene";
  40490. import { Vector3 } from "babylonjs/Maths/math.vector";
  40491. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40492. /**
  40493. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  40494. * @see http://doc.babylonjs.com/features/cameras
  40495. */
  40496. export class StereoscopicFreeCamera extends FreeCamera {
  40497. /**
  40498. * Creates a new StereoscopicFreeCamera
  40499. * @param name defines camera name
  40500. * @param position defines initial position
  40501. * @param interaxialDistance defines distance between each color axis
  40502. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40503. * @param scene defines the hosting scene
  40504. */
  40505. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40506. /**
  40507. * Gets camera class name
  40508. * @returns StereoscopicFreeCamera
  40509. */
  40510. getClassName(): string;
  40511. }
  40512. }
  40513. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  40514. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40515. import { Scene } from "babylonjs/scene";
  40516. import { Vector3 } from "babylonjs/Maths/math.vector";
  40517. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40518. /**
  40519. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  40520. * @see http://doc.babylonjs.com/features/cameras
  40521. */
  40522. export class StereoscopicGamepadCamera extends GamepadCamera {
  40523. /**
  40524. * Creates a new StereoscopicGamepadCamera
  40525. * @param name defines camera name
  40526. * @param position defines initial position
  40527. * @param interaxialDistance defines distance between each color axis
  40528. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40529. * @param scene defines the hosting scene
  40530. */
  40531. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40532. /**
  40533. * Gets camera class name
  40534. * @returns StereoscopicGamepadCamera
  40535. */
  40536. getClassName(): string;
  40537. }
  40538. }
  40539. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  40540. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40541. import { Scene } from "babylonjs/scene";
  40542. import { Vector3 } from "babylonjs/Maths/math.vector";
  40543. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40544. /**
  40545. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  40546. * @see http://doc.babylonjs.com/features/cameras
  40547. */
  40548. export class StereoscopicUniversalCamera extends UniversalCamera {
  40549. /**
  40550. * Creates a new StereoscopicUniversalCamera
  40551. * @param name defines camera name
  40552. * @param position defines initial position
  40553. * @param interaxialDistance defines distance between each color axis
  40554. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40555. * @param scene defines the hosting scene
  40556. */
  40557. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40558. /**
  40559. * Gets camera class name
  40560. * @returns StereoscopicUniversalCamera
  40561. */
  40562. getClassName(): string;
  40563. }
  40564. }
  40565. declare module "babylonjs/Cameras/Stereoscopic/index" {
  40566. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  40567. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  40568. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  40569. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  40570. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  40571. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  40572. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  40573. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  40574. }
  40575. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  40576. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40577. import { Scene } from "babylonjs/scene";
  40578. import { Vector3 } from "babylonjs/Maths/math.vector";
  40579. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  40580. /**
  40581. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  40582. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40583. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40584. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40585. */
  40586. export class VirtualJoysticksCamera extends FreeCamera {
  40587. /**
  40588. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  40589. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40590. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40591. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40592. * @param name Define the name of the camera in the scene
  40593. * @param position Define the start position of the camera in the scene
  40594. * @param scene Define the scene the camera belongs to
  40595. */
  40596. constructor(name: string, position: Vector3, scene: Scene);
  40597. /**
  40598. * Gets the current object class name.
  40599. * @return the class name
  40600. */
  40601. getClassName(): string;
  40602. }
  40603. }
  40604. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  40605. import { Matrix } from "babylonjs/Maths/math.vector";
  40606. /**
  40607. * This represents all the required metrics to create a VR camera.
  40608. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  40609. */
  40610. export class VRCameraMetrics {
  40611. /**
  40612. * Define the horizontal resolution off the screen.
  40613. */
  40614. hResolution: number;
  40615. /**
  40616. * Define the vertical resolution off the screen.
  40617. */
  40618. vResolution: number;
  40619. /**
  40620. * Define the horizontal screen size.
  40621. */
  40622. hScreenSize: number;
  40623. /**
  40624. * Define the vertical screen size.
  40625. */
  40626. vScreenSize: number;
  40627. /**
  40628. * Define the vertical screen center position.
  40629. */
  40630. vScreenCenter: number;
  40631. /**
  40632. * Define the distance of the eyes to the screen.
  40633. */
  40634. eyeToScreenDistance: number;
  40635. /**
  40636. * Define the distance between both lenses
  40637. */
  40638. lensSeparationDistance: number;
  40639. /**
  40640. * Define the distance between both viewer's eyes.
  40641. */
  40642. interpupillaryDistance: number;
  40643. /**
  40644. * Define the distortion factor of the VR postprocess.
  40645. * Please, touch with care.
  40646. */
  40647. distortionK: number[];
  40648. /**
  40649. * Define the chromatic aberration correction factors for the VR post process.
  40650. */
  40651. chromaAbCorrection: number[];
  40652. /**
  40653. * Define the scale factor of the post process.
  40654. * The smaller the better but the slower.
  40655. */
  40656. postProcessScaleFactor: number;
  40657. /**
  40658. * Define an offset for the lens center.
  40659. */
  40660. lensCenterOffset: number;
  40661. /**
  40662. * Define if the current vr camera should compensate the distortion of the lense or not.
  40663. */
  40664. compensateDistortion: boolean;
  40665. /**
  40666. * Defines if multiview should be enabled when rendering (Default: false)
  40667. */
  40668. multiviewEnabled: boolean;
  40669. /**
  40670. * Gets the rendering aspect ratio based on the provided resolutions.
  40671. */
  40672. readonly aspectRatio: number;
  40673. /**
  40674. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  40675. */
  40676. readonly aspectRatioFov: number;
  40677. /**
  40678. * @hidden
  40679. */
  40680. readonly leftHMatrix: Matrix;
  40681. /**
  40682. * @hidden
  40683. */
  40684. readonly rightHMatrix: Matrix;
  40685. /**
  40686. * @hidden
  40687. */
  40688. readonly leftPreViewMatrix: Matrix;
  40689. /**
  40690. * @hidden
  40691. */
  40692. readonly rightPreViewMatrix: Matrix;
  40693. /**
  40694. * Get the default VRMetrics based on the most generic setup.
  40695. * @returns the default vr metrics
  40696. */
  40697. static GetDefault(): VRCameraMetrics;
  40698. }
  40699. }
  40700. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  40701. /** @hidden */
  40702. export var vrDistortionCorrectionPixelShader: {
  40703. name: string;
  40704. shader: string;
  40705. };
  40706. }
  40707. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  40708. import { Camera } from "babylonjs/Cameras/camera";
  40709. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40710. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40711. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  40712. /**
  40713. * VRDistortionCorrectionPostProcess used for mobile VR
  40714. */
  40715. export class VRDistortionCorrectionPostProcess extends PostProcess {
  40716. private _isRightEye;
  40717. private _distortionFactors;
  40718. private _postProcessScaleFactor;
  40719. private _lensCenterOffset;
  40720. private _scaleIn;
  40721. private _scaleFactor;
  40722. private _lensCenter;
  40723. /**
  40724. * Initializes the VRDistortionCorrectionPostProcess
  40725. * @param name The name of the effect.
  40726. * @param camera The camera to apply the render pass to.
  40727. * @param isRightEye If this is for the right eye distortion
  40728. * @param vrMetrics All the required metrics for the VR camera
  40729. */
  40730. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  40731. }
  40732. }
  40733. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  40734. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  40735. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40736. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40737. import { Scene } from "babylonjs/scene";
  40738. import { Vector3 } from "babylonjs/Maths/math.vector";
  40739. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  40740. import "babylonjs/Cameras/RigModes/vrRigMode";
  40741. /**
  40742. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  40743. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40744. */
  40745. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  40746. /**
  40747. * Creates a new VRDeviceOrientationArcRotateCamera
  40748. * @param name defines camera name
  40749. * @param alpha defines the camera rotation along the logitudinal axis
  40750. * @param beta defines the camera rotation along the latitudinal axis
  40751. * @param radius defines the camera distance from its target
  40752. * @param target defines the camera target
  40753. * @param scene defines the scene the camera belongs to
  40754. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40755. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40756. */
  40757. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40758. /**
  40759. * Gets camera class name
  40760. * @returns VRDeviceOrientationArcRotateCamera
  40761. */
  40762. getClassName(): string;
  40763. }
  40764. }
  40765. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  40766. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40767. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40768. import { Scene } from "babylonjs/scene";
  40769. import { Vector3 } from "babylonjs/Maths/math.vector";
  40770. import "babylonjs/Cameras/RigModes/vrRigMode";
  40771. /**
  40772. * Camera used to simulate VR rendering (based on FreeCamera)
  40773. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40774. */
  40775. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  40776. /**
  40777. * Creates a new VRDeviceOrientationFreeCamera
  40778. * @param name defines camera name
  40779. * @param position defines the start position of the camera
  40780. * @param scene defines the scene the camera belongs to
  40781. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40782. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40783. */
  40784. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40785. /**
  40786. * Gets camera class name
  40787. * @returns VRDeviceOrientationFreeCamera
  40788. */
  40789. getClassName(): string;
  40790. }
  40791. }
  40792. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  40793. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40794. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40795. import { Scene } from "babylonjs/scene";
  40796. import { Vector3 } from "babylonjs/Maths/math.vector";
  40797. import "babylonjs/Gamepads/gamepadSceneComponent";
  40798. /**
  40799. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  40800. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40801. */
  40802. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  40803. /**
  40804. * Creates a new VRDeviceOrientationGamepadCamera
  40805. * @param name defines camera name
  40806. * @param position defines the start position of the camera
  40807. * @param scene defines the scene the camera belongs to
  40808. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40809. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40810. */
  40811. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40812. /**
  40813. * Gets camera class name
  40814. * @returns VRDeviceOrientationGamepadCamera
  40815. */
  40816. getClassName(): string;
  40817. }
  40818. }
  40819. declare module "babylonjs/Materials/pushMaterial" {
  40820. import { Nullable } from "babylonjs/types";
  40821. import { Scene } from "babylonjs/scene";
  40822. import { Matrix } from "babylonjs/Maths/math.vector";
  40823. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40824. import { Mesh } from "babylonjs/Meshes/mesh";
  40825. import { Material } from "babylonjs/Materials/material";
  40826. import { Effect } from "babylonjs/Materials/effect";
  40827. /**
  40828. * Base class of materials working in push mode in babylon JS
  40829. * @hidden
  40830. */
  40831. export class PushMaterial extends Material {
  40832. protected _activeEffect: Effect;
  40833. protected _normalMatrix: Matrix;
  40834. /**
  40835. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  40836. * This means that the material can keep using a previous shader while a new one is being compiled.
  40837. * This is mostly used when shader parallel compilation is supported (true by default)
  40838. */
  40839. allowShaderHotSwapping: boolean;
  40840. constructor(name: string, scene: Scene);
  40841. getEffect(): Effect;
  40842. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  40843. /**
  40844. * Binds the given world matrix to the active effect
  40845. *
  40846. * @param world the matrix to bind
  40847. */
  40848. bindOnlyWorldMatrix(world: Matrix): void;
  40849. /**
  40850. * Binds the given normal matrix to the active effect
  40851. *
  40852. * @param normalMatrix the matrix to bind
  40853. */
  40854. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  40855. bind(world: Matrix, mesh?: Mesh): void;
  40856. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  40857. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  40858. }
  40859. }
  40860. declare module "babylonjs/Materials/materialFlags" {
  40861. /**
  40862. * This groups all the flags used to control the materials channel.
  40863. */
  40864. export class MaterialFlags {
  40865. private static _DiffuseTextureEnabled;
  40866. /**
  40867. * Are diffuse textures enabled in the application.
  40868. */
  40869. static DiffuseTextureEnabled: boolean;
  40870. private static _AmbientTextureEnabled;
  40871. /**
  40872. * Are ambient textures enabled in the application.
  40873. */
  40874. static AmbientTextureEnabled: boolean;
  40875. private static _OpacityTextureEnabled;
  40876. /**
  40877. * Are opacity textures enabled in the application.
  40878. */
  40879. static OpacityTextureEnabled: boolean;
  40880. private static _ReflectionTextureEnabled;
  40881. /**
  40882. * Are reflection textures enabled in the application.
  40883. */
  40884. static ReflectionTextureEnabled: boolean;
  40885. private static _EmissiveTextureEnabled;
  40886. /**
  40887. * Are emissive textures enabled in the application.
  40888. */
  40889. static EmissiveTextureEnabled: boolean;
  40890. private static _SpecularTextureEnabled;
  40891. /**
  40892. * Are specular textures enabled in the application.
  40893. */
  40894. static SpecularTextureEnabled: boolean;
  40895. private static _BumpTextureEnabled;
  40896. /**
  40897. * Are bump textures enabled in the application.
  40898. */
  40899. static BumpTextureEnabled: boolean;
  40900. private static _LightmapTextureEnabled;
  40901. /**
  40902. * Are lightmap textures enabled in the application.
  40903. */
  40904. static LightmapTextureEnabled: boolean;
  40905. private static _RefractionTextureEnabled;
  40906. /**
  40907. * Are refraction textures enabled in the application.
  40908. */
  40909. static RefractionTextureEnabled: boolean;
  40910. private static _ColorGradingTextureEnabled;
  40911. /**
  40912. * Are color grading textures enabled in the application.
  40913. */
  40914. static ColorGradingTextureEnabled: boolean;
  40915. private static _FresnelEnabled;
  40916. /**
  40917. * Are fresnels enabled in the application.
  40918. */
  40919. static FresnelEnabled: boolean;
  40920. private static _ClearCoatTextureEnabled;
  40921. /**
  40922. * Are clear coat textures enabled in the application.
  40923. */
  40924. static ClearCoatTextureEnabled: boolean;
  40925. private static _ClearCoatBumpTextureEnabled;
  40926. /**
  40927. * Are clear coat bump textures enabled in the application.
  40928. */
  40929. static ClearCoatBumpTextureEnabled: boolean;
  40930. private static _ClearCoatTintTextureEnabled;
  40931. /**
  40932. * Are clear coat tint textures enabled in the application.
  40933. */
  40934. static ClearCoatTintTextureEnabled: boolean;
  40935. private static _SheenTextureEnabled;
  40936. /**
  40937. * Are sheen textures enabled in the application.
  40938. */
  40939. static SheenTextureEnabled: boolean;
  40940. private static _AnisotropicTextureEnabled;
  40941. /**
  40942. * Are anisotropic textures enabled in the application.
  40943. */
  40944. static AnisotropicTextureEnabled: boolean;
  40945. private static _ThicknessTextureEnabled;
  40946. /**
  40947. * Are thickness textures enabled in the application.
  40948. */
  40949. static ThicknessTextureEnabled: boolean;
  40950. }
  40951. }
  40952. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  40953. /** @hidden */
  40954. export var defaultFragmentDeclaration: {
  40955. name: string;
  40956. shader: string;
  40957. };
  40958. }
  40959. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  40960. /** @hidden */
  40961. export var defaultUboDeclaration: {
  40962. name: string;
  40963. shader: string;
  40964. };
  40965. }
  40966. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  40967. /** @hidden */
  40968. export var lightFragmentDeclaration: {
  40969. name: string;
  40970. shader: string;
  40971. };
  40972. }
  40973. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  40974. /** @hidden */
  40975. export var lightUboDeclaration: {
  40976. name: string;
  40977. shader: string;
  40978. };
  40979. }
  40980. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  40981. /** @hidden */
  40982. export var lightsFragmentFunctions: {
  40983. name: string;
  40984. shader: string;
  40985. };
  40986. }
  40987. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  40988. /** @hidden */
  40989. export var shadowsFragmentFunctions: {
  40990. name: string;
  40991. shader: string;
  40992. };
  40993. }
  40994. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  40995. /** @hidden */
  40996. export var fresnelFunction: {
  40997. name: string;
  40998. shader: string;
  40999. };
  41000. }
  41001. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  41002. /** @hidden */
  41003. export var reflectionFunction: {
  41004. name: string;
  41005. shader: string;
  41006. };
  41007. }
  41008. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  41009. /** @hidden */
  41010. export var bumpFragmentFunctions: {
  41011. name: string;
  41012. shader: string;
  41013. };
  41014. }
  41015. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  41016. /** @hidden */
  41017. export var logDepthDeclaration: {
  41018. name: string;
  41019. shader: string;
  41020. };
  41021. }
  41022. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  41023. /** @hidden */
  41024. export var bumpFragment: {
  41025. name: string;
  41026. shader: string;
  41027. };
  41028. }
  41029. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  41030. /** @hidden */
  41031. export var depthPrePass: {
  41032. name: string;
  41033. shader: string;
  41034. };
  41035. }
  41036. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  41037. /** @hidden */
  41038. export var lightFragment: {
  41039. name: string;
  41040. shader: string;
  41041. };
  41042. }
  41043. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  41044. /** @hidden */
  41045. export var logDepthFragment: {
  41046. name: string;
  41047. shader: string;
  41048. };
  41049. }
  41050. declare module "babylonjs/Shaders/default.fragment" {
  41051. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  41052. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41053. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41054. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41055. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41056. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  41057. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  41058. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  41059. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  41060. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41061. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41062. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  41063. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  41064. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41065. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  41066. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  41067. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  41068. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  41069. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  41070. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  41071. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  41072. /** @hidden */
  41073. export var defaultPixelShader: {
  41074. name: string;
  41075. shader: string;
  41076. };
  41077. }
  41078. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  41079. /** @hidden */
  41080. export var defaultVertexDeclaration: {
  41081. name: string;
  41082. shader: string;
  41083. };
  41084. }
  41085. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  41086. /** @hidden */
  41087. export var bumpVertexDeclaration: {
  41088. name: string;
  41089. shader: string;
  41090. };
  41091. }
  41092. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  41093. /** @hidden */
  41094. export var bumpVertex: {
  41095. name: string;
  41096. shader: string;
  41097. };
  41098. }
  41099. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  41100. /** @hidden */
  41101. export var fogVertex: {
  41102. name: string;
  41103. shader: string;
  41104. };
  41105. }
  41106. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  41107. /** @hidden */
  41108. export var shadowsVertex: {
  41109. name: string;
  41110. shader: string;
  41111. };
  41112. }
  41113. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  41114. /** @hidden */
  41115. export var pointCloudVertex: {
  41116. name: string;
  41117. shader: string;
  41118. };
  41119. }
  41120. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  41121. /** @hidden */
  41122. export var logDepthVertex: {
  41123. name: string;
  41124. shader: string;
  41125. };
  41126. }
  41127. declare module "babylonjs/Shaders/default.vertex" {
  41128. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  41129. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41130. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41131. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  41132. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  41133. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  41134. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  41135. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  41136. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41137. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41138. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  41139. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  41140. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41141. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  41142. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  41143. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  41144. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  41145. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  41146. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  41147. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  41148. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  41149. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  41150. /** @hidden */
  41151. export var defaultVertexShader: {
  41152. name: string;
  41153. shader: string;
  41154. };
  41155. }
  41156. declare module "babylonjs/Materials/standardMaterial" {
  41157. import { SmartArray } from "babylonjs/Misc/smartArray";
  41158. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  41159. import { Nullable } from "babylonjs/types";
  41160. import { Scene } from "babylonjs/scene";
  41161. import { Matrix } from "babylonjs/Maths/math.vector";
  41162. import { Color3 } from "babylonjs/Maths/math.color";
  41163. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41164. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41165. import { Mesh } from "babylonjs/Meshes/mesh";
  41166. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  41167. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41168. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  41169. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  41170. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  41171. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41172. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41173. import "babylonjs/Shaders/default.fragment";
  41174. import "babylonjs/Shaders/default.vertex";
  41175. /** @hidden */
  41176. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  41177. MAINUV1: boolean;
  41178. MAINUV2: boolean;
  41179. DIFFUSE: boolean;
  41180. DIFFUSEDIRECTUV: number;
  41181. AMBIENT: boolean;
  41182. AMBIENTDIRECTUV: number;
  41183. OPACITY: boolean;
  41184. OPACITYDIRECTUV: number;
  41185. OPACITYRGB: boolean;
  41186. REFLECTION: boolean;
  41187. EMISSIVE: boolean;
  41188. EMISSIVEDIRECTUV: number;
  41189. SPECULAR: boolean;
  41190. SPECULARDIRECTUV: number;
  41191. BUMP: boolean;
  41192. BUMPDIRECTUV: number;
  41193. PARALLAX: boolean;
  41194. PARALLAXOCCLUSION: boolean;
  41195. SPECULAROVERALPHA: boolean;
  41196. CLIPPLANE: boolean;
  41197. CLIPPLANE2: boolean;
  41198. CLIPPLANE3: boolean;
  41199. CLIPPLANE4: boolean;
  41200. ALPHATEST: boolean;
  41201. DEPTHPREPASS: boolean;
  41202. ALPHAFROMDIFFUSE: boolean;
  41203. POINTSIZE: boolean;
  41204. FOG: boolean;
  41205. SPECULARTERM: boolean;
  41206. DIFFUSEFRESNEL: boolean;
  41207. OPACITYFRESNEL: boolean;
  41208. REFLECTIONFRESNEL: boolean;
  41209. REFRACTIONFRESNEL: boolean;
  41210. EMISSIVEFRESNEL: boolean;
  41211. FRESNEL: boolean;
  41212. NORMAL: boolean;
  41213. UV1: boolean;
  41214. UV2: boolean;
  41215. VERTEXCOLOR: boolean;
  41216. VERTEXALPHA: boolean;
  41217. NUM_BONE_INFLUENCERS: number;
  41218. BonesPerMesh: number;
  41219. BONETEXTURE: boolean;
  41220. INSTANCES: boolean;
  41221. GLOSSINESS: boolean;
  41222. ROUGHNESS: boolean;
  41223. EMISSIVEASILLUMINATION: boolean;
  41224. LINKEMISSIVEWITHDIFFUSE: boolean;
  41225. REFLECTIONFRESNELFROMSPECULAR: boolean;
  41226. LIGHTMAP: boolean;
  41227. LIGHTMAPDIRECTUV: number;
  41228. OBJECTSPACE_NORMALMAP: boolean;
  41229. USELIGHTMAPASSHADOWMAP: boolean;
  41230. REFLECTIONMAP_3D: boolean;
  41231. REFLECTIONMAP_SPHERICAL: boolean;
  41232. REFLECTIONMAP_PLANAR: boolean;
  41233. REFLECTIONMAP_CUBIC: boolean;
  41234. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  41235. REFLECTIONMAP_PROJECTION: boolean;
  41236. REFLECTIONMAP_SKYBOX: boolean;
  41237. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  41238. REFLECTIONMAP_EXPLICIT: boolean;
  41239. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  41240. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  41241. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  41242. INVERTCUBICMAP: boolean;
  41243. LOGARITHMICDEPTH: boolean;
  41244. REFRACTION: boolean;
  41245. REFRACTIONMAP_3D: boolean;
  41246. REFLECTIONOVERALPHA: boolean;
  41247. TWOSIDEDLIGHTING: boolean;
  41248. SHADOWFLOAT: boolean;
  41249. MORPHTARGETS: boolean;
  41250. MORPHTARGETS_NORMAL: boolean;
  41251. MORPHTARGETS_TANGENT: boolean;
  41252. MORPHTARGETS_UV: boolean;
  41253. NUM_MORPH_INFLUENCERS: number;
  41254. NONUNIFORMSCALING: boolean;
  41255. PREMULTIPLYALPHA: boolean;
  41256. IMAGEPROCESSING: boolean;
  41257. VIGNETTE: boolean;
  41258. VIGNETTEBLENDMODEMULTIPLY: boolean;
  41259. VIGNETTEBLENDMODEOPAQUE: boolean;
  41260. TONEMAPPING: boolean;
  41261. TONEMAPPING_ACES: boolean;
  41262. CONTRAST: boolean;
  41263. COLORCURVES: boolean;
  41264. COLORGRADING: boolean;
  41265. COLORGRADING3D: boolean;
  41266. SAMPLER3DGREENDEPTH: boolean;
  41267. SAMPLER3DBGRMAP: boolean;
  41268. IMAGEPROCESSINGPOSTPROCESS: boolean;
  41269. MULTIVIEW: boolean;
  41270. /**
  41271. * If the reflection texture on this material is in linear color space
  41272. * @hidden
  41273. */
  41274. IS_REFLECTION_LINEAR: boolean;
  41275. /**
  41276. * If the refraction texture on this material is in linear color space
  41277. * @hidden
  41278. */
  41279. IS_REFRACTION_LINEAR: boolean;
  41280. EXPOSURE: boolean;
  41281. constructor();
  41282. setReflectionMode(modeToEnable: string): void;
  41283. }
  41284. /**
  41285. * This is the default material used in Babylon. It is the best trade off between quality
  41286. * and performances.
  41287. * @see http://doc.babylonjs.com/babylon101/materials
  41288. */
  41289. export class StandardMaterial extends PushMaterial {
  41290. private _diffuseTexture;
  41291. /**
  41292. * The basic texture of the material as viewed under a light.
  41293. */
  41294. diffuseTexture: Nullable<BaseTexture>;
  41295. private _ambientTexture;
  41296. /**
  41297. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  41298. */
  41299. ambientTexture: Nullable<BaseTexture>;
  41300. private _opacityTexture;
  41301. /**
  41302. * Define the transparency of the material from a texture.
  41303. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  41304. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  41305. */
  41306. opacityTexture: Nullable<BaseTexture>;
  41307. private _reflectionTexture;
  41308. /**
  41309. * Define the texture used to display the reflection.
  41310. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41311. */
  41312. reflectionTexture: Nullable<BaseTexture>;
  41313. private _emissiveTexture;
  41314. /**
  41315. * Define texture of the material as if self lit.
  41316. * This will be mixed in the final result even in the absence of light.
  41317. */
  41318. emissiveTexture: Nullable<BaseTexture>;
  41319. private _specularTexture;
  41320. /**
  41321. * Define how the color and intensity of the highlight given by the light in the material.
  41322. */
  41323. specularTexture: Nullable<BaseTexture>;
  41324. private _bumpTexture;
  41325. /**
  41326. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  41327. * 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.
  41328. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  41329. */
  41330. bumpTexture: Nullable<BaseTexture>;
  41331. private _lightmapTexture;
  41332. /**
  41333. * Complex lighting can be computationally expensive to compute at runtime.
  41334. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  41335. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  41336. */
  41337. lightmapTexture: Nullable<BaseTexture>;
  41338. private _refractionTexture;
  41339. /**
  41340. * Define the texture used to display the refraction.
  41341. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41342. */
  41343. refractionTexture: Nullable<BaseTexture>;
  41344. /**
  41345. * The color of the material lit by the environmental background lighting.
  41346. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  41347. */
  41348. ambientColor: Color3;
  41349. /**
  41350. * The basic color of the material as viewed under a light.
  41351. */
  41352. diffuseColor: Color3;
  41353. /**
  41354. * Define how the color and intensity of the highlight given by the light in the material.
  41355. */
  41356. specularColor: Color3;
  41357. /**
  41358. * Define the color of the material as if self lit.
  41359. * This will be mixed in the final result even in the absence of light.
  41360. */
  41361. emissiveColor: Color3;
  41362. /**
  41363. * Defines how sharp are the highlights in the material.
  41364. * The bigger the value the sharper giving a more glossy feeling to the result.
  41365. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  41366. */
  41367. specularPower: number;
  41368. private _useAlphaFromDiffuseTexture;
  41369. /**
  41370. * Does the transparency come from the diffuse texture alpha channel.
  41371. */
  41372. useAlphaFromDiffuseTexture: boolean;
  41373. private _useEmissiveAsIllumination;
  41374. /**
  41375. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  41376. */
  41377. useEmissiveAsIllumination: boolean;
  41378. private _linkEmissiveWithDiffuse;
  41379. /**
  41380. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  41381. * the emissive level when the final color is close to one.
  41382. */
  41383. linkEmissiveWithDiffuse: boolean;
  41384. private _useSpecularOverAlpha;
  41385. /**
  41386. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  41387. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  41388. */
  41389. useSpecularOverAlpha: boolean;
  41390. private _useReflectionOverAlpha;
  41391. /**
  41392. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  41393. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  41394. */
  41395. useReflectionOverAlpha: boolean;
  41396. private _disableLighting;
  41397. /**
  41398. * Does lights from the scene impacts this material.
  41399. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  41400. */
  41401. disableLighting: boolean;
  41402. private _useObjectSpaceNormalMap;
  41403. /**
  41404. * Allows using an object space normal map (instead of tangent space).
  41405. */
  41406. useObjectSpaceNormalMap: boolean;
  41407. private _useParallax;
  41408. /**
  41409. * Is parallax enabled or not.
  41410. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41411. */
  41412. useParallax: boolean;
  41413. private _useParallaxOcclusion;
  41414. /**
  41415. * Is parallax occlusion enabled or not.
  41416. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  41417. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41418. */
  41419. useParallaxOcclusion: boolean;
  41420. /**
  41421. * 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.
  41422. */
  41423. parallaxScaleBias: number;
  41424. private _roughness;
  41425. /**
  41426. * Helps to define how blurry the reflections should appears in the material.
  41427. */
  41428. roughness: number;
  41429. /**
  41430. * In case of refraction, define the value of the index of refraction.
  41431. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41432. */
  41433. indexOfRefraction: number;
  41434. /**
  41435. * Invert the refraction texture alongside the y axis.
  41436. * It can be useful with procedural textures or probe for instance.
  41437. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41438. */
  41439. invertRefractionY: boolean;
  41440. /**
  41441. * Defines the alpha limits in alpha test mode.
  41442. */
  41443. alphaCutOff: number;
  41444. private _useLightmapAsShadowmap;
  41445. /**
  41446. * In case of light mapping, define whether the map contains light or shadow informations.
  41447. */
  41448. useLightmapAsShadowmap: boolean;
  41449. private _diffuseFresnelParameters;
  41450. /**
  41451. * Define the diffuse fresnel parameters of the material.
  41452. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41453. */
  41454. diffuseFresnelParameters: FresnelParameters;
  41455. private _opacityFresnelParameters;
  41456. /**
  41457. * Define the opacity fresnel parameters of the material.
  41458. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41459. */
  41460. opacityFresnelParameters: FresnelParameters;
  41461. private _reflectionFresnelParameters;
  41462. /**
  41463. * Define the reflection fresnel parameters of the material.
  41464. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41465. */
  41466. reflectionFresnelParameters: FresnelParameters;
  41467. private _refractionFresnelParameters;
  41468. /**
  41469. * Define the refraction fresnel parameters of the material.
  41470. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41471. */
  41472. refractionFresnelParameters: FresnelParameters;
  41473. private _emissiveFresnelParameters;
  41474. /**
  41475. * Define the emissive fresnel parameters of the material.
  41476. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41477. */
  41478. emissiveFresnelParameters: FresnelParameters;
  41479. private _useReflectionFresnelFromSpecular;
  41480. /**
  41481. * If true automatically deducts the fresnels values from the material specularity.
  41482. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41483. */
  41484. useReflectionFresnelFromSpecular: boolean;
  41485. private _useGlossinessFromSpecularMapAlpha;
  41486. /**
  41487. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  41488. */
  41489. useGlossinessFromSpecularMapAlpha: boolean;
  41490. private _maxSimultaneousLights;
  41491. /**
  41492. * Defines the maximum number of lights that can be used in the material
  41493. */
  41494. maxSimultaneousLights: number;
  41495. private _invertNormalMapX;
  41496. /**
  41497. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  41498. */
  41499. invertNormalMapX: boolean;
  41500. private _invertNormalMapY;
  41501. /**
  41502. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  41503. */
  41504. invertNormalMapY: boolean;
  41505. private _twoSidedLighting;
  41506. /**
  41507. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  41508. */
  41509. twoSidedLighting: boolean;
  41510. /**
  41511. * Default configuration related to image processing available in the standard Material.
  41512. */
  41513. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41514. /**
  41515. * Gets the image processing configuration used either in this material.
  41516. */
  41517. /**
  41518. * Sets the Default image processing configuration used either in the this material.
  41519. *
  41520. * If sets to null, the scene one is in use.
  41521. */
  41522. imageProcessingConfiguration: ImageProcessingConfiguration;
  41523. /**
  41524. * Keep track of the image processing observer to allow dispose and replace.
  41525. */
  41526. private _imageProcessingObserver;
  41527. /**
  41528. * Attaches a new image processing configuration to the Standard Material.
  41529. * @param configuration
  41530. */
  41531. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  41532. /**
  41533. * Gets wether the color curves effect is enabled.
  41534. */
  41535. /**
  41536. * Sets wether the color curves effect is enabled.
  41537. */
  41538. cameraColorCurvesEnabled: boolean;
  41539. /**
  41540. * Gets wether the color grading effect is enabled.
  41541. */
  41542. /**
  41543. * Gets wether the color grading effect is enabled.
  41544. */
  41545. cameraColorGradingEnabled: boolean;
  41546. /**
  41547. * Gets wether tonemapping is enabled or not.
  41548. */
  41549. /**
  41550. * Sets wether tonemapping is enabled or not
  41551. */
  41552. cameraToneMappingEnabled: boolean;
  41553. /**
  41554. * The camera exposure used on this material.
  41555. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41556. * This corresponds to a photographic exposure.
  41557. */
  41558. /**
  41559. * The camera exposure used on this material.
  41560. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41561. * This corresponds to a photographic exposure.
  41562. */
  41563. cameraExposure: number;
  41564. /**
  41565. * Gets The camera contrast used on this material.
  41566. */
  41567. /**
  41568. * Sets The camera contrast used on this material.
  41569. */
  41570. cameraContrast: number;
  41571. /**
  41572. * Gets the Color Grading 2D Lookup Texture.
  41573. */
  41574. /**
  41575. * Sets the Color Grading 2D Lookup Texture.
  41576. */
  41577. cameraColorGradingTexture: Nullable<BaseTexture>;
  41578. /**
  41579. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41580. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41581. * 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;
  41582. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41583. */
  41584. /**
  41585. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41586. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41587. * 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;
  41588. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41589. */
  41590. cameraColorCurves: Nullable<ColorCurves>;
  41591. /**
  41592. * Custom callback helping to override the default shader used in the material.
  41593. */
  41594. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  41595. protected _renderTargets: SmartArray<RenderTargetTexture>;
  41596. protected _worldViewProjectionMatrix: Matrix;
  41597. protected _globalAmbientColor: Color3;
  41598. protected _useLogarithmicDepth: boolean;
  41599. protected _rebuildInParallel: boolean;
  41600. /**
  41601. * Instantiates a new standard material.
  41602. * This is the default material used in Babylon. It is the best trade off between quality
  41603. * and performances.
  41604. * @see http://doc.babylonjs.com/babylon101/materials
  41605. * @param name Define the name of the material in the scene
  41606. * @param scene Define the scene the material belong to
  41607. */
  41608. constructor(name: string, scene: Scene);
  41609. /**
  41610. * Gets a boolean indicating that current material needs to register RTT
  41611. */
  41612. readonly hasRenderTargetTextures: boolean;
  41613. /**
  41614. * Gets the current class name of the material e.g. "StandardMaterial"
  41615. * Mainly use in serialization.
  41616. * @returns the class name
  41617. */
  41618. getClassName(): string;
  41619. /**
  41620. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  41621. * You can try switching to logarithmic depth.
  41622. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  41623. */
  41624. useLogarithmicDepth: boolean;
  41625. /**
  41626. * Specifies if the material will require alpha blending
  41627. * @returns a boolean specifying if alpha blending is needed
  41628. */
  41629. needAlphaBlending(): boolean;
  41630. /**
  41631. * Specifies if this material should be rendered in alpha test mode
  41632. * @returns a boolean specifying if an alpha test is needed.
  41633. */
  41634. needAlphaTesting(): boolean;
  41635. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  41636. /**
  41637. * Get the texture used for alpha test purpose.
  41638. * @returns the diffuse texture in case of the standard material.
  41639. */
  41640. getAlphaTestTexture(): Nullable<BaseTexture>;
  41641. /**
  41642. * Get if the submesh is ready to be used and all its information available.
  41643. * Child classes can use it to update shaders
  41644. * @param mesh defines the mesh to check
  41645. * @param subMesh defines which submesh to check
  41646. * @param useInstances specifies that instances should be used
  41647. * @returns a boolean indicating that the submesh is ready or not
  41648. */
  41649. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  41650. /**
  41651. * Builds the material UBO layouts.
  41652. * Used internally during the effect preparation.
  41653. */
  41654. buildUniformLayout(): void;
  41655. /**
  41656. * Unbinds the material from the mesh
  41657. */
  41658. unbind(): void;
  41659. /**
  41660. * Binds the submesh to this material by preparing the effect and shader to draw
  41661. * @param world defines the world transformation matrix
  41662. * @param mesh defines the mesh containing the submesh
  41663. * @param subMesh defines the submesh to bind the material to
  41664. */
  41665. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  41666. /**
  41667. * Get the list of animatables in the material.
  41668. * @returns the list of animatables object used in the material
  41669. */
  41670. getAnimatables(): IAnimatable[];
  41671. /**
  41672. * Gets the active textures from the material
  41673. * @returns an array of textures
  41674. */
  41675. getActiveTextures(): BaseTexture[];
  41676. /**
  41677. * Specifies if the material uses a texture
  41678. * @param texture defines the texture to check against the material
  41679. * @returns a boolean specifying if the material uses the texture
  41680. */
  41681. hasTexture(texture: BaseTexture): boolean;
  41682. /**
  41683. * Disposes the material
  41684. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  41685. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  41686. */
  41687. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  41688. /**
  41689. * Makes a duplicate of the material, and gives it a new name
  41690. * @param name defines the new name for the duplicated material
  41691. * @returns the cloned material
  41692. */
  41693. clone(name: string): StandardMaterial;
  41694. /**
  41695. * Serializes this material in a JSON representation
  41696. * @returns the serialized material object
  41697. */
  41698. serialize(): any;
  41699. /**
  41700. * Creates a standard material from parsed material data
  41701. * @param source defines the JSON representation of the material
  41702. * @param scene defines the hosting scene
  41703. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  41704. * @returns a new standard material
  41705. */
  41706. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  41707. /**
  41708. * Are diffuse textures enabled in the application.
  41709. */
  41710. static DiffuseTextureEnabled: boolean;
  41711. /**
  41712. * Are ambient textures enabled in the application.
  41713. */
  41714. static AmbientTextureEnabled: boolean;
  41715. /**
  41716. * Are opacity textures enabled in the application.
  41717. */
  41718. static OpacityTextureEnabled: boolean;
  41719. /**
  41720. * Are reflection textures enabled in the application.
  41721. */
  41722. static ReflectionTextureEnabled: boolean;
  41723. /**
  41724. * Are emissive textures enabled in the application.
  41725. */
  41726. static EmissiveTextureEnabled: boolean;
  41727. /**
  41728. * Are specular textures enabled in the application.
  41729. */
  41730. static SpecularTextureEnabled: boolean;
  41731. /**
  41732. * Are bump textures enabled in the application.
  41733. */
  41734. static BumpTextureEnabled: boolean;
  41735. /**
  41736. * Are lightmap textures enabled in the application.
  41737. */
  41738. static LightmapTextureEnabled: boolean;
  41739. /**
  41740. * Are refraction textures enabled in the application.
  41741. */
  41742. static RefractionTextureEnabled: boolean;
  41743. /**
  41744. * Are color grading textures enabled in the application.
  41745. */
  41746. static ColorGradingTextureEnabled: boolean;
  41747. /**
  41748. * Are fresnels enabled in the application.
  41749. */
  41750. static FresnelEnabled: boolean;
  41751. }
  41752. }
  41753. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  41754. import { Scene } from "babylonjs/scene";
  41755. import { Texture } from "babylonjs/Materials/Textures/texture";
  41756. /**
  41757. * A class extending Texture allowing drawing on a texture
  41758. * @see http://doc.babylonjs.com/how_to/dynamictexture
  41759. */
  41760. export class DynamicTexture extends Texture {
  41761. private _generateMipMaps;
  41762. private _canvas;
  41763. private _context;
  41764. private _engine;
  41765. /**
  41766. * Creates a DynamicTexture
  41767. * @param name defines the name of the texture
  41768. * @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
  41769. * @param scene defines the scene where you want the texture
  41770. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  41771. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  41772. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  41773. */
  41774. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  41775. /**
  41776. * Get the current class name of the texture useful for serialization or dynamic coding.
  41777. * @returns "DynamicTexture"
  41778. */
  41779. getClassName(): string;
  41780. /**
  41781. * Gets the current state of canRescale
  41782. */
  41783. readonly canRescale: boolean;
  41784. private _recreate;
  41785. /**
  41786. * Scales the texture
  41787. * @param ratio the scale factor to apply to both width and height
  41788. */
  41789. scale(ratio: number): void;
  41790. /**
  41791. * Resizes the texture
  41792. * @param width the new width
  41793. * @param height the new height
  41794. */
  41795. scaleTo(width: number, height: number): void;
  41796. /**
  41797. * Gets the context of the canvas used by the texture
  41798. * @returns the canvas context of the dynamic texture
  41799. */
  41800. getContext(): CanvasRenderingContext2D;
  41801. /**
  41802. * Clears the texture
  41803. */
  41804. clear(): void;
  41805. /**
  41806. * Updates the texture
  41807. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41808. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  41809. */
  41810. update(invertY?: boolean, premulAlpha?: boolean): void;
  41811. /**
  41812. * Draws text onto the texture
  41813. * @param text defines the text to be drawn
  41814. * @param x defines the placement of the text from the left
  41815. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  41816. * @param font defines the font to be used with font-style, font-size, font-name
  41817. * @param color defines the color used for the text
  41818. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  41819. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41820. * @param update defines whether texture is immediately update (default is true)
  41821. */
  41822. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  41823. /**
  41824. * Clones the texture
  41825. * @returns the clone of the texture.
  41826. */
  41827. clone(): DynamicTexture;
  41828. /**
  41829. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  41830. * @returns a serialized dynamic texture object
  41831. */
  41832. serialize(): any;
  41833. /** @hidden */
  41834. _rebuild(): void;
  41835. }
  41836. }
  41837. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  41838. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41839. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41840. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41841. /** @hidden */
  41842. export var imageProcessingPixelShader: {
  41843. name: string;
  41844. shader: string;
  41845. };
  41846. }
  41847. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  41848. import { Nullable } from "babylonjs/types";
  41849. import { Color4 } from "babylonjs/Maths/math.color";
  41850. import { Camera } from "babylonjs/Cameras/camera";
  41851. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41852. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41853. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  41854. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  41855. import { Engine } from "babylonjs/Engines/engine";
  41856. import "babylonjs/Shaders/imageProcessing.fragment";
  41857. import "babylonjs/Shaders/postprocess.vertex";
  41858. /**
  41859. * ImageProcessingPostProcess
  41860. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  41861. */
  41862. export class ImageProcessingPostProcess extends PostProcess {
  41863. /**
  41864. * Default configuration related to image processing available in the PBR Material.
  41865. */
  41866. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41867. /**
  41868. * Gets the image processing configuration used either in this material.
  41869. */
  41870. /**
  41871. * Sets the Default image processing configuration used either in the this material.
  41872. *
  41873. * If sets to null, the scene one is in use.
  41874. */
  41875. imageProcessingConfiguration: ImageProcessingConfiguration;
  41876. /**
  41877. * Keep track of the image processing observer to allow dispose and replace.
  41878. */
  41879. private _imageProcessingObserver;
  41880. /**
  41881. * Attaches a new image processing configuration to the PBR Material.
  41882. * @param configuration
  41883. */
  41884. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  41885. /**
  41886. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41887. */
  41888. /**
  41889. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41890. */
  41891. colorCurves: Nullable<ColorCurves>;
  41892. /**
  41893. * Gets wether the color curves effect is enabled.
  41894. */
  41895. /**
  41896. * Sets wether the color curves effect is enabled.
  41897. */
  41898. colorCurvesEnabled: boolean;
  41899. /**
  41900. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41901. */
  41902. /**
  41903. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41904. */
  41905. colorGradingTexture: Nullable<BaseTexture>;
  41906. /**
  41907. * Gets wether the color grading effect is enabled.
  41908. */
  41909. /**
  41910. * Gets wether the color grading effect is enabled.
  41911. */
  41912. colorGradingEnabled: boolean;
  41913. /**
  41914. * Gets exposure used in the effect.
  41915. */
  41916. /**
  41917. * Sets exposure used in the effect.
  41918. */
  41919. exposure: number;
  41920. /**
  41921. * Gets wether tonemapping is enabled or not.
  41922. */
  41923. /**
  41924. * Sets wether tonemapping is enabled or not
  41925. */
  41926. toneMappingEnabled: boolean;
  41927. /**
  41928. * Gets the type of tone mapping effect.
  41929. */
  41930. /**
  41931. * Sets the type of tone mapping effect.
  41932. */
  41933. toneMappingType: number;
  41934. /**
  41935. * Gets contrast used in the effect.
  41936. */
  41937. /**
  41938. * Sets contrast used in the effect.
  41939. */
  41940. contrast: number;
  41941. /**
  41942. * Gets Vignette stretch size.
  41943. */
  41944. /**
  41945. * Sets Vignette stretch size.
  41946. */
  41947. vignetteStretch: number;
  41948. /**
  41949. * Gets Vignette centre X Offset.
  41950. */
  41951. /**
  41952. * Sets Vignette centre X Offset.
  41953. */
  41954. vignetteCentreX: number;
  41955. /**
  41956. * Gets Vignette centre Y Offset.
  41957. */
  41958. /**
  41959. * Sets Vignette centre Y Offset.
  41960. */
  41961. vignetteCentreY: number;
  41962. /**
  41963. * Gets Vignette weight or intensity of the vignette effect.
  41964. */
  41965. /**
  41966. * Sets Vignette weight or intensity of the vignette effect.
  41967. */
  41968. vignetteWeight: number;
  41969. /**
  41970. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41971. * if vignetteEnabled is set to true.
  41972. */
  41973. /**
  41974. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41975. * if vignetteEnabled is set to true.
  41976. */
  41977. vignetteColor: Color4;
  41978. /**
  41979. * Gets Camera field of view used by the Vignette effect.
  41980. */
  41981. /**
  41982. * Sets Camera field of view used by the Vignette effect.
  41983. */
  41984. vignetteCameraFov: number;
  41985. /**
  41986. * Gets the vignette blend mode allowing different kind of effect.
  41987. */
  41988. /**
  41989. * Sets the vignette blend mode allowing different kind of effect.
  41990. */
  41991. vignetteBlendMode: number;
  41992. /**
  41993. * Gets wether the vignette effect is enabled.
  41994. */
  41995. /**
  41996. * Sets wether the vignette effect is enabled.
  41997. */
  41998. vignetteEnabled: boolean;
  41999. private _fromLinearSpace;
  42000. /**
  42001. * Gets wether the input of the processing is in Gamma or Linear Space.
  42002. */
  42003. /**
  42004. * Sets wether the input of the processing is in Gamma or Linear Space.
  42005. */
  42006. fromLinearSpace: boolean;
  42007. /**
  42008. * Defines cache preventing GC.
  42009. */
  42010. private _defines;
  42011. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42012. /**
  42013. * "ImageProcessingPostProcess"
  42014. * @returns "ImageProcessingPostProcess"
  42015. */
  42016. getClassName(): string;
  42017. protected _updateParameters(): void;
  42018. dispose(camera?: Camera): void;
  42019. }
  42020. }
  42021. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  42022. import { Scene } from "babylonjs/scene";
  42023. import { Color3 } from "babylonjs/Maths/math.color";
  42024. import { Mesh } from "babylonjs/Meshes/mesh";
  42025. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  42026. import { Nullable } from "babylonjs/types";
  42027. /**
  42028. * Class containing static functions to help procedurally build meshes
  42029. */
  42030. export class GroundBuilder {
  42031. /**
  42032. * Creates a ground mesh
  42033. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42034. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42035. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42036. * @param name defines the name of the mesh
  42037. * @param options defines the options used to create the mesh
  42038. * @param scene defines the hosting scene
  42039. * @returns the ground mesh
  42040. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42041. */
  42042. static CreateGround(name: string, options: {
  42043. width?: number;
  42044. height?: number;
  42045. subdivisions?: number;
  42046. subdivisionsX?: number;
  42047. subdivisionsY?: number;
  42048. updatable?: boolean;
  42049. }, scene: any): Mesh;
  42050. /**
  42051. * Creates a tiled ground mesh
  42052. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42053. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42054. * * 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
  42055. * * 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
  42056. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42057. * @param name defines the name of the mesh
  42058. * @param options defines the options used to create the mesh
  42059. * @param scene defines the hosting scene
  42060. * @returns the tiled ground mesh
  42061. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42062. */
  42063. static CreateTiledGround(name: string, options: {
  42064. xmin: number;
  42065. zmin: number;
  42066. xmax: number;
  42067. zmax: number;
  42068. subdivisions?: {
  42069. w: number;
  42070. h: number;
  42071. };
  42072. precision?: {
  42073. w: number;
  42074. h: number;
  42075. };
  42076. updatable?: boolean;
  42077. }, scene?: Nullable<Scene>): Mesh;
  42078. /**
  42079. * Creates a ground mesh from a height map
  42080. * * The parameter `url` sets the URL of the height map image resource.
  42081. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42082. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42083. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42084. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42085. * * 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.
  42086. * * 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).
  42087. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42088. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42089. * @param name defines the name of the mesh
  42090. * @param url defines the url to the height map
  42091. * @param options defines the options used to create the mesh
  42092. * @param scene defines the hosting scene
  42093. * @returns the ground mesh
  42094. * @see https://doc.babylonjs.com/babylon101/height_map
  42095. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42096. */
  42097. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42098. width?: number;
  42099. height?: number;
  42100. subdivisions?: number;
  42101. minHeight?: number;
  42102. maxHeight?: number;
  42103. colorFilter?: Color3;
  42104. alphaFilter?: number;
  42105. updatable?: boolean;
  42106. onReady?: (mesh: GroundMesh) => void;
  42107. }, scene?: Nullable<Scene>): GroundMesh;
  42108. }
  42109. }
  42110. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  42111. import { Vector4 } from "babylonjs/Maths/math.vector";
  42112. import { Mesh } from "babylonjs/Meshes/mesh";
  42113. /**
  42114. * Class containing static functions to help procedurally build meshes
  42115. */
  42116. export class TorusBuilder {
  42117. /**
  42118. * Creates a torus mesh
  42119. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42120. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42121. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42122. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42123. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42124. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42125. * @param name defines the name of the mesh
  42126. * @param options defines the options used to create the mesh
  42127. * @param scene defines the hosting scene
  42128. * @returns the torus mesh
  42129. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42130. */
  42131. static CreateTorus(name: string, options: {
  42132. diameter?: number;
  42133. thickness?: number;
  42134. tessellation?: number;
  42135. updatable?: boolean;
  42136. sideOrientation?: number;
  42137. frontUVs?: Vector4;
  42138. backUVs?: Vector4;
  42139. }, scene: any): Mesh;
  42140. }
  42141. }
  42142. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  42143. import { Vector4 } from "babylonjs/Maths/math.vector";
  42144. import { Color4 } from "babylonjs/Maths/math.color";
  42145. import { Mesh } from "babylonjs/Meshes/mesh";
  42146. /**
  42147. * Class containing static functions to help procedurally build meshes
  42148. */
  42149. export class CylinderBuilder {
  42150. /**
  42151. * Creates a cylinder or a cone mesh
  42152. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42153. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42154. * * 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.
  42155. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42156. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42157. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42158. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42159. * * 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).
  42160. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42161. * * 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).
  42162. * * 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
  42163. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42164. * * 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
  42165. * * 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.
  42166. * * If `enclose` is false, a ring surface is one element.
  42167. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42168. * * 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
  42169. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42170. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42171. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42172. * @param name defines the name of the mesh
  42173. * @param options defines the options used to create the mesh
  42174. * @param scene defines the hosting scene
  42175. * @returns the cylinder mesh
  42176. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42177. */
  42178. static CreateCylinder(name: string, options: {
  42179. height?: number;
  42180. diameterTop?: number;
  42181. diameterBottom?: number;
  42182. diameter?: number;
  42183. tessellation?: number;
  42184. subdivisions?: number;
  42185. arc?: number;
  42186. faceColors?: Color4[];
  42187. faceUV?: Vector4[];
  42188. updatable?: boolean;
  42189. hasRings?: boolean;
  42190. enclose?: boolean;
  42191. cap?: number;
  42192. sideOrientation?: number;
  42193. frontUVs?: Vector4;
  42194. backUVs?: Vector4;
  42195. }, scene: any): Mesh;
  42196. }
  42197. }
  42198. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  42199. import { Observable } from "babylonjs/Misc/observable";
  42200. import { Nullable } from "babylonjs/types";
  42201. import { Camera } from "babylonjs/Cameras/camera";
  42202. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42203. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42204. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  42205. import { Scene } from "babylonjs/scene";
  42206. import { Vector3 } from "babylonjs/Maths/math.vector";
  42207. import { Color3 } from "babylonjs/Maths/math.color";
  42208. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42209. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42210. import { Mesh } from "babylonjs/Meshes/mesh";
  42211. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  42212. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42213. import "babylonjs/Meshes/Builders/groundBuilder";
  42214. import "babylonjs/Meshes/Builders/torusBuilder";
  42215. import "babylonjs/Meshes/Builders/cylinderBuilder";
  42216. import "babylonjs/Gamepads/gamepadSceneComponent";
  42217. import "babylonjs/Animations/animatable";
  42218. /**
  42219. * Options to modify the vr teleportation behavior.
  42220. */
  42221. export interface VRTeleportationOptions {
  42222. /**
  42223. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42224. */
  42225. floorMeshName?: string;
  42226. /**
  42227. * A list of meshes to be used as the teleportation floor. (default: empty)
  42228. */
  42229. floorMeshes?: Mesh[];
  42230. }
  42231. /**
  42232. * Options to modify the vr experience helper's behavior.
  42233. */
  42234. export interface VRExperienceHelperOptions extends WebVROptions {
  42235. /**
  42236. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42237. */
  42238. createDeviceOrientationCamera?: boolean;
  42239. /**
  42240. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42241. */
  42242. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42243. /**
  42244. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42245. */
  42246. laserToggle?: boolean;
  42247. /**
  42248. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42249. */
  42250. floorMeshes?: Mesh[];
  42251. /**
  42252. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  42253. */
  42254. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  42255. }
  42256. /**
  42257. * Event containing information after VR has been entered
  42258. */
  42259. export class OnAfterEnteringVRObservableEvent {
  42260. /**
  42261. * If entering vr was successful
  42262. */
  42263. success: boolean;
  42264. }
  42265. /**
  42266. * Helps to quickly add VR support to an existing scene.
  42267. * See http://doc.babylonjs.com/how_to/webvr_helper
  42268. */
  42269. export class VRExperienceHelper {
  42270. /** Options to modify the vr experience helper's behavior. */
  42271. webVROptions: VRExperienceHelperOptions;
  42272. private _scene;
  42273. private _position;
  42274. private _btnVR;
  42275. private _btnVRDisplayed;
  42276. private _webVRsupported;
  42277. private _webVRready;
  42278. private _webVRrequesting;
  42279. private _webVRpresenting;
  42280. private _hasEnteredVR;
  42281. private _fullscreenVRpresenting;
  42282. private _canvas;
  42283. private _webVRCamera;
  42284. private _vrDeviceOrientationCamera;
  42285. private _deviceOrientationCamera;
  42286. private _existingCamera;
  42287. private _onKeyDown;
  42288. private _onVrDisplayPresentChange;
  42289. private _onVRDisplayChanged;
  42290. private _onVRRequestPresentStart;
  42291. private _onVRRequestPresentComplete;
  42292. /**
  42293. * 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)
  42294. */
  42295. enableGazeEvenWhenNoPointerLock: boolean;
  42296. /**
  42297. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  42298. */
  42299. exitVROnDoubleTap: boolean;
  42300. /**
  42301. * Observable raised right before entering VR.
  42302. */
  42303. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42304. /**
  42305. * Observable raised when entering VR has completed.
  42306. */
  42307. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  42308. /**
  42309. * Observable raised when exiting VR.
  42310. */
  42311. onExitingVRObservable: Observable<VRExperienceHelper>;
  42312. /**
  42313. * Observable raised when controller mesh is loaded.
  42314. */
  42315. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42316. /** Return this.onEnteringVRObservable
  42317. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42318. */
  42319. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42320. /** Return this.onExitingVRObservable
  42321. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42322. */
  42323. readonly onExitingVR: Observable<VRExperienceHelper>;
  42324. /** Return this.onControllerMeshLoadedObservable
  42325. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42326. */
  42327. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42328. private _rayLength;
  42329. private _useCustomVRButton;
  42330. private _teleportationRequested;
  42331. private _teleportActive;
  42332. private _floorMeshName;
  42333. private _floorMeshesCollection;
  42334. private _rotationAllowed;
  42335. private _teleportBackwardsVector;
  42336. private _teleportationTarget;
  42337. private _isDefaultTeleportationTarget;
  42338. private _postProcessMove;
  42339. private _teleportationFillColor;
  42340. private _teleportationBorderColor;
  42341. private _rotationAngle;
  42342. private _haloCenter;
  42343. private _cameraGazer;
  42344. private _padSensibilityUp;
  42345. private _padSensibilityDown;
  42346. private _leftController;
  42347. private _rightController;
  42348. /**
  42349. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42350. */
  42351. onNewMeshSelected: Observable<AbstractMesh>;
  42352. /**
  42353. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  42354. * This observable will provide the mesh and the controller used to select the mesh
  42355. */
  42356. onMeshSelectedWithController: Observable<{
  42357. mesh: AbstractMesh;
  42358. controller: WebVRController;
  42359. }>;
  42360. /**
  42361. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42362. */
  42363. onNewMeshPicked: Observable<PickingInfo>;
  42364. private _circleEase;
  42365. /**
  42366. * Observable raised before camera teleportation
  42367. */
  42368. onBeforeCameraTeleport: Observable<Vector3>;
  42369. /**
  42370. * Observable raised after camera teleportation
  42371. */
  42372. onAfterCameraTeleport: Observable<Vector3>;
  42373. /**
  42374. * Observable raised when current selected mesh gets unselected
  42375. */
  42376. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42377. private _raySelectionPredicate;
  42378. /**
  42379. * To be optionaly changed by user to define custom ray selection
  42380. */
  42381. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42382. /**
  42383. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42384. */
  42385. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42386. /**
  42387. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42388. */
  42389. teleportationEnabled: boolean;
  42390. private _defaultHeight;
  42391. private _teleportationInitialized;
  42392. private _interactionsEnabled;
  42393. private _interactionsRequested;
  42394. private _displayGaze;
  42395. private _displayLaserPointer;
  42396. /**
  42397. * The mesh used to display where the user is going to teleport.
  42398. */
  42399. /**
  42400. * Sets the mesh to be used to display where the user is going to teleport.
  42401. */
  42402. teleportationTarget: Mesh;
  42403. /**
  42404. * 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
  42405. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42406. * See http://doc.babylonjs.com/resources/baking_transformations
  42407. */
  42408. gazeTrackerMesh: Mesh;
  42409. /**
  42410. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42411. */
  42412. updateGazeTrackerScale: boolean;
  42413. /**
  42414. * If the gaze trackers color should be updated when selecting meshes
  42415. */
  42416. updateGazeTrackerColor: boolean;
  42417. /**
  42418. * The gaze tracking mesh corresponding to the left controller
  42419. */
  42420. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42421. /**
  42422. * The gaze tracking mesh corresponding to the right controller
  42423. */
  42424. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42425. /**
  42426. * If the ray of the gaze should be displayed.
  42427. */
  42428. /**
  42429. * Sets if the ray of the gaze should be displayed.
  42430. */
  42431. displayGaze: boolean;
  42432. /**
  42433. * If the ray of the LaserPointer should be displayed.
  42434. */
  42435. /**
  42436. * Sets if the ray of the LaserPointer should be displayed.
  42437. */
  42438. displayLaserPointer: boolean;
  42439. /**
  42440. * The deviceOrientationCamera used as the camera when not in VR.
  42441. */
  42442. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42443. /**
  42444. * Based on the current WebVR support, returns the current VR camera used.
  42445. */
  42446. readonly currentVRCamera: Nullable<Camera>;
  42447. /**
  42448. * The webVRCamera which is used when in VR.
  42449. */
  42450. readonly webVRCamera: WebVRFreeCamera;
  42451. /**
  42452. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42453. */
  42454. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42455. /**
  42456. * The html button that is used to trigger entering into VR.
  42457. */
  42458. readonly vrButton: Nullable<HTMLButtonElement>;
  42459. private readonly _teleportationRequestInitiated;
  42460. /**
  42461. * Defines wether or not Pointer lock should be requested when switching to
  42462. * full screen.
  42463. */
  42464. requestPointerLockOnFullScreen: boolean;
  42465. /**
  42466. * Instantiates a VRExperienceHelper.
  42467. * Helps to quickly add VR support to an existing scene.
  42468. * @param scene The scene the VRExperienceHelper belongs to.
  42469. * @param webVROptions Options to modify the vr experience helper's behavior.
  42470. */
  42471. constructor(scene: Scene,
  42472. /** Options to modify the vr experience helper's behavior. */
  42473. webVROptions?: VRExperienceHelperOptions);
  42474. private _onDefaultMeshLoaded;
  42475. private _onResize;
  42476. private _onFullscreenChange;
  42477. /**
  42478. * Gets a value indicating if we are currently in VR mode.
  42479. */
  42480. readonly isInVRMode: boolean;
  42481. private onVrDisplayPresentChange;
  42482. private onVRDisplayChanged;
  42483. private moveButtonToBottomRight;
  42484. private displayVRButton;
  42485. private updateButtonVisibility;
  42486. private _cachedAngularSensibility;
  42487. /**
  42488. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42489. * Otherwise, will use the fullscreen API.
  42490. */
  42491. enterVR(): void;
  42492. /**
  42493. * Attempt to exit VR, or fullscreen.
  42494. */
  42495. exitVR(): void;
  42496. /**
  42497. * The position of the vr experience helper.
  42498. */
  42499. /**
  42500. * Sets the position of the vr experience helper.
  42501. */
  42502. position: Vector3;
  42503. /**
  42504. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42505. */
  42506. enableInteractions(): void;
  42507. private readonly _noControllerIsActive;
  42508. private beforeRender;
  42509. private _isTeleportationFloor;
  42510. /**
  42511. * Adds a floor mesh to be used for teleportation.
  42512. * @param floorMesh the mesh to be used for teleportation.
  42513. */
  42514. addFloorMesh(floorMesh: Mesh): void;
  42515. /**
  42516. * Removes a floor mesh from being used for teleportation.
  42517. * @param floorMesh the mesh to be removed.
  42518. */
  42519. removeFloorMesh(floorMesh: Mesh): void;
  42520. /**
  42521. * Enables interactions and teleportation using the VR controllers and gaze.
  42522. * @param vrTeleportationOptions options to modify teleportation behavior.
  42523. */
  42524. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42525. private _onNewGamepadConnected;
  42526. private _tryEnableInteractionOnController;
  42527. private _onNewGamepadDisconnected;
  42528. private _enableInteractionOnController;
  42529. private _checkTeleportWithRay;
  42530. private _checkRotate;
  42531. private _checkTeleportBackwards;
  42532. private _enableTeleportationOnController;
  42533. private _createTeleportationCircles;
  42534. private _displayTeleportationTarget;
  42535. private _hideTeleportationTarget;
  42536. private _rotateCamera;
  42537. private _moveTeleportationSelectorTo;
  42538. private _workingVector;
  42539. private _workingQuaternion;
  42540. private _workingMatrix;
  42541. /**
  42542. * Teleports the users feet to the desired location
  42543. * @param location The location where the user's feet should be placed
  42544. */
  42545. teleportCamera(location: Vector3): void;
  42546. private _convertNormalToDirectionOfRay;
  42547. private _castRayAndSelectObject;
  42548. private _notifySelectedMeshUnselected;
  42549. /**
  42550. * Sets the color of the laser ray from the vr controllers.
  42551. * @param color new color for the ray.
  42552. */
  42553. changeLaserColor(color: Color3): void;
  42554. /**
  42555. * Sets the color of the ray from the vr headsets gaze.
  42556. * @param color new color for the ray.
  42557. */
  42558. changeGazeColor(color: Color3): void;
  42559. /**
  42560. * Exits VR and disposes of the vr experience helper
  42561. */
  42562. dispose(): void;
  42563. /**
  42564. * Gets the name of the VRExperienceHelper class
  42565. * @returns "VRExperienceHelper"
  42566. */
  42567. getClassName(): string;
  42568. }
  42569. }
  42570. declare module "babylonjs/Cameras/VR/index" {
  42571. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  42572. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  42573. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42574. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  42575. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  42576. export * from "babylonjs/Cameras/VR/webVRCamera";
  42577. }
  42578. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  42579. import { Observable } from "babylonjs/Misc/observable";
  42580. import { Nullable } from "babylonjs/types";
  42581. import { IDisposable, Scene } from "babylonjs/scene";
  42582. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42583. /**
  42584. * Manages an XRSession to work with Babylon's engine
  42585. * @see https://doc.babylonjs.com/how_to/webxr
  42586. */
  42587. export class WebXRSessionManager implements IDisposable {
  42588. private scene;
  42589. /**
  42590. * Fires every time a new xrFrame arrives which can be used to update the camera
  42591. */
  42592. onXRFrameObservable: Observable<any>;
  42593. /**
  42594. * Fires when the xr session is ended either by the device or manually done
  42595. */
  42596. onXRSessionEnded: Observable<any>;
  42597. /**
  42598. * Underlying xr session
  42599. */
  42600. session: XRSession;
  42601. /**
  42602. * Type of reference space used when creating the session
  42603. */
  42604. referenceSpace: XRReferenceSpace;
  42605. /** @hidden */
  42606. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  42607. /**
  42608. * Current XR frame
  42609. */
  42610. currentFrame: Nullable<XRFrame>;
  42611. private _xrNavigator;
  42612. private baseLayer;
  42613. /**
  42614. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42615. * @param scene The scene which the session should be created for
  42616. */
  42617. constructor(scene: Scene);
  42618. /**
  42619. * Initializes the manager
  42620. * After initialization enterXR can be called to start an XR session
  42621. * @returns Promise which resolves after it is initialized
  42622. */
  42623. initializeAsync(): Promise<void>;
  42624. /**
  42625. * Initializes an xr session
  42626. * @param xrSessionMode mode to initialize
  42627. * @returns a promise which will resolve once the session has been initialized
  42628. */
  42629. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  42630. /**
  42631. * Sets the reference space on the xr session
  42632. * @param referenceSpace space to set
  42633. * @returns a promise that will resolve once the reference space has been set
  42634. */
  42635. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  42636. /**
  42637. * Updates the render state of the session
  42638. * @param state state to set
  42639. * @returns a promise that resolves once the render state has been updated
  42640. */
  42641. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42642. /**
  42643. * Starts rendering to the xr layer
  42644. * @returns a promise that will resolve once rendering has started
  42645. */
  42646. startRenderingToXRAsync(): Promise<void>;
  42647. /**
  42648. * Stops the xrSession and restores the renderloop
  42649. * @returns Promise which resolves after it exits XR
  42650. */
  42651. exitXRAsync(): Promise<unknown>;
  42652. /**
  42653. * Checks if a session would be supported for the creation options specified
  42654. * @param sessionMode session mode to check if supported eg. immersive-vr
  42655. * @returns true if supported
  42656. */
  42657. supportsSessionAsync(sessionMode: XRSessionMode): any;
  42658. /**
  42659. * @hidden
  42660. * Converts the render layer of xrSession to a render target
  42661. * @param session session to create render target for
  42662. * @param scene scene the new render target should be created for
  42663. */
  42664. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42665. /**
  42666. * Disposes of the session manager
  42667. */
  42668. dispose(): void;
  42669. }
  42670. }
  42671. declare module "babylonjs/Cameras/XR/webXRCamera" {
  42672. import { Scene } from "babylonjs/scene";
  42673. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42674. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42675. /**
  42676. * WebXR Camera which holds the views for the xrSession
  42677. * @see https://doc.babylonjs.com/how_to/webxr
  42678. */
  42679. export class WebXRCamera extends FreeCamera {
  42680. private static _TmpMatrix;
  42681. /**
  42682. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42683. * @param name the name of the camera
  42684. * @param scene the scene to add the camera to
  42685. */
  42686. constructor(name: string, scene: Scene);
  42687. private _updateNumberOfRigCameras;
  42688. /** @hidden */
  42689. _updateForDualEyeDebugging(pupilDistance?: number): void;
  42690. /**
  42691. * Updates the cameras position from the current pose information of the XR session
  42692. * @param xrSessionManager the session containing pose information
  42693. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  42694. */
  42695. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  42696. }
  42697. }
  42698. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  42699. import { Nullable } from "babylonjs/types";
  42700. import { IDisposable } from "babylonjs/scene";
  42701. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42702. /**
  42703. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42704. */
  42705. export class WebXRManagedOutputCanvas implements IDisposable {
  42706. private helper;
  42707. private _canvas;
  42708. /**
  42709. * xrpresent context of the canvas which can be used to display/mirror xr content
  42710. */
  42711. canvasContext: WebGLRenderingContext;
  42712. /**
  42713. * xr layer for the canvas
  42714. */
  42715. xrLayer: Nullable<XRWebGLLayer>;
  42716. /**
  42717. * Initializes the xr layer for the session
  42718. * @param xrSession xr session
  42719. * @returns a promise that will resolve once the XR Layer has been created
  42720. */
  42721. initializeXRLayerAsync(xrSession: any): any;
  42722. /**
  42723. * Initializes the canvas to be added/removed upon entering/exiting xr
  42724. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  42725. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  42726. */
  42727. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  42728. /**
  42729. * Disposes of the object
  42730. */
  42731. dispose(): void;
  42732. private _setManagedOutputCanvas;
  42733. private _addCanvas;
  42734. private _removeCanvas;
  42735. }
  42736. }
  42737. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  42738. import { Observable } from "babylonjs/Misc/observable";
  42739. import { IDisposable, Scene } from "babylonjs/scene";
  42740. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  42741. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42742. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42743. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  42744. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42745. /**
  42746. * States of the webXR experience
  42747. */
  42748. export enum WebXRState {
  42749. /**
  42750. * Transitioning to being in XR mode
  42751. */
  42752. ENTERING_XR = 0,
  42753. /**
  42754. * Transitioning to non XR mode
  42755. */
  42756. EXITING_XR = 1,
  42757. /**
  42758. * In XR mode and presenting
  42759. */
  42760. IN_XR = 2,
  42761. /**
  42762. * Not entered XR mode
  42763. */
  42764. NOT_IN_XR = 3
  42765. }
  42766. /**
  42767. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  42768. * @see https://doc.babylonjs.com/how_to/webxr
  42769. */
  42770. export class WebXRExperienceHelper implements IDisposable {
  42771. private scene;
  42772. /**
  42773. * 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
  42774. */
  42775. container: AbstractMesh;
  42776. /**
  42777. * Camera used to render xr content
  42778. */
  42779. camera: WebXRCamera;
  42780. /**
  42781. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42782. */
  42783. state: WebXRState;
  42784. private _setState;
  42785. private static _TmpVector;
  42786. /**
  42787. * Fires when the state of the experience helper has changed
  42788. */
  42789. onStateChangedObservable: Observable<WebXRState>;
  42790. /** Session manager used to keep track of xr session */
  42791. sessionManager: WebXRSessionManager;
  42792. private _nonVRCamera;
  42793. private _originalSceneAutoClear;
  42794. private _supported;
  42795. /**
  42796. * Creates the experience helper
  42797. * @param scene the scene to attach the experience helper to
  42798. * @returns a promise for the experience helper
  42799. */
  42800. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  42801. /**
  42802. * Creates a WebXRExperienceHelper
  42803. * @param scene The scene the helper should be created in
  42804. */
  42805. private constructor();
  42806. /**
  42807. * Exits XR mode and returns the scene to its original state
  42808. * @returns promise that resolves after xr mode has exited
  42809. */
  42810. exitXRAsync(): Promise<unknown>;
  42811. /**
  42812. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  42813. * @param sessionCreationOptions options for the XR session
  42814. * @param referenceSpaceType frame of reference of the XR session
  42815. * @param outputCanvas the output canvas that will be used to enter XR mode
  42816. * @returns promise that resolves after xr mode has entered
  42817. */
  42818. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  42819. /**
  42820. * Updates the global position of the camera by moving the camera's container
  42821. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  42822. * @param position The desired global position of the camera
  42823. */
  42824. setPositionOfCameraUsingContainer(position: Vector3): void;
  42825. /**
  42826. * Rotates the xr camera by rotating the camera's container around the camera's position
  42827. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  42828. * @param rotation the desired quaternion rotation to apply to the camera
  42829. */
  42830. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  42831. /**
  42832. * Disposes of the experience helper
  42833. */
  42834. dispose(): void;
  42835. }
  42836. }
  42837. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  42838. import { Nullable } from "babylonjs/types";
  42839. import { Observable } from "babylonjs/Misc/observable";
  42840. import { IDisposable, Scene } from "babylonjs/scene";
  42841. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42842. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42843. /**
  42844. * Button which can be used to enter a different mode of XR
  42845. */
  42846. export class WebXREnterExitUIButton {
  42847. /** button element */
  42848. element: HTMLElement;
  42849. /** XR initialization options for the button */
  42850. sessionMode: XRSessionMode;
  42851. /** Reference space type */
  42852. referenceSpaceType: XRReferenceSpaceType;
  42853. /**
  42854. * Creates a WebXREnterExitUIButton
  42855. * @param element button element
  42856. * @param sessionMode XR initialization session mode
  42857. * @param referenceSpaceType the type of reference space to be used
  42858. */
  42859. constructor(
  42860. /** button element */
  42861. element: HTMLElement,
  42862. /** XR initialization options for the button */
  42863. sessionMode: XRSessionMode,
  42864. /** Reference space type */
  42865. referenceSpaceType: XRReferenceSpaceType);
  42866. /**
  42867. * Overwritable function which can be used to update the button's visuals when the state changes
  42868. * @param activeButton the current active button in the UI
  42869. */
  42870. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  42871. }
  42872. /**
  42873. * Options to create the webXR UI
  42874. */
  42875. export class WebXREnterExitUIOptions {
  42876. /**
  42877. * Context to enter xr with
  42878. */
  42879. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  42880. /**
  42881. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  42882. */
  42883. customButtons?: Array<WebXREnterExitUIButton>;
  42884. }
  42885. /**
  42886. * UI to allow the user to enter/exit XR mode
  42887. */
  42888. export class WebXREnterExitUI implements IDisposable {
  42889. private scene;
  42890. private _overlay;
  42891. private _buttons;
  42892. private _activeButton;
  42893. /**
  42894. * Fired every time the active button is changed.
  42895. *
  42896. * When xr is entered via a button that launches xr that button will be the callback parameter
  42897. *
  42898. * When exiting xr the callback parameter will be null)
  42899. */
  42900. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  42901. /**
  42902. * Creates UI to allow the user to enter/exit XR mode
  42903. * @param scene the scene to add the ui to
  42904. * @param helper the xr experience helper to enter/exit xr with
  42905. * @param options options to configure the UI
  42906. * @returns the created ui
  42907. */
  42908. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  42909. private constructor();
  42910. private _updateButtons;
  42911. /**
  42912. * Disposes of the object
  42913. */
  42914. dispose(): void;
  42915. }
  42916. }
  42917. declare module "babylonjs/Cameras/XR/webXRController" {
  42918. import { Nullable } from "babylonjs/types";
  42919. import { Observable } from "babylonjs/Misc/observable";
  42920. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42921. import { Ray } from "babylonjs/Culling/ray";
  42922. import { Scene } from "babylonjs/scene";
  42923. /**
  42924. * Represents an XR input
  42925. */
  42926. export class WebXRController {
  42927. private scene;
  42928. /** The underlying input source for the controller */
  42929. inputSource: XRInputSource;
  42930. private parentContainer;
  42931. /**
  42932. * 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
  42933. */
  42934. grip?: AbstractMesh;
  42935. /**
  42936. * Pointer which can be used to select objects or attach a visible laser to
  42937. */
  42938. pointer: AbstractMesh;
  42939. /**
  42940. * Event that fires when the controller is removed/disposed
  42941. */
  42942. onDisposeObservable: Observable<{}>;
  42943. private _tmpMatrix;
  42944. private _tmpQuaternion;
  42945. private _tmpVector;
  42946. /**
  42947. * Creates the controller
  42948. * @see https://doc.babylonjs.com/how_to/webxr
  42949. * @param scene the scene which the controller should be associated to
  42950. * @param inputSource the underlying input source for the controller
  42951. * @param parentContainer parent that the controller meshes should be children of
  42952. */
  42953. constructor(scene: Scene,
  42954. /** The underlying input source for the controller */
  42955. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  42956. /**
  42957. * Updates the controller pose based on the given XRFrame
  42958. * @param xrFrame xr frame to update the pose with
  42959. * @param referenceSpace reference space to use
  42960. */
  42961. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  42962. /**
  42963. * Gets a world space ray coming from the controller
  42964. * @param result the resulting ray
  42965. */
  42966. getWorldPointerRayToRef(result: Ray): void;
  42967. /**
  42968. * Disposes of the object
  42969. */
  42970. dispose(): void;
  42971. }
  42972. }
  42973. declare module "babylonjs/Cameras/XR/webXRInput" {
  42974. import { Observable } from "babylonjs/Misc/observable";
  42975. import { IDisposable } from "babylonjs/scene";
  42976. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42977. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  42978. /**
  42979. * XR input used to track XR inputs such as controllers/rays
  42980. */
  42981. export class WebXRInput implements IDisposable {
  42982. /**
  42983. * Base experience the input listens to
  42984. */
  42985. baseExperience: WebXRExperienceHelper;
  42986. /**
  42987. * XR controllers being tracked
  42988. */
  42989. controllers: Array<WebXRController>;
  42990. private _frameObserver;
  42991. private _stateObserver;
  42992. /**
  42993. * Event when a controller has been connected/added
  42994. */
  42995. onControllerAddedObservable: Observable<WebXRController>;
  42996. /**
  42997. * Event when a controller has been removed/disconnected
  42998. */
  42999. onControllerRemovedObservable: Observable<WebXRController>;
  43000. /**
  43001. * Initializes the WebXRInput
  43002. * @param baseExperience experience helper which the input should be created for
  43003. */
  43004. constructor(
  43005. /**
  43006. * Base experience the input listens to
  43007. */
  43008. baseExperience: WebXRExperienceHelper);
  43009. private _onInputSourcesChange;
  43010. private _addAndRemoveControllers;
  43011. /**
  43012. * Disposes of the object
  43013. */
  43014. dispose(): void;
  43015. }
  43016. }
  43017. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  43018. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43019. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43020. /**
  43021. * Enables teleportation
  43022. */
  43023. export class WebXRControllerTeleportation {
  43024. private _teleportationFillColor;
  43025. private _teleportationBorderColor;
  43026. private _tmpRay;
  43027. private _tmpVector;
  43028. /**
  43029. * Creates a WebXRControllerTeleportation
  43030. * @param input input manager to add teleportation to
  43031. * @param floorMeshes floormeshes which can be teleported to
  43032. */
  43033. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  43034. }
  43035. }
  43036. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  43037. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43038. /**
  43039. * Handles pointer input automatically for the pointer of XR controllers
  43040. */
  43041. export class WebXRControllerPointerSelection {
  43042. private static _idCounter;
  43043. private _tmpRay;
  43044. /**
  43045. * Creates a WebXRControllerPointerSelection
  43046. * @param input input manager to setup pointer selection
  43047. */
  43048. constructor(input: WebXRInput);
  43049. private _convertNormalToDirectionOfRay;
  43050. private _updatePointerDistance;
  43051. }
  43052. }
  43053. declare module "babylonjs/Loading/sceneLoader" {
  43054. import { Observable } from "babylonjs/Misc/observable";
  43055. import { Nullable } from "babylonjs/types";
  43056. import { Scene } from "babylonjs/scene";
  43057. import { Engine } from "babylonjs/Engines/engine";
  43058. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43059. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43060. import { AssetContainer } from "babylonjs/assetContainer";
  43061. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43062. import { Skeleton } from "babylonjs/Bones/skeleton";
  43063. /**
  43064. * Class used to represent data loading progression
  43065. */
  43066. export class SceneLoaderProgressEvent {
  43067. /** defines if data length to load can be evaluated */
  43068. readonly lengthComputable: boolean;
  43069. /** defines the loaded data length */
  43070. readonly loaded: number;
  43071. /** defines the data length to load */
  43072. readonly total: number;
  43073. /**
  43074. * Create a new progress event
  43075. * @param lengthComputable defines if data length to load can be evaluated
  43076. * @param loaded defines the loaded data length
  43077. * @param total defines the data length to load
  43078. */
  43079. constructor(
  43080. /** defines if data length to load can be evaluated */
  43081. lengthComputable: boolean,
  43082. /** defines the loaded data length */
  43083. loaded: number,
  43084. /** defines the data length to load */
  43085. total: number);
  43086. /**
  43087. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43088. * @param event defines the source event
  43089. * @returns a new SceneLoaderProgressEvent
  43090. */
  43091. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43092. }
  43093. /**
  43094. * Interface used by SceneLoader plugins to define supported file extensions
  43095. */
  43096. export interface ISceneLoaderPluginExtensions {
  43097. /**
  43098. * Defines the list of supported extensions
  43099. */
  43100. [extension: string]: {
  43101. isBinary: boolean;
  43102. };
  43103. }
  43104. /**
  43105. * Interface used by SceneLoader plugin factory
  43106. */
  43107. export interface ISceneLoaderPluginFactory {
  43108. /**
  43109. * Defines the name of the factory
  43110. */
  43111. name: string;
  43112. /**
  43113. * Function called to create a new plugin
  43114. * @return the new plugin
  43115. */
  43116. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43117. /**
  43118. * Boolean indicating if the plugin can direct load specific data
  43119. */
  43120. canDirectLoad?: (data: string) => boolean;
  43121. }
  43122. /**
  43123. * Interface used to define a SceneLoader plugin
  43124. */
  43125. export interface ISceneLoaderPlugin {
  43126. /**
  43127. * The friendly name of this plugin.
  43128. */
  43129. name: string;
  43130. /**
  43131. * The file extensions supported by this plugin.
  43132. */
  43133. extensions: string | ISceneLoaderPluginExtensions;
  43134. /**
  43135. * Import meshes into a scene.
  43136. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43137. * @param scene The scene to import into
  43138. * @param data The data to import
  43139. * @param rootUrl The root url for scene and resources
  43140. * @param meshes The meshes array to import into
  43141. * @param particleSystems The particle systems array to import into
  43142. * @param skeletons The skeletons array to import into
  43143. * @param onError The callback when import fails
  43144. * @returns True if successful or false otherwise
  43145. */
  43146. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43147. /**
  43148. * Load into a scene.
  43149. * @param scene The scene to load into
  43150. * @param data The data to import
  43151. * @param rootUrl The root url for scene and resources
  43152. * @param onError The callback when import fails
  43153. * @returns true if successful or false otherwise
  43154. */
  43155. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43156. /**
  43157. * The callback that returns true if the data can be directly loaded.
  43158. */
  43159. canDirectLoad?: (data: string) => boolean;
  43160. /**
  43161. * The callback that allows custom handling of the root url based on the response url.
  43162. */
  43163. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43164. /**
  43165. * Load into an asset container.
  43166. * @param scene The scene to load into
  43167. * @param data The data to import
  43168. * @param rootUrl The root url for scene and resources
  43169. * @param onError The callback when import fails
  43170. * @returns The loaded asset container
  43171. */
  43172. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43173. }
  43174. /**
  43175. * Interface used to define an async SceneLoader plugin
  43176. */
  43177. export interface ISceneLoaderPluginAsync {
  43178. /**
  43179. * The friendly name of this plugin.
  43180. */
  43181. name: string;
  43182. /**
  43183. * The file extensions supported by this plugin.
  43184. */
  43185. extensions: string | ISceneLoaderPluginExtensions;
  43186. /**
  43187. * Import meshes into a scene.
  43188. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43189. * @param scene The scene to import into
  43190. * @param data The data to import
  43191. * @param rootUrl The root url for scene and resources
  43192. * @param onProgress The callback when the load progresses
  43193. * @param fileName Defines the name of the file to load
  43194. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43195. */
  43196. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43197. meshes: AbstractMesh[];
  43198. particleSystems: IParticleSystem[];
  43199. skeletons: Skeleton[];
  43200. animationGroups: AnimationGroup[];
  43201. }>;
  43202. /**
  43203. * Load into a scene.
  43204. * @param scene The scene to load into
  43205. * @param data The data to import
  43206. * @param rootUrl The root url for scene and resources
  43207. * @param onProgress The callback when the load progresses
  43208. * @param fileName Defines the name of the file to load
  43209. * @returns Nothing
  43210. */
  43211. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43212. /**
  43213. * The callback that returns true if the data can be directly loaded.
  43214. */
  43215. canDirectLoad?: (data: string) => boolean;
  43216. /**
  43217. * The callback that allows custom handling of the root url based on the response url.
  43218. */
  43219. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43220. /**
  43221. * Load into an asset container.
  43222. * @param scene The scene to load into
  43223. * @param data The data to import
  43224. * @param rootUrl The root url for scene and resources
  43225. * @param onProgress The callback when the load progresses
  43226. * @param fileName Defines the name of the file to load
  43227. * @returns The loaded asset container
  43228. */
  43229. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43230. }
  43231. /**
  43232. * Class used to load scene from various file formats using registered plugins
  43233. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43234. */
  43235. export class SceneLoader {
  43236. /**
  43237. * No logging while loading
  43238. */
  43239. static readonly NO_LOGGING: number;
  43240. /**
  43241. * Minimal logging while loading
  43242. */
  43243. static readonly MINIMAL_LOGGING: number;
  43244. /**
  43245. * Summary logging while loading
  43246. */
  43247. static readonly SUMMARY_LOGGING: number;
  43248. /**
  43249. * Detailled logging while loading
  43250. */
  43251. static readonly DETAILED_LOGGING: number;
  43252. /**
  43253. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43254. */
  43255. static ForceFullSceneLoadingForIncremental: boolean;
  43256. /**
  43257. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43258. */
  43259. static ShowLoadingScreen: boolean;
  43260. /**
  43261. * Defines the current logging level (while loading the scene)
  43262. * @ignorenaming
  43263. */
  43264. static loggingLevel: number;
  43265. /**
  43266. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43267. */
  43268. static CleanBoneMatrixWeights: boolean;
  43269. /**
  43270. * Event raised when a plugin is used to load a scene
  43271. */
  43272. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43273. private static _registeredPlugins;
  43274. private static _getDefaultPlugin;
  43275. private static _getPluginForExtension;
  43276. private static _getPluginForDirectLoad;
  43277. private static _getPluginForFilename;
  43278. private static _getDirectLoad;
  43279. private static _loadData;
  43280. private static _getFileInfo;
  43281. /**
  43282. * Gets a plugin that can load the given extension
  43283. * @param extension defines the extension to load
  43284. * @returns a plugin or null if none works
  43285. */
  43286. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43287. /**
  43288. * Gets a boolean indicating that the given extension can be loaded
  43289. * @param extension defines the extension to load
  43290. * @returns true if the extension is supported
  43291. */
  43292. static IsPluginForExtensionAvailable(extension: string): boolean;
  43293. /**
  43294. * Adds a new plugin to the list of registered plugins
  43295. * @param plugin defines the plugin to add
  43296. */
  43297. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43298. /**
  43299. * Import meshes into a scene
  43300. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43301. * @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)
  43302. * @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)
  43303. * @param scene the instance of BABYLON.Scene to append to
  43304. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43305. * @param onProgress a callback with a progress event for each file being loaded
  43306. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43307. * @param pluginExtension the extension used to determine the plugin
  43308. * @returns The loaded plugin
  43309. */
  43310. 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>;
  43311. /**
  43312. * Import meshes into a scene
  43313. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43314. * @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)
  43315. * @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)
  43316. * @param scene the instance of BABYLON.Scene to append to
  43317. * @param onProgress a callback with a progress event for each file being loaded
  43318. * @param pluginExtension the extension used to determine the plugin
  43319. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43320. */
  43321. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43322. meshes: AbstractMesh[];
  43323. particleSystems: IParticleSystem[];
  43324. skeletons: Skeleton[];
  43325. animationGroups: AnimationGroup[];
  43326. }>;
  43327. /**
  43328. * Load a scene
  43329. * @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)
  43330. * @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)
  43331. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43332. * @param onSuccess a callback with the scene when import succeeds
  43333. * @param onProgress a callback with a progress event for each file being loaded
  43334. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43335. * @param pluginExtension the extension used to determine the plugin
  43336. * @returns The loaded plugin
  43337. */
  43338. 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>;
  43339. /**
  43340. * Load a scene
  43341. * @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)
  43342. * @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)
  43343. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43344. * @param onProgress a callback with a progress event for each file being loaded
  43345. * @param pluginExtension the extension used to determine the plugin
  43346. * @returns The loaded scene
  43347. */
  43348. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43349. /**
  43350. * Append a scene
  43351. * @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)
  43352. * @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)
  43353. * @param scene is the instance of BABYLON.Scene to append to
  43354. * @param onSuccess a callback with the scene when import succeeds
  43355. * @param onProgress a callback with a progress event for each file being loaded
  43356. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43357. * @param pluginExtension the extension used to determine the plugin
  43358. * @returns The loaded plugin
  43359. */
  43360. 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>;
  43361. /**
  43362. * Append a scene
  43363. * @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)
  43364. * @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)
  43365. * @param scene is the instance of BABYLON.Scene to append to
  43366. * @param onProgress a callback with a progress event for each file being loaded
  43367. * @param pluginExtension the extension used to determine the plugin
  43368. * @returns The given scene
  43369. */
  43370. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43371. /**
  43372. * Load a scene into an asset container
  43373. * @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)
  43374. * @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)
  43375. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43376. * @param onSuccess a callback with the scene when import succeeds
  43377. * @param onProgress a callback with a progress event for each file being loaded
  43378. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43379. * @param pluginExtension the extension used to determine the plugin
  43380. * @returns The loaded plugin
  43381. */
  43382. 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>;
  43383. /**
  43384. * Load a scene into an asset container
  43385. * @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)
  43386. * @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)
  43387. * @param scene is the instance of Scene to append to
  43388. * @param onProgress a callback with a progress event for each file being loaded
  43389. * @param pluginExtension the extension used to determine the plugin
  43390. * @returns The loaded asset container
  43391. */
  43392. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43393. }
  43394. }
  43395. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43396. import { Scene } from "babylonjs/scene";
  43397. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43398. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43399. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43400. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43401. /**
  43402. * Generic Controller
  43403. */
  43404. export class GenericController extends WebVRController {
  43405. /**
  43406. * Base Url for the controller model.
  43407. */
  43408. static readonly MODEL_BASE_URL: string;
  43409. /**
  43410. * File name for the controller model.
  43411. */
  43412. static readonly MODEL_FILENAME: string;
  43413. /**
  43414. * Creates a new GenericController from a gamepad
  43415. * @param vrGamepad the gamepad that the controller should be created from
  43416. */
  43417. constructor(vrGamepad: any);
  43418. /**
  43419. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43420. * @param scene scene in which to add meshes
  43421. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43422. */
  43423. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43424. /**
  43425. * Called once for each button that changed state since the last frame
  43426. * @param buttonIdx Which button index changed
  43427. * @param state New state of the button
  43428. * @param changes Which properties on the state changed since last frame
  43429. */
  43430. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43431. }
  43432. }
  43433. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43434. import { Observable } from "babylonjs/Misc/observable";
  43435. import { Scene } from "babylonjs/scene";
  43436. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43437. import { Ray } from "babylonjs/Culling/ray";
  43438. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43439. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43440. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43441. /**
  43442. * Defines the WindowsMotionController object that the state of the windows motion controller
  43443. */
  43444. export class WindowsMotionController extends WebVRController {
  43445. /**
  43446. * The base url used to load the left and right controller models
  43447. */
  43448. static MODEL_BASE_URL: string;
  43449. /**
  43450. * The name of the left controller model file
  43451. */
  43452. static MODEL_LEFT_FILENAME: string;
  43453. /**
  43454. * The name of the right controller model file
  43455. */
  43456. static MODEL_RIGHT_FILENAME: string;
  43457. /**
  43458. * The controller name prefix for this controller type
  43459. */
  43460. static readonly GAMEPAD_ID_PREFIX: string;
  43461. /**
  43462. * The controller id pattern for this controller type
  43463. */
  43464. private static readonly GAMEPAD_ID_PATTERN;
  43465. private _loadedMeshInfo;
  43466. private readonly _mapping;
  43467. /**
  43468. * Fired when the trackpad on this controller is clicked
  43469. */
  43470. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43471. /**
  43472. * Fired when the trackpad on this controller is modified
  43473. */
  43474. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43475. /**
  43476. * The current x and y values of this controller's trackpad
  43477. */
  43478. trackpad: StickValues;
  43479. /**
  43480. * Creates a new WindowsMotionController from a gamepad
  43481. * @param vrGamepad the gamepad that the controller should be created from
  43482. */
  43483. constructor(vrGamepad: any);
  43484. /**
  43485. * Fired when the trigger on this controller is modified
  43486. */
  43487. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43488. /**
  43489. * Fired when the menu button on this controller is modified
  43490. */
  43491. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43492. /**
  43493. * Fired when the grip button on this controller is modified
  43494. */
  43495. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43496. /**
  43497. * Fired when the thumbstick button on this controller is modified
  43498. */
  43499. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43500. /**
  43501. * Fired when the touchpad button on this controller is modified
  43502. */
  43503. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43504. /**
  43505. * Fired when the touchpad values on this controller are modified
  43506. */
  43507. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43508. private _updateTrackpad;
  43509. /**
  43510. * Called once per frame by the engine.
  43511. */
  43512. update(): void;
  43513. /**
  43514. * Called once for each button that changed state since the last frame
  43515. * @param buttonIdx Which button index changed
  43516. * @param state New state of the button
  43517. * @param changes Which properties on the state changed since last frame
  43518. */
  43519. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43520. /**
  43521. * Moves the buttons on the controller mesh based on their current state
  43522. * @param buttonName the name of the button to move
  43523. * @param buttonValue the value of the button which determines the buttons new position
  43524. */
  43525. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43526. /**
  43527. * Moves the axis on the controller mesh based on its current state
  43528. * @param axis the index of the axis
  43529. * @param axisValue the value of the axis which determines the meshes new position
  43530. * @hidden
  43531. */
  43532. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43533. /**
  43534. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43535. * @param scene scene in which to add meshes
  43536. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43537. */
  43538. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43539. /**
  43540. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43541. * can be transformed by button presses and axes values, based on this._mapping.
  43542. *
  43543. * @param scene scene in which the meshes exist
  43544. * @param meshes list of meshes that make up the controller model to process
  43545. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43546. */
  43547. private processModel;
  43548. private createMeshInfo;
  43549. /**
  43550. * Gets the ray of the controller in the direction the controller is pointing
  43551. * @param length the length the resulting ray should be
  43552. * @returns a ray in the direction the controller is pointing
  43553. */
  43554. getForwardRay(length?: number): Ray;
  43555. /**
  43556. * Disposes of the controller
  43557. */
  43558. dispose(): void;
  43559. }
  43560. }
  43561. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43562. import { Observable } from "babylonjs/Misc/observable";
  43563. import { Scene } from "babylonjs/scene";
  43564. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43565. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43566. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43567. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43568. /**
  43569. * Oculus Touch Controller
  43570. */
  43571. export class OculusTouchController extends WebVRController {
  43572. /**
  43573. * Base Url for the controller model.
  43574. */
  43575. static MODEL_BASE_URL: string;
  43576. /**
  43577. * File name for the left controller model.
  43578. */
  43579. static MODEL_LEFT_FILENAME: string;
  43580. /**
  43581. * File name for the right controller model.
  43582. */
  43583. static MODEL_RIGHT_FILENAME: string;
  43584. /**
  43585. * Base Url for the Quest controller model.
  43586. */
  43587. static QUEST_MODEL_BASE_URL: string;
  43588. /**
  43589. * @hidden
  43590. * If the controllers are running on a device that needs the updated Quest controller models
  43591. */
  43592. static _IsQuest: boolean;
  43593. /**
  43594. * Fired when the secondary trigger on this controller is modified
  43595. */
  43596. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43597. /**
  43598. * Fired when the thumb rest on this controller is modified
  43599. */
  43600. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43601. /**
  43602. * Creates a new OculusTouchController from a gamepad
  43603. * @param vrGamepad the gamepad that the controller should be created from
  43604. */
  43605. constructor(vrGamepad: any);
  43606. /**
  43607. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43608. * @param scene scene in which to add meshes
  43609. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43610. */
  43611. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43612. /**
  43613. * Fired when the A button on this controller is modified
  43614. */
  43615. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43616. /**
  43617. * Fired when the B button on this controller is modified
  43618. */
  43619. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43620. /**
  43621. * Fired when the X button on this controller is modified
  43622. */
  43623. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43624. /**
  43625. * Fired when the Y button on this controller is modified
  43626. */
  43627. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43628. /**
  43629. * Called once for each button that changed state since the last frame
  43630. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43631. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43632. * 2) secondary trigger (same)
  43633. * 3) A (right) X (left), touch, pressed = value
  43634. * 4) B / Y
  43635. * 5) thumb rest
  43636. * @param buttonIdx Which button index changed
  43637. * @param state New state of the button
  43638. * @param changes Which properties on the state changed since last frame
  43639. */
  43640. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43641. }
  43642. }
  43643. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43644. import { Scene } from "babylonjs/scene";
  43645. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43646. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43647. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43648. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43649. import { Observable } from "babylonjs/Misc/observable";
  43650. /**
  43651. * Vive Controller
  43652. */
  43653. export class ViveController extends WebVRController {
  43654. /**
  43655. * Base Url for the controller model.
  43656. */
  43657. static MODEL_BASE_URL: string;
  43658. /**
  43659. * File name for the controller model.
  43660. */
  43661. static MODEL_FILENAME: string;
  43662. /**
  43663. * Creates a new ViveController from a gamepad
  43664. * @param vrGamepad the gamepad that the controller should be created from
  43665. */
  43666. constructor(vrGamepad: any);
  43667. /**
  43668. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43669. * @param scene scene in which to add meshes
  43670. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43671. */
  43672. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43673. /**
  43674. * Fired when the left button on this controller is modified
  43675. */
  43676. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43677. /**
  43678. * Fired when the right button on this controller is modified
  43679. */
  43680. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43681. /**
  43682. * Fired when the menu button on this controller is modified
  43683. */
  43684. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43685. /**
  43686. * Called once for each button that changed state since the last frame
  43687. * Vive mapping:
  43688. * 0: touchpad
  43689. * 1: trigger
  43690. * 2: left AND right buttons
  43691. * 3: menu button
  43692. * @param buttonIdx Which button index changed
  43693. * @param state New state of the button
  43694. * @param changes Which properties on the state changed since last frame
  43695. */
  43696. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43697. }
  43698. }
  43699. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  43700. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43701. /**
  43702. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  43703. */
  43704. export class WebXRControllerModelLoader {
  43705. /**
  43706. * Creates the WebXRControllerModelLoader
  43707. * @param input xr input that creates the controllers
  43708. */
  43709. constructor(input: WebXRInput);
  43710. }
  43711. }
  43712. declare module "babylonjs/Cameras/XR/index" {
  43713. export * from "babylonjs/Cameras/XR/webXRCamera";
  43714. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  43715. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43716. export * from "babylonjs/Cameras/XR/webXRInput";
  43717. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  43718. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  43719. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  43720. export * from "babylonjs/Cameras/XR/webXRController";
  43721. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43722. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  43723. }
  43724. declare module "babylonjs/Cameras/RigModes/index" {
  43725. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43726. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43727. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  43728. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  43729. }
  43730. declare module "babylonjs/Cameras/index" {
  43731. export * from "babylonjs/Cameras/Inputs/index";
  43732. export * from "babylonjs/Cameras/cameraInputsManager";
  43733. export * from "babylonjs/Cameras/camera";
  43734. export * from "babylonjs/Cameras/targetCamera";
  43735. export * from "babylonjs/Cameras/freeCamera";
  43736. export * from "babylonjs/Cameras/freeCameraInputsManager";
  43737. export * from "babylonjs/Cameras/touchCamera";
  43738. export * from "babylonjs/Cameras/arcRotateCamera";
  43739. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  43740. export * from "babylonjs/Cameras/deviceOrientationCamera";
  43741. export * from "babylonjs/Cameras/flyCamera";
  43742. export * from "babylonjs/Cameras/flyCameraInputsManager";
  43743. export * from "babylonjs/Cameras/followCamera";
  43744. export * from "babylonjs/Cameras/followCameraInputsManager";
  43745. export * from "babylonjs/Cameras/gamepadCamera";
  43746. export * from "babylonjs/Cameras/Stereoscopic/index";
  43747. export * from "babylonjs/Cameras/universalCamera";
  43748. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  43749. export * from "babylonjs/Cameras/VR/index";
  43750. export * from "babylonjs/Cameras/XR/index";
  43751. export * from "babylonjs/Cameras/RigModes/index";
  43752. }
  43753. declare module "babylonjs/Collisions/index" {
  43754. export * from "babylonjs/Collisions/collider";
  43755. export * from "babylonjs/Collisions/collisionCoordinator";
  43756. export * from "babylonjs/Collisions/pickingInfo";
  43757. export * from "babylonjs/Collisions/intersectionInfo";
  43758. export * from "babylonjs/Collisions/meshCollisionData";
  43759. }
  43760. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  43761. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  43762. import { Vector3 } from "babylonjs/Maths/math.vector";
  43763. import { Ray } from "babylonjs/Culling/ray";
  43764. import { Plane } from "babylonjs/Maths/math.plane";
  43765. /**
  43766. * Contains an array of blocks representing the octree
  43767. */
  43768. export interface IOctreeContainer<T> {
  43769. /**
  43770. * Blocks within the octree
  43771. */
  43772. blocks: Array<OctreeBlock<T>>;
  43773. }
  43774. /**
  43775. * Class used to store a cell in an octree
  43776. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43777. */
  43778. export class OctreeBlock<T> {
  43779. /**
  43780. * Gets the content of the current block
  43781. */
  43782. entries: T[];
  43783. /**
  43784. * Gets the list of block children
  43785. */
  43786. blocks: Array<OctreeBlock<T>>;
  43787. private _depth;
  43788. private _maxDepth;
  43789. private _capacity;
  43790. private _minPoint;
  43791. private _maxPoint;
  43792. private _boundingVectors;
  43793. private _creationFunc;
  43794. /**
  43795. * Creates a new block
  43796. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  43797. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  43798. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43799. * @param depth defines the current depth of this block in the octree
  43800. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  43801. * @param creationFunc defines a callback to call when an element is added to the block
  43802. */
  43803. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  43804. /**
  43805. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43806. */
  43807. readonly capacity: number;
  43808. /**
  43809. * Gets the minimum vector (in world space) of the block's bounding box
  43810. */
  43811. readonly minPoint: Vector3;
  43812. /**
  43813. * Gets the maximum vector (in world space) of the block's bounding box
  43814. */
  43815. readonly maxPoint: Vector3;
  43816. /**
  43817. * Add a new element to this block
  43818. * @param entry defines the element to add
  43819. */
  43820. addEntry(entry: T): void;
  43821. /**
  43822. * Remove an element from this block
  43823. * @param entry defines the element to remove
  43824. */
  43825. removeEntry(entry: T): void;
  43826. /**
  43827. * Add an array of elements to this block
  43828. * @param entries defines the array of elements to add
  43829. */
  43830. addEntries(entries: T[]): void;
  43831. /**
  43832. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  43833. * @param frustumPlanes defines the frustum planes to test
  43834. * @param selection defines the array to store current content if selection is positive
  43835. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43836. */
  43837. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43838. /**
  43839. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  43840. * @param sphereCenter defines the bounding sphere center
  43841. * @param sphereRadius defines the bounding sphere radius
  43842. * @param selection defines the array to store current content if selection is positive
  43843. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43844. */
  43845. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43846. /**
  43847. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  43848. * @param ray defines the ray to test with
  43849. * @param selection defines the array to store current content if selection is positive
  43850. */
  43851. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  43852. /**
  43853. * Subdivide the content into child blocks (this block will then be empty)
  43854. */
  43855. createInnerBlocks(): void;
  43856. /**
  43857. * @hidden
  43858. */
  43859. 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;
  43860. }
  43861. }
  43862. declare module "babylonjs/Culling/Octrees/octree" {
  43863. import { SmartArray } from "babylonjs/Misc/smartArray";
  43864. import { Vector3 } from "babylonjs/Maths/math.vector";
  43865. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43866. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43867. import { Ray } from "babylonjs/Culling/ray";
  43868. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  43869. import { Plane } from "babylonjs/Maths/math.plane";
  43870. /**
  43871. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  43872. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43873. */
  43874. export class Octree<T> {
  43875. /** 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.) */
  43876. maxDepth: number;
  43877. /**
  43878. * Blocks within the octree containing objects
  43879. */
  43880. blocks: Array<OctreeBlock<T>>;
  43881. /**
  43882. * Content stored in the octree
  43883. */
  43884. dynamicContent: T[];
  43885. private _maxBlockCapacity;
  43886. private _selectionContent;
  43887. private _creationFunc;
  43888. /**
  43889. * Creates a octree
  43890. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43891. * @param creationFunc function to be used to instatiate the octree
  43892. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  43893. * @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.)
  43894. */
  43895. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  43896. /** 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.) */
  43897. maxDepth?: number);
  43898. /**
  43899. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  43900. * @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);
  43901. * @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);
  43902. * @param entries meshes to be added to the octree blocks
  43903. */
  43904. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  43905. /**
  43906. * Adds a mesh to the octree
  43907. * @param entry Mesh to add to the octree
  43908. */
  43909. addMesh(entry: T): void;
  43910. /**
  43911. * Remove an element from the octree
  43912. * @param entry defines the element to remove
  43913. */
  43914. removeMesh(entry: T): void;
  43915. /**
  43916. * Selects an array of meshes within the frustum
  43917. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  43918. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  43919. * @returns array of meshes within the frustum
  43920. */
  43921. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  43922. /**
  43923. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  43924. * @param sphereCenter defines the bounding sphere center
  43925. * @param sphereRadius defines the bounding sphere radius
  43926. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43927. * @returns an array of objects that intersect the sphere
  43928. */
  43929. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  43930. /**
  43931. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  43932. * @param ray defines the ray to test with
  43933. * @returns array of intersected objects
  43934. */
  43935. intersectsRay(ray: Ray): SmartArray<T>;
  43936. /**
  43937. * Adds a mesh into the octree block if it intersects the block
  43938. */
  43939. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  43940. /**
  43941. * Adds a submesh into the octree block if it intersects the block
  43942. */
  43943. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  43944. }
  43945. }
  43946. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  43947. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  43948. import { Scene } from "babylonjs/scene";
  43949. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43950. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43951. import { Ray } from "babylonjs/Culling/ray";
  43952. import { Octree } from "babylonjs/Culling/Octrees/octree";
  43953. import { Collider } from "babylonjs/Collisions/collider";
  43954. module "babylonjs/scene" {
  43955. interface Scene {
  43956. /**
  43957. * @hidden
  43958. * Backing Filed
  43959. */
  43960. _selectionOctree: Octree<AbstractMesh>;
  43961. /**
  43962. * Gets the octree used to boost mesh selection (picking)
  43963. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43964. */
  43965. selectionOctree: Octree<AbstractMesh>;
  43966. /**
  43967. * Creates or updates the octree used to boost selection (picking)
  43968. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43969. * @param maxCapacity defines the maximum capacity per leaf
  43970. * @param maxDepth defines the maximum depth of the octree
  43971. * @returns an octree of AbstractMesh
  43972. */
  43973. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  43974. }
  43975. }
  43976. module "babylonjs/Meshes/abstractMesh" {
  43977. interface AbstractMesh {
  43978. /**
  43979. * @hidden
  43980. * Backing Field
  43981. */
  43982. _submeshesOctree: Octree<SubMesh>;
  43983. /**
  43984. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  43985. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  43986. * @param maxCapacity defines the maximum size of each block (64 by default)
  43987. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  43988. * @returns the new octree
  43989. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  43990. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43991. */
  43992. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  43993. }
  43994. }
  43995. /**
  43996. * Defines the octree scene component responsible to manage any octrees
  43997. * in a given scene.
  43998. */
  43999. export class OctreeSceneComponent {
  44000. /**
  44001. * The component name help to identify the component in the list of scene components.
  44002. */
  44003. readonly name: string;
  44004. /**
  44005. * The scene the component belongs to.
  44006. */
  44007. scene: Scene;
  44008. /**
  44009. * Indicates if the meshes have been checked to make sure they are isEnabled()
  44010. */
  44011. readonly checksIsEnabled: boolean;
  44012. /**
  44013. * Creates a new instance of the component for the given scene
  44014. * @param scene Defines the scene to register the component in
  44015. */
  44016. constructor(scene: Scene);
  44017. /**
  44018. * Registers the component in a given scene
  44019. */
  44020. register(): void;
  44021. /**
  44022. * Return the list of active meshes
  44023. * @returns the list of active meshes
  44024. */
  44025. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44026. /**
  44027. * Return the list of active sub meshes
  44028. * @param mesh The mesh to get the candidates sub meshes from
  44029. * @returns the list of active sub meshes
  44030. */
  44031. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44032. private _tempRay;
  44033. /**
  44034. * Return the list of sub meshes intersecting with a given local ray
  44035. * @param mesh defines the mesh to find the submesh for
  44036. * @param localRay defines the ray in local space
  44037. * @returns the list of intersecting sub meshes
  44038. */
  44039. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  44040. /**
  44041. * Return the list of sub meshes colliding with a collider
  44042. * @param mesh defines the mesh to find the submesh for
  44043. * @param collider defines the collider to evaluate the collision against
  44044. * @returns the list of colliding sub meshes
  44045. */
  44046. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  44047. /**
  44048. * Rebuilds the elements related to this component in case of
  44049. * context lost for instance.
  44050. */
  44051. rebuild(): void;
  44052. /**
  44053. * Disposes the component and the associated ressources.
  44054. */
  44055. dispose(): void;
  44056. }
  44057. }
  44058. declare module "babylonjs/Culling/Octrees/index" {
  44059. export * from "babylonjs/Culling/Octrees/octree";
  44060. export * from "babylonjs/Culling/Octrees/octreeBlock";
  44061. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  44062. }
  44063. declare module "babylonjs/Culling/index" {
  44064. export * from "babylonjs/Culling/boundingBox";
  44065. export * from "babylonjs/Culling/boundingInfo";
  44066. export * from "babylonjs/Culling/boundingSphere";
  44067. export * from "babylonjs/Culling/Octrees/index";
  44068. export * from "babylonjs/Culling/ray";
  44069. }
  44070. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  44071. import { IDisposable, Scene } from "babylonjs/scene";
  44072. import { Nullable } from "babylonjs/types";
  44073. import { Observable } from "babylonjs/Misc/observable";
  44074. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44075. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  44076. import { Camera } from "babylonjs/Cameras/camera";
  44077. /**
  44078. * Renders a layer on top of an existing scene
  44079. */
  44080. export class UtilityLayerRenderer implements IDisposable {
  44081. /** the original scene that will be rendered on top of */
  44082. originalScene: Scene;
  44083. private _pointerCaptures;
  44084. private _lastPointerEvents;
  44085. private static _DefaultUtilityLayer;
  44086. private static _DefaultKeepDepthUtilityLayer;
  44087. private _sharedGizmoLight;
  44088. private _renderCamera;
  44089. /**
  44090. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44091. * @returns the camera that is used when rendering the utility layer
  44092. */
  44093. getRenderCamera(): Nullable<Camera>;
  44094. /**
  44095. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44096. * @param cam the camera that should be used when rendering the utility layer
  44097. */
  44098. setRenderCamera(cam: Nullable<Camera>): void;
  44099. /**
  44100. * @hidden
  44101. * Light which used by gizmos to get light shading
  44102. */
  44103. _getSharedGizmoLight(): HemisphericLight;
  44104. /**
  44105. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44106. */
  44107. pickUtilitySceneFirst: boolean;
  44108. /**
  44109. * 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)
  44110. */
  44111. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  44112. /**
  44113. * 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)
  44114. */
  44115. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  44116. /**
  44117. * The scene that is rendered on top of the original scene
  44118. */
  44119. utilityLayerScene: Scene;
  44120. /**
  44121. * If the utility layer should automatically be rendered on top of existing scene
  44122. */
  44123. shouldRender: boolean;
  44124. /**
  44125. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44126. */
  44127. onlyCheckPointerDownEvents: boolean;
  44128. /**
  44129. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44130. */
  44131. processAllEvents: boolean;
  44132. /**
  44133. * Observable raised when the pointer move from the utility layer scene to the main scene
  44134. */
  44135. onPointerOutObservable: Observable<number>;
  44136. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44137. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44138. private _afterRenderObserver;
  44139. private _sceneDisposeObserver;
  44140. private _originalPointerObserver;
  44141. /**
  44142. * Instantiates a UtilityLayerRenderer
  44143. * @param originalScene the original scene that will be rendered on top of
  44144. * @param handleEvents boolean indicating if the utility layer should handle events
  44145. */
  44146. constructor(
  44147. /** the original scene that will be rendered on top of */
  44148. originalScene: Scene, handleEvents?: boolean);
  44149. private _notifyObservers;
  44150. /**
  44151. * Renders the utility layers scene on top of the original scene
  44152. */
  44153. render(): void;
  44154. /**
  44155. * Disposes of the renderer
  44156. */
  44157. dispose(): void;
  44158. private _updateCamera;
  44159. }
  44160. }
  44161. declare module "babylonjs/Gizmos/gizmo" {
  44162. import { Nullable } from "babylonjs/types";
  44163. import { IDisposable } from "babylonjs/scene";
  44164. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44165. import { Mesh } from "babylonjs/Meshes/mesh";
  44166. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44167. /**
  44168. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  44169. */
  44170. export class Gizmo implements IDisposable {
  44171. /** The utility layer the gizmo will be added to */
  44172. gizmoLayer: UtilityLayerRenderer;
  44173. /**
  44174. * The root mesh of the gizmo
  44175. */
  44176. _rootMesh: Mesh;
  44177. private _attachedMesh;
  44178. /**
  44179. * Ratio for the scale of the gizmo (Default: 1)
  44180. */
  44181. scaleRatio: number;
  44182. /**
  44183. * If a custom mesh has been set (Default: false)
  44184. */
  44185. protected _customMeshSet: boolean;
  44186. /**
  44187. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  44188. * * When set, interactions will be enabled
  44189. */
  44190. attachedMesh: Nullable<AbstractMesh>;
  44191. /**
  44192. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44193. * @param mesh The mesh to replace the default mesh of the gizmo
  44194. */
  44195. setCustomMesh(mesh: Mesh): void;
  44196. /**
  44197. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  44198. */
  44199. updateGizmoRotationToMatchAttachedMesh: boolean;
  44200. /**
  44201. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  44202. */
  44203. updateGizmoPositionToMatchAttachedMesh: boolean;
  44204. /**
  44205. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  44206. */
  44207. updateScale: boolean;
  44208. protected _interactionsEnabled: boolean;
  44209. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44210. private _beforeRenderObserver;
  44211. private _tempVector;
  44212. /**
  44213. * Creates a gizmo
  44214. * @param gizmoLayer The utility layer the gizmo will be added to
  44215. */
  44216. constructor(
  44217. /** The utility layer the gizmo will be added to */
  44218. gizmoLayer?: UtilityLayerRenderer);
  44219. /**
  44220. * Updates the gizmo to match the attached mesh's position/rotation
  44221. */
  44222. protected _update(): void;
  44223. /**
  44224. * Disposes of the gizmo
  44225. */
  44226. dispose(): void;
  44227. }
  44228. }
  44229. declare module "babylonjs/Gizmos/planeDragGizmo" {
  44230. import { Observable } from "babylonjs/Misc/observable";
  44231. import { Nullable } from "babylonjs/types";
  44232. import { Vector3 } from "babylonjs/Maths/math.vector";
  44233. import { Color3 } from "babylonjs/Maths/math.color";
  44234. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44235. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44236. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44237. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44238. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44239. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44240. import { Scene } from "babylonjs/scene";
  44241. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44242. /**
  44243. * Single plane drag gizmo
  44244. */
  44245. export class PlaneDragGizmo extends Gizmo {
  44246. /**
  44247. * Drag behavior responsible for the gizmos dragging interactions
  44248. */
  44249. dragBehavior: PointerDragBehavior;
  44250. private _pointerObserver;
  44251. /**
  44252. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44253. */
  44254. snapDistance: number;
  44255. /**
  44256. * Event that fires each time the gizmo snaps to a new location.
  44257. * * snapDistance is the the change in distance
  44258. */
  44259. onSnapObservable: Observable<{
  44260. snapDistance: number;
  44261. }>;
  44262. private _plane;
  44263. private _coloredMaterial;
  44264. private _hoverMaterial;
  44265. private _isEnabled;
  44266. private _parent;
  44267. /** @hidden */
  44268. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  44269. /** @hidden */
  44270. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44271. /**
  44272. * Creates a PlaneDragGizmo
  44273. * @param gizmoLayer The utility layer the gizmo will be added to
  44274. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  44275. * @param color The color of the gizmo
  44276. */
  44277. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44278. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44279. /**
  44280. * If the gizmo is enabled
  44281. */
  44282. isEnabled: boolean;
  44283. /**
  44284. * Disposes of the gizmo
  44285. */
  44286. dispose(): void;
  44287. }
  44288. }
  44289. declare module "babylonjs/Gizmos/positionGizmo" {
  44290. import { Observable } from "babylonjs/Misc/observable";
  44291. import { Nullable } from "babylonjs/types";
  44292. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44293. import { Mesh } from "babylonjs/Meshes/mesh";
  44294. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44295. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44296. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  44297. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44298. /**
  44299. * Gizmo that enables dragging a mesh along 3 axis
  44300. */
  44301. export class PositionGizmo extends Gizmo {
  44302. /**
  44303. * Internal gizmo used for interactions on the x axis
  44304. */
  44305. xGizmo: AxisDragGizmo;
  44306. /**
  44307. * Internal gizmo used for interactions on the y axis
  44308. */
  44309. yGizmo: AxisDragGizmo;
  44310. /**
  44311. * Internal gizmo used for interactions on the z axis
  44312. */
  44313. zGizmo: AxisDragGizmo;
  44314. /**
  44315. * Internal gizmo used for interactions on the yz plane
  44316. */
  44317. xPlaneGizmo: PlaneDragGizmo;
  44318. /**
  44319. * Internal gizmo used for interactions on the xz plane
  44320. */
  44321. yPlaneGizmo: PlaneDragGizmo;
  44322. /**
  44323. * Internal gizmo used for interactions on the xy plane
  44324. */
  44325. zPlaneGizmo: PlaneDragGizmo;
  44326. /**
  44327. * private variables
  44328. */
  44329. private _meshAttached;
  44330. private _updateGizmoRotationToMatchAttachedMesh;
  44331. private _snapDistance;
  44332. private _scaleRatio;
  44333. /** Fires an event when any of it's sub gizmos are dragged */
  44334. onDragStartObservable: Observable<unknown>;
  44335. /** Fires an event when any of it's sub gizmos are released from dragging */
  44336. onDragEndObservable: Observable<unknown>;
  44337. /**
  44338. * If set to true, planar drag is enabled
  44339. */
  44340. private _planarGizmoEnabled;
  44341. attachedMesh: Nullable<AbstractMesh>;
  44342. /**
  44343. * Creates a PositionGizmo
  44344. * @param gizmoLayer The utility layer the gizmo will be added to
  44345. */
  44346. constructor(gizmoLayer?: UtilityLayerRenderer);
  44347. /**
  44348. * If the planar drag gizmo is enabled
  44349. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  44350. */
  44351. planarGizmoEnabled: boolean;
  44352. updateGizmoRotationToMatchAttachedMesh: boolean;
  44353. /**
  44354. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44355. */
  44356. snapDistance: number;
  44357. /**
  44358. * Ratio for the scale of the gizmo (Default: 1)
  44359. */
  44360. scaleRatio: number;
  44361. /**
  44362. * Disposes of the gizmo
  44363. */
  44364. dispose(): void;
  44365. /**
  44366. * CustomMeshes are not supported by this gizmo
  44367. * @param mesh The mesh to replace the default mesh of the gizmo
  44368. */
  44369. setCustomMesh(mesh: Mesh): void;
  44370. }
  44371. }
  44372. declare module "babylonjs/Gizmos/axisDragGizmo" {
  44373. import { Observable } from "babylonjs/Misc/observable";
  44374. import { Nullable } from "babylonjs/types";
  44375. import { Vector3 } from "babylonjs/Maths/math.vector";
  44376. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44377. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44378. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44379. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44380. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44381. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44382. import { Scene } from "babylonjs/scene";
  44383. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44384. import { Color3 } from "babylonjs/Maths/math.color";
  44385. /**
  44386. * Single axis drag gizmo
  44387. */
  44388. export class AxisDragGizmo extends Gizmo {
  44389. /**
  44390. * Drag behavior responsible for the gizmos dragging interactions
  44391. */
  44392. dragBehavior: PointerDragBehavior;
  44393. private _pointerObserver;
  44394. /**
  44395. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44396. */
  44397. snapDistance: number;
  44398. /**
  44399. * Event that fires each time the gizmo snaps to a new location.
  44400. * * snapDistance is the the change in distance
  44401. */
  44402. onSnapObservable: Observable<{
  44403. snapDistance: number;
  44404. }>;
  44405. private _isEnabled;
  44406. private _parent;
  44407. private _arrow;
  44408. private _coloredMaterial;
  44409. private _hoverMaterial;
  44410. /** @hidden */
  44411. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  44412. /** @hidden */
  44413. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44414. /**
  44415. * Creates an AxisDragGizmo
  44416. * @param gizmoLayer The utility layer the gizmo will be added to
  44417. * @param dragAxis The axis which the gizmo will be able to drag on
  44418. * @param color The color of the gizmo
  44419. */
  44420. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44421. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44422. /**
  44423. * If the gizmo is enabled
  44424. */
  44425. isEnabled: boolean;
  44426. /**
  44427. * Disposes of the gizmo
  44428. */
  44429. dispose(): void;
  44430. }
  44431. }
  44432. declare module "babylonjs/Debug/axesViewer" {
  44433. import { Vector3 } from "babylonjs/Maths/math.vector";
  44434. import { Nullable } from "babylonjs/types";
  44435. import { Scene } from "babylonjs/scene";
  44436. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44437. /**
  44438. * The Axes viewer will show 3 axes in a specific point in space
  44439. */
  44440. export class AxesViewer {
  44441. private _xAxis;
  44442. private _yAxis;
  44443. private _zAxis;
  44444. private _scaleLinesFactor;
  44445. private _instanced;
  44446. /**
  44447. * Gets the hosting scene
  44448. */
  44449. scene: Scene;
  44450. /**
  44451. * Gets or sets a number used to scale line length
  44452. */
  44453. scaleLines: number;
  44454. /** Gets the node hierarchy used to render x-axis */
  44455. readonly xAxis: TransformNode;
  44456. /** Gets the node hierarchy used to render y-axis */
  44457. readonly yAxis: TransformNode;
  44458. /** Gets the node hierarchy used to render z-axis */
  44459. readonly zAxis: TransformNode;
  44460. /**
  44461. * Creates a new AxesViewer
  44462. * @param scene defines the hosting scene
  44463. * @param scaleLines defines a number used to scale line length (1 by default)
  44464. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  44465. * @param xAxis defines the node hierarchy used to render the x-axis
  44466. * @param yAxis defines the node hierarchy used to render the y-axis
  44467. * @param zAxis defines the node hierarchy used to render the z-axis
  44468. */
  44469. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  44470. /**
  44471. * Force the viewer to update
  44472. * @param position defines the position of the viewer
  44473. * @param xaxis defines the x axis of the viewer
  44474. * @param yaxis defines the y axis of the viewer
  44475. * @param zaxis defines the z axis of the viewer
  44476. */
  44477. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  44478. /**
  44479. * Creates an instance of this axes viewer.
  44480. * @returns a new axes viewer with instanced meshes
  44481. */
  44482. createInstance(): AxesViewer;
  44483. /** Releases resources */
  44484. dispose(): void;
  44485. private static _SetRenderingGroupId;
  44486. }
  44487. }
  44488. declare module "babylonjs/Debug/boneAxesViewer" {
  44489. import { Nullable } from "babylonjs/types";
  44490. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  44491. import { Vector3 } from "babylonjs/Maths/math.vector";
  44492. import { Mesh } from "babylonjs/Meshes/mesh";
  44493. import { Bone } from "babylonjs/Bones/bone";
  44494. import { Scene } from "babylonjs/scene";
  44495. /**
  44496. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  44497. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  44498. */
  44499. export class BoneAxesViewer extends AxesViewer {
  44500. /**
  44501. * Gets or sets the target mesh where to display the axes viewer
  44502. */
  44503. mesh: Nullable<Mesh>;
  44504. /**
  44505. * Gets or sets the target bone where to display the axes viewer
  44506. */
  44507. bone: Nullable<Bone>;
  44508. /** Gets current position */
  44509. pos: Vector3;
  44510. /** Gets direction of X axis */
  44511. xaxis: Vector3;
  44512. /** Gets direction of Y axis */
  44513. yaxis: Vector3;
  44514. /** Gets direction of Z axis */
  44515. zaxis: Vector3;
  44516. /**
  44517. * Creates a new BoneAxesViewer
  44518. * @param scene defines the hosting scene
  44519. * @param bone defines the target bone
  44520. * @param mesh defines the target mesh
  44521. * @param scaleLines defines a scaling factor for line length (1 by default)
  44522. */
  44523. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  44524. /**
  44525. * Force the viewer to update
  44526. */
  44527. update(): void;
  44528. /** Releases resources */
  44529. dispose(): void;
  44530. }
  44531. }
  44532. declare module "babylonjs/Debug/debugLayer" {
  44533. import { Scene } from "babylonjs/scene";
  44534. /**
  44535. * Interface used to define scene explorer extensibility option
  44536. */
  44537. export interface IExplorerExtensibilityOption {
  44538. /**
  44539. * Define the option label
  44540. */
  44541. label: string;
  44542. /**
  44543. * Defines the action to execute on click
  44544. */
  44545. action: (entity: any) => void;
  44546. }
  44547. /**
  44548. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  44549. */
  44550. export interface IExplorerExtensibilityGroup {
  44551. /**
  44552. * Defines a predicate to test if a given type mut be extended
  44553. */
  44554. predicate: (entity: any) => boolean;
  44555. /**
  44556. * Gets the list of options added to a type
  44557. */
  44558. entries: IExplorerExtensibilityOption[];
  44559. }
  44560. /**
  44561. * Interface used to define the options to use to create the Inspector
  44562. */
  44563. export interface IInspectorOptions {
  44564. /**
  44565. * Display in overlay mode (default: false)
  44566. */
  44567. overlay?: boolean;
  44568. /**
  44569. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  44570. */
  44571. globalRoot?: HTMLElement;
  44572. /**
  44573. * Display the Scene explorer
  44574. */
  44575. showExplorer?: boolean;
  44576. /**
  44577. * Display the property inspector
  44578. */
  44579. showInspector?: boolean;
  44580. /**
  44581. * Display in embed mode (both panes on the right)
  44582. */
  44583. embedMode?: boolean;
  44584. /**
  44585. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  44586. */
  44587. handleResize?: boolean;
  44588. /**
  44589. * Allow the panes to popup (default: true)
  44590. */
  44591. enablePopup?: boolean;
  44592. /**
  44593. * Allow the panes to be closed by users (default: true)
  44594. */
  44595. enableClose?: boolean;
  44596. /**
  44597. * Optional list of extensibility entries
  44598. */
  44599. explorerExtensibility?: IExplorerExtensibilityGroup[];
  44600. /**
  44601. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  44602. */
  44603. inspectorURL?: string;
  44604. }
  44605. module "babylonjs/scene" {
  44606. interface Scene {
  44607. /**
  44608. * @hidden
  44609. * Backing field
  44610. */
  44611. _debugLayer: DebugLayer;
  44612. /**
  44613. * Gets the debug layer (aka Inspector) associated with the scene
  44614. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44615. */
  44616. debugLayer: DebugLayer;
  44617. }
  44618. }
  44619. /**
  44620. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44621. * what is happening in your scene
  44622. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44623. */
  44624. export class DebugLayer {
  44625. /**
  44626. * Define the url to get the inspector script from.
  44627. * By default it uses the babylonjs CDN.
  44628. * @ignoreNaming
  44629. */
  44630. static InspectorURL: string;
  44631. private _scene;
  44632. private BJSINSPECTOR;
  44633. private _onPropertyChangedObservable?;
  44634. /**
  44635. * Observable triggered when a property is changed through the inspector.
  44636. */
  44637. readonly onPropertyChangedObservable: any;
  44638. /**
  44639. * Instantiates a new debug layer.
  44640. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44641. * what is happening in your scene
  44642. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44643. * @param scene Defines the scene to inspect
  44644. */
  44645. constructor(scene: Scene);
  44646. /** Creates the inspector window. */
  44647. private _createInspector;
  44648. /**
  44649. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  44650. * @param entity defines the entity to select
  44651. * @param lineContainerTitle defines the specific block to highlight
  44652. */
  44653. select(entity: any, lineContainerTitle?: string): void;
  44654. /** Get the inspector from bundle or global */
  44655. private _getGlobalInspector;
  44656. /**
  44657. * Get if the inspector is visible or not.
  44658. * @returns true if visible otherwise, false
  44659. */
  44660. isVisible(): boolean;
  44661. /**
  44662. * Hide the inspector and close its window.
  44663. */
  44664. hide(): void;
  44665. /**
  44666. * Launch the debugLayer.
  44667. * @param config Define the configuration of the inspector
  44668. * @return a promise fulfilled when the debug layer is visible
  44669. */
  44670. show(config?: IInspectorOptions): Promise<DebugLayer>;
  44671. }
  44672. }
  44673. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  44674. import { Nullable } from "babylonjs/types";
  44675. import { Scene } from "babylonjs/scene";
  44676. import { Vector4 } from "babylonjs/Maths/math.vector";
  44677. import { Color4 } from "babylonjs/Maths/math.color";
  44678. import { Mesh } from "babylonjs/Meshes/mesh";
  44679. /**
  44680. * Class containing static functions to help procedurally build meshes
  44681. */
  44682. export class BoxBuilder {
  44683. /**
  44684. * Creates a box mesh
  44685. * * The parameter `size` sets the size (float) of each box side (default 1)
  44686. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  44687. * * 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)
  44688. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  44689. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44690. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44691. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44692. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  44693. * @param name defines the name of the mesh
  44694. * @param options defines the options used to create the mesh
  44695. * @param scene defines the hosting scene
  44696. * @returns the box mesh
  44697. */
  44698. static CreateBox(name: string, options: {
  44699. size?: number;
  44700. width?: number;
  44701. height?: number;
  44702. depth?: number;
  44703. faceUV?: Vector4[];
  44704. faceColors?: Color4[];
  44705. sideOrientation?: number;
  44706. frontUVs?: Vector4;
  44707. backUVs?: Vector4;
  44708. wrap?: boolean;
  44709. topBaseAt?: number;
  44710. bottomBaseAt?: number;
  44711. updatable?: boolean;
  44712. }, scene?: Nullable<Scene>): Mesh;
  44713. }
  44714. }
  44715. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  44716. import { Vector4 } from "babylonjs/Maths/math.vector";
  44717. import { Mesh } from "babylonjs/Meshes/mesh";
  44718. import { Scene } from "babylonjs/scene";
  44719. import { Nullable } from "babylonjs/types";
  44720. /**
  44721. * Class containing static functions to help procedurally build meshes
  44722. */
  44723. export class SphereBuilder {
  44724. /**
  44725. * Creates a sphere mesh
  44726. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44727. * * 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`)
  44728. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44729. * * 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
  44730. * * 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)
  44731. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44732. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44733. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44734. * @param name defines the name of the mesh
  44735. * @param options defines the options used to create the mesh
  44736. * @param scene defines the hosting scene
  44737. * @returns the sphere mesh
  44738. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44739. */
  44740. static CreateSphere(name: string, options: {
  44741. segments?: number;
  44742. diameter?: number;
  44743. diameterX?: number;
  44744. diameterY?: number;
  44745. diameterZ?: number;
  44746. arc?: number;
  44747. slice?: number;
  44748. sideOrientation?: number;
  44749. frontUVs?: Vector4;
  44750. backUVs?: Vector4;
  44751. updatable?: boolean;
  44752. }, scene?: Nullable<Scene>): Mesh;
  44753. }
  44754. }
  44755. declare module "babylonjs/Debug/physicsViewer" {
  44756. import { Nullable } from "babylonjs/types";
  44757. import { Scene } from "babylonjs/scene";
  44758. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44759. import { Mesh } from "babylonjs/Meshes/mesh";
  44760. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  44761. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  44762. /**
  44763. * Used to show the physics impostor around the specific mesh
  44764. */
  44765. export class PhysicsViewer {
  44766. /** @hidden */
  44767. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  44768. /** @hidden */
  44769. protected _meshes: Array<Nullable<AbstractMesh>>;
  44770. /** @hidden */
  44771. protected _scene: Nullable<Scene>;
  44772. /** @hidden */
  44773. protected _numMeshes: number;
  44774. /** @hidden */
  44775. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  44776. private _renderFunction;
  44777. private _utilityLayer;
  44778. private _debugBoxMesh;
  44779. private _debugSphereMesh;
  44780. private _debugCylinderMesh;
  44781. private _debugMaterial;
  44782. private _debugMeshMeshes;
  44783. /**
  44784. * Creates a new PhysicsViewer
  44785. * @param scene defines the hosting scene
  44786. */
  44787. constructor(scene: Scene);
  44788. /** @hidden */
  44789. protected _updateDebugMeshes(): void;
  44790. /**
  44791. * Renders a specified physic impostor
  44792. * @param impostor defines the impostor to render
  44793. * @param targetMesh defines the mesh represented by the impostor
  44794. * @returns the new debug mesh used to render the impostor
  44795. */
  44796. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  44797. /**
  44798. * Hides a specified physic impostor
  44799. * @param impostor defines the impostor to hide
  44800. */
  44801. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  44802. private _getDebugMaterial;
  44803. private _getDebugBoxMesh;
  44804. private _getDebugSphereMesh;
  44805. private _getDebugCylinderMesh;
  44806. private _getDebugMeshMesh;
  44807. private _getDebugMesh;
  44808. /** Releases all resources */
  44809. dispose(): void;
  44810. }
  44811. }
  44812. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  44813. import { Vector3 } from "babylonjs/Maths/math.vector";
  44814. import { Color4 } from "babylonjs/Maths/math.color";
  44815. import { Nullable } from "babylonjs/types";
  44816. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  44817. import { Scene } from "babylonjs/scene";
  44818. /**
  44819. * Class containing static functions to help procedurally build meshes
  44820. */
  44821. export class LinesBuilder {
  44822. /**
  44823. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  44824. * * 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
  44825. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  44826. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  44827. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  44828. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  44829. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44830. * * 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
  44831. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  44832. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44833. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  44834. * @param name defines the name of the new line system
  44835. * @param options defines the options used to create the line system
  44836. * @param scene defines the hosting scene
  44837. * @returns a new line system mesh
  44838. */
  44839. static CreateLineSystem(name: string, options: {
  44840. lines: Vector3[][];
  44841. updatable?: boolean;
  44842. instance?: Nullable<LinesMesh>;
  44843. colors?: Nullable<Color4[][]>;
  44844. useVertexAlpha?: boolean;
  44845. }, scene: Nullable<Scene>): LinesMesh;
  44846. /**
  44847. * Creates a line mesh
  44848. * 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
  44849. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44850. * * The parameter `points` is an array successive Vector3
  44851. * * 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
  44852. * * The optional parameter `colors` is an array of successive Color4, one per line point
  44853. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  44854. * * When updating an instance, remember that only point positions can change, not the number of points
  44855. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44856. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  44857. * @param name defines the name of the new line system
  44858. * @param options defines the options used to create the line system
  44859. * @param scene defines the hosting scene
  44860. * @returns a new line mesh
  44861. */
  44862. static CreateLines(name: string, options: {
  44863. points: Vector3[];
  44864. updatable?: boolean;
  44865. instance?: Nullable<LinesMesh>;
  44866. colors?: Color4[];
  44867. useVertexAlpha?: boolean;
  44868. }, scene?: Nullable<Scene>): LinesMesh;
  44869. /**
  44870. * Creates a dashed line mesh
  44871. * * 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
  44872. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44873. * * The parameter `points` is an array successive Vector3
  44874. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  44875. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  44876. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  44877. * * 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
  44878. * * When updating an instance, remember that only point positions can change, not the number of points
  44879. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44880. * @param name defines the name of the mesh
  44881. * @param options defines the options used to create the mesh
  44882. * @param scene defines the hosting scene
  44883. * @returns the dashed line mesh
  44884. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  44885. */
  44886. static CreateDashedLines(name: string, options: {
  44887. points: Vector3[];
  44888. dashSize?: number;
  44889. gapSize?: number;
  44890. dashNb?: number;
  44891. updatable?: boolean;
  44892. instance?: LinesMesh;
  44893. }, scene?: Nullable<Scene>): LinesMesh;
  44894. }
  44895. }
  44896. declare module "babylonjs/Debug/rayHelper" {
  44897. import { Nullable } from "babylonjs/types";
  44898. import { Ray } from "babylonjs/Culling/ray";
  44899. import { Vector3 } from "babylonjs/Maths/math.vector";
  44900. import { Color3 } from "babylonjs/Maths/math.color";
  44901. import { Scene } from "babylonjs/scene";
  44902. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44903. import "babylonjs/Meshes/Builders/linesBuilder";
  44904. /**
  44905. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44906. * in order to better appreciate the issue one might have.
  44907. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44908. */
  44909. export class RayHelper {
  44910. /**
  44911. * Defines the ray we are currently tryin to visualize.
  44912. */
  44913. ray: Nullable<Ray>;
  44914. private _renderPoints;
  44915. private _renderLine;
  44916. private _renderFunction;
  44917. private _scene;
  44918. private _updateToMeshFunction;
  44919. private _attachedToMesh;
  44920. private _meshSpaceDirection;
  44921. private _meshSpaceOrigin;
  44922. /**
  44923. * Helper function to create a colored helper in a scene in one line.
  44924. * @param ray Defines the ray we are currently tryin to visualize
  44925. * @param scene Defines the scene the ray is used in
  44926. * @param color Defines the color we want to see the ray in
  44927. * @returns The newly created ray helper.
  44928. */
  44929. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  44930. /**
  44931. * Instantiate a new ray helper.
  44932. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44933. * in order to better appreciate the issue one might have.
  44934. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44935. * @param ray Defines the ray we are currently tryin to visualize
  44936. */
  44937. constructor(ray: Ray);
  44938. /**
  44939. * Shows the ray we are willing to debug.
  44940. * @param scene Defines the scene the ray needs to be rendered in
  44941. * @param color Defines the color the ray needs to be rendered in
  44942. */
  44943. show(scene: Scene, color?: Color3): void;
  44944. /**
  44945. * Hides the ray we are debugging.
  44946. */
  44947. hide(): void;
  44948. private _render;
  44949. /**
  44950. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  44951. * @param mesh Defines the mesh we want the helper attached to
  44952. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  44953. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  44954. * @param length Defines the length of the ray
  44955. */
  44956. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  44957. /**
  44958. * Detach the ray helper from the mesh it has previously been attached to.
  44959. */
  44960. detachFromMesh(): void;
  44961. private _updateToMesh;
  44962. /**
  44963. * Dispose the helper and release its associated resources.
  44964. */
  44965. dispose(): void;
  44966. }
  44967. }
  44968. declare module "babylonjs/Debug/skeletonViewer" {
  44969. import { Color3 } from "babylonjs/Maths/math.color";
  44970. import { Scene } from "babylonjs/scene";
  44971. import { Nullable } from "babylonjs/types";
  44972. import { Skeleton } from "babylonjs/Bones/skeleton";
  44973. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44974. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  44975. /**
  44976. * Class used to render a debug view of a given skeleton
  44977. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  44978. */
  44979. export class SkeletonViewer {
  44980. /** defines the skeleton to render */
  44981. skeleton: Skeleton;
  44982. /** defines the mesh attached to the skeleton */
  44983. mesh: AbstractMesh;
  44984. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  44985. autoUpdateBonesMatrices: boolean;
  44986. /** defines the rendering group id to use with the viewer */
  44987. renderingGroupId: number;
  44988. /** Gets or sets the color used to render the skeleton */
  44989. color: Color3;
  44990. private _scene;
  44991. private _debugLines;
  44992. private _debugMesh;
  44993. private _isEnabled;
  44994. private _renderFunction;
  44995. private _utilityLayer;
  44996. /**
  44997. * Returns the mesh used to render the bones
  44998. */
  44999. readonly debugMesh: Nullable<LinesMesh>;
  45000. /**
  45001. * Creates a new SkeletonViewer
  45002. * @param skeleton defines the skeleton to render
  45003. * @param mesh defines the mesh attached to the skeleton
  45004. * @param scene defines the hosting scene
  45005. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  45006. * @param renderingGroupId defines the rendering group id to use with the viewer
  45007. */
  45008. constructor(
  45009. /** defines the skeleton to render */
  45010. skeleton: Skeleton,
  45011. /** defines the mesh attached to the skeleton */
  45012. mesh: AbstractMesh, scene: Scene,
  45013. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45014. autoUpdateBonesMatrices?: boolean,
  45015. /** defines the rendering group id to use with the viewer */
  45016. renderingGroupId?: number);
  45017. /** Gets or sets a boolean indicating if the viewer is enabled */
  45018. isEnabled: boolean;
  45019. private _getBonePosition;
  45020. private _getLinesForBonesWithLength;
  45021. private _getLinesForBonesNoLength;
  45022. /** Update the viewer to sync with current skeleton state */
  45023. update(): void;
  45024. /** Release associated resources */
  45025. dispose(): void;
  45026. }
  45027. }
  45028. declare module "babylonjs/Debug/index" {
  45029. export * from "babylonjs/Debug/axesViewer";
  45030. export * from "babylonjs/Debug/boneAxesViewer";
  45031. export * from "babylonjs/Debug/debugLayer";
  45032. export * from "babylonjs/Debug/physicsViewer";
  45033. export * from "babylonjs/Debug/rayHelper";
  45034. export * from "babylonjs/Debug/skeletonViewer";
  45035. }
  45036. declare module "babylonjs/Engines/nullEngine" {
  45037. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  45038. import { Scene } from "babylonjs/scene";
  45039. import { Engine } from "babylonjs/Engines/engine";
  45040. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  45041. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  45042. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45043. import { Effect } from "babylonjs/Materials/effect";
  45044. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45045. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45046. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  45047. /**
  45048. * Options to create the null engine
  45049. */
  45050. export class NullEngineOptions {
  45051. /**
  45052. * Render width (Default: 512)
  45053. */
  45054. renderWidth: number;
  45055. /**
  45056. * Render height (Default: 256)
  45057. */
  45058. renderHeight: number;
  45059. /**
  45060. * Texture size (Default: 512)
  45061. */
  45062. textureSize: number;
  45063. /**
  45064. * If delta time between frames should be constant
  45065. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45066. */
  45067. deterministicLockstep: boolean;
  45068. /**
  45069. * Maximum about of steps between frames (Default: 4)
  45070. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45071. */
  45072. lockstepMaxSteps: number;
  45073. }
  45074. /**
  45075. * The null engine class provides support for headless version of babylon.js.
  45076. * This can be used in server side scenario or for testing purposes
  45077. */
  45078. export class NullEngine extends Engine {
  45079. private _options;
  45080. /**
  45081. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45082. */
  45083. isDeterministicLockStep(): boolean;
  45084. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  45085. getLockstepMaxSteps(): number;
  45086. /**
  45087. * Sets hardware scaling, used to save performance if needed
  45088. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  45089. */
  45090. getHardwareScalingLevel(): number;
  45091. constructor(options?: NullEngineOptions);
  45092. createVertexBuffer(vertices: FloatArray): DataBuffer;
  45093. createIndexBuffer(indices: IndicesArray): DataBuffer;
  45094. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45095. getRenderWidth(useScreen?: boolean): number;
  45096. getRenderHeight(useScreen?: boolean): number;
  45097. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  45098. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  45099. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45100. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45101. bindSamplers(effect: Effect): void;
  45102. enableEffect(effect: Effect): void;
  45103. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45104. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45105. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45106. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45107. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45108. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45109. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45110. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45111. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45112. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45113. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45114. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45115. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45116. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45117. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45118. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45119. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45120. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45121. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45122. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45123. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45124. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45125. bindBuffers(vertexBuffers: {
  45126. [key: string]: VertexBuffer;
  45127. }, indexBuffer: DataBuffer, effect: Effect): void;
  45128. wipeCaches(bruteForce?: boolean): void;
  45129. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  45130. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45131. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45132. /** @hidden */
  45133. _createTexture(): WebGLTexture;
  45134. /** @hidden */
  45135. _releaseTexture(texture: InternalTexture): void;
  45136. 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;
  45137. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45138. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45139. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45140. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45141. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  45142. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  45143. areAllEffectsReady(): boolean;
  45144. /**
  45145. * @hidden
  45146. * Get the current error code of the webGL context
  45147. * @returns the error code
  45148. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  45149. */
  45150. getError(): number;
  45151. /** @hidden */
  45152. _getUnpackAlignement(): number;
  45153. /** @hidden */
  45154. _unpackFlipY(value: boolean): void;
  45155. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  45156. /**
  45157. * Updates a dynamic vertex buffer.
  45158. * @param vertexBuffer the vertex buffer to update
  45159. * @param data the data used to update the vertex buffer
  45160. * @param byteOffset the byte offset of the data (optional)
  45161. * @param byteLength the byte length of the data (optional)
  45162. */
  45163. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  45164. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  45165. /** @hidden */
  45166. _bindTexture(channel: number, texture: InternalTexture): void;
  45167. /** @hidden */
  45168. _releaseBuffer(buffer: DataBuffer): boolean;
  45169. releaseEffects(): void;
  45170. displayLoadingUI(): void;
  45171. hideLoadingUI(): void;
  45172. /** @hidden */
  45173. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45174. /** @hidden */
  45175. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45176. /** @hidden */
  45177. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45178. /** @hidden */
  45179. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  45180. }
  45181. }
  45182. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  45183. import { Nullable, int } from "babylonjs/types";
  45184. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  45185. /** @hidden */
  45186. export class _OcclusionDataStorage {
  45187. /** @hidden */
  45188. occlusionInternalRetryCounter: number;
  45189. /** @hidden */
  45190. isOcclusionQueryInProgress: boolean;
  45191. /** @hidden */
  45192. isOccluded: boolean;
  45193. /** @hidden */
  45194. occlusionRetryCount: number;
  45195. /** @hidden */
  45196. occlusionType: number;
  45197. /** @hidden */
  45198. occlusionQueryAlgorithmType: number;
  45199. }
  45200. module "babylonjs/Engines/engine" {
  45201. interface Engine {
  45202. /**
  45203. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  45204. * @return the new query
  45205. */
  45206. createQuery(): WebGLQuery;
  45207. /**
  45208. * Delete and release a webGL query
  45209. * @param query defines the query to delete
  45210. * @return the current engine
  45211. */
  45212. deleteQuery(query: WebGLQuery): Engine;
  45213. /**
  45214. * Check if a given query has resolved and got its value
  45215. * @param query defines the query to check
  45216. * @returns true if the query got its value
  45217. */
  45218. isQueryResultAvailable(query: WebGLQuery): boolean;
  45219. /**
  45220. * Gets the value of a given query
  45221. * @param query defines the query to check
  45222. * @returns the value of the query
  45223. */
  45224. getQueryResult(query: WebGLQuery): number;
  45225. /**
  45226. * Initiates an occlusion query
  45227. * @param algorithmType defines the algorithm to use
  45228. * @param query defines the query to use
  45229. * @returns the current engine
  45230. * @see http://doc.babylonjs.com/features/occlusionquery
  45231. */
  45232. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  45233. /**
  45234. * Ends an occlusion query
  45235. * @see http://doc.babylonjs.com/features/occlusionquery
  45236. * @param algorithmType defines the algorithm to use
  45237. * @returns the current engine
  45238. */
  45239. endOcclusionQuery(algorithmType: number): Engine;
  45240. /**
  45241. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  45242. * Please note that only one query can be issued at a time
  45243. * @returns a time token used to track the time span
  45244. */
  45245. startTimeQuery(): Nullable<_TimeToken>;
  45246. /**
  45247. * Ends a time query
  45248. * @param token defines the token used to measure the time span
  45249. * @returns the time spent (in ns)
  45250. */
  45251. endTimeQuery(token: _TimeToken): int;
  45252. /** @hidden */
  45253. _currentNonTimestampToken: Nullable<_TimeToken>;
  45254. /** @hidden */
  45255. _createTimeQuery(): WebGLQuery;
  45256. /** @hidden */
  45257. _deleteTimeQuery(query: WebGLQuery): void;
  45258. /** @hidden */
  45259. _getGlAlgorithmType(algorithmType: number): number;
  45260. /** @hidden */
  45261. _getTimeQueryResult(query: WebGLQuery): any;
  45262. /** @hidden */
  45263. _getTimeQueryAvailability(query: WebGLQuery): any;
  45264. }
  45265. }
  45266. module "babylonjs/Meshes/abstractMesh" {
  45267. interface AbstractMesh {
  45268. /**
  45269. * Backing filed
  45270. * @hidden
  45271. */
  45272. __occlusionDataStorage: _OcclusionDataStorage;
  45273. /**
  45274. * Access property
  45275. * @hidden
  45276. */
  45277. _occlusionDataStorage: _OcclusionDataStorage;
  45278. /**
  45279. * 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.
  45280. * The default value is -1 which means don't break the query and wait till the result
  45281. * @see http://doc.babylonjs.com/features/occlusionquery
  45282. */
  45283. occlusionRetryCount: number;
  45284. /**
  45285. * 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:
  45286. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  45287. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  45288. * * 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.
  45289. * @see http://doc.babylonjs.com/features/occlusionquery
  45290. */
  45291. occlusionType: number;
  45292. /**
  45293. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  45294. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  45295. * * 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.
  45296. * @see http://doc.babylonjs.com/features/occlusionquery
  45297. */
  45298. occlusionQueryAlgorithmType: number;
  45299. /**
  45300. * 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
  45301. * @see http://doc.babylonjs.com/features/occlusionquery
  45302. */
  45303. isOccluded: boolean;
  45304. /**
  45305. * Flag to check the progress status of the query
  45306. * @see http://doc.babylonjs.com/features/occlusionquery
  45307. */
  45308. isOcclusionQueryInProgress: boolean;
  45309. }
  45310. }
  45311. }
  45312. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  45313. import { Nullable } from "babylonjs/types";
  45314. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45315. /** @hidden */
  45316. export var _forceTransformFeedbackToBundle: boolean;
  45317. module "babylonjs/Engines/engine" {
  45318. interface Engine {
  45319. /**
  45320. * Creates a webGL transform feedback object
  45321. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  45322. * @returns the webGL transform feedback object
  45323. */
  45324. createTransformFeedback(): WebGLTransformFeedback;
  45325. /**
  45326. * Delete a webGL transform feedback object
  45327. * @param value defines the webGL transform feedback object to delete
  45328. */
  45329. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  45330. /**
  45331. * Bind a webGL transform feedback object to the webgl context
  45332. * @param value defines the webGL transform feedback object to bind
  45333. */
  45334. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  45335. /**
  45336. * Begins a transform feedback operation
  45337. * @param usePoints defines if points or triangles must be used
  45338. */
  45339. beginTransformFeedback(usePoints: boolean): void;
  45340. /**
  45341. * Ends a transform feedback operation
  45342. */
  45343. endTransformFeedback(): void;
  45344. /**
  45345. * Specify the varyings to use with transform feedback
  45346. * @param program defines the associated webGL program
  45347. * @param value defines the list of strings representing the varying names
  45348. */
  45349. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  45350. /**
  45351. * Bind a webGL buffer for a transform feedback operation
  45352. * @param value defines the webGL buffer to bind
  45353. */
  45354. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  45355. }
  45356. }
  45357. }
  45358. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  45359. import { Scene } from "babylonjs/scene";
  45360. import { Engine } from "babylonjs/Engines/engine";
  45361. import { Texture } from "babylonjs/Materials/Textures/texture";
  45362. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  45363. import "babylonjs/Engines/Extensions/engine.multiRender";
  45364. /**
  45365. * Creation options of the multi render target texture.
  45366. */
  45367. export interface IMultiRenderTargetOptions {
  45368. /**
  45369. * Define if the texture needs to create mip maps after render.
  45370. */
  45371. generateMipMaps?: boolean;
  45372. /**
  45373. * Define the types of all the draw buffers we want to create
  45374. */
  45375. types?: number[];
  45376. /**
  45377. * Define the sampling modes of all the draw buffers we want to create
  45378. */
  45379. samplingModes?: number[];
  45380. /**
  45381. * Define if a depth buffer is required
  45382. */
  45383. generateDepthBuffer?: boolean;
  45384. /**
  45385. * Define if a stencil buffer is required
  45386. */
  45387. generateStencilBuffer?: boolean;
  45388. /**
  45389. * Define if a depth texture is required instead of a depth buffer
  45390. */
  45391. generateDepthTexture?: boolean;
  45392. /**
  45393. * Define the number of desired draw buffers
  45394. */
  45395. textureCount?: number;
  45396. /**
  45397. * Define if aspect ratio should be adapted to the texture or stay the scene one
  45398. */
  45399. doNotChangeAspectRatio?: boolean;
  45400. /**
  45401. * Define the default type of the buffers we are creating
  45402. */
  45403. defaultType?: number;
  45404. }
  45405. /**
  45406. * A multi render target, like a render target provides the ability to render to a texture.
  45407. * Unlike the render target, it can render to several draw buffers in one draw.
  45408. * This is specially interesting in deferred rendering or for any effects requiring more than
  45409. * just one color from a single pass.
  45410. */
  45411. export class MultiRenderTarget extends RenderTargetTexture {
  45412. private _internalTextures;
  45413. private _textures;
  45414. private _multiRenderTargetOptions;
  45415. /**
  45416. * Get if draw buffers are currently supported by the used hardware and browser.
  45417. */
  45418. readonly isSupported: boolean;
  45419. /**
  45420. * Get the list of textures generated by the multi render target.
  45421. */
  45422. readonly textures: Texture[];
  45423. /**
  45424. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  45425. */
  45426. readonly depthTexture: Texture;
  45427. /**
  45428. * Set the wrapping mode on U of all the textures we are rendering to.
  45429. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45430. */
  45431. wrapU: number;
  45432. /**
  45433. * Set the wrapping mode on V of all the textures we are rendering to.
  45434. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45435. */
  45436. wrapV: number;
  45437. /**
  45438. * Instantiate a new multi render target texture.
  45439. * A multi render target, like a render target provides the ability to render to a texture.
  45440. * Unlike the render target, it can render to several draw buffers in one draw.
  45441. * This is specially interesting in deferred rendering or for any effects requiring more than
  45442. * just one color from a single pass.
  45443. * @param name Define the name of the texture
  45444. * @param size Define the size of the buffers to render to
  45445. * @param count Define the number of target we are rendering into
  45446. * @param scene Define the scene the texture belongs to
  45447. * @param options Define the options used to create the multi render target
  45448. */
  45449. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  45450. /** @hidden */
  45451. _rebuild(): void;
  45452. private _createInternalTextures;
  45453. private _createTextures;
  45454. /**
  45455. * Define the number of samples used if MSAA is enabled.
  45456. */
  45457. samples: number;
  45458. /**
  45459. * Resize all the textures in the multi render target.
  45460. * Be carrefull as it will recreate all the data in the new texture.
  45461. * @param size Define the new size
  45462. */
  45463. resize(size: any): void;
  45464. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  45465. /**
  45466. * Dispose the render targets and their associated resources
  45467. */
  45468. dispose(): void;
  45469. /**
  45470. * Release all the underlying texture used as draw buffers.
  45471. */
  45472. releaseInternalTextures(): void;
  45473. }
  45474. }
  45475. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  45476. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45477. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  45478. import { Nullable } from "babylonjs/types";
  45479. module "babylonjs/Engines/engine" {
  45480. interface Engine {
  45481. /**
  45482. * Unbind a list of render target textures from the webGL context
  45483. * This is used only when drawBuffer extension or webGL2 are active
  45484. * @param textures defines the render target textures to unbind
  45485. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45486. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45487. */
  45488. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  45489. /**
  45490. * Create a multi render target texture
  45491. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  45492. * @param size defines the size of the texture
  45493. * @param options defines the creation options
  45494. * @returns the cube texture as an InternalTexture
  45495. */
  45496. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  45497. /**
  45498. * Update the sample count for a given multiple render target texture
  45499. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  45500. * @param textures defines the textures to update
  45501. * @param samples defines the sample count to set
  45502. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  45503. */
  45504. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  45505. }
  45506. }
  45507. }
  45508. declare module "babylonjs/Engines/Extensions/index" {
  45509. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  45510. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  45511. export * from "babylonjs/Engines/Extensions/engine.multiview";
  45512. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  45513. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  45514. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  45515. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  45516. export * from "babylonjs/Engines/Extensions/engine.webVR";
  45517. }
  45518. declare module "babylonjs/Engines/index" {
  45519. export * from "babylonjs/Engines/constants";
  45520. export * from "babylonjs/Engines/engine";
  45521. export * from "babylonjs/Engines/engineStore";
  45522. export * from "babylonjs/Engines/nullEngine";
  45523. export * from "babylonjs/Engines/Extensions/index";
  45524. export * from "babylonjs/Engines/IPipelineContext";
  45525. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  45526. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  45527. }
  45528. declare module "babylonjs/Events/clipboardEvents" {
  45529. /**
  45530. * Gather the list of clipboard event types as constants.
  45531. */
  45532. export class ClipboardEventTypes {
  45533. /**
  45534. * The clipboard event is fired when a copy command is active (pressed).
  45535. */
  45536. static readonly COPY: number;
  45537. /**
  45538. * The clipboard event is fired when a cut command is active (pressed).
  45539. */
  45540. static readonly CUT: number;
  45541. /**
  45542. * The clipboard event is fired when a paste command is active (pressed).
  45543. */
  45544. static readonly PASTE: number;
  45545. }
  45546. /**
  45547. * This class is used to store clipboard related info for the onClipboardObservable event.
  45548. */
  45549. export class ClipboardInfo {
  45550. /**
  45551. * Defines the type of event (BABYLON.ClipboardEventTypes)
  45552. */
  45553. type: number;
  45554. /**
  45555. * Defines the related dom event
  45556. */
  45557. event: ClipboardEvent;
  45558. /**
  45559. *Creates an instance of ClipboardInfo.
  45560. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  45561. * @param event Defines the related dom event
  45562. */
  45563. constructor(
  45564. /**
  45565. * Defines the type of event (BABYLON.ClipboardEventTypes)
  45566. */
  45567. type: number,
  45568. /**
  45569. * Defines the related dom event
  45570. */
  45571. event: ClipboardEvent);
  45572. /**
  45573. * Get the clipboard event's type from the keycode.
  45574. * @param keyCode Defines the keyCode for the current keyboard event.
  45575. * @return {number}
  45576. */
  45577. static GetTypeFromCharacter(keyCode: number): number;
  45578. }
  45579. }
  45580. declare module "babylonjs/Events/index" {
  45581. export * from "babylonjs/Events/keyboardEvents";
  45582. export * from "babylonjs/Events/pointerEvents";
  45583. export * from "babylonjs/Events/clipboardEvents";
  45584. }
  45585. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  45586. import { Scene } from "babylonjs/scene";
  45587. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45588. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  45589. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  45590. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  45591. /**
  45592. * Google Daydream controller
  45593. */
  45594. export class DaydreamController extends WebVRController {
  45595. /**
  45596. * Base Url for the controller model.
  45597. */
  45598. static MODEL_BASE_URL: string;
  45599. /**
  45600. * File name for the controller model.
  45601. */
  45602. static MODEL_FILENAME: string;
  45603. /**
  45604. * Gamepad Id prefix used to identify Daydream Controller.
  45605. */
  45606. static readonly GAMEPAD_ID_PREFIX: string;
  45607. /**
  45608. * Creates a new DaydreamController from a gamepad
  45609. * @param vrGamepad the gamepad that the controller should be created from
  45610. */
  45611. constructor(vrGamepad: any);
  45612. /**
  45613. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  45614. * @param scene scene in which to add meshes
  45615. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  45616. */
  45617. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  45618. /**
  45619. * Called once for each button that changed state since the last frame
  45620. * @param buttonIdx Which button index changed
  45621. * @param state New state of the button
  45622. * @param changes Which properties on the state changed since last frame
  45623. */
  45624. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45625. }
  45626. }
  45627. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  45628. import { Scene } from "babylonjs/scene";
  45629. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45630. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  45631. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  45632. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  45633. /**
  45634. * Gear VR Controller
  45635. */
  45636. export class GearVRController extends WebVRController {
  45637. /**
  45638. * Base Url for the controller model.
  45639. */
  45640. static MODEL_BASE_URL: string;
  45641. /**
  45642. * File name for the controller model.
  45643. */
  45644. static MODEL_FILENAME: string;
  45645. /**
  45646. * Gamepad Id prefix used to identify this controller.
  45647. */
  45648. static readonly GAMEPAD_ID_PREFIX: string;
  45649. private readonly _buttonIndexToObservableNameMap;
  45650. /**
  45651. * Creates a new GearVRController from a gamepad
  45652. * @param vrGamepad the gamepad that the controller should be created from
  45653. */
  45654. constructor(vrGamepad: any);
  45655. /**
  45656. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  45657. * @param scene scene in which to add meshes
  45658. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  45659. */
  45660. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  45661. /**
  45662. * Called once for each button that changed state since the last frame
  45663. * @param buttonIdx Which button index changed
  45664. * @param state New state of the button
  45665. * @param changes Which properties on the state changed since last frame
  45666. */
  45667. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45668. }
  45669. }
  45670. declare module "babylonjs/Gamepads/Controllers/index" {
  45671. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  45672. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  45673. export * from "babylonjs/Gamepads/Controllers/genericController";
  45674. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  45675. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  45676. export * from "babylonjs/Gamepads/Controllers/viveController";
  45677. export * from "babylonjs/Gamepads/Controllers/webVRController";
  45678. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  45679. }
  45680. declare module "babylonjs/Gamepads/index" {
  45681. export * from "babylonjs/Gamepads/Controllers/index";
  45682. export * from "babylonjs/Gamepads/gamepad";
  45683. export * from "babylonjs/Gamepads/gamepadManager";
  45684. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  45685. export * from "babylonjs/Gamepads/xboxGamepad";
  45686. export * from "babylonjs/Gamepads/dualShockGamepad";
  45687. }
  45688. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  45689. import { Scene } from "babylonjs/scene";
  45690. import { Vector4 } from "babylonjs/Maths/math.vector";
  45691. import { Color4 } from "babylonjs/Maths/math.color";
  45692. import { Mesh } from "babylonjs/Meshes/mesh";
  45693. import { Nullable } from "babylonjs/types";
  45694. /**
  45695. * Class containing static functions to help procedurally build meshes
  45696. */
  45697. export class PolyhedronBuilder {
  45698. /**
  45699. * Creates a polyhedron mesh
  45700. * * 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
  45701. * * The parameter `size` (positive float, default 1) sets the polygon size
  45702. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  45703. * * 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`
  45704. * * 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
  45705. * * 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)`)
  45706. * * 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
  45707. * * 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
  45708. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45709. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45710. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45711. * @param name defines the name of the mesh
  45712. * @param options defines the options used to create the mesh
  45713. * @param scene defines the hosting scene
  45714. * @returns the polyhedron mesh
  45715. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  45716. */
  45717. static CreatePolyhedron(name: string, options: {
  45718. type?: number;
  45719. size?: number;
  45720. sizeX?: number;
  45721. sizeY?: number;
  45722. sizeZ?: number;
  45723. custom?: any;
  45724. faceUV?: Vector4[];
  45725. faceColors?: Color4[];
  45726. flat?: boolean;
  45727. updatable?: boolean;
  45728. sideOrientation?: number;
  45729. frontUVs?: Vector4;
  45730. backUVs?: Vector4;
  45731. }, scene?: Nullable<Scene>): Mesh;
  45732. }
  45733. }
  45734. declare module "babylonjs/Gizmos/scaleGizmo" {
  45735. import { Observable } from "babylonjs/Misc/observable";
  45736. import { Nullable } from "babylonjs/types";
  45737. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45738. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45739. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  45740. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45741. /**
  45742. * Gizmo that enables scaling a mesh along 3 axis
  45743. */
  45744. export class ScaleGizmo extends Gizmo {
  45745. /**
  45746. * Internal gizmo used for interactions on the x axis
  45747. */
  45748. xGizmo: AxisScaleGizmo;
  45749. /**
  45750. * Internal gizmo used for interactions on the y axis
  45751. */
  45752. yGizmo: AxisScaleGizmo;
  45753. /**
  45754. * Internal gizmo used for interactions on the z axis
  45755. */
  45756. zGizmo: AxisScaleGizmo;
  45757. /**
  45758. * Internal gizmo used to scale all axis equally
  45759. */
  45760. uniformScaleGizmo: AxisScaleGizmo;
  45761. private _meshAttached;
  45762. private _updateGizmoRotationToMatchAttachedMesh;
  45763. private _snapDistance;
  45764. private _scaleRatio;
  45765. private _uniformScalingMesh;
  45766. private _octahedron;
  45767. /** Fires an event when any of it's sub gizmos are dragged */
  45768. onDragStartObservable: Observable<unknown>;
  45769. /** Fires an event when any of it's sub gizmos are released from dragging */
  45770. onDragEndObservable: Observable<unknown>;
  45771. attachedMesh: Nullable<AbstractMesh>;
  45772. /**
  45773. * Creates a ScaleGizmo
  45774. * @param gizmoLayer The utility layer the gizmo will be added to
  45775. */
  45776. constructor(gizmoLayer?: UtilityLayerRenderer);
  45777. updateGizmoRotationToMatchAttachedMesh: boolean;
  45778. /**
  45779. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45780. */
  45781. snapDistance: number;
  45782. /**
  45783. * Ratio for the scale of the gizmo (Default: 1)
  45784. */
  45785. scaleRatio: number;
  45786. /**
  45787. * Disposes of the gizmo
  45788. */
  45789. dispose(): void;
  45790. }
  45791. }
  45792. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  45793. import { Observable } from "babylonjs/Misc/observable";
  45794. import { Nullable } from "babylonjs/types";
  45795. import { Vector3 } from "babylonjs/Maths/math.vector";
  45796. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45797. import { Mesh } from "babylonjs/Meshes/mesh";
  45798. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45799. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45800. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45801. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  45802. import { Color3 } from "babylonjs/Maths/math.color";
  45803. /**
  45804. * Single axis scale gizmo
  45805. */
  45806. export class AxisScaleGizmo extends Gizmo {
  45807. /**
  45808. * Drag behavior responsible for the gizmos dragging interactions
  45809. */
  45810. dragBehavior: PointerDragBehavior;
  45811. private _pointerObserver;
  45812. /**
  45813. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45814. */
  45815. snapDistance: number;
  45816. /**
  45817. * Event that fires each time the gizmo snaps to a new location.
  45818. * * snapDistance is the the change in distance
  45819. */
  45820. onSnapObservable: Observable<{
  45821. snapDistance: number;
  45822. }>;
  45823. /**
  45824. * If the scaling operation should be done on all axis (default: false)
  45825. */
  45826. uniformScaling: boolean;
  45827. private _isEnabled;
  45828. private _parent;
  45829. private _arrow;
  45830. private _coloredMaterial;
  45831. private _hoverMaterial;
  45832. /**
  45833. * Creates an AxisScaleGizmo
  45834. * @param gizmoLayer The utility layer the gizmo will be added to
  45835. * @param dragAxis The axis which the gizmo will be able to scale on
  45836. * @param color The color of the gizmo
  45837. */
  45838. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  45839. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45840. /**
  45841. * If the gizmo is enabled
  45842. */
  45843. isEnabled: boolean;
  45844. /**
  45845. * Disposes of the gizmo
  45846. */
  45847. dispose(): void;
  45848. /**
  45849. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45850. * @param mesh The mesh to replace the default mesh of the gizmo
  45851. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  45852. */
  45853. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  45854. }
  45855. }
  45856. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  45857. import { Observable } from "babylonjs/Misc/observable";
  45858. import { Nullable } from "babylonjs/types";
  45859. import { Vector3 } from "babylonjs/Maths/math.vector";
  45860. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45861. import { Mesh } from "babylonjs/Meshes/mesh";
  45862. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45863. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45864. import { Color3 } from "babylonjs/Maths/math.color";
  45865. import "babylonjs/Meshes/Builders/boxBuilder";
  45866. /**
  45867. * Bounding box gizmo
  45868. */
  45869. export class BoundingBoxGizmo extends Gizmo {
  45870. private _lineBoundingBox;
  45871. private _rotateSpheresParent;
  45872. private _scaleBoxesParent;
  45873. private _boundingDimensions;
  45874. private _renderObserver;
  45875. private _pointerObserver;
  45876. private _scaleDragSpeed;
  45877. private _tmpQuaternion;
  45878. private _tmpVector;
  45879. private _tmpRotationMatrix;
  45880. /**
  45881. * 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)
  45882. */
  45883. ignoreChildren: boolean;
  45884. /**
  45885. * 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)
  45886. */
  45887. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  45888. /**
  45889. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  45890. */
  45891. rotationSphereSize: number;
  45892. /**
  45893. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  45894. */
  45895. scaleBoxSize: number;
  45896. /**
  45897. * 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)
  45898. */
  45899. fixedDragMeshScreenSize: boolean;
  45900. /**
  45901. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  45902. */
  45903. fixedDragMeshScreenSizeDistanceFactor: number;
  45904. /**
  45905. * Fired when a rotation sphere or scale box is dragged
  45906. */
  45907. onDragStartObservable: Observable<{}>;
  45908. /**
  45909. * Fired when a scale box is dragged
  45910. */
  45911. onScaleBoxDragObservable: Observable<{}>;
  45912. /**
  45913. * Fired when a scale box drag is ended
  45914. */
  45915. onScaleBoxDragEndObservable: Observable<{}>;
  45916. /**
  45917. * Fired when a rotation sphere is dragged
  45918. */
  45919. onRotationSphereDragObservable: Observable<{}>;
  45920. /**
  45921. * Fired when a rotation sphere drag is ended
  45922. */
  45923. onRotationSphereDragEndObservable: Observable<{}>;
  45924. /**
  45925. * 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)
  45926. */
  45927. scalePivot: Nullable<Vector3>;
  45928. /**
  45929. * Mesh used as a pivot to rotate the attached mesh
  45930. */
  45931. private _anchorMesh;
  45932. private _existingMeshScale;
  45933. private _dragMesh;
  45934. private pointerDragBehavior;
  45935. private coloredMaterial;
  45936. private hoverColoredMaterial;
  45937. /**
  45938. * Sets the color of the bounding box gizmo
  45939. * @param color the color to set
  45940. */
  45941. setColor(color: Color3): void;
  45942. /**
  45943. * Creates an BoundingBoxGizmo
  45944. * @param gizmoLayer The utility layer the gizmo will be added to
  45945. * @param color The color of the gizmo
  45946. */
  45947. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  45948. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45949. private _selectNode;
  45950. /**
  45951. * Updates the bounding box information for the Gizmo
  45952. */
  45953. updateBoundingBox(): void;
  45954. private _updateRotationSpheres;
  45955. private _updateScaleBoxes;
  45956. /**
  45957. * Enables rotation on the specified axis and disables rotation on the others
  45958. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  45959. */
  45960. setEnabledRotationAxis(axis: string): void;
  45961. /**
  45962. * Enables/disables scaling
  45963. * @param enable if scaling should be enabled
  45964. */
  45965. setEnabledScaling(enable: boolean): void;
  45966. private _updateDummy;
  45967. /**
  45968. * Enables a pointer drag behavior on the bounding box of the gizmo
  45969. */
  45970. enableDragBehavior(): void;
  45971. /**
  45972. * Disposes of the gizmo
  45973. */
  45974. dispose(): void;
  45975. /**
  45976. * 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)
  45977. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  45978. * @returns the bounding box mesh with the passed in mesh as a child
  45979. */
  45980. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  45981. /**
  45982. * CustomMeshes are not supported by this gizmo
  45983. * @param mesh The mesh to replace the default mesh of the gizmo
  45984. */
  45985. setCustomMesh(mesh: Mesh): void;
  45986. }
  45987. }
  45988. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  45989. import { Observable } from "babylonjs/Misc/observable";
  45990. import { Nullable } from "babylonjs/types";
  45991. import { Vector3 } from "babylonjs/Maths/math.vector";
  45992. import { Color3 } from "babylonjs/Maths/math.color";
  45993. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45994. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45995. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45996. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45997. import "babylonjs/Meshes/Builders/linesBuilder";
  45998. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  45999. /**
  46000. * Single plane rotation gizmo
  46001. */
  46002. export class PlaneRotationGizmo extends Gizmo {
  46003. /**
  46004. * Drag behavior responsible for the gizmos dragging interactions
  46005. */
  46006. dragBehavior: PointerDragBehavior;
  46007. private _pointerObserver;
  46008. /**
  46009. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  46010. */
  46011. snapDistance: number;
  46012. /**
  46013. * Event that fires each time the gizmo snaps to a new location.
  46014. * * snapDistance is the the change in distance
  46015. */
  46016. onSnapObservable: Observable<{
  46017. snapDistance: number;
  46018. }>;
  46019. private _isEnabled;
  46020. private _parent;
  46021. /**
  46022. * Creates a PlaneRotationGizmo
  46023. * @param gizmoLayer The utility layer the gizmo will be added to
  46024. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  46025. * @param color The color of the gizmo
  46026. * @param tessellation Amount of tessellation to be used when creating rotation circles
  46027. * @param useEulerRotation Use and update Euler angle instead of quaternion
  46028. */
  46029. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  46030. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46031. /**
  46032. * If the gizmo is enabled
  46033. */
  46034. isEnabled: boolean;
  46035. /**
  46036. * Disposes of the gizmo
  46037. */
  46038. dispose(): void;
  46039. }
  46040. }
  46041. declare module "babylonjs/Gizmos/rotationGizmo" {
  46042. import { Observable } from "babylonjs/Misc/observable";
  46043. import { Nullable } from "babylonjs/types";
  46044. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46045. import { Mesh } from "babylonjs/Meshes/mesh";
  46046. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46047. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  46048. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46049. /**
  46050. * Gizmo that enables rotating a mesh along 3 axis
  46051. */
  46052. export class RotationGizmo extends Gizmo {
  46053. /**
  46054. * Internal gizmo used for interactions on the x axis
  46055. */
  46056. xGizmo: PlaneRotationGizmo;
  46057. /**
  46058. * Internal gizmo used for interactions on the y axis
  46059. */
  46060. yGizmo: PlaneRotationGizmo;
  46061. /**
  46062. * Internal gizmo used for interactions on the z axis
  46063. */
  46064. zGizmo: PlaneRotationGizmo;
  46065. /** Fires an event when any of it's sub gizmos are dragged */
  46066. onDragStartObservable: Observable<unknown>;
  46067. /** Fires an event when any of it's sub gizmos are released from dragging */
  46068. onDragEndObservable: Observable<unknown>;
  46069. private _meshAttached;
  46070. attachedMesh: Nullable<AbstractMesh>;
  46071. /**
  46072. * Creates a RotationGizmo
  46073. * @param gizmoLayer The utility layer the gizmo will be added to
  46074. * @param tessellation Amount of tessellation to be used when creating rotation circles
  46075. * @param useEulerRotation Use and update Euler angle instead of quaternion
  46076. */
  46077. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  46078. updateGizmoRotationToMatchAttachedMesh: boolean;
  46079. /**
  46080. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46081. */
  46082. snapDistance: number;
  46083. /**
  46084. * Ratio for the scale of the gizmo (Default: 1)
  46085. */
  46086. scaleRatio: number;
  46087. /**
  46088. * Disposes of the gizmo
  46089. */
  46090. dispose(): void;
  46091. /**
  46092. * CustomMeshes are not supported by this gizmo
  46093. * @param mesh The mesh to replace the default mesh of the gizmo
  46094. */
  46095. setCustomMesh(mesh: Mesh): void;
  46096. }
  46097. }
  46098. declare module "babylonjs/Gizmos/gizmoManager" {
  46099. import { Observable } from "babylonjs/Misc/observable";
  46100. import { Nullable } from "babylonjs/types";
  46101. import { Scene, IDisposable } from "babylonjs/scene";
  46102. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46103. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46104. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  46105. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  46106. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  46107. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  46108. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  46109. /**
  46110. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  46111. */
  46112. export class GizmoManager implements IDisposable {
  46113. private scene;
  46114. /**
  46115. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  46116. */
  46117. gizmos: {
  46118. positionGizmo: Nullable<PositionGizmo>;
  46119. rotationGizmo: Nullable<RotationGizmo>;
  46120. scaleGizmo: Nullable<ScaleGizmo>;
  46121. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  46122. };
  46123. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  46124. clearGizmoOnEmptyPointerEvent: boolean;
  46125. /** Fires an event when the manager is attached to a mesh */
  46126. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  46127. private _gizmosEnabled;
  46128. private _pointerObserver;
  46129. private _attachedMesh;
  46130. private _boundingBoxColor;
  46131. private _defaultUtilityLayer;
  46132. private _defaultKeepDepthUtilityLayer;
  46133. /**
  46134. * When bounding box gizmo is enabled, this can be used to track drag/end events
  46135. */
  46136. boundingBoxDragBehavior: SixDofDragBehavior;
  46137. /**
  46138. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  46139. */
  46140. attachableMeshes: Nullable<Array<AbstractMesh>>;
  46141. /**
  46142. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  46143. */
  46144. usePointerToAttachGizmos: boolean;
  46145. /**
  46146. * Utility layer that the bounding box gizmo belongs to
  46147. */
  46148. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  46149. /**
  46150. * Utility layer that all gizmos besides bounding box belong to
  46151. */
  46152. readonly utilityLayer: UtilityLayerRenderer;
  46153. /**
  46154. * Instatiates a gizmo manager
  46155. * @param scene the scene to overlay the gizmos on top of
  46156. */
  46157. constructor(scene: Scene);
  46158. /**
  46159. * Attaches a set of gizmos to the specified mesh
  46160. * @param mesh The mesh the gizmo's should be attached to
  46161. */
  46162. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  46163. /**
  46164. * If the position gizmo is enabled
  46165. */
  46166. positionGizmoEnabled: boolean;
  46167. /**
  46168. * If the rotation gizmo is enabled
  46169. */
  46170. rotationGizmoEnabled: boolean;
  46171. /**
  46172. * If the scale gizmo is enabled
  46173. */
  46174. scaleGizmoEnabled: boolean;
  46175. /**
  46176. * If the boundingBox gizmo is enabled
  46177. */
  46178. boundingBoxGizmoEnabled: boolean;
  46179. /**
  46180. * Disposes of the gizmo manager
  46181. */
  46182. dispose(): void;
  46183. }
  46184. }
  46185. declare module "babylonjs/Lights/directionalLight" {
  46186. import { Camera } from "babylonjs/Cameras/camera";
  46187. import { Scene } from "babylonjs/scene";
  46188. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  46189. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46190. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46191. import { Effect } from "babylonjs/Materials/effect";
  46192. /**
  46193. * A directional light is defined by a direction (what a surprise!).
  46194. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  46195. * 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.
  46196. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46197. */
  46198. export class DirectionalLight extends ShadowLight {
  46199. private _shadowFrustumSize;
  46200. /**
  46201. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  46202. */
  46203. /**
  46204. * Specifies a fix frustum size for the shadow generation.
  46205. */
  46206. shadowFrustumSize: number;
  46207. private _shadowOrthoScale;
  46208. /**
  46209. * Gets the shadow projection scale against the optimal computed one.
  46210. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46211. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46212. */
  46213. /**
  46214. * Sets the shadow projection scale against the optimal computed one.
  46215. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46216. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46217. */
  46218. shadowOrthoScale: number;
  46219. /**
  46220. * Automatically compute the projection matrix to best fit (including all the casters)
  46221. * on each frame.
  46222. */
  46223. autoUpdateExtends: boolean;
  46224. private _orthoLeft;
  46225. private _orthoRight;
  46226. private _orthoTop;
  46227. private _orthoBottom;
  46228. /**
  46229. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  46230. * The directional light is emitted from everywhere in the given direction.
  46231. * It can cast shadows.
  46232. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46233. * @param name The friendly name of the light
  46234. * @param direction The direction of the light
  46235. * @param scene The scene the light belongs to
  46236. */
  46237. constructor(name: string, direction: Vector3, scene: Scene);
  46238. /**
  46239. * Returns the string "DirectionalLight".
  46240. * @return The class name
  46241. */
  46242. getClassName(): string;
  46243. /**
  46244. * Returns the integer 1.
  46245. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46246. */
  46247. getTypeID(): number;
  46248. /**
  46249. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  46250. * Returns the DirectionalLight Shadow projection matrix.
  46251. */
  46252. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46253. /**
  46254. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  46255. * Returns the DirectionalLight Shadow projection matrix.
  46256. */
  46257. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  46258. /**
  46259. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  46260. * Returns the DirectionalLight Shadow projection matrix.
  46261. */
  46262. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46263. protected _buildUniformLayout(): void;
  46264. /**
  46265. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  46266. * @param effect The effect to update
  46267. * @param lightIndex The index of the light in the effect to update
  46268. * @returns The directional light
  46269. */
  46270. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  46271. /**
  46272. * Gets the minZ used for shadow according to both the scene and the light.
  46273. *
  46274. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46275. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46276. * @param activeCamera The camera we are returning the min for
  46277. * @returns the depth min z
  46278. */
  46279. getDepthMinZ(activeCamera: Camera): number;
  46280. /**
  46281. * Gets the maxZ used for shadow according to both the scene and the light.
  46282. *
  46283. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46284. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46285. * @param activeCamera The camera we are returning the max for
  46286. * @returns the depth max z
  46287. */
  46288. getDepthMaxZ(activeCamera: Camera): number;
  46289. /**
  46290. * Prepares the list of defines specific to the light type.
  46291. * @param defines the list of defines
  46292. * @param lightIndex defines the index of the light for the effect
  46293. */
  46294. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46295. }
  46296. }
  46297. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  46298. import { Mesh } from "babylonjs/Meshes/mesh";
  46299. /**
  46300. * Class containing static functions to help procedurally build meshes
  46301. */
  46302. export class HemisphereBuilder {
  46303. /**
  46304. * Creates a hemisphere mesh
  46305. * @param name defines the name of the mesh
  46306. * @param options defines the options used to create the mesh
  46307. * @param scene defines the hosting scene
  46308. * @returns the hemisphere mesh
  46309. */
  46310. static CreateHemisphere(name: string, options: {
  46311. segments?: number;
  46312. diameter?: number;
  46313. sideOrientation?: number;
  46314. }, scene: any): Mesh;
  46315. }
  46316. }
  46317. declare module "babylonjs/Lights/spotLight" {
  46318. import { Nullable } from "babylonjs/types";
  46319. import { Scene } from "babylonjs/scene";
  46320. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  46321. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46322. import { Effect } from "babylonjs/Materials/effect";
  46323. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46324. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46325. /**
  46326. * A spot light is defined by a position, a direction, an angle, and an exponent.
  46327. * These values define a cone of light starting from the position, emitting toward the direction.
  46328. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  46329. * and the exponent defines the speed of the decay of the light with distance (reach).
  46330. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46331. */
  46332. export class SpotLight extends ShadowLight {
  46333. private _angle;
  46334. private _innerAngle;
  46335. private _cosHalfAngle;
  46336. private _lightAngleScale;
  46337. private _lightAngleOffset;
  46338. /**
  46339. * Gets the cone angle of the spot light in Radians.
  46340. */
  46341. /**
  46342. * Sets the cone angle of the spot light in Radians.
  46343. */
  46344. angle: number;
  46345. /**
  46346. * Only used in gltf falloff mode, this defines the angle where
  46347. * the directional falloff will start before cutting at angle which could be seen
  46348. * as outer angle.
  46349. */
  46350. /**
  46351. * Only used in gltf falloff mode, this defines the angle where
  46352. * the directional falloff will start before cutting at angle which could be seen
  46353. * as outer angle.
  46354. */
  46355. innerAngle: number;
  46356. private _shadowAngleScale;
  46357. /**
  46358. * Allows scaling the angle of the light for shadow generation only.
  46359. */
  46360. /**
  46361. * Allows scaling the angle of the light for shadow generation only.
  46362. */
  46363. shadowAngleScale: number;
  46364. /**
  46365. * The light decay speed with the distance from the emission spot.
  46366. */
  46367. exponent: number;
  46368. private _projectionTextureMatrix;
  46369. /**
  46370. * Allows reading the projecton texture
  46371. */
  46372. readonly projectionTextureMatrix: Matrix;
  46373. protected _projectionTextureLightNear: number;
  46374. /**
  46375. * Gets the near clip of the Spotlight for texture projection.
  46376. */
  46377. /**
  46378. * Sets the near clip of the Spotlight for texture projection.
  46379. */
  46380. projectionTextureLightNear: number;
  46381. protected _projectionTextureLightFar: number;
  46382. /**
  46383. * Gets the far clip of the Spotlight for texture projection.
  46384. */
  46385. /**
  46386. * Sets the far clip of the Spotlight for texture projection.
  46387. */
  46388. projectionTextureLightFar: number;
  46389. protected _projectionTextureUpDirection: Vector3;
  46390. /**
  46391. * Gets the Up vector of the Spotlight for texture projection.
  46392. */
  46393. /**
  46394. * Sets the Up vector of the Spotlight for texture projection.
  46395. */
  46396. projectionTextureUpDirection: Vector3;
  46397. private _projectionTexture;
  46398. /**
  46399. * Gets the projection texture of the light.
  46400. */
  46401. /**
  46402. * Sets the projection texture of the light.
  46403. */
  46404. projectionTexture: Nullable<BaseTexture>;
  46405. private _projectionTextureViewLightDirty;
  46406. private _projectionTextureProjectionLightDirty;
  46407. private _projectionTextureDirty;
  46408. private _projectionTextureViewTargetVector;
  46409. private _projectionTextureViewLightMatrix;
  46410. private _projectionTextureProjectionLightMatrix;
  46411. private _projectionTextureScalingMatrix;
  46412. /**
  46413. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  46414. * It can cast shadows.
  46415. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46416. * @param name The light friendly name
  46417. * @param position The position of the spot light in the scene
  46418. * @param direction The direction of the light in the scene
  46419. * @param angle The cone angle of the light in Radians
  46420. * @param exponent The light decay speed with the distance from the emission spot
  46421. * @param scene The scene the lights belongs to
  46422. */
  46423. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  46424. /**
  46425. * Returns the string "SpotLight".
  46426. * @returns the class name
  46427. */
  46428. getClassName(): string;
  46429. /**
  46430. * Returns the integer 2.
  46431. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46432. */
  46433. getTypeID(): number;
  46434. /**
  46435. * Overrides the direction setter to recompute the projection texture view light Matrix.
  46436. */
  46437. protected _setDirection(value: Vector3): void;
  46438. /**
  46439. * Overrides the position setter to recompute the projection texture view light Matrix.
  46440. */
  46441. protected _setPosition(value: Vector3): void;
  46442. /**
  46443. * 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.
  46444. * Returns the SpotLight.
  46445. */
  46446. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46447. protected _computeProjectionTextureViewLightMatrix(): void;
  46448. protected _computeProjectionTextureProjectionLightMatrix(): void;
  46449. /**
  46450. * Main function for light texture projection matrix computing.
  46451. */
  46452. protected _computeProjectionTextureMatrix(): void;
  46453. protected _buildUniformLayout(): void;
  46454. private _computeAngleValues;
  46455. /**
  46456. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  46457. * @param effect The effect to update
  46458. * @param lightIndex The index of the light in the effect to update
  46459. * @returns The spot light
  46460. */
  46461. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  46462. /**
  46463. * Disposes the light and the associated resources.
  46464. */
  46465. dispose(): void;
  46466. /**
  46467. * Prepares the list of defines specific to the light type.
  46468. * @param defines the list of defines
  46469. * @param lightIndex defines the index of the light for the effect
  46470. */
  46471. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46472. }
  46473. }
  46474. declare module "babylonjs/Gizmos/lightGizmo" {
  46475. import { Nullable } from "babylonjs/types";
  46476. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46477. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46478. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  46479. import { Light } from "babylonjs/Lights/light";
  46480. /**
  46481. * Gizmo that enables viewing a light
  46482. */
  46483. export class LightGizmo extends Gizmo {
  46484. private _lightMesh;
  46485. private _material;
  46486. private cachedPosition;
  46487. private cachedForward;
  46488. /**
  46489. * Creates a LightGizmo
  46490. * @param gizmoLayer The utility layer the gizmo will be added to
  46491. */
  46492. constructor(gizmoLayer?: UtilityLayerRenderer);
  46493. private _light;
  46494. /**
  46495. * The light that the gizmo is attached to
  46496. */
  46497. light: Nullable<Light>;
  46498. /**
  46499. * Gets the material used to render the light gizmo
  46500. */
  46501. readonly material: StandardMaterial;
  46502. /**
  46503. * @hidden
  46504. * Updates the gizmo to match the attached mesh's position/rotation
  46505. */
  46506. protected _update(): void;
  46507. private static _Scale;
  46508. /**
  46509. * Creates the lines for a light mesh
  46510. */
  46511. private static _createLightLines;
  46512. /**
  46513. * Disposes of the light gizmo
  46514. */
  46515. dispose(): void;
  46516. private static _CreateHemisphericLightMesh;
  46517. private static _CreatePointLightMesh;
  46518. private static _CreateSpotLightMesh;
  46519. private static _CreateDirectionalLightMesh;
  46520. }
  46521. }
  46522. declare module "babylonjs/Gizmos/index" {
  46523. export * from "babylonjs/Gizmos/axisDragGizmo";
  46524. export * from "babylonjs/Gizmos/axisScaleGizmo";
  46525. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  46526. export * from "babylonjs/Gizmos/gizmo";
  46527. export * from "babylonjs/Gizmos/gizmoManager";
  46528. export * from "babylonjs/Gizmos/planeRotationGizmo";
  46529. export * from "babylonjs/Gizmos/positionGizmo";
  46530. export * from "babylonjs/Gizmos/rotationGizmo";
  46531. export * from "babylonjs/Gizmos/scaleGizmo";
  46532. export * from "babylonjs/Gizmos/lightGizmo";
  46533. export * from "babylonjs/Gizmos/planeDragGizmo";
  46534. }
  46535. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  46536. /** @hidden */
  46537. export var backgroundFragmentDeclaration: {
  46538. name: string;
  46539. shader: string;
  46540. };
  46541. }
  46542. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  46543. /** @hidden */
  46544. export var backgroundUboDeclaration: {
  46545. name: string;
  46546. shader: string;
  46547. };
  46548. }
  46549. declare module "babylonjs/Shaders/background.fragment" {
  46550. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  46551. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  46552. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  46553. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  46554. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46555. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46556. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46557. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  46558. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  46559. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  46560. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  46561. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  46562. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  46563. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  46564. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  46565. /** @hidden */
  46566. export var backgroundPixelShader: {
  46567. name: string;
  46568. shader: string;
  46569. };
  46570. }
  46571. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  46572. /** @hidden */
  46573. export var backgroundVertexDeclaration: {
  46574. name: string;
  46575. shader: string;
  46576. };
  46577. }
  46578. declare module "babylonjs/Shaders/background.vertex" {
  46579. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  46580. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  46581. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46582. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  46583. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  46584. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  46585. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  46586. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46587. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46588. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  46589. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  46590. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  46591. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  46592. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  46593. /** @hidden */
  46594. export var backgroundVertexShader: {
  46595. name: string;
  46596. shader: string;
  46597. };
  46598. }
  46599. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  46600. import { Nullable, int, float } from "babylonjs/types";
  46601. import { Scene } from "babylonjs/scene";
  46602. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  46603. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46604. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46605. import { Mesh } from "babylonjs/Meshes/mesh";
  46606. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  46607. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  46608. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  46609. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46610. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  46611. import { Color3 } from "babylonjs/Maths/math.color";
  46612. import "babylonjs/Shaders/background.fragment";
  46613. import "babylonjs/Shaders/background.vertex";
  46614. /**
  46615. * Background material used to create an efficient environement around your scene.
  46616. */
  46617. export class BackgroundMaterial extends PushMaterial {
  46618. /**
  46619. * Standard reflectance value at parallel view angle.
  46620. */
  46621. static StandardReflectance0: number;
  46622. /**
  46623. * Standard reflectance value at grazing angle.
  46624. */
  46625. static StandardReflectance90: number;
  46626. protected _primaryColor: Color3;
  46627. /**
  46628. * Key light Color (multiply against the environement texture)
  46629. */
  46630. primaryColor: Color3;
  46631. protected __perceptualColor: Nullable<Color3>;
  46632. /**
  46633. * Experimental Internal Use Only.
  46634. *
  46635. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  46636. * This acts as a helper to set the primary color to a more "human friendly" value.
  46637. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  46638. * output color as close as possible from the chosen value.
  46639. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  46640. * part of lighting setup.)
  46641. */
  46642. _perceptualColor: Nullable<Color3>;
  46643. protected _primaryColorShadowLevel: float;
  46644. /**
  46645. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  46646. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  46647. */
  46648. primaryColorShadowLevel: float;
  46649. protected _primaryColorHighlightLevel: float;
  46650. /**
  46651. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  46652. * The primary color is used at the level chosen to define what the white area would look.
  46653. */
  46654. primaryColorHighlightLevel: float;
  46655. protected _reflectionTexture: Nullable<BaseTexture>;
  46656. /**
  46657. * Reflection Texture used in the material.
  46658. * Should be author in a specific way for the best result (refer to the documentation).
  46659. */
  46660. reflectionTexture: Nullable<BaseTexture>;
  46661. protected _reflectionBlur: float;
  46662. /**
  46663. * Reflection Texture level of blur.
  46664. *
  46665. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  46666. * texture twice.
  46667. */
  46668. reflectionBlur: float;
  46669. protected _diffuseTexture: Nullable<BaseTexture>;
  46670. /**
  46671. * Diffuse Texture used in the material.
  46672. * Should be author in a specific way for the best result (refer to the documentation).
  46673. */
  46674. diffuseTexture: Nullable<BaseTexture>;
  46675. protected _shadowLights: Nullable<IShadowLight[]>;
  46676. /**
  46677. * Specify the list of lights casting shadow on the material.
  46678. * All scene shadow lights will be included if null.
  46679. */
  46680. shadowLights: Nullable<IShadowLight[]>;
  46681. protected _shadowLevel: float;
  46682. /**
  46683. * Helps adjusting the shadow to a softer level if required.
  46684. * 0 means black shadows and 1 means no shadows.
  46685. */
  46686. shadowLevel: float;
  46687. protected _sceneCenter: Vector3;
  46688. /**
  46689. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  46690. * It is usually zero but might be interesting to modify according to your setup.
  46691. */
  46692. sceneCenter: Vector3;
  46693. protected _opacityFresnel: boolean;
  46694. /**
  46695. * This helps specifying that the material is falling off to the sky box at grazing angle.
  46696. * This helps ensuring a nice transition when the camera goes under the ground.
  46697. */
  46698. opacityFresnel: boolean;
  46699. protected _reflectionFresnel: boolean;
  46700. /**
  46701. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  46702. * This helps adding a mirror texture on the ground.
  46703. */
  46704. reflectionFresnel: boolean;
  46705. protected _reflectionFalloffDistance: number;
  46706. /**
  46707. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  46708. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  46709. */
  46710. reflectionFalloffDistance: number;
  46711. protected _reflectionAmount: number;
  46712. /**
  46713. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  46714. */
  46715. reflectionAmount: number;
  46716. protected _reflectionReflectance0: number;
  46717. /**
  46718. * This specifies the weight of the reflection at grazing angle.
  46719. */
  46720. reflectionReflectance0: number;
  46721. protected _reflectionReflectance90: number;
  46722. /**
  46723. * This specifies the weight of the reflection at a perpendicular point of view.
  46724. */
  46725. reflectionReflectance90: number;
  46726. /**
  46727. * Sets the reflection reflectance fresnel values according to the default standard
  46728. * empirically know to work well :-)
  46729. */
  46730. reflectionStandardFresnelWeight: number;
  46731. protected _useRGBColor: boolean;
  46732. /**
  46733. * Helps to directly use the maps channels instead of their level.
  46734. */
  46735. useRGBColor: boolean;
  46736. protected _enableNoise: boolean;
  46737. /**
  46738. * This helps reducing the banding effect that could occur on the background.
  46739. */
  46740. enableNoise: boolean;
  46741. /**
  46742. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46743. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  46744. * Recommended to be keep at 1.0 except for special cases.
  46745. */
  46746. fovMultiplier: number;
  46747. private _fovMultiplier;
  46748. /**
  46749. * Enable the FOV adjustment feature controlled by fovMultiplier.
  46750. */
  46751. useEquirectangularFOV: boolean;
  46752. private _maxSimultaneousLights;
  46753. /**
  46754. * Number of Simultaneous lights allowed on the material.
  46755. */
  46756. maxSimultaneousLights: int;
  46757. /**
  46758. * Default configuration related to image processing available in the Background Material.
  46759. */
  46760. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46761. /**
  46762. * Keep track of the image processing observer to allow dispose and replace.
  46763. */
  46764. private _imageProcessingObserver;
  46765. /**
  46766. * Attaches a new image processing configuration to the PBR Material.
  46767. * @param configuration (if null the scene configuration will be use)
  46768. */
  46769. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  46770. /**
  46771. * Gets the image processing configuration used either in this material.
  46772. */
  46773. /**
  46774. * Sets the Default image processing configuration used either in the this material.
  46775. *
  46776. * If sets to null, the scene one is in use.
  46777. */
  46778. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  46779. /**
  46780. * Gets wether the color curves effect is enabled.
  46781. */
  46782. /**
  46783. * Sets wether the color curves effect is enabled.
  46784. */
  46785. cameraColorCurvesEnabled: boolean;
  46786. /**
  46787. * Gets wether the color grading effect is enabled.
  46788. */
  46789. /**
  46790. * Gets wether the color grading effect is enabled.
  46791. */
  46792. cameraColorGradingEnabled: boolean;
  46793. /**
  46794. * Gets wether tonemapping is enabled or not.
  46795. */
  46796. /**
  46797. * Sets wether tonemapping is enabled or not
  46798. */
  46799. cameraToneMappingEnabled: boolean;
  46800. /**
  46801. * The camera exposure used on this material.
  46802. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46803. * This corresponds to a photographic exposure.
  46804. */
  46805. /**
  46806. * The camera exposure used on this material.
  46807. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46808. * This corresponds to a photographic exposure.
  46809. */
  46810. cameraExposure: float;
  46811. /**
  46812. * Gets The camera contrast used on this material.
  46813. */
  46814. /**
  46815. * Sets The camera contrast used on this material.
  46816. */
  46817. cameraContrast: float;
  46818. /**
  46819. * Gets the Color Grading 2D Lookup Texture.
  46820. */
  46821. /**
  46822. * Sets the Color Grading 2D Lookup Texture.
  46823. */
  46824. cameraColorGradingTexture: Nullable<BaseTexture>;
  46825. /**
  46826. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46827. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46828. * 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;
  46829. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46830. */
  46831. /**
  46832. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46833. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46834. * 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;
  46835. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46836. */
  46837. cameraColorCurves: Nullable<ColorCurves>;
  46838. /**
  46839. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  46840. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  46841. */
  46842. switchToBGR: boolean;
  46843. private _renderTargets;
  46844. private _reflectionControls;
  46845. private _white;
  46846. private _primaryShadowColor;
  46847. private _primaryHighlightColor;
  46848. /**
  46849. * Instantiates a Background Material in the given scene
  46850. * @param name The friendly name of the material
  46851. * @param scene The scene to add the material to
  46852. */
  46853. constructor(name: string, scene: Scene);
  46854. /**
  46855. * Gets a boolean indicating that current material needs to register RTT
  46856. */
  46857. readonly hasRenderTargetTextures: boolean;
  46858. /**
  46859. * The entire material has been created in order to prevent overdraw.
  46860. * @returns false
  46861. */
  46862. needAlphaTesting(): boolean;
  46863. /**
  46864. * The entire material has been created in order to prevent overdraw.
  46865. * @returns true if blending is enable
  46866. */
  46867. needAlphaBlending(): boolean;
  46868. /**
  46869. * Checks wether the material is ready to be rendered for a given mesh.
  46870. * @param mesh The mesh to render
  46871. * @param subMesh The submesh to check against
  46872. * @param useInstances Specify wether or not the material is used with instances
  46873. * @returns true if all the dependencies are ready (Textures, Effects...)
  46874. */
  46875. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46876. /**
  46877. * Compute the primary color according to the chosen perceptual color.
  46878. */
  46879. private _computePrimaryColorFromPerceptualColor;
  46880. /**
  46881. * Compute the highlights and shadow colors according to their chosen levels.
  46882. */
  46883. private _computePrimaryColors;
  46884. /**
  46885. * Build the uniform buffer used in the material.
  46886. */
  46887. buildUniformLayout(): void;
  46888. /**
  46889. * Unbind the material.
  46890. */
  46891. unbind(): void;
  46892. /**
  46893. * Bind only the world matrix to the material.
  46894. * @param world The world matrix to bind.
  46895. */
  46896. bindOnlyWorldMatrix(world: Matrix): void;
  46897. /**
  46898. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  46899. * @param world The world matrix to bind.
  46900. * @param subMesh The submesh to bind for.
  46901. */
  46902. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46903. /**
  46904. * Checks to see if a texture is used in the material.
  46905. * @param texture - Base texture to use.
  46906. * @returns - Boolean specifying if a texture is used in the material.
  46907. */
  46908. hasTexture(texture: BaseTexture): boolean;
  46909. /**
  46910. * Dispose the material.
  46911. * @param forceDisposeEffect Force disposal of the associated effect.
  46912. * @param forceDisposeTextures Force disposal of the associated textures.
  46913. */
  46914. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  46915. /**
  46916. * Clones the material.
  46917. * @param name The cloned name.
  46918. * @returns The cloned material.
  46919. */
  46920. clone(name: string): BackgroundMaterial;
  46921. /**
  46922. * Serializes the current material to its JSON representation.
  46923. * @returns The JSON representation.
  46924. */
  46925. serialize(): any;
  46926. /**
  46927. * Gets the class name of the material
  46928. * @returns "BackgroundMaterial"
  46929. */
  46930. getClassName(): string;
  46931. /**
  46932. * Parse a JSON input to create back a background material.
  46933. * @param source The JSON data to parse
  46934. * @param scene The scene to create the parsed material in
  46935. * @param rootUrl The root url of the assets the material depends upon
  46936. * @returns the instantiated BackgroundMaterial.
  46937. */
  46938. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  46939. }
  46940. }
  46941. declare module "babylonjs/Helpers/environmentHelper" {
  46942. import { Observable } from "babylonjs/Misc/observable";
  46943. import { Nullable } from "babylonjs/types";
  46944. import { Scene } from "babylonjs/scene";
  46945. import { Vector3 } from "babylonjs/Maths/math.vector";
  46946. import { Color3 } from "babylonjs/Maths/math.color";
  46947. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46948. import { Mesh } from "babylonjs/Meshes/mesh";
  46949. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46950. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  46951. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46952. import "babylonjs/Meshes/Builders/planeBuilder";
  46953. import "babylonjs/Meshes/Builders/boxBuilder";
  46954. /**
  46955. * Represents the different options available during the creation of
  46956. * a Environment helper.
  46957. *
  46958. * This can control the default ground, skybox and image processing setup of your scene.
  46959. */
  46960. export interface IEnvironmentHelperOptions {
  46961. /**
  46962. * Specifies wether or not to create a ground.
  46963. * True by default.
  46964. */
  46965. createGround: boolean;
  46966. /**
  46967. * Specifies the ground size.
  46968. * 15 by default.
  46969. */
  46970. groundSize: number;
  46971. /**
  46972. * The texture used on the ground for the main color.
  46973. * Comes from the BabylonJS CDN by default.
  46974. *
  46975. * Remarks: Can be either a texture or a url.
  46976. */
  46977. groundTexture: string | BaseTexture;
  46978. /**
  46979. * The color mixed in the ground texture by default.
  46980. * BabylonJS clearColor by default.
  46981. */
  46982. groundColor: Color3;
  46983. /**
  46984. * Specifies the ground opacity.
  46985. * 1 by default.
  46986. */
  46987. groundOpacity: number;
  46988. /**
  46989. * Enables the ground to receive shadows.
  46990. * True by default.
  46991. */
  46992. enableGroundShadow: boolean;
  46993. /**
  46994. * Helps preventing the shadow to be fully black on the ground.
  46995. * 0.5 by default.
  46996. */
  46997. groundShadowLevel: number;
  46998. /**
  46999. * Creates a mirror texture attach to the ground.
  47000. * false by default.
  47001. */
  47002. enableGroundMirror: boolean;
  47003. /**
  47004. * Specifies the ground mirror size ratio.
  47005. * 0.3 by default as the default kernel is 64.
  47006. */
  47007. groundMirrorSizeRatio: number;
  47008. /**
  47009. * Specifies the ground mirror blur kernel size.
  47010. * 64 by default.
  47011. */
  47012. groundMirrorBlurKernel: number;
  47013. /**
  47014. * Specifies the ground mirror visibility amount.
  47015. * 1 by default
  47016. */
  47017. groundMirrorAmount: number;
  47018. /**
  47019. * Specifies the ground mirror reflectance weight.
  47020. * This uses the standard weight of the background material to setup the fresnel effect
  47021. * of the mirror.
  47022. * 1 by default.
  47023. */
  47024. groundMirrorFresnelWeight: number;
  47025. /**
  47026. * Specifies the ground mirror Falloff distance.
  47027. * This can helps reducing the size of the reflection.
  47028. * 0 by Default.
  47029. */
  47030. groundMirrorFallOffDistance: number;
  47031. /**
  47032. * Specifies the ground mirror texture type.
  47033. * Unsigned Int by Default.
  47034. */
  47035. groundMirrorTextureType: number;
  47036. /**
  47037. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  47038. * the shown objects.
  47039. */
  47040. groundYBias: number;
  47041. /**
  47042. * Specifies wether or not to create a skybox.
  47043. * True by default.
  47044. */
  47045. createSkybox: boolean;
  47046. /**
  47047. * Specifies the skybox size.
  47048. * 20 by default.
  47049. */
  47050. skyboxSize: number;
  47051. /**
  47052. * The texture used on the skybox for the main color.
  47053. * Comes from the BabylonJS CDN by default.
  47054. *
  47055. * Remarks: Can be either a texture or a url.
  47056. */
  47057. skyboxTexture: string | BaseTexture;
  47058. /**
  47059. * The color mixed in the skybox texture by default.
  47060. * BabylonJS clearColor by default.
  47061. */
  47062. skyboxColor: Color3;
  47063. /**
  47064. * The background rotation around the Y axis of the scene.
  47065. * This helps aligning the key lights of your scene with the background.
  47066. * 0 by default.
  47067. */
  47068. backgroundYRotation: number;
  47069. /**
  47070. * Compute automatically the size of the elements to best fit with the scene.
  47071. */
  47072. sizeAuto: boolean;
  47073. /**
  47074. * Default position of the rootMesh if autoSize is not true.
  47075. */
  47076. rootPosition: Vector3;
  47077. /**
  47078. * Sets up the image processing in the scene.
  47079. * true by default.
  47080. */
  47081. setupImageProcessing: boolean;
  47082. /**
  47083. * The texture used as your environment texture in the scene.
  47084. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  47085. *
  47086. * Remarks: Can be either a texture or a url.
  47087. */
  47088. environmentTexture: string | BaseTexture;
  47089. /**
  47090. * The value of the exposure to apply to the scene.
  47091. * 0.6 by default if setupImageProcessing is true.
  47092. */
  47093. cameraExposure: number;
  47094. /**
  47095. * The value of the contrast to apply to the scene.
  47096. * 1.6 by default if setupImageProcessing is true.
  47097. */
  47098. cameraContrast: number;
  47099. /**
  47100. * Specifies wether or not tonemapping should be enabled in the scene.
  47101. * true by default if setupImageProcessing is true.
  47102. */
  47103. toneMappingEnabled: boolean;
  47104. }
  47105. /**
  47106. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  47107. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  47108. * It also helps with the default setup of your imageProcessing configuration.
  47109. */
  47110. export class EnvironmentHelper {
  47111. /**
  47112. * Default ground texture URL.
  47113. */
  47114. private static _groundTextureCDNUrl;
  47115. /**
  47116. * Default skybox texture URL.
  47117. */
  47118. private static _skyboxTextureCDNUrl;
  47119. /**
  47120. * Default environment texture URL.
  47121. */
  47122. private static _environmentTextureCDNUrl;
  47123. /**
  47124. * Creates the default options for the helper.
  47125. */
  47126. private static _getDefaultOptions;
  47127. private _rootMesh;
  47128. /**
  47129. * Gets the root mesh created by the helper.
  47130. */
  47131. readonly rootMesh: Mesh;
  47132. private _skybox;
  47133. /**
  47134. * Gets the skybox created by the helper.
  47135. */
  47136. readonly skybox: Nullable<Mesh>;
  47137. private _skyboxTexture;
  47138. /**
  47139. * Gets the skybox texture created by the helper.
  47140. */
  47141. readonly skyboxTexture: Nullable<BaseTexture>;
  47142. private _skyboxMaterial;
  47143. /**
  47144. * Gets the skybox material created by the helper.
  47145. */
  47146. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  47147. private _ground;
  47148. /**
  47149. * Gets the ground mesh created by the helper.
  47150. */
  47151. readonly ground: Nullable<Mesh>;
  47152. private _groundTexture;
  47153. /**
  47154. * Gets the ground texture created by the helper.
  47155. */
  47156. readonly groundTexture: Nullable<BaseTexture>;
  47157. private _groundMirror;
  47158. /**
  47159. * Gets the ground mirror created by the helper.
  47160. */
  47161. readonly groundMirror: Nullable<MirrorTexture>;
  47162. /**
  47163. * Gets the ground mirror render list to helps pushing the meshes
  47164. * you wish in the ground reflection.
  47165. */
  47166. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  47167. private _groundMaterial;
  47168. /**
  47169. * Gets the ground material created by the helper.
  47170. */
  47171. readonly groundMaterial: Nullable<BackgroundMaterial>;
  47172. /**
  47173. * Stores the creation options.
  47174. */
  47175. private readonly _scene;
  47176. private _options;
  47177. /**
  47178. * This observable will be notified with any error during the creation of the environment,
  47179. * mainly texture creation errors.
  47180. */
  47181. onErrorObservable: Observable<{
  47182. message?: string;
  47183. exception?: any;
  47184. }>;
  47185. /**
  47186. * constructor
  47187. * @param options Defines the options we want to customize the helper
  47188. * @param scene The scene to add the material to
  47189. */
  47190. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  47191. /**
  47192. * Updates the background according to the new options
  47193. * @param options
  47194. */
  47195. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  47196. /**
  47197. * Sets the primary color of all the available elements.
  47198. * @param color the main color to affect to the ground and the background
  47199. */
  47200. setMainColor(color: Color3): void;
  47201. /**
  47202. * Setup the image processing according to the specified options.
  47203. */
  47204. private _setupImageProcessing;
  47205. /**
  47206. * Setup the environment texture according to the specified options.
  47207. */
  47208. private _setupEnvironmentTexture;
  47209. /**
  47210. * Setup the background according to the specified options.
  47211. */
  47212. private _setupBackground;
  47213. /**
  47214. * Get the scene sizes according to the setup.
  47215. */
  47216. private _getSceneSize;
  47217. /**
  47218. * Setup the ground according to the specified options.
  47219. */
  47220. private _setupGround;
  47221. /**
  47222. * Setup the ground material according to the specified options.
  47223. */
  47224. private _setupGroundMaterial;
  47225. /**
  47226. * Setup the ground diffuse texture according to the specified options.
  47227. */
  47228. private _setupGroundDiffuseTexture;
  47229. /**
  47230. * Setup the ground mirror texture according to the specified options.
  47231. */
  47232. private _setupGroundMirrorTexture;
  47233. /**
  47234. * Setup the ground to receive the mirror texture.
  47235. */
  47236. private _setupMirrorInGroundMaterial;
  47237. /**
  47238. * Setup the skybox according to the specified options.
  47239. */
  47240. private _setupSkybox;
  47241. /**
  47242. * Setup the skybox material according to the specified options.
  47243. */
  47244. private _setupSkyboxMaterial;
  47245. /**
  47246. * Setup the skybox reflection texture according to the specified options.
  47247. */
  47248. private _setupSkyboxReflectionTexture;
  47249. private _errorHandler;
  47250. /**
  47251. * Dispose all the elements created by the Helper.
  47252. */
  47253. dispose(): void;
  47254. }
  47255. }
  47256. declare module "babylonjs/Helpers/photoDome" {
  47257. import { Observable } from "babylonjs/Misc/observable";
  47258. import { Nullable } from "babylonjs/types";
  47259. import { Scene } from "babylonjs/scene";
  47260. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47261. import { Mesh } from "babylonjs/Meshes/mesh";
  47262. import { Texture } from "babylonjs/Materials/Textures/texture";
  47263. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  47264. import "babylonjs/Meshes/Builders/sphereBuilder";
  47265. /**
  47266. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  47267. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  47268. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  47269. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  47270. */
  47271. export class PhotoDome extends TransformNode {
  47272. /**
  47273. * Define the image as a Monoscopic panoramic 360 image.
  47274. */
  47275. static readonly MODE_MONOSCOPIC: number;
  47276. /**
  47277. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  47278. */
  47279. static readonly MODE_TOPBOTTOM: number;
  47280. /**
  47281. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  47282. */
  47283. static readonly MODE_SIDEBYSIDE: number;
  47284. private _useDirectMapping;
  47285. /**
  47286. * The texture being displayed on the sphere
  47287. */
  47288. protected _photoTexture: Texture;
  47289. /**
  47290. * Gets or sets the texture being displayed on the sphere
  47291. */
  47292. photoTexture: Texture;
  47293. /**
  47294. * Observable raised when an error occured while loading the 360 image
  47295. */
  47296. onLoadErrorObservable: Observable<string>;
  47297. /**
  47298. * The skybox material
  47299. */
  47300. protected _material: BackgroundMaterial;
  47301. /**
  47302. * The surface used for the skybox
  47303. */
  47304. protected _mesh: Mesh;
  47305. /**
  47306. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47307. * Also see the options.resolution property.
  47308. */
  47309. fovMultiplier: number;
  47310. private _imageMode;
  47311. /**
  47312. * Gets or set the current video mode for the video. It can be:
  47313. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  47314. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  47315. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  47316. */
  47317. imageMode: number;
  47318. /**
  47319. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  47320. * @param name Element's name, child elements will append suffixes for their own names.
  47321. * @param urlsOfPhoto defines the url of the photo to display
  47322. * @param options defines an object containing optional or exposed sub element properties
  47323. * @param onError defines a callback called when an error occured while loading the texture
  47324. */
  47325. constructor(name: string, urlOfPhoto: string, options: {
  47326. resolution?: number;
  47327. size?: number;
  47328. useDirectMapping?: boolean;
  47329. faceForward?: boolean;
  47330. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  47331. private _onBeforeCameraRenderObserver;
  47332. private _changeImageMode;
  47333. /**
  47334. * Releases resources associated with this node.
  47335. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47336. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47337. */
  47338. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  47339. }
  47340. }
  47341. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  47342. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47343. /** @hidden */
  47344. export var rgbdDecodePixelShader: {
  47345. name: string;
  47346. shader: string;
  47347. };
  47348. }
  47349. declare module "babylonjs/Misc/brdfTextureTools" {
  47350. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47351. import { Scene } from "babylonjs/scene";
  47352. import "babylonjs/Shaders/rgbdDecode.fragment";
  47353. /**
  47354. * Class used to host texture specific utilities
  47355. */
  47356. export class BRDFTextureTools {
  47357. /**
  47358. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  47359. * @param texture the texture to expand.
  47360. */
  47361. private static _ExpandDefaultBRDFTexture;
  47362. /**
  47363. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  47364. * @param scene defines the hosting scene
  47365. * @returns the environment BRDF texture
  47366. */
  47367. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  47368. private static _environmentBRDFBase64Texture;
  47369. }
  47370. }
  47371. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  47372. import { Nullable } from "babylonjs/types";
  47373. import { Color3 } from "babylonjs/Maths/math.color";
  47374. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47375. import { EffectFallbacks } from "babylonjs/Materials/effect";
  47376. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47377. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47378. import { Engine } from "babylonjs/Engines/engine";
  47379. import { Scene } from "babylonjs/scene";
  47380. /**
  47381. * @hidden
  47382. */
  47383. export interface IMaterialClearCoatDefines {
  47384. CLEARCOAT: boolean;
  47385. CLEARCOAT_DEFAULTIOR: boolean;
  47386. CLEARCOAT_TEXTURE: boolean;
  47387. CLEARCOAT_TEXTUREDIRECTUV: number;
  47388. CLEARCOAT_BUMP: boolean;
  47389. CLEARCOAT_BUMPDIRECTUV: number;
  47390. CLEARCOAT_TINT: boolean;
  47391. CLEARCOAT_TINT_TEXTURE: boolean;
  47392. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47393. /** @hidden */
  47394. _areTexturesDirty: boolean;
  47395. }
  47396. /**
  47397. * Define the code related to the clear coat parameters of the pbr material.
  47398. */
  47399. export class PBRClearCoatConfiguration {
  47400. /**
  47401. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47402. * The default fits with a polyurethane material.
  47403. */
  47404. private static readonly _DefaultIndexOfRefraction;
  47405. private _isEnabled;
  47406. /**
  47407. * Defines if the clear coat is enabled in the material.
  47408. */
  47409. isEnabled: boolean;
  47410. /**
  47411. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  47412. */
  47413. intensity: number;
  47414. /**
  47415. * Defines the clear coat layer roughness.
  47416. */
  47417. roughness: number;
  47418. private _indexOfRefraction;
  47419. /**
  47420. * Defines the index of refraction of the clear coat.
  47421. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47422. * The default fits with a polyurethane material.
  47423. * Changing the default value is more performance intensive.
  47424. */
  47425. indexOfRefraction: number;
  47426. private _texture;
  47427. /**
  47428. * Stores the clear coat values in a texture.
  47429. */
  47430. texture: Nullable<BaseTexture>;
  47431. private _bumpTexture;
  47432. /**
  47433. * Define the clear coat specific bump texture.
  47434. */
  47435. bumpTexture: Nullable<BaseTexture>;
  47436. private _isTintEnabled;
  47437. /**
  47438. * Defines if the clear coat tint is enabled in the material.
  47439. */
  47440. isTintEnabled: boolean;
  47441. /**
  47442. * Defines the clear coat tint of the material.
  47443. * This is only use if tint is enabled
  47444. */
  47445. tintColor: Color3;
  47446. /**
  47447. * Defines the distance at which the tint color should be found in the
  47448. * clear coat media.
  47449. * This is only use if tint is enabled
  47450. */
  47451. tintColorAtDistance: number;
  47452. /**
  47453. * Defines the clear coat layer thickness.
  47454. * This is only use if tint is enabled
  47455. */
  47456. tintThickness: number;
  47457. private _tintTexture;
  47458. /**
  47459. * Stores the clear tint values in a texture.
  47460. * rgb is tint
  47461. * a is a thickness factor
  47462. */
  47463. tintTexture: Nullable<BaseTexture>;
  47464. /** @hidden */
  47465. private _internalMarkAllSubMeshesAsTexturesDirty;
  47466. /** @hidden */
  47467. _markAllSubMeshesAsTexturesDirty(): void;
  47468. /**
  47469. * Instantiate a new istance of clear coat configuration.
  47470. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47471. */
  47472. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47473. /**
  47474. * Gets wehter the submesh is ready to be used or not.
  47475. * @param defines the list of "defines" to update.
  47476. * @param scene defines the scene the material belongs to.
  47477. * @param engine defines the engine the material belongs to.
  47478. * @param disableBumpMap defines wether the material disables bump or not.
  47479. * @returns - boolean indicating that the submesh is ready or not.
  47480. */
  47481. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  47482. /**
  47483. * Checks to see if a texture is used in the material.
  47484. * @param defines the list of "defines" to update.
  47485. * @param scene defines the scene to the material belongs to.
  47486. */
  47487. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  47488. /**
  47489. * Binds the material data.
  47490. * @param uniformBuffer defines the Uniform buffer to fill in.
  47491. * @param scene defines the scene the material belongs to.
  47492. * @param engine defines the engine the material belongs to.
  47493. * @param disableBumpMap defines wether the material disables bump or not.
  47494. * @param isFrozen defines wether the material is frozen or not.
  47495. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47496. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47497. */
  47498. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  47499. /**
  47500. * Checks to see if a texture is used in the material.
  47501. * @param texture - Base texture to use.
  47502. * @returns - Boolean specifying if a texture is used in the material.
  47503. */
  47504. hasTexture(texture: BaseTexture): boolean;
  47505. /**
  47506. * Returns an array of the actively used textures.
  47507. * @param activeTextures Array of BaseTextures
  47508. */
  47509. getActiveTextures(activeTextures: BaseTexture[]): void;
  47510. /**
  47511. * Returns the animatable textures.
  47512. * @param animatables Array of animatable textures.
  47513. */
  47514. getAnimatables(animatables: IAnimatable[]): void;
  47515. /**
  47516. * Disposes the resources of the material.
  47517. * @param forceDisposeTextures - Forces the disposal of all textures.
  47518. */
  47519. dispose(forceDisposeTextures?: boolean): void;
  47520. /**
  47521. * Get the current class name of the texture useful for serialization or dynamic coding.
  47522. * @returns "PBRClearCoatConfiguration"
  47523. */
  47524. getClassName(): string;
  47525. /**
  47526. * Add fallbacks to the effect fallbacks list.
  47527. * @param defines defines the Base texture to use.
  47528. * @param fallbacks defines the current fallback list.
  47529. * @param currentRank defines the current fallback rank.
  47530. * @returns the new fallback rank.
  47531. */
  47532. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47533. /**
  47534. * Add the required uniforms to the current list.
  47535. * @param uniforms defines the current uniform list.
  47536. */
  47537. static AddUniforms(uniforms: string[]): void;
  47538. /**
  47539. * Add the required samplers to the current list.
  47540. * @param samplers defines the current sampler list.
  47541. */
  47542. static AddSamplers(samplers: string[]): void;
  47543. /**
  47544. * Add the required uniforms to the current buffer.
  47545. * @param uniformBuffer defines the current uniform buffer.
  47546. */
  47547. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47548. /**
  47549. * Makes a duplicate of the current configuration into another one.
  47550. * @param clearCoatConfiguration define the config where to copy the info
  47551. */
  47552. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  47553. /**
  47554. * Serializes this clear coat configuration.
  47555. * @returns - An object with the serialized config.
  47556. */
  47557. serialize(): any;
  47558. /**
  47559. * Parses a anisotropy Configuration from a serialized object.
  47560. * @param source - Serialized object.
  47561. * @param scene Defines the scene we are parsing for
  47562. * @param rootUrl Defines the rootUrl to load from
  47563. */
  47564. parse(source: any, scene: Scene, rootUrl: string): void;
  47565. }
  47566. }
  47567. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  47568. import { EffectFallbacks } from "babylonjs/Materials/effect";
  47569. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47570. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47571. import { Vector2 } from "babylonjs/Maths/math.vector";
  47572. import { Scene } from "babylonjs/scene";
  47573. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47574. import { Nullable } from "babylonjs/types";
  47575. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47576. /**
  47577. * @hidden
  47578. */
  47579. export interface IMaterialAnisotropicDefines {
  47580. ANISOTROPIC: boolean;
  47581. ANISOTROPIC_TEXTURE: boolean;
  47582. ANISOTROPIC_TEXTUREDIRECTUV: number;
  47583. MAINUV1: boolean;
  47584. _areTexturesDirty: boolean;
  47585. _needUVs: boolean;
  47586. }
  47587. /**
  47588. * Define the code related to the anisotropic parameters of the pbr material.
  47589. */
  47590. export class PBRAnisotropicConfiguration {
  47591. private _isEnabled;
  47592. /**
  47593. * Defines if the anisotropy is enabled in the material.
  47594. */
  47595. isEnabled: boolean;
  47596. /**
  47597. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  47598. */
  47599. intensity: number;
  47600. /**
  47601. * Defines if the effect is along the tangents, bitangents or in between.
  47602. * By default, the effect is "strectching" the highlights along the tangents.
  47603. */
  47604. direction: Vector2;
  47605. private _texture;
  47606. /**
  47607. * Stores the anisotropy values in a texture.
  47608. * rg is direction (like normal from -1 to 1)
  47609. * b is a intensity
  47610. */
  47611. texture: Nullable<BaseTexture>;
  47612. /** @hidden */
  47613. private _internalMarkAllSubMeshesAsTexturesDirty;
  47614. /** @hidden */
  47615. _markAllSubMeshesAsTexturesDirty(): void;
  47616. /**
  47617. * Instantiate a new istance of anisotropy configuration.
  47618. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47619. */
  47620. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47621. /**
  47622. * Specifies that the submesh is ready to be used.
  47623. * @param defines the list of "defines" to update.
  47624. * @param scene defines the scene the material belongs to.
  47625. * @returns - boolean indicating that the submesh is ready or not.
  47626. */
  47627. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  47628. /**
  47629. * Checks to see if a texture is used in the material.
  47630. * @param defines the list of "defines" to update.
  47631. * @param mesh the mesh we are preparing the defines for.
  47632. * @param scene defines the scene the material belongs to.
  47633. */
  47634. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  47635. /**
  47636. * Binds the material data.
  47637. * @param uniformBuffer defines the Uniform buffer to fill in.
  47638. * @param scene defines the scene the material belongs to.
  47639. * @param isFrozen defines wether the material is frozen or not.
  47640. */
  47641. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  47642. /**
  47643. * Checks to see if a texture is used in the material.
  47644. * @param texture - Base texture to use.
  47645. * @returns - Boolean specifying if a texture is used in the material.
  47646. */
  47647. hasTexture(texture: BaseTexture): boolean;
  47648. /**
  47649. * Returns an array of the actively used textures.
  47650. * @param activeTextures Array of BaseTextures
  47651. */
  47652. getActiveTextures(activeTextures: BaseTexture[]): void;
  47653. /**
  47654. * Returns the animatable textures.
  47655. * @param animatables Array of animatable textures.
  47656. */
  47657. getAnimatables(animatables: IAnimatable[]): void;
  47658. /**
  47659. * Disposes the resources of the material.
  47660. * @param forceDisposeTextures - Forces the disposal of all textures.
  47661. */
  47662. dispose(forceDisposeTextures?: boolean): void;
  47663. /**
  47664. * Get the current class name of the texture useful for serialization or dynamic coding.
  47665. * @returns "PBRAnisotropicConfiguration"
  47666. */
  47667. getClassName(): string;
  47668. /**
  47669. * Add fallbacks to the effect fallbacks list.
  47670. * @param defines defines the Base texture to use.
  47671. * @param fallbacks defines the current fallback list.
  47672. * @param currentRank defines the current fallback rank.
  47673. * @returns the new fallback rank.
  47674. */
  47675. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47676. /**
  47677. * Add the required uniforms to the current list.
  47678. * @param uniforms defines the current uniform list.
  47679. */
  47680. static AddUniforms(uniforms: string[]): void;
  47681. /**
  47682. * Add the required uniforms to the current buffer.
  47683. * @param uniformBuffer defines the current uniform buffer.
  47684. */
  47685. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47686. /**
  47687. * Add the required samplers to the current list.
  47688. * @param samplers defines the current sampler list.
  47689. */
  47690. static AddSamplers(samplers: string[]): void;
  47691. /**
  47692. * Makes a duplicate of the current configuration into another one.
  47693. * @param anisotropicConfiguration define the config where to copy the info
  47694. */
  47695. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  47696. /**
  47697. * Serializes this anisotropy configuration.
  47698. * @returns - An object with the serialized config.
  47699. */
  47700. serialize(): any;
  47701. /**
  47702. * Parses a anisotropy Configuration from a serialized object.
  47703. * @param source - Serialized object.
  47704. * @param scene Defines the scene we are parsing for
  47705. * @param rootUrl Defines the rootUrl to load from
  47706. */
  47707. parse(source: any, scene: Scene, rootUrl: string): void;
  47708. }
  47709. }
  47710. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  47711. import { Scene } from "babylonjs/scene";
  47712. /**
  47713. * @hidden
  47714. */
  47715. export interface IMaterialBRDFDefines {
  47716. BRDF_V_HEIGHT_CORRELATED: boolean;
  47717. MS_BRDF_ENERGY_CONSERVATION: boolean;
  47718. SPHERICAL_HARMONICS: boolean;
  47719. /** @hidden */
  47720. _areMiscDirty: boolean;
  47721. }
  47722. /**
  47723. * Define the code related to the BRDF parameters of the pbr material.
  47724. */
  47725. export class PBRBRDFConfiguration {
  47726. /**
  47727. * Default value used for the energy conservation.
  47728. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  47729. */
  47730. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  47731. /**
  47732. * Default value used for the Smith Visibility Height Correlated mode.
  47733. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  47734. */
  47735. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  47736. /**
  47737. * Default value used for the IBL diffuse part.
  47738. * This can help switching back to the polynomials mode globally which is a tiny bit
  47739. * less GPU intensive at the drawback of a lower quality.
  47740. */
  47741. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  47742. private _useEnergyConservation;
  47743. /**
  47744. * Defines if the material uses energy conservation.
  47745. */
  47746. useEnergyConservation: boolean;
  47747. private _useSmithVisibilityHeightCorrelated;
  47748. /**
  47749. * LEGACY Mode set to false
  47750. * Defines if the material uses height smith correlated visibility term.
  47751. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  47752. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  47753. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  47754. * Not relying on height correlated will also disable energy conservation.
  47755. */
  47756. useSmithVisibilityHeightCorrelated: boolean;
  47757. private _useSphericalHarmonics;
  47758. /**
  47759. * LEGACY Mode set to false
  47760. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  47761. * diffuse part of the IBL.
  47762. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  47763. * to the ground truth.
  47764. */
  47765. useSphericalHarmonics: boolean;
  47766. /** @hidden */
  47767. private _internalMarkAllSubMeshesAsMiscDirty;
  47768. /** @hidden */
  47769. _markAllSubMeshesAsMiscDirty(): void;
  47770. /**
  47771. * Instantiate a new istance of clear coat configuration.
  47772. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  47773. */
  47774. constructor(markAllSubMeshesAsMiscDirty: () => void);
  47775. /**
  47776. * Checks to see if a texture is used in the material.
  47777. * @param defines the list of "defines" to update.
  47778. */
  47779. prepareDefines(defines: IMaterialBRDFDefines): void;
  47780. /**
  47781. * Get the current class name of the texture useful for serialization or dynamic coding.
  47782. * @returns "PBRClearCoatConfiguration"
  47783. */
  47784. getClassName(): string;
  47785. /**
  47786. * Makes a duplicate of the current configuration into another one.
  47787. * @param brdfConfiguration define the config where to copy the info
  47788. */
  47789. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  47790. /**
  47791. * Serializes this BRDF configuration.
  47792. * @returns - An object with the serialized config.
  47793. */
  47794. serialize(): any;
  47795. /**
  47796. * Parses a anisotropy Configuration from a serialized object.
  47797. * @param source - Serialized object.
  47798. * @param scene Defines the scene we are parsing for
  47799. * @param rootUrl Defines the rootUrl to load from
  47800. */
  47801. parse(source: any, scene: Scene, rootUrl: string): void;
  47802. }
  47803. }
  47804. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  47805. import { EffectFallbacks } from "babylonjs/Materials/effect";
  47806. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47807. import { Color3 } from "babylonjs/Maths/math.color";
  47808. import { Scene } from "babylonjs/scene";
  47809. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47810. import { Nullable } from "babylonjs/types";
  47811. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47812. /**
  47813. * @hidden
  47814. */
  47815. export interface IMaterialSheenDefines {
  47816. SHEEN: boolean;
  47817. SHEEN_TEXTURE: boolean;
  47818. SHEEN_TEXTUREDIRECTUV: number;
  47819. SHEEN_LINKWITHALBEDO: boolean;
  47820. /** @hidden */
  47821. _areTexturesDirty: boolean;
  47822. }
  47823. /**
  47824. * Define the code related to the Sheen parameters of the pbr material.
  47825. */
  47826. export class PBRSheenConfiguration {
  47827. private _isEnabled;
  47828. /**
  47829. * Defines if the material uses sheen.
  47830. */
  47831. isEnabled: boolean;
  47832. private _linkSheenWithAlbedo;
  47833. /**
  47834. * Defines if the sheen is linked to the sheen color.
  47835. */
  47836. linkSheenWithAlbedo: boolean;
  47837. /**
  47838. * Defines the sheen intensity.
  47839. */
  47840. intensity: number;
  47841. /**
  47842. * Defines the sheen color.
  47843. */
  47844. color: Color3;
  47845. private _texture;
  47846. /**
  47847. * Stores the sheen tint values in a texture.
  47848. * rgb is tint
  47849. * a is a intensity
  47850. */
  47851. texture: Nullable<BaseTexture>;
  47852. /** @hidden */
  47853. private _internalMarkAllSubMeshesAsTexturesDirty;
  47854. /** @hidden */
  47855. _markAllSubMeshesAsTexturesDirty(): void;
  47856. /**
  47857. * Instantiate a new istance of clear coat configuration.
  47858. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47859. */
  47860. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47861. /**
  47862. * Specifies that the submesh is ready to be used.
  47863. * @param defines the list of "defines" to update.
  47864. * @param scene defines the scene the material belongs to.
  47865. * @returns - boolean indicating that the submesh is ready or not.
  47866. */
  47867. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  47868. /**
  47869. * Checks to see if a texture is used in the material.
  47870. * @param defines the list of "defines" to update.
  47871. * @param scene defines the scene the material belongs to.
  47872. */
  47873. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  47874. /**
  47875. * Binds the material data.
  47876. * @param uniformBuffer defines the Uniform buffer to fill in.
  47877. * @param scene defines the scene the material belongs to.
  47878. * @param isFrozen defines wether the material is frozen or not.
  47879. */
  47880. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  47881. /**
  47882. * Checks to see if a texture is used in the material.
  47883. * @param texture - Base texture to use.
  47884. * @returns - Boolean specifying if a texture is used in the material.
  47885. */
  47886. hasTexture(texture: BaseTexture): boolean;
  47887. /**
  47888. * Returns an array of the actively used textures.
  47889. * @param activeTextures Array of BaseTextures
  47890. */
  47891. getActiveTextures(activeTextures: BaseTexture[]): void;
  47892. /**
  47893. * Returns the animatable textures.
  47894. * @param animatables Array of animatable textures.
  47895. */
  47896. getAnimatables(animatables: IAnimatable[]): void;
  47897. /**
  47898. * Disposes the resources of the material.
  47899. * @param forceDisposeTextures - Forces the disposal of all textures.
  47900. */
  47901. dispose(forceDisposeTextures?: boolean): void;
  47902. /**
  47903. * Get the current class name of the texture useful for serialization or dynamic coding.
  47904. * @returns "PBRSheenConfiguration"
  47905. */
  47906. getClassName(): string;
  47907. /**
  47908. * Add fallbacks to the effect fallbacks list.
  47909. * @param defines defines the Base texture to use.
  47910. * @param fallbacks defines the current fallback list.
  47911. * @param currentRank defines the current fallback rank.
  47912. * @returns the new fallback rank.
  47913. */
  47914. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47915. /**
  47916. * Add the required uniforms to the current list.
  47917. * @param uniforms defines the current uniform list.
  47918. */
  47919. static AddUniforms(uniforms: string[]): void;
  47920. /**
  47921. * Add the required uniforms to the current buffer.
  47922. * @param uniformBuffer defines the current uniform buffer.
  47923. */
  47924. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47925. /**
  47926. * Add the required samplers to the current list.
  47927. * @param samplers defines the current sampler list.
  47928. */
  47929. static AddSamplers(samplers: string[]): void;
  47930. /**
  47931. * Makes a duplicate of the current configuration into another one.
  47932. * @param sheenConfiguration define the config where to copy the info
  47933. */
  47934. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  47935. /**
  47936. * Serializes this BRDF configuration.
  47937. * @returns - An object with the serialized config.
  47938. */
  47939. serialize(): any;
  47940. /**
  47941. * Parses a anisotropy Configuration from a serialized object.
  47942. * @param source - Serialized object.
  47943. * @param scene Defines the scene we are parsing for
  47944. * @param rootUrl Defines the rootUrl to load from
  47945. */
  47946. parse(source: any, scene: Scene, rootUrl: string): void;
  47947. }
  47948. }
  47949. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  47950. import { Nullable } from "babylonjs/types";
  47951. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47952. import { Color3 } from "babylonjs/Maths/math.color";
  47953. import { SmartArray } from "babylonjs/Misc/smartArray";
  47954. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47955. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47956. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  47957. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47958. import { Engine } from "babylonjs/Engines/engine";
  47959. import { Scene } from "babylonjs/scene";
  47960. /**
  47961. * @hidden
  47962. */
  47963. export interface IMaterialSubSurfaceDefines {
  47964. SUBSURFACE: boolean;
  47965. SS_REFRACTION: boolean;
  47966. SS_TRANSLUCENCY: boolean;
  47967. SS_SCATERRING: boolean;
  47968. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47969. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47970. SS_REFRACTIONMAP_3D: boolean;
  47971. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47972. SS_LODINREFRACTIONALPHA: boolean;
  47973. SS_GAMMAREFRACTION: boolean;
  47974. SS_RGBDREFRACTION: boolean;
  47975. SS_LINEARSPECULARREFRACTION: boolean;
  47976. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47977. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47978. /** @hidden */
  47979. _areTexturesDirty: boolean;
  47980. }
  47981. /**
  47982. * Define the code related to the sub surface parameters of the pbr material.
  47983. */
  47984. export class PBRSubSurfaceConfiguration {
  47985. private _isRefractionEnabled;
  47986. /**
  47987. * Defines if the refraction is enabled in the material.
  47988. */
  47989. isRefractionEnabled: boolean;
  47990. private _isTranslucencyEnabled;
  47991. /**
  47992. * Defines if the translucency is enabled in the material.
  47993. */
  47994. isTranslucencyEnabled: boolean;
  47995. private _isScatteringEnabled;
  47996. /**
  47997. * Defines the refraction intensity of the material.
  47998. * The refraction when enabled replaces the Diffuse part of the material.
  47999. * The intensity helps transitionning between diffuse and refraction.
  48000. */
  48001. refractionIntensity: number;
  48002. /**
  48003. * Defines the translucency intensity of the material.
  48004. * When translucency has been enabled, this defines how much of the "translucency"
  48005. * is addded to the diffuse part of the material.
  48006. */
  48007. translucencyIntensity: number;
  48008. /**
  48009. * Defines the scattering intensity of the material.
  48010. * When scattering has been enabled, this defines how much of the "scattered light"
  48011. * is addded to the diffuse part of the material.
  48012. */
  48013. scatteringIntensity: number;
  48014. private _thicknessTexture;
  48015. /**
  48016. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  48017. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  48018. * 0 would mean minimumThickness
  48019. * 1 would mean maximumThickness
  48020. * The other channels might be use as a mask to vary the different effects intensity.
  48021. */
  48022. thicknessTexture: Nullable<BaseTexture>;
  48023. private _refractionTexture;
  48024. /**
  48025. * Defines the texture to use for refraction.
  48026. */
  48027. refractionTexture: Nullable<BaseTexture>;
  48028. private _indexOfRefraction;
  48029. /**
  48030. * Defines the index of refraction used in the material.
  48031. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  48032. */
  48033. indexOfRefraction: number;
  48034. private _invertRefractionY;
  48035. /**
  48036. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48037. */
  48038. invertRefractionY: boolean;
  48039. private _linkRefractionWithTransparency;
  48040. /**
  48041. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48042. * Materials half opaque for instance using refraction could benefit from this control.
  48043. */
  48044. linkRefractionWithTransparency: boolean;
  48045. /**
  48046. * Defines the minimum thickness stored in the thickness map.
  48047. * If no thickness map is defined, this value will be used to simulate thickness.
  48048. */
  48049. minimumThickness: number;
  48050. /**
  48051. * Defines the maximum thickness stored in the thickness map.
  48052. */
  48053. maximumThickness: number;
  48054. /**
  48055. * Defines the volume tint of the material.
  48056. * This is used for both translucency and scattering.
  48057. */
  48058. tintColor: Color3;
  48059. /**
  48060. * Defines the distance at which the tint color should be found in the media.
  48061. * This is used for refraction only.
  48062. */
  48063. tintColorAtDistance: number;
  48064. /**
  48065. * Defines how far each channel transmit through the media.
  48066. * It is defined as a color to simplify it selection.
  48067. */
  48068. diffusionDistance: Color3;
  48069. private _useMaskFromThicknessTexture;
  48070. /**
  48071. * Stores the intensity of the different subsurface effects in the thickness texture.
  48072. * * the green channel is the translucency intensity.
  48073. * * the blue channel is the scattering intensity.
  48074. * * the alpha channel is the refraction intensity.
  48075. */
  48076. useMaskFromThicknessTexture: boolean;
  48077. /** @hidden */
  48078. private _internalMarkAllSubMeshesAsTexturesDirty;
  48079. /** @hidden */
  48080. _markAllSubMeshesAsTexturesDirty(): void;
  48081. /**
  48082. * Instantiate a new istance of sub surface configuration.
  48083. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48084. */
  48085. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48086. /**
  48087. * Gets wehter the submesh is ready to be used or not.
  48088. * @param defines the list of "defines" to update.
  48089. * @param scene defines the scene the material belongs to.
  48090. * @returns - boolean indicating that the submesh is ready or not.
  48091. */
  48092. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  48093. /**
  48094. * Checks to see if a texture is used in the material.
  48095. * @param defines the list of "defines" to update.
  48096. * @param scene defines the scene to the material belongs to.
  48097. */
  48098. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  48099. /**
  48100. * Binds the material data.
  48101. * @param uniformBuffer defines the Uniform buffer to fill in.
  48102. * @param scene defines the scene the material belongs to.
  48103. * @param engine defines the engine the material belongs to.
  48104. * @param isFrozen defines wether the material is frozen or not.
  48105. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  48106. */
  48107. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  48108. /**
  48109. * Unbinds the material from the mesh.
  48110. * @param activeEffect defines the effect that should be unbound from.
  48111. * @returns true if unbound, otherwise false
  48112. */
  48113. unbind(activeEffect: Effect): boolean;
  48114. /**
  48115. * Returns the texture used for refraction or null if none is used.
  48116. * @param scene defines the scene the material belongs to.
  48117. * @returns - Refraction texture if present. If no refraction texture and refraction
  48118. * is linked with transparency, returns environment texture. Otherwise, returns null.
  48119. */
  48120. private _getRefractionTexture;
  48121. /**
  48122. * Returns true if alpha blending should be disabled.
  48123. */
  48124. readonly disableAlphaBlending: boolean;
  48125. /**
  48126. * Fills the list of render target textures.
  48127. * @param renderTargets the list of render targets to update
  48128. */
  48129. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  48130. /**
  48131. * Checks to see if a texture is used in the material.
  48132. * @param texture - Base texture to use.
  48133. * @returns - Boolean specifying if a texture is used in the material.
  48134. */
  48135. hasTexture(texture: BaseTexture): boolean;
  48136. /**
  48137. * Gets a boolean indicating that current material needs to register RTT
  48138. * @returns true if this uses a render target otherwise false.
  48139. */
  48140. hasRenderTargetTextures(): boolean;
  48141. /**
  48142. * Returns an array of the actively used textures.
  48143. * @param activeTextures Array of BaseTextures
  48144. */
  48145. getActiveTextures(activeTextures: BaseTexture[]): void;
  48146. /**
  48147. * Returns the animatable textures.
  48148. * @param animatables Array of animatable textures.
  48149. */
  48150. getAnimatables(animatables: IAnimatable[]): void;
  48151. /**
  48152. * Disposes the resources of the material.
  48153. * @param forceDisposeTextures - Forces the disposal of all textures.
  48154. */
  48155. dispose(forceDisposeTextures?: boolean): void;
  48156. /**
  48157. * Get the current class name of the texture useful for serialization or dynamic coding.
  48158. * @returns "PBRSubSurfaceConfiguration"
  48159. */
  48160. getClassName(): string;
  48161. /**
  48162. * Add fallbacks to the effect fallbacks list.
  48163. * @param defines defines the Base texture to use.
  48164. * @param fallbacks defines the current fallback list.
  48165. * @param currentRank defines the current fallback rank.
  48166. * @returns the new fallback rank.
  48167. */
  48168. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48169. /**
  48170. * Add the required uniforms to the current list.
  48171. * @param uniforms defines the current uniform list.
  48172. */
  48173. static AddUniforms(uniforms: string[]): void;
  48174. /**
  48175. * Add the required samplers to the current list.
  48176. * @param samplers defines the current sampler list.
  48177. */
  48178. static AddSamplers(samplers: string[]): void;
  48179. /**
  48180. * Add the required uniforms to the current buffer.
  48181. * @param uniformBuffer defines the current uniform buffer.
  48182. */
  48183. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48184. /**
  48185. * Makes a duplicate of the current configuration into another one.
  48186. * @param configuration define the config where to copy the info
  48187. */
  48188. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  48189. /**
  48190. * Serializes this Sub Surface configuration.
  48191. * @returns - An object with the serialized config.
  48192. */
  48193. serialize(): any;
  48194. /**
  48195. * Parses a anisotropy Configuration from a serialized object.
  48196. * @param source - Serialized object.
  48197. * @param scene Defines the scene we are parsing for
  48198. * @param rootUrl Defines the rootUrl to load from
  48199. */
  48200. parse(source: any, scene: Scene, rootUrl: string): void;
  48201. }
  48202. }
  48203. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  48204. /** @hidden */
  48205. export var pbrFragmentDeclaration: {
  48206. name: string;
  48207. shader: string;
  48208. };
  48209. }
  48210. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  48211. /** @hidden */
  48212. export var pbrUboDeclaration: {
  48213. name: string;
  48214. shader: string;
  48215. };
  48216. }
  48217. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  48218. /** @hidden */
  48219. export var pbrFragmentExtraDeclaration: {
  48220. name: string;
  48221. shader: string;
  48222. };
  48223. }
  48224. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  48225. /** @hidden */
  48226. export var pbrFragmentSamplersDeclaration: {
  48227. name: string;
  48228. shader: string;
  48229. };
  48230. }
  48231. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  48232. /** @hidden */
  48233. export var pbrHelperFunctions: {
  48234. name: string;
  48235. shader: string;
  48236. };
  48237. }
  48238. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  48239. /** @hidden */
  48240. export var harmonicsFunctions: {
  48241. name: string;
  48242. shader: string;
  48243. };
  48244. }
  48245. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  48246. /** @hidden */
  48247. export var pbrDirectLightingSetupFunctions: {
  48248. name: string;
  48249. shader: string;
  48250. };
  48251. }
  48252. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  48253. /** @hidden */
  48254. export var pbrDirectLightingFalloffFunctions: {
  48255. name: string;
  48256. shader: string;
  48257. };
  48258. }
  48259. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  48260. /** @hidden */
  48261. export var pbrBRDFFunctions: {
  48262. name: string;
  48263. shader: string;
  48264. };
  48265. }
  48266. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  48267. /** @hidden */
  48268. export var pbrDirectLightingFunctions: {
  48269. name: string;
  48270. shader: string;
  48271. };
  48272. }
  48273. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  48274. /** @hidden */
  48275. export var pbrIBLFunctions: {
  48276. name: string;
  48277. shader: string;
  48278. };
  48279. }
  48280. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  48281. /** @hidden */
  48282. export var pbrDebug: {
  48283. name: string;
  48284. shader: string;
  48285. };
  48286. }
  48287. declare module "babylonjs/Shaders/pbr.fragment" {
  48288. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  48289. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  48290. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  48291. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48292. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48293. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  48294. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  48295. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  48296. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  48297. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  48298. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48299. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  48300. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  48301. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  48302. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  48303. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  48304. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  48305. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  48306. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  48307. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  48308. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  48309. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  48310. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  48311. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  48312. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  48313. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  48314. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  48315. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  48316. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  48317. /** @hidden */
  48318. export var pbrPixelShader: {
  48319. name: string;
  48320. shader: string;
  48321. };
  48322. }
  48323. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  48324. /** @hidden */
  48325. export var pbrVertexDeclaration: {
  48326. name: string;
  48327. shader: string;
  48328. };
  48329. }
  48330. declare module "babylonjs/Shaders/pbr.vertex" {
  48331. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  48332. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  48333. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48334. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48335. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48336. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  48337. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  48338. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  48339. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  48340. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48341. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48342. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  48343. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  48344. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  48345. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  48346. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48347. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48348. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  48349. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  48350. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  48351. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  48352. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  48353. /** @hidden */
  48354. export var pbrVertexShader: {
  48355. name: string;
  48356. shader: string;
  48357. };
  48358. }
  48359. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  48360. import { Nullable } from "babylonjs/types";
  48361. import { Scene } from "babylonjs/scene";
  48362. import { Matrix } from "babylonjs/Maths/math.vector";
  48363. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48364. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48365. import { Mesh } from "babylonjs/Meshes/mesh";
  48366. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  48367. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  48368. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  48369. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  48370. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  48371. import { Color3 } from "babylonjs/Maths/math.color";
  48372. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  48373. import { Material } from "babylonjs/Materials/material";
  48374. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  48375. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  48376. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48377. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48378. import "babylonjs/Shaders/pbr.fragment";
  48379. import "babylonjs/Shaders/pbr.vertex";
  48380. /**
  48381. * Manages the defines for the PBR Material.
  48382. * @hidden
  48383. */
  48384. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  48385. PBR: boolean;
  48386. MAINUV1: boolean;
  48387. MAINUV2: boolean;
  48388. UV1: boolean;
  48389. UV2: boolean;
  48390. ALBEDO: boolean;
  48391. ALBEDODIRECTUV: number;
  48392. VERTEXCOLOR: boolean;
  48393. AMBIENT: boolean;
  48394. AMBIENTDIRECTUV: number;
  48395. AMBIENTINGRAYSCALE: boolean;
  48396. OPACITY: boolean;
  48397. VERTEXALPHA: boolean;
  48398. OPACITYDIRECTUV: number;
  48399. OPACITYRGB: boolean;
  48400. ALPHATEST: boolean;
  48401. DEPTHPREPASS: boolean;
  48402. ALPHABLEND: boolean;
  48403. ALPHAFROMALBEDO: boolean;
  48404. ALPHATESTVALUE: string;
  48405. SPECULAROVERALPHA: boolean;
  48406. RADIANCEOVERALPHA: boolean;
  48407. ALPHAFRESNEL: boolean;
  48408. LINEARALPHAFRESNEL: boolean;
  48409. PREMULTIPLYALPHA: boolean;
  48410. EMISSIVE: boolean;
  48411. EMISSIVEDIRECTUV: number;
  48412. REFLECTIVITY: boolean;
  48413. REFLECTIVITYDIRECTUV: number;
  48414. SPECULARTERM: boolean;
  48415. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  48416. MICROSURFACEAUTOMATIC: boolean;
  48417. LODBASEDMICROSFURACE: boolean;
  48418. MICROSURFACEMAP: boolean;
  48419. MICROSURFACEMAPDIRECTUV: number;
  48420. METALLICWORKFLOW: boolean;
  48421. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  48422. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  48423. METALLNESSSTOREINMETALMAPBLUE: boolean;
  48424. AOSTOREINMETALMAPRED: boolean;
  48425. ENVIRONMENTBRDF: boolean;
  48426. ENVIRONMENTBRDF_RGBD: boolean;
  48427. NORMAL: boolean;
  48428. TANGENT: boolean;
  48429. BUMP: boolean;
  48430. BUMPDIRECTUV: number;
  48431. OBJECTSPACE_NORMALMAP: boolean;
  48432. PARALLAX: boolean;
  48433. PARALLAXOCCLUSION: boolean;
  48434. NORMALXYSCALE: boolean;
  48435. LIGHTMAP: boolean;
  48436. LIGHTMAPDIRECTUV: number;
  48437. USELIGHTMAPASSHADOWMAP: boolean;
  48438. GAMMALIGHTMAP: boolean;
  48439. REFLECTION: boolean;
  48440. REFLECTIONMAP_3D: boolean;
  48441. REFLECTIONMAP_SPHERICAL: boolean;
  48442. REFLECTIONMAP_PLANAR: boolean;
  48443. REFLECTIONMAP_CUBIC: boolean;
  48444. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  48445. REFLECTIONMAP_PROJECTION: boolean;
  48446. REFLECTIONMAP_SKYBOX: boolean;
  48447. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  48448. REFLECTIONMAP_EXPLICIT: boolean;
  48449. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  48450. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  48451. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  48452. INVERTCUBICMAP: boolean;
  48453. USESPHERICALFROMREFLECTIONMAP: boolean;
  48454. USEIRRADIANCEMAP: boolean;
  48455. SPHERICAL_HARMONICS: boolean;
  48456. USESPHERICALINVERTEX: boolean;
  48457. REFLECTIONMAP_OPPOSITEZ: boolean;
  48458. LODINREFLECTIONALPHA: boolean;
  48459. GAMMAREFLECTION: boolean;
  48460. RGBDREFLECTION: boolean;
  48461. LINEARSPECULARREFLECTION: boolean;
  48462. RADIANCEOCCLUSION: boolean;
  48463. HORIZONOCCLUSION: boolean;
  48464. INSTANCES: boolean;
  48465. NUM_BONE_INFLUENCERS: number;
  48466. BonesPerMesh: number;
  48467. BONETEXTURE: boolean;
  48468. NONUNIFORMSCALING: boolean;
  48469. MORPHTARGETS: boolean;
  48470. MORPHTARGETS_NORMAL: boolean;
  48471. MORPHTARGETS_TANGENT: boolean;
  48472. MORPHTARGETS_UV: boolean;
  48473. NUM_MORPH_INFLUENCERS: number;
  48474. IMAGEPROCESSING: boolean;
  48475. VIGNETTE: boolean;
  48476. VIGNETTEBLENDMODEMULTIPLY: boolean;
  48477. VIGNETTEBLENDMODEOPAQUE: boolean;
  48478. TONEMAPPING: boolean;
  48479. TONEMAPPING_ACES: boolean;
  48480. CONTRAST: boolean;
  48481. COLORCURVES: boolean;
  48482. COLORGRADING: boolean;
  48483. COLORGRADING3D: boolean;
  48484. SAMPLER3DGREENDEPTH: boolean;
  48485. SAMPLER3DBGRMAP: boolean;
  48486. IMAGEPROCESSINGPOSTPROCESS: boolean;
  48487. EXPOSURE: boolean;
  48488. MULTIVIEW: boolean;
  48489. USEPHYSICALLIGHTFALLOFF: boolean;
  48490. USEGLTFLIGHTFALLOFF: boolean;
  48491. TWOSIDEDLIGHTING: boolean;
  48492. SHADOWFLOAT: boolean;
  48493. CLIPPLANE: boolean;
  48494. CLIPPLANE2: boolean;
  48495. CLIPPLANE3: boolean;
  48496. CLIPPLANE4: boolean;
  48497. POINTSIZE: boolean;
  48498. FOG: boolean;
  48499. LOGARITHMICDEPTH: boolean;
  48500. FORCENORMALFORWARD: boolean;
  48501. SPECULARAA: boolean;
  48502. CLEARCOAT: boolean;
  48503. CLEARCOAT_DEFAULTIOR: boolean;
  48504. CLEARCOAT_TEXTURE: boolean;
  48505. CLEARCOAT_TEXTUREDIRECTUV: number;
  48506. CLEARCOAT_BUMP: boolean;
  48507. CLEARCOAT_BUMPDIRECTUV: number;
  48508. CLEARCOAT_TINT: boolean;
  48509. CLEARCOAT_TINT_TEXTURE: boolean;
  48510. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  48511. ANISOTROPIC: boolean;
  48512. ANISOTROPIC_TEXTURE: boolean;
  48513. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48514. BRDF_V_HEIGHT_CORRELATED: boolean;
  48515. MS_BRDF_ENERGY_CONSERVATION: boolean;
  48516. SHEEN: boolean;
  48517. SHEEN_TEXTURE: boolean;
  48518. SHEEN_TEXTUREDIRECTUV: number;
  48519. SHEEN_LINKWITHALBEDO: boolean;
  48520. SUBSURFACE: boolean;
  48521. SS_REFRACTION: boolean;
  48522. SS_TRANSLUCENCY: boolean;
  48523. SS_SCATERRING: boolean;
  48524. SS_THICKNESSANDMASK_TEXTURE: boolean;
  48525. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  48526. SS_REFRACTIONMAP_3D: boolean;
  48527. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  48528. SS_LODINREFRACTIONALPHA: boolean;
  48529. SS_GAMMAREFRACTION: boolean;
  48530. SS_RGBDREFRACTION: boolean;
  48531. SS_LINEARSPECULARREFRACTION: boolean;
  48532. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  48533. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  48534. UNLIT: boolean;
  48535. DEBUGMODE: number;
  48536. /**
  48537. * Initializes the PBR Material defines.
  48538. */
  48539. constructor();
  48540. /**
  48541. * Resets the PBR Material defines.
  48542. */
  48543. reset(): void;
  48544. }
  48545. /**
  48546. * The Physically based material base class of BJS.
  48547. *
  48548. * This offers the main features of a standard PBR material.
  48549. * For more information, please refer to the documentation :
  48550. * https://doc.babylonjs.com/how_to/physically_based_rendering
  48551. */
  48552. export abstract class PBRBaseMaterial extends PushMaterial {
  48553. /**
  48554. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  48555. */
  48556. static readonly PBRMATERIAL_OPAQUE: number;
  48557. /**
  48558. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  48559. */
  48560. static readonly PBRMATERIAL_ALPHATEST: number;
  48561. /**
  48562. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48563. */
  48564. static readonly PBRMATERIAL_ALPHABLEND: number;
  48565. /**
  48566. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48567. * They are also discarded below the alpha cutoff threshold to improve performances.
  48568. */
  48569. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  48570. /**
  48571. * Defines the default value of how much AO map is occluding the analytical lights
  48572. * (point spot...).
  48573. */
  48574. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  48575. /**
  48576. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  48577. */
  48578. static readonly LIGHTFALLOFF_PHYSICAL: number;
  48579. /**
  48580. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  48581. * to enhance interoperability with other engines.
  48582. */
  48583. static readonly LIGHTFALLOFF_GLTF: number;
  48584. /**
  48585. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  48586. * to enhance interoperability with other materials.
  48587. */
  48588. static readonly LIGHTFALLOFF_STANDARD: number;
  48589. /**
  48590. * Intensity of the direct lights e.g. the four lights available in your scene.
  48591. * This impacts both the direct diffuse and specular highlights.
  48592. */
  48593. protected _directIntensity: number;
  48594. /**
  48595. * Intensity of the emissive part of the material.
  48596. * This helps controlling the emissive effect without modifying the emissive color.
  48597. */
  48598. protected _emissiveIntensity: number;
  48599. /**
  48600. * Intensity of the environment e.g. how much the environment will light the object
  48601. * either through harmonics for rough material or through the refelction for shiny ones.
  48602. */
  48603. protected _environmentIntensity: number;
  48604. /**
  48605. * This is a special control allowing the reduction of the specular highlights coming from the
  48606. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  48607. */
  48608. protected _specularIntensity: number;
  48609. /**
  48610. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  48611. */
  48612. private _lightingInfos;
  48613. /**
  48614. * Debug Control allowing disabling the bump map on this material.
  48615. */
  48616. protected _disableBumpMap: boolean;
  48617. /**
  48618. * AKA Diffuse Texture in standard nomenclature.
  48619. */
  48620. protected _albedoTexture: Nullable<BaseTexture>;
  48621. /**
  48622. * AKA Occlusion Texture in other nomenclature.
  48623. */
  48624. protected _ambientTexture: Nullable<BaseTexture>;
  48625. /**
  48626. * AKA Occlusion Texture Intensity in other nomenclature.
  48627. */
  48628. protected _ambientTextureStrength: number;
  48629. /**
  48630. * Defines how much the AO map is occluding the analytical lights (point spot...).
  48631. * 1 means it completely occludes it
  48632. * 0 mean it has no impact
  48633. */
  48634. protected _ambientTextureImpactOnAnalyticalLights: number;
  48635. /**
  48636. * Stores the alpha values in a texture.
  48637. */
  48638. protected _opacityTexture: Nullable<BaseTexture>;
  48639. /**
  48640. * Stores the reflection values in a texture.
  48641. */
  48642. protected _reflectionTexture: Nullable<BaseTexture>;
  48643. /**
  48644. * Stores the emissive values in a texture.
  48645. */
  48646. protected _emissiveTexture: Nullable<BaseTexture>;
  48647. /**
  48648. * AKA Specular texture in other nomenclature.
  48649. */
  48650. protected _reflectivityTexture: Nullable<BaseTexture>;
  48651. /**
  48652. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48653. */
  48654. protected _metallicTexture: Nullable<BaseTexture>;
  48655. /**
  48656. * Specifies the metallic scalar of the metallic/roughness workflow.
  48657. * Can also be used to scale the metalness values of the metallic texture.
  48658. */
  48659. protected _metallic: Nullable<number>;
  48660. /**
  48661. * Specifies the roughness scalar of the metallic/roughness workflow.
  48662. * Can also be used to scale the roughness values of the metallic texture.
  48663. */
  48664. protected _roughness: Nullable<number>;
  48665. /**
  48666. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48667. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48668. */
  48669. protected _microSurfaceTexture: Nullable<BaseTexture>;
  48670. /**
  48671. * Stores surface normal data used to displace a mesh in a texture.
  48672. */
  48673. protected _bumpTexture: Nullable<BaseTexture>;
  48674. /**
  48675. * Stores the pre-calculated light information of a mesh in a texture.
  48676. */
  48677. protected _lightmapTexture: Nullable<BaseTexture>;
  48678. /**
  48679. * The color of a material in ambient lighting.
  48680. */
  48681. protected _ambientColor: Color3;
  48682. /**
  48683. * AKA Diffuse Color in other nomenclature.
  48684. */
  48685. protected _albedoColor: Color3;
  48686. /**
  48687. * AKA Specular Color in other nomenclature.
  48688. */
  48689. protected _reflectivityColor: Color3;
  48690. /**
  48691. * The color applied when light is reflected from a material.
  48692. */
  48693. protected _reflectionColor: Color3;
  48694. /**
  48695. * The color applied when light is emitted from a material.
  48696. */
  48697. protected _emissiveColor: Color3;
  48698. /**
  48699. * AKA Glossiness in other nomenclature.
  48700. */
  48701. protected _microSurface: number;
  48702. /**
  48703. * Specifies that the material will use the light map as a show map.
  48704. */
  48705. protected _useLightmapAsShadowmap: boolean;
  48706. /**
  48707. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48708. * makes the reflect vector face the model (under horizon).
  48709. */
  48710. protected _useHorizonOcclusion: boolean;
  48711. /**
  48712. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48713. * too much the area relying on ambient texture to define their ambient occlusion.
  48714. */
  48715. protected _useRadianceOcclusion: boolean;
  48716. /**
  48717. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48718. */
  48719. protected _useAlphaFromAlbedoTexture: boolean;
  48720. /**
  48721. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  48722. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48723. */
  48724. protected _useSpecularOverAlpha: boolean;
  48725. /**
  48726. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48727. */
  48728. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48729. /**
  48730. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48731. */
  48732. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  48733. /**
  48734. * Specifies if the metallic texture contains the roughness information in its green channel.
  48735. */
  48736. protected _useRoughnessFromMetallicTextureGreen: boolean;
  48737. /**
  48738. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48739. */
  48740. protected _useMetallnessFromMetallicTextureBlue: boolean;
  48741. /**
  48742. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48743. */
  48744. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  48745. /**
  48746. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48747. */
  48748. protected _useAmbientInGrayScale: boolean;
  48749. /**
  48750. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48751. * The material will try to infer what glossiness each pixel should be.
  48752. */
  48753. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  48754. /**
  48755. * Defines the falloff type used in this material.
  48756. * It by default is Physical.
  48757. */
  48758. protected _lightFalloff: number;
  48759. /**
  48760. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48761. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48762. */
  48763. protected _useRadianceOverAlpha: boolean;
  48764. /**
  48765. * Allows using an object space normal map (instead of tangent space).
  48766. */
  48767. protected _useObjectSpaceNormalMap: boolean;
  48768. /**
  48769. * Allows using the bump map in parallax mode.
  48770. */
  48771. protected _useParallax: boolean;
  48772. /**
  48773. * Allows using the bump map in parallax occlusion mode.
  48774. */
  48775. protected _useParallaxOcclusion: boolean;
  48776. /**
  48777. * Controls the scale bias of the parallax mode.
  48778. */
  48779. protected _parallaxScaleBias: number;
  48780. /**
  48781. * If sets to true, disables all the lights affecting the material.
  48782. */
  48783. protected _disableLighting: boolean;
  48784. /**
  48785. * Number of Simultaneous lights allowed on the material.
  48786. */
  48787. protected _maxSimultaneousLights: number;
  48788. /**
  48789. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48790. */
  48791. protected _invertNormalMapX: boolean;
  48792. /**
  48793. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48794. */
  48795. protected _invertNormalMapY: boolean;
  48796. /**
  48797. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48798. */
  48799. protected _twoSidedLighting: boolean;
  48800. /**
  48801. * Defines the alpha limits in alpha test mode.
  48802. */
  48803. protected _alphaCutOff: number;
  48804. /**
  48805. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48806. */
  48807. protected _forceAlphaTest: boolean;
  48808. /**
  48809. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48810. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48811. */
  48812. protected _useAlphaFresnel: boolean;
  48813. /**
  48814. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48815. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48816. */
  48817. protected _useLinearAlphaFresnel: boolean;
  48818. /**
  48819. * The transparency mode of the material.
  48820. */
  48821. protected _transparencyMode: Nullable<number>;
  48822. /**
  48823. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  48824. * from cos thetav and roughness:
  48825. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  48826. */
  48827. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  48828. /**
  48829. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48830. */
  48831. protected _forceIrradianceInFragment: boolean;
  48832. /**
  48833. * Force normal to face away from face.
  48834. */
  48835. protected _forceNormalForward: boolean;
  48836. /**
  48837. * Enables specular anti aliasing in the PBR shader.
  48838. * It will both interacts on the Geometry for analytical and IBL lighting.
  48839. * It also prefilter the roughness map based on the bump values.
  48840. */
  48841. protected _enableSpecularAntiAliasing: boolean;
  48842. /**
  48843. * Default configuration related to image processing available in the PBR Material.
  48844. */
  48845. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  48846. /**
  48847. * Keep track of the image processing observer to allow dispose and replace.
  48848. */
  48849. private _imageProcessingObserver;
  48850. /**
  48851. * Attaches a new image processing configuration to the PBR Material.
  48852. * @param configuration
  48853. */
  48854. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  48855. /**
  48856. * Stores the available render targets.
  48857. */
  48858. private _renderTargets;
  48859. /**
  48860. * Sets the global ambient color for the material used in lighting calculations.
  48861. */
  48862. private _globalAmbientColor;
  48863. /**
  48864. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  48865. */
  48866. private _useLogarithmicDepth;
  48867. /**
  48868. * If set to true, no lighting calculations will be applied.
  48869. */
  48870. private _unlit;
  48871. private _debugMode;
  48872. /**
  48873. * @hidden
  48874. * This is reserved for the inspector.
  48875. * Defines the material debug mode.
  48876. * It helps seeing only some components of the material while troubleshooting.
  48877. */
  48878. debugMode: number;
  48879. /**
  48880. * @hidden
  48881. * This is reserved for the inspector.
  48882. * Specify from where on screen the debug mode should start.
  48883. * The value goes from -1 (full screen) to 1 (not visible)
  48884. * It helps with side by side comparison against the final render
  48885. * This defaults to -1
  48886. */
  48887. private debugLimit;
  48888. /**
  48889. * @hidden
  48890. * This is reserved for the inspector.
  48891. * As the default viewing range might not be enough (if the ambient is really small for instance)
  48892. * You can use the factor to better multiply the final value.
  48893. */
  48894. private debugFactor;
  48895. /**
  48896. * Defines the clear coat layer parameters for the material.
  48897. */
  48898. readonly clearCoat: PBRClearCoatConfiguration;
  48899. /**
  48900. * Defines the anisotropic parameters for the material.
  48901. */
  48902. readonly anisotropy: PBRAnisotropicConfiguration;
  48903. /**
  48904. * Defines the BRDF parameters for the material.
  48905. */
  48906. readonly brdf: PBRBRDFConfiguration;
  48907. /**
  48908. * Defines the Sheen parameters for the material.
  48909. */
  48910. readonly sheen: PBRSheenConfiguration;
  48911. /**
  48912. * Defines the SubSurface parameters for the material.
  48913. */
  48914. readonly subSurface: PBRSubSurfaceConfiguration;
  48915. /**
  48916. * Custom callback helping to override the default shader used in the material.
  48917. */
  48918. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  48919. protected _rebuildInParallel: boolean;
  48920. /**
  48921. * Instantiates a new PBRMaterial instance.
  48922. *
  48923. * @param name The material name
  48924. * @param scene The scene the material will be use in.
  48925. */
  48926. constructor(name: string, scene: Scene);
  48927. /**
  48928. * Gets a boolean indicating that current material needs to register RTT
  48929. */
  48930. readonly hasRenderTargetTextures: boolean;
  48931. /**
  48932. * Gets the name of the material class.
  48933. */
  48934. getClassName(): string;
  48935. /**
  48936. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48937. */
  48938. /**
  48939. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48940. */
  48941. useLogarithmicDepth: boolean;
  48942. /**
  48943. * Gets the current transparency mode.
  48944. */
  48945. /**
  48946. * Sets the transparency mode of the material.
  48947. *
  48948. * | Value | Type | Description |
  48949. * | ----- | ----------------------------------- | ----------- |
  48950. * | 0 | OPAQUE | |
  48951. * | 1 | ALPHATEST | |
  48952. * | 2 | ALPHABLEND | |
  48953. * | 3 | ALPHATESTANDBLEND | |
  48954. *
  48955. */
  48956. transparencyMode: Nullable<number>;
  48957. /**
  48958. * Returns true if alpha blending should be disabled.
  48959. */
  48960. private readonly _disableAlphaBlending;
  48961. /**
  48962. * Specifies whether or not this material should be rendered in alpha blend mode.
  48963. */
  48964. needAlphaBlending(): boolean;
  48965. /**
  48966. * Specifies if the mesh will require alpha blending.
  48967. * @param mesh - BJS mesh.
  48968. */
  48969. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  48970. /**
  48971. * Specifies whether or not this material should be rendered in alpha test mode.
  48972. */
  48973. needAlphaTesting(): boolean;
  48974. /**
  48975. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  48976. */
  48977. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  48978. /**
  48979. * Gets the texture used for the alpha test.
  48980. */
  48981. getAlphaTestTexture(): Nullable<BaseTexture>;
  48982. /**
  48983. * Specifies that the submesh is ready to be used.
  48984. * @param mesh - BJS mesh.
  48985. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  48986. * @param useInstances - Specifies that instances should be used.
  48987. * @returns - boolean indicating that the submesh is ready or not.
  48988. */
  48989. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  48990. /**
  48991. * Specifies if the material uses metallic roughness workflow.
  48992. * @returns boolean specifiying if the material uses metallic roughness workflow.
  48993. */
  48994. isMetallicWorkflow(): boolean;
  48995. private _prepareEffect;
  48996. private _prepareDefines;
  48997. /**
  48998. * Force shader compilation
  48999. */
  49000. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  49001. clipPlane: boolean;
  49002. }>): void;
  49003. /**
  49004. * Initializes the uniform buffer layout for the shader.
  49005. */
  49006. buildUniformLayout(): void;
  49007. /**
  49008. * Unbinds the material from the mesh
  49009. */
  49010. unbind(): void;
  49011. /**
  49012. * Binds the submesh data.
  49013. * @param world - The world matrix.
  49014. * @param mesh - The BJS mesh.
  49015. * @param subMesh - A submesh of the BJS mesh.
  49016. */
  49017. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49018. /**
  49019. * Returns the animatable textures.
  49020. * @returns - Array of animatable textures.
  49021. */
  49022. getAnimatables(): IAnimatable[];
  49023. /**
  49024. * Returns the texture used for reflections.
  49025. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  49026. */
  49027. private _getReflectionTexture;
  49028. /**
  49029. * Returns an array of the actively used textures.
  49030. * @returns - Array of BaseTextures
  49031. */
  49032. getActiveTextures(): BaseTexture[];
  49033. /**
  49034. * Checks to see if a texture is used in the material.
  49035. * @param texture - Base texture to use.
  49036. * @returns - Boolean specifying if a texture is used in the material.
  49037. */
  49038. hasTexture(texture: BaseTexture): boolean;
  49039. /**
  49040. * Disposes the resources of the material.
  49041. * @param forceDisposeEffect - Forces the disposal of effects.
  49042. * @param forceDisposeTextures - Forces the disposal of all textures.
  49043. */
  49044. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49045. }
  49046. }
  49047. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  49048. import { Nullable } from "babylonjs/types";
  49049. import { Scene } from "babylonjs/scene";
  49050. import { Color3 } from "babylonjs/Maths/math.color";
  49051. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  49052. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  49053. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49054. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  49055. /**
  49056. * The Physically based material of BJS.
  49057. *
  49058. * This offers the main features of a standard PBR material.
  49059. * For more information, please refer to the documentation :
  49060. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49061. */
  49062. export class PBRMaterial extends PBRBaseMaterial {
  49063. /**
  49064. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49065. */
  49066. static readonly PBRMATERIAL_OPAQUE: number;
  49067. /**
  49068. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49069. */
  49070. static readonly PBRMATERIAL_ALPHATEST: number;
  49071. /**
  49072. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49073. */
  49074. static readonly PBRMATERIAL_ALPHABLEND: number;
  49075. /**
  49076. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49077. * They are also discarded below the alpha cutoff threshold to improve performances.
  49078. */
  49079. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49080. /**
  49081. * Defines the default value of how much AO map is occluding the analytical lights
  49082. * (point spot...).
  49083. */
  49084. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49085. /**
  49086. * Intensity of the direct lights e.g. the four lights available in your scene.
  49087. * This impacts both the direct diffuse and specular highlights.
  49088. */
  49089. directIntensity: number;
  49090. /**
  49091. * Intensity of the emissive part of the material.
  49092. * This helps controlling the emissive effect without modifying the emissive color.
  49093. */
  49094. emissiveIntensity: number;
  49095. /**
  49096. * Intensity of the environment e.g. how much the environment will light the object
  49097. * either through harmonics for rough material or through the refelction for shiny ones.
  49098. */
  49099. environmentIntensity: number;
  49100. /**
  49101. * This is a special control allowing the reduction of the specular highlights coming from the
  49102. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49103. */
  49104. specularIntensity: number;
  49105. /**
  49106. * Debug Control allowing disabling the bump map on this material.
  49107. */
  49108. disableBumpMap: boolean;
  49109. /**
  49110. * AKA Diffuse Texture in standard nomenclature.
  49111. */
  49112. albedoTexture: BaseTexture;
  49113. /**
  49114. * AKA Occlusion Texture in other nomenclature.
  49115. */
  49116. ambientTexture: BaseTexture;
  49117. /**
  49118. * AKA Occlusion Texture Intensity in other nomenclature.
  49119. */
  49120. ambientTextureStrength: number;
  49121. /**
  49122. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49123. * 1 means it completely occludes it
  49124. * 0 mean it has no impact
  49125. */
  49126. ambientTextureImpactOnAnalyticalLights: number;
  49127. /**
  49128. * Stores the alpha values in a texture.
  49129. */
  49130. opacityTexture: BaseTexture;
  49131. /**
  49132. * Stores the reflection values in a texture.
  49133. */
  49134. reflectionTexture: Nullable<BaseTexture>;
  49135. /**
  49136. * Stores the emissive values in a texture.
  49137. */
  49138. emissiveTexture: BaseTexture;
  49139. /**
  49140. * AKA Specular texture in other nomenclature.
  49141. */
  49142. reflectivityTexture: BaseTexture;
  49143. /**
  49144. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49145. */
  49146. metallicTexture: BaseTexture;
  49147. /**
  49148. * Specifies the metallic scalar of the metallic/roughness workflow.
  49149. * Can also be used to scale the metalness values of the metallic texture.
  49150. */
  49151. metallic: Nullable<number>;
  49152. /**
  49153. * Specifies the roughness scalar of the metallic/roughness workflow.
  49154. * Can also be used to scale the roughness values of the metallic texture.
  49155. */
  49156. roughness: Nullable<number>;
  49157. /**
  49158. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49159. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49160. */
  49161. microSurfaceTexture: BaseTexture;
  49162. /**
  49163. * Stores surface normal data used to displace a mesh in a texture.
  49164. */
  49165. bumpTexture: BaseTexture;
  49166. /**
  49167. * Stores the pre-calculated light information of a mesh in a texture.
  49168. */
  49169. lightmapTexture: BaseTexture;
  49170. /**
  49171. * Stores the refracted light information in a texture.
  49172. */
  49173. refractionTexture: Nullable<BaseTexture>;
  49174. /**
  49175. * The color of a material in ambient lighting.
  49176. */
  49177. ambientColor: Color3;
  49178. /**
  49179. * AKA Diffuse Color in other nomenclature.
  49180. */
  49181. albedoColor: Color3;
  49182. /**
  49183. * AKA Specular Color in other nomenclature.
  49184. */
  49185. reflectivityColor: Color3;
  49186. /**
  49187. * The color reflected from the material.
  49188. */
  49189. reflectionColor: Color3;
  49190. /**
  49191. * The color emitted from the material.
  49192. */
  49193. emissiveColor: Color3;
  49194. /**
  49195. * AKA Glossiness in other nomenclature.
  49196. */
  49197. microSurface: number;
  49198. /**
  49199. * source material index of refraction (IOR)' / 'destination material IOR.
  49200. */
  49201. indexOfRefraction: number;
  49202. /**
  49203. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49204. */
  49205. invertRefractionY: boolean;
  49206. /**
  49207. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49208. * Materials half opaque for instance using refraction could benefit from this control.
  49209. */
  49210. linkRefractionWithTransparency: boolean;
  49211. /**
  49212. * If true, the light map contains occlusion information instead of lighting info.
  49213. */
  49214. useLightmapAsShadowmap: boolean;
  49215. /**
  49216. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49217. */
  49218. useAlphaFromAlbedoTexture: boolean;
  49219. /**
  49220. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  49221. */
  49222. forceAlphaTest: boolean;
  49223. /**
  49224. * Defines the alpha limits in alpha test mode.
  49225. */
  49226. alphaCutOff: number;
  49227. /**
  49228. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  49229. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  49230. */
  49231. useSpecularOverAlpha: boolean;
  49232. /**
  49233. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49234. */
  49235. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  49236. /**
  49237. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49238. */
  49239. useRoughnessFromMetallicTextureAlpha: boolean;
  49240. /**
  49241. * Specifies if the metallic texture contains the roughness information in its green channel.
  49242. */
  49243. useRoughnessFromMetallicTextureGreen: boolean;
  49244. /**
  49245. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49246. */
  49247. useMetallnessFromMetallicTextureBlue: boolean;
  49248. /**
  49249. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49250. */
  49251. useAmbientOcclusionFromMetallicTextureRed: boolean;
  49252. /**
  49253. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49254. */
  49255. useAmbientInGrayScale: boolean;
  49256. /**
  49257. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49258. * The material will try to infer what glossiness each pixel should be.
  49259. */
  49260. useAutoMicroSurfaceFromReflectivityMap: boolean;
  49261. /**
  49262. * BJS is using an harcoded light falloff based on a manually sets up range.
  49263. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  49264. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  49265. */
  49266. /**
  49267. * BJS is using an harcoded light falloff based on a manually sets up range.
  49268. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  49269. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  49270. */
  49271. usePhysicalLightFalloff: boolean;
  49272. /**
  49273. * In order to support the falloff compatibility with gltf, a special mode has been added
  49274. * to reproduce the gltf light falloff.
  49275. */
  49276. /**
  49277. * In order to support the falloff compatibility with gltf, a special mode has been added
  49278. * to reproduce the gltf light falloff.
  49279. */
  49280. useGLTFLightFalloff: boolean;
  49281. /**
  49282. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49283. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49284. */
  49285. useRadianceOverAlpha: boolean;
  49286. /**
  49287. * Allows using an object space normal map (instead of tangent space).
  49288. */
  49289. useObjectSpaceNormalMap: boolean;
  49290. /**
  49291. * Allows using the bump map in parallax mode.
  49292. */
  49293. useParallax: boolean;
  49294. /**
  49295. * Allows using the bump map in parallax occlusion mode.
  49296. */
  49297. useParallaxOcclusion: boolean;
  49298. /**
  49299. * Controls the scale bias of the parallax mode.
  49300. */
  49301. parallaxScaleBias: number;
  49302. /**
  49303. * If sets to true, disables all the lights affecting the material.
  49304. */
  49305. disableLighting: boolean;
  49306. /**
  49307. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49308. */
  49309. forceIrradianceInFragment: boolean;
  49310. /**
  49311. * Number of Simultaneous lights allowed on the material.
  49312. */
  49313. maxSimultaneousLights: number;
  49314. /**
  49315. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  49316. */
  49317. invertNormalMapX: boolean;
  49318. /**
  49319. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  49320. */
  49321. invertNormalMapY: boolean;
  49322. /**
  49323. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49324. */
  49325. twoSidedLighting: boolean;
  49326. /**
  49327. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49328. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  49329. */
  49330. useAlphaFresnel: boolean;
  49331. /**
  49332. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49333. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49334. */
  49335. useLinearAlphaFresnel: boolean;
  49336. /**
  49337. * Let user defines the brdf lookup texture used for IBL.
  49338. * A default 8bit version is embedded but you could point at :
  49339. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  49340. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  49341. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  49342. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  49343. */
  49344. environmentBRDFTexture: Nullable<BaseTexture>;
  49345. /**
  49346. * Force normal to face away from face.
  49347. */
  49348. forceNormalForward: boolean;
  49349. /**
  49350. * Enables specular anti aliasing in the PBR shader.
  49351. * It will both interacts on the Geometry for analytical and IBL lighting.
  49352. * It also prefilter the roughness map based on the bump values.
  49353. */
  49354. enableSpecularAntiAliasing: boolean;
  49355. /**
  49356. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49357. * makes the reflect vector face the model (under horizon).
  49358. */
  49359. useHorizonOcclusion: boolean;
  49360. /**
  49361. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49362. * too much the area relying on ambient texture to define their ambient occlusion.
  49363. */
  49364. useRadianceOcclusion: boolean;
  49365. /**
  49366. * If set to true, no lighting calculations will be applied.
  49367. */
  49368. unlit: boolean;
  49369. /**
  49370. * Gets the image processing configuration used either in this material.
  49371. */
  49372. /**
  49373. * Sets the Default image processing configuration used either in the this material.
  49374. *
  49375. * If sets to null, the scene one is in use.
  49376. */
  49377. imageProcessingConfiguration: ImageProcessingConfiguration;
  49378. /**
  49379. * Gets wether the color curves effect is enabled.
  49380. */
  49381. /**
  49382. * Sets wether the color curves effect is enabled.
  49383. */
  49384. cameraColorCurvesEnabled: boolean;
  49385. /**
  49386. * Gets wether the color grading effect is enabled.
  49387. */
  49388. /**
  49389. * Gets wether the color grading effect is enabled.
  49390. */
  49391. cameraColorGradingEnabled: boolean;
  49392. /**
  49393. * Gets wether tonemapping is enabled or not.
  49394. */
  49395. /**
  49396. * Sets wether tonemapping is enabled or not
  49397. */
  49398. cameraToneMappingEnabled: boolean;
  49399. /**
  49400. * The camera exposure used on this material.
  49401. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49402. * This corresponds to a photographic exposure.
  49403. */
  49404. /**
  49405. * The camera exposure used on this material.
  49406. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49407. * This corresponds to a photographic exposure.
  49408. */
  49409. cameraExposure: number;
  49410. /**
  49411. * Gets The camera contrast used on this material.
  49412. */
  49413. /**
  49414. * Sets The camera contrast used on this material.
  49415. */
  49416. cameraContrast: number;
  49417. /**
  49418. * Gets the Color Grading 2D Lookup Texture.
  49419. */
  49420. /**
  49421. * Sets the Color Grading 2D Lookup Texture.
  49422. */
  49423. cameraColorGradingTexture: Nullable<BaseTexture>;
  49424. /**
  49425. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49426. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49427. * 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;
  49428. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49429. */
  49430. /**
  49431. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49432. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49433. * 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;
  49434. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49435. */
  49436. cameraColorCurves: Nullable<ColorCurves>;
  49437. /**
  49438. * Instantiates a new PBRMaterial instance.
  49439. *
  49440. * @param name The material name
  49441. * @param scene The scene the material will be use in.
  49442. */
  49443. constructor(name: string, scene: Scene);
  49444. /**
  49445. * Returns the name of this material class.
  49446. */
  49447. getClassName(): string;
  49448. /**
  49449. * Makes a duplicate of the current material.
  49450. * @param name - name to use for the new material.
  49451. */
  49452. clone(name: string): PBRMaterial;
  49453. /**
  49454. * Serializes this PBR Material.
  49455. * @returns - An object with the serialized material.
  49456. */
  49457. serialize(): any;
  49458. /**
  49459. * Parses a PBR Material from a serialized object.
  49460. * @param source - Serialized object.
  49461. * @param scene - BJS scene instance.
  49462. * @param rootUrl - url for the scene object
  49463. * @returns - PBRMaterial
  49464. */
  49465. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  49466. }
  49467. }
  49468. declare module "babylonjs/Misc/dds" {
  49469. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49470. import { Engine } from "babylonjs/Engines/engine";
  49471. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49472. import { Nullable } from "babylonjs/types";
  49473. import { Scene } from "babylonjs/scene";
  49474. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  49475. /**
  49476. * Direct draw surface info
  49477. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  49478. */
  49479. export interface DDSInfo {
  49480. /**
  49481. * Width of the texture
  49482. */
  49483. width: number;
  49484. /**
  49485. * Width of the texture
  49486. */
  49487. height: number;
  49488. /**
  49489. * Number of Mipmaps for the texture
  49490. * @see https://en.wikipedia.org/wiki/Mipmap
  49491. */
  49492. mipmapCount: number;
  49493. /**
  49494. * If the textures format is a known fourCC format
  49495. * @see https://www.fourcc.org/
  49496. */
  49497. isFourCC: boolean;
  49498. /**
  49499. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  49500. */
  49501. isRGB: boolean;
  49502. /**
  49503. * If the texture is a lumincance format
  49504. */
  49505. isLuminance: boolean;
  49506. /**
  49507. * If this is a cube texture
  49508. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  49509. */
  49510. isCube: boolean;
  49511. /**
  49512. * If the texture is a compressed format eg. FOURCC_DXT1
  49513. */
  49514. isCompressed: boolean;
  49515. /**
  49516. * The dxgiFormat of the texture
  49517. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  49518. */
  49519. dxgiFormat: number;
  49520. /**
  49521. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  49522. */
  49523. textureType: number;
  49524. /**
  49525. * Sphericle polynomial created for the dds texture
  49526. */
  49527. sphericalPolynomial?: SphericalPolynomial;
  49528. }
  49529. /**
  49530. * Class used to provide DDS decompression tools
  49531. */
  49532. export class DDSTools {
  49533. /**
  49534. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  49535. */
  49536. static StoreLODInAlphaChannel: boolean;
  49537. /**
  49538. * Gets DDS information from an array buffer
  49539. * @param arrayBuffer defines the array buffer to read data from
  49540. * @returns the DDS information
  49541. */
  49542. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  49543. private static _FloatView;
  49544. private static _Int32View;
  49545. private static _ToHalfFloat;
  49546. private static _FromHalfFloat;
  49547. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  49548. private static _GetHalfFloatRGBAArrayBuffer;
  49549. private static _GetFloatRGBAArrayBuffer;
  49550. private static _GetFloatAsUIntRGBAArrayBuffer;
  49551. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  49552. private static _GetRGBAArrayBuffer;
  49553. private static _ExtractLongWordOrder;
  49554. private static _GetRGBArrayBuffer;
  49555. private static _GetLuminanceArrayBuffer;
  49556. /**
  49557. * Uploads DDS Levels to a Babylon Texture
  49558. * @hidden
  49559. */
  49560. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  49561. }
  49562. module "babylonjs/Engines/engine" {
  49563. interface Engine {
  49564. /**
  49565. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  49566. * @param rootUrl defines the url where the file to load is located
  49567. * @param scene defines the current scene
  49568. * @param lodScale defines scale to apply to the mip map selection
  49569. * @param lodOffset defines offset to apply to the mip map selection
  49570. * @param onLoad defines an optional callback raised when the texture is loaded
  49571. * @param onError defines an optional callback raised if there is an issue to load the texture
  49572. * @param format defines the format of the data
  49573. * @param forcedExtension defines the extension to use to pick the right loader
  49574. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  49575. * @returns the cube texture as an InternalTexture
  49576. */
  49577. 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;
  49578. }
  49579. }
  49580. }
  49581. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  49582. import { Nullable } from "babylonjs/types";
  49583. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49584. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49585. /**
  49586. * Implementation of the DDS Texture Loader.
  49587. * @hidden
  49588. */
  49589. export class _DDSTextureLoader implements IInternalTextureLoader {
  49590. /**
  49591. * Defines wether the loader supports cascade loading the different faces.
  49592. */
  49593. readonly supportCascades: boolean;
  49594. /**
  49595. * This returns if the loader support the current file information.
  49596. * @param extension defines the file extension of the file being loaded
  49597. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49598. * @param fallback defines the fallback internal texture if any
  49599. * @param isBase64 defines whether the texture is encoded as a base64
  49600. * @param isBuffer defines whether the texture data are stored as a buffer
  49601. * @returns true if the loader can load the specified file
  49602. */
  49603. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49604. /**
  49605. * Transform the url before loading if required.
  49606. * @param rootUrl the url of the texture
  49607. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49608. * @returns the transformed texture
  49609. */
  49610. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49611. /**
  49612. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49613. * @param rootUrl the url of the texture
  49614. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49615. * @returns the fallback texture
  49616. */
  49617. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49618. /**
  49619. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49620. * @param data contains the texture data
  49621. * @param texture defines the BabylonJS internal texture
  49622. * @param createPolynomials will be true if polynomials have been requested
  49623. * @param onLoad defines the callback to trigger once the texture is ready
  49624. * @param onError defines the callback to trigger in case of error
  49625. */
  49626. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49627. /**
  49628. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49629. * @param data contains the texture data
  49630. * @param texture defines the BabylonJS internal texture
  49631. * @param callback defines the method to call once ready to upload
  49632. */
  49633. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49634. }
  49635. }
  49636. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  49637. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49638. /** @hidden */
  49639. export var rgbdEncodePixelShader: {
  49640. name: string;
  49641. shader: string;
  49642. };
  49643. }
  49644. declare module "babylonjs/Misc/environmentTextureTools" {
  49645. import { Nullable } from "babylonjs/types";
  49646. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49647. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49648. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49649. import "babylonjs/Engines/Extensions/engine.renderTarget";
  49650. import "babylonjs/Shaders/rgbdEncode.fragment";
  49651. import "babylonjs/Shaders/rgbdDecode.fragment";
  49652. /**
  49653. * Raw texture data and descriptor sufficient for WebGL texture upload
  49654. */
  49655. export interface EnvironmentTextureInfo {
  49656. /**
  49657. * Version of the environment map
  49658. */
  49659. version: number;
  49660. /**
  49661. * Width of image
  49662. */
  49663. width: number;
  49664. /**
  49665. * Irradiance information stored in the file.
  49666. */
  49667. irradiance: any;
  49668. /**
  49669. * Specular information stored in the file.
  49670. */
  49671. specular: any;
  49672. }
  49673. /**
  49674. * Sets of helpers addressing the serialization and deserialization of environment texture
  49675. * stored in a BabylonJS env file.
  49676. * Those files are usually stored as .env files.
  49677. */
  49678. export class EnvironmentTextureTools {
  49679. /**
  49680. * Magic number identifying the env file.
  49681. */
  49682. private static _MagicBytes;
  49683. /**
  49684. * Gets the environment info from an env file.
  49685. * @param data The array buffer containing the .env bytes.
  49686. * @returns the environment file info (the json header) if successfully parsed.
  49687. */
  49688. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  49689. /**
  49690. * Creates an environment texture from a loaded cube texture.
  49691. * @param texture defines the cube texture to convert in env file
  49692. * @return a promise containing the environment data if succesfull.
  49693. */
  49694. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  49695. /**
  49696. * Creates a JSON representation of the spherical data.
  49697. * @param texture defines the texture containing the polynomials
  49698. * @return the JSON representation of the spherical info
  49699. */
  49700. private static _CreateEnvTextureIrradiance;
  49701. /**
  49702. * Uploads the texture info contained in the env file to the GPU.
  49703. * @param texture defines the internal texture to upload to
  49704. * @param arrayBuffer defines the buffer cotaining the data to load
  49705. * @param info defines the texture info retrieved through the GetEnvInfo method
  49706. * @returns a promise
  49707. */
  49708. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  49709. /**
  49710. * Uploads the levels of image data to the GPU.
  49711. * @param texture defines the internal texture to upload to
  49712. * @param imageData defines the array buffer views of image data [mipmap][face]
  49713. * @returns a promise
  49714. */
  49715. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  49716. /**
  49717. * Uploads spherical polynomials information to the texture.
  49718. * @param texture defines the texture we are trying to upload the information to
  49719. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  49720. */
  49721. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  49722. /** @hidden */
  49723. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49724. }
  49725. }
  49726. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  49727. import { Nullable } from "babylonjs/types";
  49728. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49729. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49730. /**
  49731. * Implementation of the ENV Texture Loader.
  49732. * @hidden
  49733. */
  49734. export class _ENVTextureLoader implements IInternalTextureLoader {
  49735. /**
  49736. * Defines wether the loader supports cascade loading the different faces.
  49737. */
  49738. readonly supportCascades: boolean;
  49739. /**
  49740. * This returns if the loader support the current file information.
  49741. * @param extension defines the file extension of the file being loaded
  49742. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49743. * @param fallback defines the fallback internal texture if any
  49744. * @param isBase64 defines whether the texture is encoded as a base64
  49745. * @param isBuffer defines whether the texture data are stored as a buffer
  49746. * @returns true if the loader can load the specified file
  49747. */
  49748. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49749. /**
  49750. * Transform the url before loading if required.
  49751. * @param rootUrl the url of the texture
  49752. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49753. * @returns the transformed texture
  49754. */
  49755. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49756. /**
  49757. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49758. * @param rootUrl the url of the texture
  49759. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49760. * @returns the fallback texture
  49761. */
  49762. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49763. /**
  49764. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49765. * @param data contains the texture data
  49766. * @param texture defines the BabylonJS internal texture
  49767. * @param createPolynomials will be true if polynomials have been requested
  49768. * @param onLoad defines the callback to trigger once the texture is ready
  49769. * @param onError defines the callback to trigger in case of error
  49770. */
  49771. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49772. /**
  49773. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49774. * @param data contains the texture data
  49775. * @param texture defines the BabylonJS internal texture
  49776. * @param callback defines the method to call once ready to upload
  49777. */
  49778. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49779. }
  49780. }
  49781. declare module "babylonjs/Misc/khronosTextureContainer" {
  49782. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49783. /**
  49784. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  49785. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  49786. */
  49787. export class KhronosTextureContainer {
  49788. /** contents of the KTX container file */
  49789. arrayBuffer: any;
  49790. private static HEADER_LEN;
  49791. private static COMPRESSED_2D;
  49792. private static COMPRESSED_3D;
  49793. private static TEX_2D;
  49794. private static TEX_3D;
  49795. /**
  49796. * Gets the openGL type
  49797. */
  49798. glType: number;
  49799. /**
  49800. * Gets the openGL type size
  49801. */
  49802. glTypeSize: number;
  49803. /**
  49804. * Gets the openGL format
  49805. */
  49806. glFormat: number;
  49807. /**
  49808. * Gets the openGL internal format
  49809. */
  49810. glInternalFormat: number;
  49811. /**
  49812. * Gets the base internal format
  49813. */
  49814. glBaseInternalFormat: number;
  49815. /**
  49816. * Gets image width in pixel
  49817. */
  49818. pixelWidth: number;
  49819. /**
  49820. * Gets image height in pixel
  49821. */
  49822. pixelHeight: number;
  49823. /**
  49824. * Gets image depth in pixels
  49825. */
  49826. pixelDepth: number;
  49827. /**
  49828. * Gets the number of array elements
  49829. */
  49830. numberOfArrayElements: number;
  49831. /**
  49832. * Gets the number of faces
  49833. */
  49834. numberOfFaces: number;
  49835. /**
  49836. * Gets the number of mipmap levels
  49837. */
  49838. numberOfMipmapLevels: number;
  49839. /**
  49840. * Gets the bytes of key value data
  49841. */
  49842. bytesOfKeyValueData: number;
  49843. /**
  49844. * Gets the load type
  49845. */
  49846. loadType: number;
  49847. /**
  49848. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  49849. */
  49850. isInvalid: boolean;
  49851. /**
  49852. * Creates a new KhronosTextureContainer
  49853. * @param arrayBuffer contents of the KTX container file
  49854. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  49855. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  49856. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  49857. */
  49858. constructor(
  49859. /** contents of the KTX container file */
  49860. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  49861. /**
  49862. * Uploads KTX content to a Babylon Texture.
  49863. * It is assumed that the texture has already been created & is currently bound
  49864. * @hidden
  49865. */
  49866. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  49867. private _upload2DCompressedLevels;
  49868. }
  49869. }
  49870. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  49871. import { Nullable } from "babylonjs/types";
  49872. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49873. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49874. /**
  49875. * Implementation of the KTX Texture Loader.
  49876. * @hidden
  49877. */
  49878. export class _KTXTextureLoader implements IInternalTextureLoader {
  49879. /**
  49880. * Defines wether the loader supports cascade loading the different faces.
  49881. */
  49882. readonly supportCascades: boolean;
  49883. /**
  49884. * This returns if the loader support the current file information.
  49885. * @param extension defines the file extension of the file being loaded
  49886. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49887. * @param fallback defines the fallback internal texture if any
  49888. * @param isBase64 defines whether the texture is encoded as a base64
  49889. * @param isBuffer defines whether the texture data are stored as a buffer
  49890. * @returns true if the loader can load the specified file
  49891. */
  49892. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49893. /**
  49894. * Transform the url before loading if required.
  49895. * @param rootUrl the url of the texture
  49896. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49897. * @returns the transformed texture
  49898. */
  49899. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49900. /**
  49901. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49902. * @param rootUrl the url of the texture
  49903. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49904. * @returns the fallback texture
  49905. */
  49906. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49907. /**
  49908. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49909. * @param data contains the texture data
  49910. * @param texture defines the BabylonJS internal texture
  49911. * @param createPolynomials will be true if polynomials have been requested
  49912. * @param onLoad defines the callback to trigger once the texture is ready
  49913. * @param onError defines the callback to trigger in case of error
  49914. */
  49915. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49916. /**
  49917. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49918. * @param data contains the texture data
  49919. * @param texture defines the BabylonJS internal texture
  49920. * @param callback defines the method to call once ready to upload
  49921. */
  49922. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  49923. }
  49924. }
  49925. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  49926. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  49927. import { Scene } from "babylonjs/scene";
  49928. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  49929. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  49930. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  49931. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  49932. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  49933. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  49934. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49935. /**
  49936. * Options for the default xr helper
  49937. */
  49938. export class WebXRDefaultExperienceOptions {
  49939. /**
  49940. * Floor meshes that should be used for teleporting
  49941. */
  49942. floorMeshes: Array<AbstractMesh>;
  49943. }
  49944. /**
  49945. * Default experience which provides a similar setup to the previous webVRExperience
  49946. */
  49947. export class WebXRDefaultExperience {
  49948. /**
  49949. * Base experience
  49950. */
  49951. baseExperience: WebXRExperienceHelper;
  49952. /**
  49953. * Input experience extension
  49954. */
  49955. input: WebXRInput;
  49956. /**
  49957. * Loads the controller models
  49958. */
  49959. controllerModelLoader: WebXRControllerModelLoader;
  49960. /**
  49961. * Enables laser pointer and selection
  49962. */
  49963. pointerSelection: WebXRControllerPointerSelection;
  49964. /**
  49965. * Enables teleportation
  49966. */
  49967. teleportation: WebXRControllerTeleportation;
  49968. /**
  49969. * Enables ui for enetering/exiting xr
  49970. */
  49971. enterExitUI: WebXREnterExitUI;
  49972. /**
  49973. * Default output canvas xr should render to
  49974. */
  49975. outputCanvas: WebXRManagedOutputCanvas;
  49976. /**
  49977. * Creates the default xr experience
  49978. * @param scene scene
  49979. * @param options options for basic configuration
  49980. * @returns resulting WebXRDefaultExperience
  49981. */
  49982. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49983. private constructor();
  49984. /**
  49985. * DIsposes of the experience helper
  49986. */
  49987. dispose(): void;
  49988. }
  49989. }
  49990. declare module "babylonjs/Helpers/sceneHelpers" {
  49991. import { Nullable } from "babylonjs/types";
  49992. import { Mesh } from "babylonjs/Meshes/mesh";
  49993. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49994. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  49995. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  49996. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  49997. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  49998. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  49999. import "babylonjs/Meshes/Builders/boxBuilder";
  50000. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  50001. /** @hidden */
  50002. export var _forceSceneHelpersToBundle: boolean;
  50003. module "babylonjs/scene" {
  50004. interface Scene {
  50005. /**
  50006. * Creates a default light for the scene.
  50007. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  50008. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  50009. */
  50010. createDefaultLight(replace?: boolean): void;
  50011. /**
  50012. * Creates a default camera for the scene.
  50013. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  50014. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  50015. * @param replace has default false, when true replaces the active camera in the scene
  50016. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  50017. */
  50018. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  50019. /**
  50020. * Creates a default camera and a default light.
  50021. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  50022. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  50023. * @param replace has the default false, when true replaces the active camera/light in the scene
  50024. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  50025. */
  50026. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  50027. /**
  50028. * Creates a new sky box
  50029. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  50030. * @param environmentTexture defines the texture to use as environment texture
  50031. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  50032. * @param scale defines the overall scale of the skybox
  50033. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  50034. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  50035. * @returns a new mesh holding the sky box
  50036. */
  50037. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  50038. /**
  50039. * Creates a new environment
  50040. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  50041. * @param options defines the options you can use to configure the environment
  50042. * @returns the new EnvironmentHelper
  50043. */
  50044. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  50045. /**
  50046. * Creates a new VREXperienceHelper
  50047. * @see http://doc.babylonjs.com/how_to/webvr_helper
  50048. * @param webVROptions defines the options used to create the new VREXperienceHelper
  50049. * @returns a new VREXperienceHelper
  50050. */
  50051. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  50052. /**
  50053. * Creates a new WebXRDefaultExperience
  50054. * @see http://doc.babylonjs.com/how_to/webxr
  50055. * @param options experience options
  50056. * @returns a promise for a new WebXRDefaultExperience
  50057. */
  50058. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  50059. }
  50060. }
  50061. }
  50062. declare module "babylonjs/Maths/math.vertexFormat" {
  50063. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  50064. /**
  50065. * Contains position and normal vectors for a vertex
  50066. */
  50067. export class PositionNormalVertex {
  50068. /** the position of the vertex (defaut: 0,0,0) */
  50069. position: Vector3;
  50070. /** the normal of the vertex (defaut: 0,1,0) */
  50071. normal: Vector3;
  50072. /**
  50073. * Creates a PositionNormalVertex
  50074. * @param position the position of the vertex (defaut: 0,0,0)
  50075. * @param normal the normal of the vertex (defaut: 0,1,0)
  50076. */
  50077. constructor(
  50078. /** the position of the vertex (defaut: 0,0,0) */
  50079. position?: Vector3,
  50080. /** the normal of the vertex (defaut: 0,1,0) */
  50081. normal?: Vector3);
  50082. /**
  50083. * Clones the PositionNormalVertex
  50084. * @returns the cloned PositionNormalVertex
  50085. */
  50086. clone(): PositionNormalVertex;
  50087. }
  50088. /**
  50089. * Contains position, normal and uv vectors for a vertex
  50090. */
  50091. export class PositionNormalTextureVertex {
  50092. /** the position of the vertex (defaut: 0,0,0) */
  50093. position: Vector3;
  50094. /** the normal of the vertex (defaut: 0,1,0) */
  50095. normal: Vector3;
  50096. /** the uv of the vertex (default: 0,0) */
  50097. uv: Vector2;
  50098. /**
  50099. * Creates a PositionNormalTextureVertex
  50100. * @param position the position of the vertex (defaut: 0,0,0)
  50101. * @param normal the normal of the vertex (defaut: 0,1,0)
  50102. * @param uv the uv of the vertex (default: 0,0)
  50103. */
  50104. constructor(
  50105. /** the position of the vertex (defaut: 0,0,0) */
  50106. position?: Vector3,
  50107. /** the normal of the vertex (defaut: 0,1,0) */
  50108. normal?: Vector3,
  50109. /** the uv of the vertex (default: 0,0) */
  50110. uv?: Vector2);
  50111. /**
  50112. * Clones the PositionNormalTextureVertex
  50113. * @returns the cloned PositionNormalTextureVertex
  50114. */
  50115. clone(): PositionNormalTextureVertex;
  50116. }
  50117. }
  50118. declare module "babylonjs/Maths/math" {
  50119. export * from "babylonjs/Maths/math.axis";
  50120. export * from "babylonjs/Maths/math.color";
  50121. export * from "babylonjs/Maths/math.constants";
  50122. export * from "babylonjs/Maths/math.frustum";
  50123. export * from "babylonjs/Maths/math.path";
  50124. export * from "babylonjs/Maths/math.plane";
  50125. export * from "babylonjs/Maths/math.size";
  50126. export * from "babylonjs/Maths/math.vector";
  50127. export * from "babylonjs/Maths/math.vertexFormat";
  50128. export * from "babylonjs/Maths/math.viewport";
  50129. }
  50130. declare module "babylonjs/Helpers/videoDome" {
  50131. import { Scene } from "babylonjs/scene";
  50132. import { TransformNode } from "babylonjs/Meshes/transformNode";
  50133. import { Mesh } from "babylonjs/Meshes/mesh";
  50134. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  50135. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  50136. import "babylonjs/Meshes/Builders/sphereBuilder";
  50137. /**
  50138. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  50139. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  50140. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  50141. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  50142. */
  50143. export class VideoDome extends TransformNode {
  50144. /**
  50145. * Define the video source as a Monoscopic panoramic 360 video.
  50146. */
  50147. static readonly MODE_MONOSCOPIC: number;
  50148. /**
  50149. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  50150. */
  50151. static readonly MODE_TOPBOTTOM: number;
  50152. /**
  50153. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  50154. */
  50155. static readonly MODE_SIDEBYSIDE: number;
  50156. private _halfDome;
  50157. private _useDirectMapping;
  50158. /**
  50159. * The video texture being displayed on the sphere
  50160. */
  50161. protected _videoTexture: VideoTexture;
  50162. /**
  50163. * Gets the video texture being displayed on the sphere
  50164. */
  50165. readonly videoTexture: VideoTexture;
  50166. /**
  50167. * The skybox material
  50168. */
  50169. protected _material: BackgroundMaterial;
  50170. /**
  50171. * The surface used for the skybox
  50172. */
  50173. protected _mesh: Mesh;
  50174. /**
  50175. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  50176. */
  50177. private _halfDomeMask;
  50178. /**
  50179. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50180. * Also see the options.resolution property.
  50181. */
  50182. fovMultiplier: number;
  50183. private _videoMode;
  50184. /**
  50185. * Gets or set the current video mode for the video. It can be:
  50186. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  50187. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  50188. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  50189. */
  50190. videoMode: number;
  50191. /**
  50192. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  50193. *
  50194. */
  50195. /**
  50196. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  50197. */
  50198. halfDome: boolean;
  50199. /**
  50200. * Oberserver used in Stereoscopic VR Mode.
  50201. */
  50202. private _onBeforeCameraRenderObserver;
  50203. /**
  50204. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  50205. * @param name Element's name, child elements will append suffixes for their own names.
  50206. * @param urlsOrVideo defines the url(s) or the video element to use
  50207. * @param options An object containing optional or exposed sub element properties
  50208. */
  50209. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  50210. resolution?: number;
  50211. clickToPlay?: boolean;
  50212. autoPlay?: boolean;
  50213. loop?: boolean;
  50214. size?: number;
  50215. poster?: string;
  50216. faceForward?: boolean;
  50217. useDirectMapping?: boolean;
  50218. halfDomeMode?: boolean;
  50219. }, scene: Scene);
  50220. private _changeVideoMode;
  50221. /**
  50222. * Releases resources associated with this node.
  50223. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50224. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50225. */
  50226. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50227. }
  50228. }
  50229. declare module "babylonjs/Helpers/index" {
  50230. export * from "babylonjs/Helpers/environmentHelper";
  50231. export * from "babylonjs/Helpers/photoDome";
  50232. export * from "babylonjs/Helpers/sceneHelpers";
  50233. export * from "babylonjs/Helpers/videoDome";
  50234. }
  50235. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  50236. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  50237. import { IDisposable } from "babylonjs/scene";
  50238. import { Engine } from "babylonjs/Engines/engine";
  50239. /**
  50240. * This class can be used to get instrumentation data from a Babylon engine
  50241. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  50242. */
  50243. export class EngineInstrumentation implements IDisposable {
  50244. /**
  50245. * Define the instrumented engine.
  50246. */
  50247. engine: Engine;
  50248. private _captureGPUFrameTime;
  50249. private _gpuFrameTimeToken;
  50250. private _gpuFrameTime;
  50251. private _captureShaderCompilationTime;
  50252. private _shaderCompilationTime;
  50253. private _onBeginFrameObserver;
  50254. private _onEndFrameObserver;
  50255. private _onBeforeShaderCompilationObserver;
  50256. private _onAfterShaderCompilationObserver;
  50257. /**
  50258. * Gets the perf counter used for GPU frame time
  50259. */
  50260. readonly gpuFrameTimeCounter: PerfCounter;
  50261. /**
  50262. * Gets the GPU frame time capture status
  50263. */
  50264. /**
  50265. * Enable or disable the GPU frame time capture
  50266. */
  50267. captureGPUFrameTime: boolean;
  50268. /**
  50269. * Gets the perf counter used for shader compilation time
  50270. */
  50271. readonly shaderCompilationTimeCounter: PerfCounter;
  50272. /**
  50273. * Gets the shader compilation time capture status
  50274. */
  50275. /**
  50276. * Enable or disable the shader compilation time capture
  50277. */
  50278. captureShaderCompilationTime: boolean;
  50279. /**
  50280. * Instantiates a new engine instrumentation.
  50281. * This class can be used to get instrumentation data from a Babylon engine
  50282. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  50283. * @param engine Defines the engine to instrument
  50284. */
  50285. constructor(
  50286. /**
  50287. * Define the instrumented engine.
  50288. */
  50289. engine: Engine);
  50290. /**
  50291. * Dispose and release associated resources.
  50292. */
  50293. dispose(): void;
  50294. }
  50295. }
  50296. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  50297. import { Scene, IDisposable } from "babylonjs/scene";
  50298. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  50299. /**
  50300. * This class can be used to get instrumentation data from a Babylon engine
  50301. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  50302. */
  50303. export class SceneInstrumentation implements IDisposable {
  50304. /**
  50305. * Defines the scene to instrument
  50306. */
  50307. scene: Scene;
  50308. private _captureActiveMeshesEvaluationTime;
  50309. private _activeMeshesEvaluationTime;
  50310. private _captureRenderTargetsRenderTime;
  50311. private _renderTargetsRenderTime;
  50312. private _captureFrameTime;
  50313. private _frameTime;
  50314. private _captureRenderTime;
  50315. private _renderTime;
  50316. private _captureInterFrameTime;
  50317. private _interFrameTime;
  50318. private _captureParticlesRenderTime;
  50319. private _particlesRenderTime;
  50320. private _captureSpritesRenderTime;
  50321. private _spritesRenderTime;
  50322. private _capturePhysicsTime;
  50323. private _physicsTime;
  50324. private _captureAnimationsTime;
  50325. private _animationsTime;
  50326. private _captureCameraRenderTime;
  50327. private _cameraRenderTime;
  50328. private _onBeforeActiveMeshesEvaluationObserver;
  50329. private _onAfterActiveMeshesEvaluationObserver;
  50330. private _onBeforeRenderTargetsRenderObserver;
  50331. private _onAfterRenderTargetsRenderObserver;
  50332. private _onAfterRenderObserver;
  50333. private _onBeforeDrawPhaseObserver;
  50334. private _onAfterDrawPhaseObserver;
  50335. private _onBeforeAnimationsObserver;
  50336. private _onBeforeParticlesRenderingObserver;
  50337. private _onAfterParticlesRenderingObserver;
  50338. private _onBeforeSpritesRenderingObserver;
  50339. private _onAfterSpritesRenderingObserver;
  50340. private _onBeforePhysicsObserver;
  50341. private _onAfterPhysicsObserver;
  50342. private _onAfterAnimationsObserver;
  50343. private _onBeforeCameraRenderObserver;
  50344. private _onAfterCameraRenderObserver;
  50345. /**
  50346. * Gets the perf counter used for active meshes evaluation time
  50347. */
  50348. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  50349. /**
  50350. * Gets the active meshes evaluation time capture status
  50351. */
  50352. /**
  50353. * Enable or disable the active meshes evaluation time capture
  50354. */
  50355. captureActiveMeshesEvaluationTime: boolean;
  50356. /**
  50357. * Gets the perf counter used for render targets render time
  50358. */
  50359. readonly renderTargetsRenderTimeCounter: PerfCounter;
  50360. /**
  50361. * Gets the render targets render time capture status
  50362. */
  50363. /**
  50364. * Enable or disable the render targets render time capture
  50365. */
  50366. captureRenderTargetsRenderTime: boolean;
  50367. /**
  50368. * Gets the perf counter used for particles render time
  50369. */
  50370. readonly particlesRenderTimeCounter: PerfCounter;
  50371. /**
  50372. * Gets the particles render time capture status
  50373. */
  50374. /**
  50375. * Enable or disable the particles render time capture
  50376. */
  50377. captureParticlesRenderTime: boolean;
  50378. /**
  50379. * Gets the perf counter used for sprites render time
  50380. */
  50381. readonly spritesRenderTimeCounter: PerfCounter;
  50382. /**
  50383. * Gets the sprites render time capture status
  50384. */
  50385. /**
  50386. * Enable or disable the sprites render time capture
  50387. */
  50388. captureSpritesRenderTime: boolean;
  50389. /**
  50390. * Gets the perf counter used for physics time
  50391. */
  50392. readonly physicsTimeCounter: PerfCounter;
  50393. /**
  50394. * Gets the physics time capture status
  50395. */
  50396. /**
  50397. * Enable or disable the physics time capture
  50398. */
  50399. capturePhysicsTime: boolean;
  50400. /**
  50401. * Gets the perf counter used for animations time
  50402. */
  50403. readonly animationsTimeCounter: PerfCounter;
  50404. /**
  50405. * Gets the animations time capture status
  50406. */
  50407. /**
  50408. * Enable or disable the animations time capture
  50409. */
  50410. captureAnimationsTime: boolean;
  50411. /**
  50412. * Gets the perf counter used for frame time capture
  50413. */
  50414. readonly frameTimeCounter: PerfCounter;
  50415. /**
  50416. * Gets the frame time capture status
  50417. */
  50418. /**
  50419. * Enable or disable the frame time capture
  50420. */
  50421. captureFrameTime: boolean;
  50422. /**
  50423. * Gets the perf counter used for inter-frames time capture
  50424. */
  50425. readonly interFrameTimeCounter: PerfCounter;
  50426. /**
  50427. * Gets the inter-frames time capture status
  50428. */
  50429. /**
  50430. * Enable or disable the inter-frames time capture
  50431. */
  50432. captureInterFrameTime: boolean;
  50433. /**
  50434. * Gets the perf counter used for render time capture
  50435. */
  50436. readonly renderTimeCounter: PerfCounter;
  50437. /**
  50438. * Gets the render time capture status
  50439. */
  50440. /**
  50441. * Enable or disable the render time capture
  50442. */
  50443. captureRenderTime: boolean;
  50444. /**
  50445. * Gets the perf counter used for camera render time capture
  50446. */
  50447. readonly cameraRenderTimeCounter: PerfCounter;
  50448. /**
  50449. * Gets the camera render time capture status
  50450. */
  50451. /**
  50452. * Enable or disable the camera render time capture
  50453. */
  50454. captureCameraRenderTime: boolean;
  50455. /**
  50456. * Gets the perf counter used for draw calls
  50457. */
  50458. readonly drawCallsCounter: PerfCounter;
  50459. /**
  50460. * Instantiates a new scene instrumentation.
  50461. * This class can be used to get instrumentation data from a Babylon engine
  50462. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  50463. * @param scene Defines the scene to instrument
  50464. */
  50465. constructor(
  50466. /**
  50467. * Defines the scene to instrument
  50468. */
  50469. scene: Scene);
  50470. /**
  50471. * Dispose and release associated resources.
  50472. */
  50473. dispose(): void;
  50474. }
  50475. }
  50476. declare module "babylonjs/Instrumentation/index" {
  50477. export * from "babylonjs/Instrumentation/engineInstrumentation";
  50478. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  50479. export * from "babylonjs/Instrumentation/timeToken";
  50480. }
  50481. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  50482. /** @hidden */
  50483. export var glowMapGenerationPixelShader: {
  50484. name: string;
  50485. shader: string;
  50486. };
  50487. }
  50488. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  50489. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  50490. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  50491. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  50492. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  50493. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  50494. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  50495. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  50496. /** @hidden */
  50497. export var glowMapGenerationVertexShader: {
  50498. name: string;
  50499. shader: string;
  50500. };
  50501. }
  50502. declare module "babylonjs/Layers/effectLayer" {
  50503. import { Observable } from "babylonjs/Misc/observable";
  50504. import { Nullable } from "babylonjs/types";
  50505. import { Camera } from "babylonjs/Cameras/camera";
  50506. import { Scene } from "babylonjs/scene";
  50507. import { ISize } from "babylonjs/Maths/math.size";
  50508. import { Color4 } from "babylonjs/Maths/math.color";
  50509. import { Engine } from "babylonjs/Engines/engine";
  50510. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50511. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50512. import { Mesh } from "babylonjs/Meshes/mesh";
  50513. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  50514. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50515. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50516. import { Effect } from "babylonjs/Materials/effect";
  50517. import { Material } from "babylonjs/Materials/material";
  50518. import "babylonjs/Shaders/glowMapGeneration.fragment";
  50519. import "babylonjs/Shaders/glowMapGeneration.vertex";
  50520. /**
  50521. * Effect layer options. This helps customizing the behaviour
  50522. * of the effect layer.
  50523. */
  50524. export interface IEffectLayerOptions {
  50525. /**
  50526. * Multiplication factor apply to the canvas size to compute the render target size
  50527. * used to generated the objects (the smaller the faster).
  50528. */
  50529. mainTextureRatio: number;
  50530. /**
  50531. * Enforces a fixed size texture to ensure effect stability across devices.
  50532. */
  50533. mainTextureFixedSize?: number;
  50534. /**
  50535. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  50536. */
  50537. alphaBlendingMode: number;
  50538. /**
  50539. * The camera attached to the layer.
  50540. */
  50541. camera: Nullable<Camera>;
  50542. /**
  50543. * The rendering group to draw the layer in.
  50544. */
  50545. renderingGroupId: number;
  50546. }
  50547. /**
  50548. * The effect layer Helps adding post process effect blended with the main pass.
  50549. *
  50550. * This can be for instance use to generate glow or higlight effects on the scene.
  50551. *
  50552. * The effect layer class can not be used directly and is intented to inherited from to be
  50553. * customized per effects.
  50554. */
  50555. export abstract class EffectLayer {
  50556. private _vertexBuffers;
  50557. private _indexBuffer;
  50558. private _cachedDefines;
  50559. private _effectLayerMapGenerationEffect;
  50560. private _effectLayerOptions;
  50561. private _mergeEffect;
  50562. protected _scene: Scene;
  50563. protected _engine: Engine;
  50564. protected _maxSize: number;
  50565. protected _mainTextureDesiredSize: ISize;
  50566. protected _mainTexture: RenderTargetTexture;
  50567. protected _shouldRender: boolean;
  50568. protected _postProcesses: PostProcess[];
  50569. protected _textures: BaseTexture[];
  50570. protected _emissiveTextureAndColor: {
  50571. texture: Nullable<BaseTexture>;
  50572. color: Color4;
  50573. };
  50574. /**
  50575. * The name of the layer
  50576. */
  50577. name: string;
  50578. /**
  50579. * The clear color of the texture used to generate the glow map.
  50580. */
  50581. neutralColor: Color4;
  50582. /**
  50583. * Specifies wether the highlight layer is enabled or not.
  50584. */
  50585. isEnabled: boolean;
  50586. /**
  50587. * Gets the camera attached to the layer.
  50588. */
  50589. readonly camera: Nullable<Camera>;
  50590. /**
  50591. * Gets the rendering group id the layer should render in.
  50592. */
  50593. renderingGroupId: number;
  50594. /**
  50595. * An event triggered when the effect layer has been disposed.
  50596. */
  50597. onDisposeObservable: Observable<EffectLayer>;
  50598. /**
  50599. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  50600. */
  50601. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  50602. /**
  50603. * An event triggered when the generated texture is being merged in the scene.
  50604. */
  50605. onBeforeComposeObservable: Observable<EffectLayer>;
  50606. /**
  50607. * An event triggered when the generated texture has been merged in the scene.
  50608. */
  50609. onAfterComposeObservable: Observable<EffectLayer>;
  50610. /**
  50611. * An event triggered when the efffect layer changes its size.
  50612. */
  50613. onSizeChangedObservable: Observable<EffectLayer>;
  50614. /** @hidden */
  50615. static _SceneComponentInitialization: (scene: Scene) => void;
  50616. /**
  50617. * Instantiates a new effect Layer and references it in the scene.
  50618. * @param name The name of the layer
  50619. * @param scene The scene to use the layer in
  50620. */
  50621. constructor(
  50622. /** The Friendly of the effect in the scene */
  50623. name: string, scene: Scene);
  50624. /**
  50625. * Get the effect name of the layer.
  50626. * @return The effect name
  50627. */
  50628. abstract getEffectName(): string;
  50629. /**
  50630. * Checks for the readiness of the element composing the layer.
  50631. * @param subMesh the mesh to check for
  50632. * @param useInstances specify wether or not to use instances to render the mesh
  50633. * @return true if ready otherwise, false
  50634. */
  50635. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50636. /**
  50637. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50638. * @returns true if the effect requires stencil during the main canvas render pass.
  50639. */
  50640. abstract needStencil(): boolean;
  50641. /**
  50642. * Create the merge effect. This is the shader use to blit the information back
  50643. * to the main canvas at the end of the scene rendering.
  50644. * @returns The effect containing the shader used to merge the effect on the main canvas
  50645. */
  50646. protected abstract _createMergeEffect(): Effect;
  50647. /**
  50648. * Creates the render target textures and post processes used in the effect layer.
  50649. */
  50650. protected abstract _createTextureAndPostProcesses(): void;
  50651. /**
  50652. * Implementation specific of rendering the generating effect on the main canvas.
  50653. * @param effect The effect used to render through
  50654. */
  50655. protected abstract _internalRender(effect: Effect): void;
  50656. /**
  50657. * Sets the required values for both the emissive texture and and the main color.
  50658. */
  50659. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50660. /**
  50661. * Free any resources and references associated to a mesh.
  50662. * Internal use
  50663. * @param mesh The mesh to free.
  50664. */
  50665. abstract _disposeMesh(mesh: Mesh): void;
  50666. /**
  50667. * Serializes this layer (Glow or Highlight for example)
  50668. * @returns a serialized layer object
  50669. */
  50670. abstract serialize?(): any;
  50671. /**
  50672. * Initializes the effect layer with the required options.
  50673. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  50674. */
  50675. protected _init(options: Partial<IEffectLayerOptions>): void;
  50676. /**
  50677. * Generates the index buffer of the full screen quad blending to the main canvas.
  50678. */
  50679. private _generateIndexBuffer;
  50680. /**
  50681. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  50682. */
  50683. private _generateVertexBuffer;
  50684. /**
  50685. * Sets the main texture desired size which is the closest power of two
  50686. * of the engine canvas size.
  50687. */
  50688. private _setMainTextureSize;
  50689. /**
  50690. * Creates the main texture for the effect layer.
  50691. */
  50692. protected _createMainTexture(): void;
  50693. /**
  50694. * Adds specific effects defines.
  50695. * @param defines The defines to add specifics to.
  50696. */
  50697. protected _addCustomEffectDefines(defines: string[]): void;
  50698. /**
  50699. * Checks for the readiness of the element composing the layer.
  50700. * @param subMesh the mesh to check for
  50701. * @param useInstances specify wether or not to use instances to render the mesh
  50702. * @param emissiveTexture the associated emissive texture used to generate the glow
  50703. * @return true if ready otherwise, false
  50704. */
  50705. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  50706. /**
  50707. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  50708. */
  50709. render(): void;
  50710. /**
  50711. * Determine if a given mesh will be used in the current effect.
  50712. * @param mesh mesh to test
  50713. * @returns true if the mesh will be used
  50714. */
  50715. hasMesh(mesh: AbstractMesh): boolean;
  50716. /**
  50717. * Returns true if the layer contains information to display, otherwise false.
  50718. * @returns true if the glow layer should be rendered
  50719. */
  50720. shouldRender(): boolean;
  50721. /**
  50722. * Returns true if the mesh should render, otherwise false.
  50723. * @param mesh The mesh to render
  50724. * @returns true if it should render otherwise false
  50725. */
  50726. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  50727. /**
  50728. * Returns true if the mesh can be rendered, otherwise false.
  50729. * @param mesh The mesh to render
  50730. * @param material The material used on the mesh
  50731. * @returns true if it can be rendered otherwise false
  50732. */
  50733. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  50734. /**
  50735. * Returns true if the mesh should render, otherwise false.
  50736. * @param mesh The mesh to render
  50737. * @returns true if it should render otherwise false
  50738. */
  50739. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  50740. /**
  50741. * Renders the submesh passed in parameter to the generation map.
  50742. */
  50743. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  50744. /**
  50745. * Rebuild the required buffers.
  50746. * @hidden Internal use only.
  50747. */
  50748. _rebuild(): void;
  50749. /**
  50750. * Dispose only the render target textures and post process.
  50751. */
  50752. private _disposeTextureAndPostProcesses;
  50753. /**
  50754. * Dispose the highlight layer and free resources.
  50755. */
  50756. dispose(): void;
  50757. /**
  50758. * Gets the class name of the effect layer
  50759. * @returns the string with the class name of the effect layer
  50760. */
  50761. getClassName(): string;
  50762. /**
  50763. * Creates an effect layer from parsed effect layer data
  50764. * @param parsedEffectLayer defines effect layer data
  50765. * @param scene defines the current scene
  50766. * @param rootUrl defines the root URL containing the effect layer information
  50767. * @returns a parsed effect Layer
  50768. */
  50769. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  50770. }
  50771. }
  50772. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  50773. import { Scene } from "babylonjs/scene";
  50774. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  50775. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  50776. import { AbstractScene } from "babylonjs/abstractScene";
  50777. module "babylonjs/abstractScene" {
  50778. interface AbstractScene {
  50779. /**
  50780. * The list of effect layers (highlights/glow) added to the scene
  50781. * @see http://doc.babylonjs.com/how_to/highlight_layer
  50782. * @see http://doc.babylonjs.com/how_to/glow_layer
  50783. */
  50784. effectLayers: Array<EffectLayer>;
  50785. /**
  50786. * Removes the given effect layer from this scene.
  50787. * @param toRemove defines the effect layer to remove
  50788. * @returns the index of the removed effect layer
  50789. */
  50790. removeEffectLayer(toRemove: EffectLayer): number;
  50791. /**
  50792. * Adds the given effect layer to this scene
  50793. * @param newEffectLayer defines the effect layer to add
  50794. */
  50795. addEffectLayer(newEffectLayer: EffectLayer): void;
  50796. }
  50797. }
  50798. /**
  50799. * Defines the layer scene component responsible to manage any effect layers
  50800. * in a given scene.
  50801. */
  50802. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  50803. /**
  50804. * The component name helpfull to identify the component in the list of scene components.
  50805. */
  50806. readonly name: string;
  50807. /**
  50808. * The scene the component belongs to.
  50809. */
  50810. scene: Scene;
  50811. private _engine;
  50812. private _renderEffects;
  50813. private _needStencil;
  50814. private _previousStencilState;
  50815. /**
  50816. * Creates a new instance of the component for the given scene
  50817. * @param scene Defines the scene to register the component in
  50818. */
  50819. constructor(scene: Scene);
  50820. /**
  50821. * Registers the component in a given scene
  50822. */
  50823. register(): void;
  50824. /**
  50825. * Rebuilds the elements related to this component in case of
  50826. * context lost for instance.
  50827. */
  50828. rebuild(): void;
  50829. /**
  50830. * Serializes the component data to the specified json object
  50831. * @param serializationObject The object to serialize to
  50832. */
  50833. serialize(serializationObject: any): void;
  50834. /**
  50835. * Adds all the elements from the container to the scene
  50836. * @param container the container holding the elements
  50837. */
  50838. addFromContainer(container: AbstractScene): void;
  50839. /**
  50840. * Removes all the elements in the container from the scene
  50841. * @param container contains the elements to remove
  50842. * @param dispose if the removed element should be disposed (default: false)
  50843. */
  50844. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50845. /**
  50846. * Disposes the component and the associated ressources.
  50847. */
  50848. dispose(): void;
  50849. private _isReadyForMesh;
  50850. private _renderMainTexture;
  50851. private _setStencil;
  50852. private _setStencilBack;
  50853. private _draw;
  50854. private _drawCamera;
  50855. private _drawRenderingGroup;
  50856. }
  50857. }
  50858. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  50859. /** @hidden */
  50860. export var glowMapMergePixelShader: {
  50861. name: string;
  50862. shader: string;
  50863. };
  50864. }
  50865. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  50866. /** @hidden */
  50867. export var glowMapMergeVertexShader: {
  50868. name: string;
  50869. shader: string;
  50870. };
  50871. }
  50872. declare module "babylonjs/Layers/glowLayer" {
  50873. import { Nullable } from "babylonjs/types";
  50874. import { Camera } from "babylonjs/Cameras/camera";
  50875. import { Scene } from "babylonjs/scene";
  50876. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50877. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50878. import { Mesh } from "babylonjs/Meshes/mesh";
  50879. import { Texture } from "babylonjs/Materials/Textures/texture";
  50880. import { Effect } from "babylonjs/Materials/effect";
  50881. import { Material } from "babylonjs/Materials/material";
  50882. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  50883. import { Color4 } from "babylonjs/Maths/math.color";
  50884. import "babylonjs/Shaders/glowMapMerge.fragment";
  50885. import "babylonjs/Shaders/glowMapMerge.vertex";
  50886. import "babylonjs/Layers/effectLayerSceneComponent";
  50887. module "babylonjs/abstractScene" {
  50888. interface AbstractScene {
  50889. /**
  50890. * Return a the first highlight layer of the scene with a given name.
  50891. * @param name The name of the highlight layer to look for.
  50892. * @return The highlight layer if found otherwise null.
  50893. */
  50894. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  50895. }
  50896. }
  50897. /**
  50898. * Glow layer options. This helps customizing the behaviour
  50899. * of the glow layer.
  50900. */
  50901. export interface IGlowLayerOptions {
  50902. /**
  50903. * Multiplication factor apply to the canvas size to compute the render target size
  50904. * used to generated the glowing objects (the smaller the faster).
  50905. */
  50906. mainTextureRatio: number;
  50907. /**
  50908. * Enforces a fixed size texture to ensure resize independant blur.
  50909. */
  50910. mainTextureFixedSize?: number;
  50911. /**
  50912. * How big is the kernel of the blur texture.
  50913. */
  50914. blurKernelSize: number;
  50915. /**
  50916. * The camera attached to the layer.
  50917. */
  50918. camera: Nullable<Camera>;
  50919. /**
  50920. * Enable MSAA by chosing the number of samples.
  50921. */
  50922. mainTextureSamples?: number;
  50923. /**
  50924. * The rendering group to draw the layer in.
  50925. */
  50926. renderingGroupId: number;
  50927. }
  50928. /**
  50929. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  50930. *
  50931. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  50932. * glowy meshes to your scene.
  50933. *
  50934. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  50935. */
  50936. export class GlowLayer extends EffectLayer {
  50937. /**
  50938. * Effect Name of the layer.
  50939. */
  50940. static readonly EffectName: string;
  50941. /**
  50942. * The default blur kernel size used for the glow.
  50943. */
  50944. static DefaultBlurKernelSize: number;
  50945. /**
  50946. * The default texture size ratio used for the glow.
  50947. */
  50948. static DefaultTextureRatio: number;
  50949. /**
  50950. * Sets the kernel size of the blur.
  50951. */
  50952. /**
  50953. * Gets the kernel size of the blur.
  50954. */
  50955. blurKernelSize: number;
  50956. /**
  50957. * Sets the glow intensity.
  50958. */
  50959. /**
  50960. * Gets the glow intensity.
  50961. */
  50962. intensity: number;
  50963. private _options;
  50964. private _intensity;
  50965. private _horizontalBlurPostprocess1;
  50966. private _verticalBlurPostprocess1;
  50967. private _horizontalBlurPostprocess2;
  50968. private _verticalBlurPostprocess2;
  50969. private _blurTexture1;
  50970. private _blurTexture2;
  50971. private _postProcesses1;
  50972. private _postProcesses2;
  50973. private _includedOnlyMeshes;
  50974. private _excludedMeshes;
  50975. /**
  50976. * Callback used to let the user override the color selection on a per mesh basis
  50977. */
  50978. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  50979. /**
  50980. * Callback used to let the user override the texture selection on a per mesh basis
  50981. */
  50982. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  50983. /**
  50984. * Instantiates a new glow Layer and references it to the scene.
  50985. * @param name The name of the layer
  50986. * @param scene The scene to use the layer in
  50987. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  50988. */
  50989. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  50990. /**
  50991. * Get the effect name of the layer.
  50992. * @return The effect name
  50993. */
  50994. getEffectName(): string;
  50995. /**
  50996. * Create the merge effect. This is the shader use to blit the information back
  50997. * to the main canvas at the end of the scene rendering.
  50998. */
  50999. protected _createMergeEffect(): Effect;
  51000. /**
  51001. * Creates the render target textures and post processes used in the glow layer.
  51002. */
  51003. protected _createTextureAndPostProcesses(): void;
  51004. /**
  51005. * Checks for the readiness of the element composing the layer.
  51006. * @param subMesh the mesh to check for
  51007. * @param useInstances specify wether or not to use instances to render the mesh
  51008. * @param emissiveTexture the associated emissive texture used to generate the glow
  51009. * @return true if ready otherwise, false
  51010. */
  51011. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51012. /**
  51013. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51014. */
  51015. needStencil(): boolean;
  51016. /**
  51017. * Returns true if the mesh can be rendered, otherwise false.
  51018. * @param mesh The mesh to render
  51019. * @param material The material used on the mesh
  51020. * @returns true if it can be rendered otherwise false
  51021. */
  51022. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51023. /**
  51024. * Implementation specific of rendering the generating effect on the main canvas.
  51025. * @param effect The effect used to render through
  51026. */
  51027. protected _internalRender(effect: Effect): void;
  51028. /**
  51029. * Sets the required values for both the emissive texture and and the main color.
  51030. */
  51031. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51032. /**
  51033. * Returns true if the mesh should render, otherwise false.
  51034. * @param mesh The mesh to render
  51035. * @returns true if it should render otherwise false
  51036. */
  51037. protected _shouldRenderMesh(mesh: Mesh): boolean;
  51038. /**
  51039. * Adds specific effects defines.
  51040. * @param defines The defines to add specifics to.
  51041. */
  51042. protected _addCustomEffectDefines(defines: string[]): void;
  51043. /**
  51044. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  51045. * @param mesh The mesh to exclude from the glow layer
  51046. */
  51047. addExcludedMesh(mesh: Mesh): void;
  51048. /**
  51049. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  51050. * @param mesh The mesh to remove
  51051. */
  51052. removeExcludedMesh(mesh: Mesh): void;
  51053. /**
  51054. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  51055. * @param mesh The mesh to include in the glow layer
  51056. */
  51057. addIncludedOnlyMesh(mesh: Mesh): void;
  51058. /**
  51059. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  51060. * @param mesh The mesh to remove
  51061. */
  51062. removeIncludedOnlyMesh(mesh: Mesh): void;
  51063. /**
  51064. * Determine if a given mesh will be used in the glow layer
  51065. * @param mesh The mesh to test
  51066. * @returns true if the mesh will be highlighted by the current glow layer
  51067. */
  51068. hasMesh(mesh: AbstractMesh): boolean;
  51069. /**
  51070. * Free any resources and references associated to a mesh.
  51071. * Internal use
  51072. * @param mesh The mesh to free.
  51073. * @hidden
  51074. */
  51075. _disposeMesh(mesh: Mesh): void;
  51076. /**
  51077. * Gets the class name of the effect layer
  51078. * @returns the string with the class name of the effect layer
  51079. */
  51080. getClassName(): string;
  51081. /**
  51082. * Serializes this glow layer
  51083. * @returns a serialized glow layer object
  51084. */
  51085. serialize(): any;
  51086. /**
  51087. * Creates a Glow Layer from parsed glow layer data
  51088. * @param parsedGlowLayer defines glow layer data
  51089. * @param scene defines the current scene
  51090. * @param rootUrl defines the root URL containing the glow layer information
  51091. * @returns a parsed Glow Layer
  51092. */
  51093. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  51094. }
  51095. }
  51096. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  51097. /** @hidden */
  51098. export var glowBlurPostProcessPixelShader: {
  51099. name: string;
  51100. shader: string;
  51101. };
  51102. }
  51103. declare module "babylonjs/Layers/highlightLayer" {
  51104. import { Observable } from "babylonjs/Misc/observable";
  51105. import { Nullable } from "babylonjs/types";
  51106. import { Camera } from "babylonjs/Cameras/camera";
  51107. import { Scene } from "babylonjs/scene";
  51108. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51109. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51110. import { Mesh } from "babylonjs/Meshes/mesh";
  51111. import { Effect } from "babylonjs/Materials/effect";
  51112. import { Material } from "babylonjs/Materials/material";
  51113. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51114. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  51115. import "babylonjs/Shaders/glowMapMerge.fragment";
  51116. import "babylonjs/Shaders/glowMapMerge.vertex";
  51117. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  51118. module "babylonjs/abstractScene" {
  51119. interface AbstractScene {
  51120. /**
  51121. * Return a the first highlight layer of the scene with a given name.
  51122. * @param name The name of the highlight layer to look for.
  51123. * @return The highlight layer if found otherwise null.
  51124. */
  51125. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  51126. }
  51127. }
  51128. /**
  51129. * Highlight layer options. This helps customizing the behaviour
  51130. * of the highlight layer.
  51131. */
  51132. export interface IHighlightLayerOptions {
  51133. /**
  51134. * Multiplication factor apply to the canvas size to compute the render target size
  51135. * used to generated the glowing objects (the smaller the faster).
  51136. */
  51137. mainTextureRatio: number;
  51138. /**
  51139. * Enforces a fixed size texture to ensure resize independant blur.
  51140. */
  51141. mainTextureFixedSize?: number;
  51142. /**
  51143. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  51144. * of the picture to blur (the smaller the faster).
  51145. */
  51146. blurTextureSizeRatio: number;
  51147. /**
  51148. * How big in texel of the blur texture is the vertical blur.
  51149. */
  51150. blurVerticalSize: number;
  51151. /**
  51152. * How big in texel of the blur texture is the horizontal blur.
  51153. */
  51154. blurHorizontalSize: number;
  51155. /**
  51156. * Alpha blending mode used to apply the blur. Default is combine.
  51157. */
  51158. alphaBlendingMode: number;
  51159. /**
  51160. * The camera attached to the layer.
  51161. */
  51162. camera: Nullable<Camera>;
  51163. /**
  51164. * Should we display highlight as a solid stroke?
  51165. */
  51166. isStroke?: boolean;
  51167. /**
  51168. * The rendering group to draw the layer in.
  51169. */
  51170. renderingGroupId: number;
  51171. }
  51172. /**
  51173. * The highlight layer Helps adding a glow effect around a mesh.
  51174. *
  51175. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  51176. * glowy meshes to your scene.
  51177. *
  51178. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  51179. */
  51180. export class HighlightLayer extends EffectLayer {
  51181. name: string;
  51182. /**
  51183. * Effect Name of the highlight layer.
  51184. */
  51185. static readonly EffectName: string;
  51186. /**
  51187. * The neutral color used during the preparation of the glow effect.
  51188. * This is black by default as the blend operation is a blend operation.
  51189. */
  51190. static NeutralColor: Color4;
  51191. /**
  51192. * Stencil value used for glowing meshes.
  51193. */
  51194. static GlowingMeshStencilReference: number;
  51195. /**
  51196. * Stencil value used for the other meshes in the scene.
  51197. */
  51198. static NormalMeshStencilReference: number;
  51199. /**
  51200. * Specifies whether or not the inner glow is ACTIVE in the layer.
  51201. */
  51202. innerGlow: boolean;
  51203. /**
  51204. * Specifies whether or not the outer glow is ACTIVE in the layer.
  51205. */
  51206. outerGlow: boolean;
  51207. /**
  51208. * Specifies the horizontal size of the blur.
  51209. */
  51210. /**
  51211. * Gets the horizontal size of the blur.
  51212. */
  51213. blurHorizontalSize: number;
  51214. /**
  51215. * Specifies the vertical size of the blur.
  51216. */
  51217. /**
  51218. * Gets the vertical size of the blur.
  51219. */
  51220. blurVerticalSize: number;
  51221. /**
  51222. * An event triggered when the highlight layer is being blurred.
  51223. */
  51224. onBeforeBlurObservable: Observable<HighlightLayer>;
  51225. /**
  51226. * An event triggered when the highlight layer has been blurred.
  51227. */
  51228. onAfterBlurObservable: Observable<HighlightLayer>;
  51229. private _instanceGlowingMeshStencilReference;
  51230. private _options;
  51231. private _downSamplePostprocess;
  51232. private _horizontalBlurPostprocess;
  51233. private _verticalBlurPostprocess;
  51234. private _blurTexture;
  51235. private _meshes;
  51236. private _excludedMeshes;
  51237. /**
  51238. * Instantiates a new highlight Layer and references it to the scene..
  51239. * @param name The name of the layer
  51240. * @param scene The scene to use the layer in
  51241. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  51242. */
  51243. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  51244. /**
  51245. * Get the effect name of the layer.
  51246. * @return The effect name
  51247. */
  51248. getEffectName(): string;
  51249. /**
  51250. * Create the merge effect. This is the shader use to blit the information back
  51251. * to the main canvas at the end of the scene rendering.
  51252. */
  51253. protected _createMergeEffect(): Effect;
  51254. /**
  51255. * Creates the render target textures and post processes used in the highlight layer.
  51256. */
  51257. protected _createTextureAndPostProcesses(): void;
  51258. /**
  51259. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51260. */
  51261. needStencil(): boolean;
  51262. /**
  51263. * Checks for the readiness of the element composing the layer.
  51264. * @param subMesh the mesh to check for
  51265. * @param useInstances specify wether or not to use instances to render the mesh
  51266. * @param emissiveTexture the associated emissive texture used to generate the glow
  51267. * @return true if ready otherwise, false
  51268. */
  51269. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51270. /**
  51271. * Implementation specific of rendering the generating effect on the main canvas.
  51272. * @param effect The effect used to render through
  51273. */
  51274. protected _internalRender(effect: Effect): void;
  51275. /**
  51276. * Returns true if the layer contains information to display, otherwise false.
  51277. */
  51278. shouldRender(): boolean;
  51279. /**
  51280. * Returns true if the mesh should render, otherwise false.
  51281. * @param mesh The mesh to render
  51282. * @returns true if it should render otherwise false
  51283. */
  51284. protected _shouldRenderMesh(mesh: Mesh): boolean;
  51285. /**
  51286. * Sets the required values for both the emissive texture and and the main color.
  51287. */
  51288. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51289. /**
  51290. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  51291. * @param mesh The mesh to exclude from the highlight layer
  51292. */
  51293. addExcludedMesh(mesh: Mesh): void;
  51294. /**
  51295. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  51296. * @param mesh The mesh to highlight
  51297. */
  51298. removeExcludedMesh(mesh: Mesh): void;
  51299. /**
  51300. * Determine if a given mesh will be highlighted by the current HighlightLayer
  51301. * @param mesh mesh to test
  51302. * @returns true if the mesh will be highlighted by the current HighlightLayer
  51303. */
  51304. hasMesh(mesh: AbstractMesh): boolean;
  51305. /**
  51306. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  51307. * @param mesh The mesh to highlight
  51308. * @param color The color of the highlight
  51309. * @param glowEmissiveOnly Extract the glow from the emissive texture
  51310. */
  51311. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  51312. /**
  51313. * Remove a mesh from the highlight layer in order to make it stop glowing.
  51314. * @param mesh The mesh to highlight
  51315. */
  51316. removeMesh(mesh: Mesh): void;
  51317. /**
  51318. * Force the stencil to the normal expected value for none glowing parts
  51319. */
  51320. private _defaultStencilReference;
  51321. /**
  51322. * Free any resources and references associated to a mesh.
  51323. * Internal use
  51324. * @param mesh The mesh to free.
  51325. * @hidden
  51326. */
  51327. _disposeMesh(mesh: Mesh): void;
  51328. /**
  51329. * Dispose the highlight layer and free resources.
  51330. */
  51331. dispose(): void;
  51332. /**
  51333. * Gets the class name of the effect layer
  51334. * @returns the string with the class name of the effect layer
  51335. */
  51336. getClassName(): string;
  51337. /**
  51338. * Serializes this Highlight layer
  51339. * @returns a serialized Highlight layer object
  51340. */
  51341. serialize(): any;
  51342. /**
  51343. * Creates a Highlight layer from parsed Highlight layer data
  51344. * @param parsedHightlightLayer defines the Highlight layer data
  51345. * @param scene defines the current scene
  51346. * @param rootUrl defines the root URL containing the Highlight layer information
  51347. * @returns a parsed Highlight layer
  51348. */
  51349. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  51350. }
  51351. }
  51352. declare module "babylonjs/Layers/layerSceneComponent" {
  51353. import { Scene } from "babylonjs/scene";
  51354. import { ISceneComponent } from "babylonjs/sceneComponent";
  51355. import { Layer } from "babylonjs/Layers/layer";
  51356. import { AbstractScene } from "babylonjs/abstractScene";
  51357. module "babylonjs/abstractScene" {
  51358. interface AbstractScene {
  51359. /**
  51360. * The list of layers (background and foreground) of the scene
  51361. */
  51362. layers: Array<Layer>;
  51363. }
  51364. }
  51365. /**
  51366. * Defines the layer scene component responsible to manage any layers
  51367. * in a given scene.
  51368. */
  51369. export class LayerSceneComponent implements ISceneComponent {
  51370. /**
  51371. * The component name helpfull to identify the component in the list of scene components.
  51372. */
  51373. readonly name: string;
  51374. /**
  51375. * The scene the component belongs to.
  51376. */
  51377. scene: Scene;
  51378. private _engine;
  51379. /**
  51380. * Creates a new instance of the component for the given scene
  51381. * @param scene Defines the scene to register the component in
  51382. */
  51383. constructor(scene: Scene);
  51384. /**
  51385. * Registers the component in a given scene
  51386. */
  51387. register(): void;
  51388. /**
  51389. * Rebuilds the elements related to this component in case of
  51390. * context lost for instance.
  51391. */
  51392. rebuild(): void;
  51393. /**
  51394. * Disposes the component and the associated ressources.
  51395. */
  51396. dispose(): void;
  51397. private _draw;
  51398. private _drawCameraPredicate;
  51399. private _drawCameraBackground;
  51400. private _drawCameraForeground;
  51401. private _drawRenderTargetPredicate;
  51402. private _drawRenderTargetBackground;
  51403. private _drawRenderTargetForeground;
  51404. /**
  51405. * Adds all the elements from the container to the scene
  51406. * @param container the container holding the elements
  51407. */
  51408. addFromContainer(container: AbstractScene): void;
  51409. /**
  51410. * Removes all the elements in the container from the scene
  51411. * @param container contains the elements to remove
  51412. * @param dispose if the removed element should be disposed (default: false)
  51413. */
  51414. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51415. }
  51416. }
  51417. declare module "babylonjs/Shaders/layer.fragment" {
  51418. /** @hidden */
  51419. export var layerPixelShader: {
  51420. name: string;
  51421. shader: string;
  51422. };
  51423. }
  51424. declare module "babylonjs/Shaders/layer.vertex" {
  51425. /** @hidden */
  51426. export var layerVertexShader: {
  51427. name: string;
  51428. shader: string;
  51429. };
  51430. }
  51431. declare module "babylonjs/Layers/layer" {
  51432. import { Observable } from "babylonjs/Misc/observable";
  51433. import { Nullable } from "babylonjs/types";
  51434. import { Scene } from "babylonjs/scene";
  51435. import { Vector2 } from "babylonjs/Maths/math.vector";
  51436. import { Color4 } from "babylonjs/Maths/math.color";
  51437. import { Texture } from "babylonjs/Materials/Textures/texture";
  51438. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51439. import "babylonjs/Shaders/layer.fragment";
  51440. import "babylonjs/Shaders/layer.vertex";
  51441. /**
  51442. * This represents a full screen 2d layer.
  51443. * This can be useful to display a picture in the background of your scene for instance.
  51444. * @see https://www.babylonjs-playground.com/#08A2BS#1
  51445. */
  51446. export class Layer {
  51447. /**
  51448. * Define the name of the layer.
  51449. */
  51450. name: string;
  51451. /**
  51452. * Define the texture the layer should display.
  51453. */
  51454. texture: Nullable<Texture>;
  51455. /**
  51456. * Is the layer in background or foreground.
  51457. */
  51458. isBackground: boolean;
  51459. /**
  51460. * Define the color of the layer (instead of texture).
  51461. */
  51462. color: Color4;
  51463. /**
  51464. * Define the scale of the layer in order to zoom in out of the texture.
  51465. */
  51466. scale: Vector2;
  51467. /**
  51468. * Define an offset for the layer in order to shift the texture.
  51469. */
  51470. offset: Vector2;
  51471. /**
  51472. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  51473. */
  51474. alphaBlendingMode: number;
  51475. /**
  51476. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  51477. * Alpha test will not mix with the background color in case of transparency.
  51478. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  51479. */
  51480. alphaTest: boolean;
  51481. /**
  51482. * Define a mask to restrict the layer to only some of the scene cameras.
  51483. */
  51484. layerMask: number;
  51485. /**
  51486. * Define the list of render target the layer is visible into.
  51487. */
  51488. renderTargetTextures: RenderTargetTexture[];
  51489. /**
  51490. * Define if the layer is only used in renderTarget or if it also
  51491. * renders in the main frame buffer of the canvas.
  51492. */
  51493. renderOnlyInRenderTargetTextures: boolean;
  51494. private _scene;
  51495. private _vertexBuffers;
  51496. private _indexBuffer;
  51497. private _effect;
  51498. private _alphaTestEffect;
  51499. /**
  51500. * An event triggered when the layer is disposed.
  51501. */
  51502. onDisposeObservable: Observable<Layer>;
  51503. private _onDisposeObserver;
  51504. /**
  51505. * Back compatibility with callback before the onDisposeObservable existed.
  51506. * The set callback will be triggered when the layer has been disposed.
  51507. */
  51508. onDispose: () => void;
  51509. /**
  51510. * An event triggered before rendering the scene
  51511. */
  51512. onBeforeRenderObservable: Observable<Layer>;
  51513. private _onBeforeRenderObserver;
  51514. /**
  51515. * Back compatibility with callback before the onBeforeRenderObservable existed.
  51516. * The set callback will be triggered just before rendering the layer.
  51517. */
  51518. onBeforeRender: () => void;
  51519. /**
  51520. * An event triggered after rendering the scene
  51521. */
  51522. onAfterRenderObservable: Observable<Layer>;
  51523. private _onAfterRenderObserver;
  51524. /**
  51525. * Back compatibility with callback before the onAfterRenderObservable existed.
  51526. * The set callback will be triggered just after rendering the layer.
  51527. */
  51528. onAfterRender: () => void;
  51529. /**
  51530. * Instantiates a new layer.
  51531. * This represents a full screen 2d layer.
  51532. * This can be useful to display a picture in the background of your scene for instance.
  51533. * @see https://www.babylonjs-playground.com/#08A2BS#1
  51534. * @param name Define the name of the layer in the scene
  51535. * @param imgUrl Define the url of the texture to display in the layer
  51536. * @param scene Define the scene the layer belongs to
  51537. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  51538. * @param color Defines a color for the layer
  51539. */
  51540. constructor(
  51541. /**
  51542. * Define the name of the layer.
  51543. */
  51544. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  51545. private _createIndexBuffer;
  51546. /** @hidden */
  51547. _rebuild(): void;
  51548. /**
  51549. * Renders the layer in the scene.
  51550. */
  51551. render(): void;
  51552. /**
  51553. * Disposes and releases the associated ressources.
  51554. */
  51555. dispose(): void;
  51556. }
  51557. }
  51558. declare module "babylonjs/Layers/index" {
  51559. export * from "babylonjs/Layers/effectLayer";
  51560. export * from "babylonjs/Layers/effectLayerSceneComponent";
  51561. export * from "babylonjs/Layers/glowLayer";
  51562. export * from "babylonjs/Layers/highlightLayer";
  51563. export * from "babylonjs/Layers/layer";
  51564. export * from "babylonjs/Layers/layerSceneComponent";
  51565. }
  51566. declare module "babylonjs/Shaders/lensFlare.fragment" {
  51567. /** @hidden */
  51568. export var lensFlarePixelShader: {
  51569. name: string;
  51570. shader: string;
  51571. };
  51572. }
  51573. declare module "babylonjs/Shaders/lensFlare.vertex" {
  51574. /** @hidden */
  51575. export var lensFlareVertexShader: {
  51576. name: string;
  51577. shader: string;
  51578. };
  51579. }
  51580. declare module "babylonjs/LensFlares/lensFlareSystem" {
  51581. import { Scene } from "babylonjs/scene";
  51582. import { Vector3 } from "babylonjs/Maths/math.vector";
  51583. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51584. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  51585. import "babylonjs/Shaders/lensFlare.fragment";
  51586. import "babylonjs/Shaders/lensFlare.vertex";
  51587. import { Viewport } from "babylonjs/Maths/math.viewport";
  51588. /**
  51589. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  51590. * It is usually composed of several `lensFlare`.
  51591. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51592. */
  51593. export class LensFlareSystem {
  51594. /**
  51595. * Define the name of the lens flare system
  51596. */
  51597. name: string;
  51598. /**
  51599. * List of lens flares used in this system.
  51600. */
  51601. lensFlares: LensFlare[];
  51602. /**
  51603. * Define a limit from the border the lens flare can be visible.
  51604. */
  51605. borderLimit: number;
  51606. /**
  51607. * Define a viewport border we do not want to see the lens flare in.
  51608. */
  51609. viewportBorder: number;
  51610. /**
  51611. * Define a predicate which could limit the list of meshes able to occlude the effect.
  51612. */
  51613. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  51614. /**
  51615. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  51616. */
  51617. layerMask: number;
  51618. /**
  51619. * Define the id of the lens flare system in the scene.
  51620. * (equal to name by default)
  51621. */
  51622. id: string;
  51623. private _scene;
  51624. private _emitter;
  51625. private _vertexBuffers;
  51626. private _indexBuffer;
  51627. private _effect;
  51628. private _positionX;
  51629. private _positionY;
  51630. private _isEnabled;
  51631. /** @hidden */
  51632. static _SceneComponentInitialization: (scene: Scene) => void;
  51633. /**
  51634. * Instantiates a lens flare system.
  51635. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  51636. * It is usually composed of several `lensFlare`.
  51637. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51638. * @param name Define the name of the lens flare system in the scene
  51639. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  51640. * @param scene Define the scene the lens flare system belongs to
  51641. */
  51642. constructor(
  51643. /**
  51644. * Define the name of the lens flare system
  51645. */
  51646. name: string, emitter: any, scene: Scene);
  51647. /**
  51648. * Define if the lens flare system is enabled.
  51649. */
  51650. isEnabled: boolean;
  51651. /**
  51652. * Get the scene the effects belongs to.
  51653. * @returns the scene holding the lens flare system
  51654. */
  51655. getScene(): Scene;
  51656. /**
  51657. * Get the emitter of the lens flare system.
  51658. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  51659. * @returns the emitter of the lens flare system
  51660. */
  51661. getEmitter(): any;
  51662. /**
  51663. * Set the emitter of the lens flare system.
  51664. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  51665. * @param newEmitter Define the new emitter of the system
  51666. */
  51667. setEmitter(newEmitter: any): void;
  51668. /**
  51669. * Get the lens flare system emitter position.
  51670. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  51671. * @returns the position
  51672. */
  51673. getEmitterPosition(): Vector3;
  51674. /**
  51675. * @hidden
  51676. */
  51677. computeEffectivePosition(globalViewport: Viewport): boolean;
  51678. /** @hidden */
  51679. _isVisible(): boolean;
  51680. /**
  51681. * @hidden
  51682. */
  51683. render(): boolean;
  51684. /**
  51685. * Dispose and release the lens flare with its associated resources.
  51686. */
  51687. dispose(): void;
  51688. /**
  51689. * Parse a lens flare system from a JSON repressentation
  51690. * @param parsedLensFlareSystem Define the JSON to parse
  51691. * @param scene Define the scene the parsed system should be instantiated in
  51692. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  51693. * @returns the parsed system
  51694. */
  51695. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  51696. /**
  51697. * Serialize the current Lens Flare System into a JSON representation.
  51698. * @returns the serialized JSON
  51699. */
  51700. serialize(): any;
  51701. }
  51702. }
  51703. declare module "babylonjs/LensFlares/lensFlare" {
  51704. import { Nullable } from "babylonjs/types";
  51705. import { Color3 } from "babylonjs/Maths/math.color";
  51706. import { Texture } from "babylonjs/Materials/Textures/texture";
  51707. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  51708. /**
  51709. * This represents one of the lens effect in a `lensFlareSystem`.
  51710. * It controls one of the indiviual texture used in the effect.
  51711. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51712. */
  51713. export class LensFlare {
  51714. /**
  51715. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  51716. */
  51717. size: number;
  51718. /**
  51719. * 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.
  51720. */
  51721. position: number;
  51722. /**
  51723. * Define the lens color.
  51724. */
  51725. color: Color3;
  51726. /**
  51727. * Define the lens texture.
  51728. */
  51729. texture: Nullable<Texture>;
  51730. /**
  51731. * Define the alpha mode to render this particular lens.
  51732. */
  51733. alphaMode: number;
  51734. private _system;
  51735. /**
  51736. * Creates a new Lens Flare.
  51737. * This represents one of the lens effect in a `lensFlareSystem`.
  51738. * It controls one of the indiviual texture used in the effect.
  51739. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51740. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  51741. * @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.
  51742. * @param color Define the lens color
  51743. * @param imgUrl Define the lens texture url
  51744. * @param system Define the `lensFlareSystem` this flare is part of
  51745. * @returns The newly created Lens Flare
  51746. */
  51747. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  51748. /**
  51749. * Instantiates a new Lens Flare.
  51750. * This represents one of the lens effect in a `lensFlareSystem`.
  51751. * It controls one of the indiviual texture used in the effect.
  51752. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51753. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  51754. * @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.
  51755. * @param color Define the lens color
  51756. * @param imgUrl Define the lens texture url
  51757. * @param system Define the `lensFlareSystem` this flare is part of
  51758. */
  51759. constructor(
  51760. /**
  51761. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  51762. */
  51763. size: number,
  51764. /**
  51765. * 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.
  51766. */
  51767. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  51768. /**
  51769. * Dispose and release the lens flare with its associated resources.
  51770. */
  51771. dispose(): void;
  51772. }
  51773. }
  51774. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  51775. import { Nullable } from "babylonjs/types";
  51776. import { Scene } from "babylonjs/scene";
  51777. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51778. import { AbstractScene } from "babylonjs/abstractScene";
  51779. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  51780. module "babylonjs/abstractScene" {
  51781. interface AbstractScene {
  51782. /**
  51783. * The list of lens flare system added to the scene
  51784. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51785. */
  51786. lensFlareSystems: Array<LensFlareSystem>;
  51787. /**
  51788. * Removes the given lens flare system from this scene.
  51789. * @param toRemove The lens flare system to remove
  51790. * @returns The index of the removed lens flare system
  51791. */
  51792. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  51793. /**
  51794. * Adds the given lens flare system to this scene
  51795. * @param newLensFlareSystem The lens flare system to add
  51796. */
  51797. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  51798. /**
  51799. * Gets a lens flare system using its name
  51800. * @param name defines the name to look for
  51801. * @returns the lens flare system or null if not found
  51802. */
  51803. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  51804. /**
  51805. * Gets a lens flare system using its id
  51806. * @param id defines the id to look for
  51807. * @returns the lens flare system or null if not found
  51808. */
  51809. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  51810. }
  51811. }
  51812. /**
  51813. * Defines the lens flare scene component responsible to manage any lens flares
  51814. * in a given scene.
  51815. */
  51816. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  51817. /**
  51818. * The component name helpfull to identify the component in the list of scene components.
  51819. */
  51820. readonly name: string;
  51821. /**
  51822. * The scene the component belongs to.
  51823. */
  51824. scene: Scene;
  51825. /**
  51826. * Creates a new instance of the component for the given scene
  51827. * @param scene Defines the scene to register the component in
  51828. */
  51829. constructor(scene: Scene);
  51830. /**
  51831. * Registers the component in a given scene
  51832. */
  51833. register(): void;
  51834. /**
  51835. * Rebuilds the elements related to this component in case of
  51836. * context lost for instance.
  51837. */
  51838. rebuild(): void;
  51839. /**
  51840. * Adds all the elements from the container to the scene
  51841. * @param container the container holding the elements
  51842. */
  51843. addFromContainer(container: AbstractScene): void;
  51844. /**
  51845. * Removes all the elements in the container from the scene
  51846. * @param container contains the elements to remove
  51847. * @param dispose if the removed element should be disposed (default: false)
  51848. */
  51849. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51850. /**
  51851. * Serializes the component data to the specified json object
  51852. * @param serializationObject The object to serialize to
  51853. */
  51854. serialize(serializationObject: any): void;
  51855. /**
  51856. * Disposes the component and the associated ressources.
  51857. */
  51858. dispose(): void;
  51859. private _draw;
  51860. }
  51861. }
  51862. declare module "babylonjs/LensFlares/index" {
  51863. export * from "babylonjs/LensFlares/lensFlare";
  51864. export * from "babylonjs/LensFlares/lensFlareSystem";
  51865. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  51866. }
  51867. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  51868. import { Scene } from "babylonjs/scene";
  51869. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51870. import { AbstractScene } from "babylonjs/abstractScene";
  51871. /**
  51872. * Defines the shadow generator component responsible to manage any shadow generators
  51873. * in a given scene.
  51874. */
  51875. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  51876. /**
  51877. * The component name helpfull to identify the component in the list of scene components.
  51878. */
  51879. readonly name: string;
  51880. /**
  51881. * The scene the component belongs to.
  51882. */
  51883. scene: Scene;
  51884. /**
  51885. * Creates a new instance of the component for the given scene
  51886. * @param scene Defines the scene to register the component in
  51887. */
  51888. constructor(scene: Scene);
  51889. /**
  51890. * Registers the component in a given scene
  51891. */
  51892. register(): void;
  51893. /**
  51894. * Rebuilds the elements related to this component in case of
  51895. * context lost for instance.
  51896. */
  51897. rebuild(): void;
  51898. /**
  51899. * Serializes the component data to the specified json object
  51900. * @param serializationObject The object to serialize to
  51901. */
  51902. serialize(serializationObject: any): void;
  51903. /**
  51904. * Adds all the elements from the container to the scene
  51905. * @param container the container holding the elements
  51906. */
  51907. addFromContainer(container: AbstractScene): void;
  51908. /**
  51909. * Removes all the elements in the container from the scene
  51910. * @param container contains the elements to remove
  51911. * @param dispose if the removed element should be disposed (default: false)
  51912. */
  51913. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51914. /**
  51915. * Rebuilds the elements related to this component in case of
  51916. * context lost for instance.
  51917. */
  51918. dispose(): void;
  51919. private _gatherRenderTargets;
  51920. }
  51921. }
  51922. declare module "babylonjs/Lights/Shadows/index" {
  51923. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  51924. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  51925. }
  51926. declare module "babylonjs/Lights/pointLight" {
  51927. import { Scene } from "babylonjs/scene";
  51928. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51929. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51930. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  51931. import { Effect } from "babylonjs/Materials/effect";
  51932. /**
  51933. * A point light is a light defined by an unique point in world space.
  51934. * The light is emitted in every direction from this point.
  51935. * A good example of a point light is a standard light bulb.
  51936. * Documentation: https://doc.babylonjs.com/babylon101/lights
  51937. */
  51938. export class PointLight extends ShadowLight {
  51939. private _shadowAngle;
  51940. /**
  51941. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51942. * This specifies what angle the shadow will use to be created.
  51943. *
  51944. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  51945. */
  51946. /**
  51947. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51948. * This specifies what angle the shadow will use to be created.
  51949. *
  51950. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  51951. */
  51952. shadowAngle: number;
  51953. /**
  51954. * Gets the direction if it has been set.
  51955. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51956. */
  51957. /**
  51958. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51959. */
  51960. direction: Vector3;
  51961. /**
  51962. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  51963. * A PointLight emits the light in every direction.
  51964. * It can cast shadows.
  51965. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  51966. * ```javascript
  51967. * var pointLight = new PointLight("pl", camera.position, scene);
  51968. * ```
  51969. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51970. * @param name The light friendly name
  51971. * @param position The position of the point light in the scene
  51972. * @param scene The scene the lights belongs to
  51973. */
  51974. constructor(name: string, position: Vector3, scene: Scene);
  51975. /**
  51976. * Returns the string "PointLight"
  51977. * @returns the class name
  51978. */
  51979. getClassName(): string;
  51980. /**
  51981. * Returns the integer 0.
  51982. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51983. */
  51984. getTypeID(): number;
  51985. /**
  51986. * Specifies wether or not the shadowmap should be a cube texture.
  51987. * @returns true if the shadowmap needs to be a cube texture.
  51988. */
  51989. needCube(): boolean;
  51990. /**
  51991. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  51992. * @param faceIndex The index of the face we are computed the direction to generate shadow
  51993. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  51994. */
  51995. getShadowDirection(faceIndex?: number): Vector3;
  51996. /**
  51997. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  51998. * - fov = PI / 2
  51999. * - aspect ratio : 1.0
  52000. * - z-near and far equal to the active camera minZ and maxZ.
  52001. * Returns the PointLight.
  52002. */
  52003. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52004. protected _buildUniformLayout(): void;
  52005. /**
  52006. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  52007. * @param effect The effect to update
  52008. * @param lightIndex The index of the light in the effect to update
  52009. * @returns The point light
  52010. */
  52011. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  52012. /**
  52013. * Prepares the list of defines specific to the light type.
  52014. * @param defines the list of defines
  52015. * @param lightIndex defines the index of the light for the effect
  52016. */
  52017. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52018. }
  52019. }
  52020. declare module "babylonjs/Lights/index" {
  52021. export * from "babylonjs/Lights/light";
  52022. export * from "babylonjs/Lights/shadowLight";
  52023. export * from "babylonjs/Lights/Shadows/index";
  52024. export * from "babylonjs/Lights/directionalLight";
  52025. export * from "babylonjs/Lights/hemisphericLight";
  52026. export * from "babylonjs/Lights/pointLight";
  52027. export * from "babylonjs/Lights/spotLight";
  52028. }
  52029. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  52030. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  52031. /**
  52032. * Header information of HDR texture files.
  52033. */
  52034. export interface HDRInfo {
  52035. /**
  52036. * The height of the texture in pixels.
  52037. */
  52038. height: number;
  52039. /**
  52040. * The width of the texture in pixels.
  52041. */
  52042. width: number;
  52043. /**
  52044. * The index of the beginning of the data in the binary file.
  52045. */
  52046. dataPosition: number;
  52047. }
  52048. /**
  52049. * This groups tools to convert HDR texture to native colors array.
  52050. */
  52051. export class HDRTools {
  52052. private static Ldexp;
  52053. private static Rgbe2float;
  52054. private static readStringLine;
  52055. /**
  52056. * Reads header information from an RGBE texture stored in a native array.
  52057. * More information on this format are available here:
  52058. * https://en.wikipedia.org/wiki/RGBE_image_format
  52059. *
  52060. * @param uint8array The binary file stored in native array.
  52061. * @return The header information.
  52062. */
  52063. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  52064. /**
  52065. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  52066. * This RGBE texture needs to store the information as a panorama.
  52067. *
  52068. * More information on this format are available here:
  52069. * https://en.wikipedia.org/wiki/RGBE_image_format
  52070. *
  52071. * @param buffer The binary file stored in an array buffer.
  52072. * @param size The expected size of the extracted cubemap.
  52073. * @return The Cube Map information.
  52074. */
  52075. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  52076. /**
  52077. * Returns the pixels data extracted from an RGBE texture.
  52078. * This pixels will be stored left to right up to down in the R G B order in one array.
  52079. *
  52080. * More information on this format are available here:
  52081. * https://en.wikipedia.org/wiki/RGBE_image_format
  52082. *
  52083. * @param uint8array The binary file stored in an array buffer.
  52084. * @param hdrInfo The header information of the file.
  52085. * @return The pixels data in RGB right to left up to down order.
  52086. */
  52087. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  52088. private static RGBE_ReadPixels_RLE;
  52089. }
  52090. }
  52091. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  52092. import { Nullable } from "babylonjs/types";
  52093. import { Scene } from "babylonjs/scene";
  52094. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  52095. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52096. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52097. /**
  52098. * This represents a texture coming from an HDR input.
  52099. *
  52100. * The only supported format is currently panorama picture stored in RGBE format.
  52101. * Example of such files can be found on HDRLib: http://hdrlib.com/
  52102. */
  52103. export class HDRCubeTexture extends BaseTexture {
  52104. private static _facesMapping;
  52105. private _generateHarmonics;
  52106. private _noMipmap;
  52107. private _textureMatrix;
  52108. private _size;
  52109. private _onLoad;
  52110. private _onError;
  52111. /**
  52112. * The texture URL.
  52113. */
  52114. url: string;
  52115. /**
  52116. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  52117. */
  52118. coordinatesMode: number;
  52119. protected _isBlocking: boolean;
  52120. /**
  52121. * Sets wether or not the texture is blocking during loading.
  52122. */
  52123. /**
  52124. * Gets wether or not the texture is blocking during loading.
  52125. */
  52126. isBlocking: boolean;
  52127. protected _rotationY: number;
  52128. /**
  52129. * Sets texture matrix rotation angle around Y axis in radians.
  52130. */
  52131. /**
  52132. * Gets texture matrix rotation angle around Y axis radians.
  52133. */
  52134. rotationY: number;
  52135. /**
  52136. * Gets or sets the center of the bounding box associated with the cube texture
  52137. * It must define where the camera used to render the texture was set
  52138. */
  52139. boundingBoxPosition: Vector3;
  52140. private _boundingBoxSize;
  52141. /**
  52142. * Gets or sets the size of the bounding box associated with the cube texture
  52143. * When defined, the cubemap will switch to local mode
  52144. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  52145. * @example https://www.babylonjs-playground.com/#RNASML
  52146. */
  52147. boundingBoxSize: Vector3;
  52148. /**
  52149. * Instantiates an HDRTexture from the following parameters.
  52150. *
  52151. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  52152. * @param scene The scene the texture will be used in
  52153. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  52154. * @param noMipmap Forces to not generate the mipmap if true
  52155. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  52156. * @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)
  52157. * @param reserved Reserved flag for internal use.
  52158. */
  52159. 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>);
  52160. /**
  52161. * Get the current class name of the texture useful for serialization or dynamic coding.
  52162. * @returns "HDRCubeTexture"
  52163. */
  52164. getClassName(): string;
  52165. /**
  52166. * Occurs when the file is raw .hdr file.
  52167. */
  52168. private loadTexture;
  52169. clone(): HDRCubeTexture;
  52170. delayLoad(): void;
  52171. /**
  52172. * Get the texture reflection matrix used to rotate/transform the reflection.
  52173. * @returns the reflection matrix
  52174. */
  52175. getReflectionTextureMatrix(): Matrix;
  52176. /**
  52177. * Set the texture reflection matrix used to rotate/transform the reflection.
  52178. * @param value Define the reflection matrix to set
  52179. */
  52180. setReflectionTextureMatrix(value: Matrix): void;
  52181. /**
  52182. * Parses a JSON representation of an HDR Texture in order to create the texture
  52183. * @param parsedTexture Define the JSON representation
  52184. * @param scene Define the scene the texture should be created in
  52185. * @param rootUrl Define the root url in case we need to load relative dependencies
  52186. * @returns the newly created texture after parsing
  52187. */
  52188. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  52189. serialize(): any;
  52190. }
  52191. }
  52192. declare module "babylonjs/Physics/physicsEngine" {
  52193. import { Nullable } from "babylonjs/types";
  52194. import { Vector3 } from "babylonjs/Maths/math.vector";
  52195. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  52196. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  52197. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  52198. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52199. /**
  52200. * Class used to control physics engine
  52201. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  52202. */
  52203. export class PhysicsEngine implements IPhysicsEngine {
  52204. private _physicsPlugin;
  52205. /**
  52206. * Global value used to control the smallest number supported by the simulation
  52207. */
  52208. static Epsilon: number;
  52209. private _impostors;
  52210. private _joints;
  52211. /**
  52212. * Gets the gravity vector used by the simulation
  52213. */
  52214. gravity: Vector3;
  52215. /**
  52216. * Factory used to create the default physics plugin.
  52217. * @returns The default physics plugin
  52218. */
  52219. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  52220. /**
  52221. * Creates a new Physics Engine
  52222. * @param gravity defines the gravity vector used by the simulation
  52223. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  52224. */
  52225. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  52226. /**
  52227. * Sets the gravity vector used by the simulation
  52228. * @param gravity defines the gravity vector to use
  52229. */
  52230. setGravity(gravity: Vector3): void;
  52231. /**
  52232. * Set the time step of the physics engine.
  52233. * Default is 1/60.
  52234. * To slow it down, enter 1/600 for example.
  52235. * To speed it up, 1/30
  52236. * @param newTimeStep defines the new timestep to apply to this world.
  52237. */
  52238. setTimeStep(newTimeStep?: number): void;
  52239. /**
  52240. * Get the time step of the physics engine.
  52241. * @returns the current time step
  52242. */
  52243. getTimeStep(): number;
  52244. /**
  52245. * Release all resources
  52246. */
  52247. dispose(): void;
  52248. /**
  52249. * Gets the name of the current physics plugin
  52250. * @returns the name of the plugin
  52251. */
  52252. getPhysicsPluginName(): string;
  52253. /**
  52254. * Adding a new impostor for the impostor tracking.
  52255. * This will be done by the impostor itself.
  52256. * @param impostor the impostor to add
  52257. */
  52258. addImpostor(impostor: PhysicsImpostor): void;
  52259. /**
  52260. * Remove an impostor from the engine.
  52261. * This impostor and its mesh will not longer be updated by the physics engine.
  52262. * @param impostor the impostor to remove
  52263. */
  52264. removeImpostor(impostor: PhysicsImpostor): void;
  52265. /**
  52266. * Add a joint to the physics engine
  52267. * @param mainImpostor defines the main impostor to which the joint is added.
  52268. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  52269. * @param joint defines the joint that will connect both impostors.
  52270. */
  52271. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  52272. /**
  52273. * Removes a joint from the simulation
  52274. * @param mainImpostor defines the impostor used with the joint
  52275. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  52276. * @param joint defines the joint to remove
  52277. */
  52278. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  52279. /**
  52280. * Called by the scene. No need to call it.
  52281. * @param delta defines the timespam between frames
  52282. */
  52283. _step(delta: number): void;
  52284. /**
  52285. * Gets the current plugin used to run the simulation
  52286. * @returns current plugin
  52287. */
  52288. getPhysicsPlugin(): IPhysicsEnginePlugin;
  52289. /**
  52290. * Gets the list of physic impostors
  52291. * @returns an array of PhysicsImpostor
  52292. */
  52293. getImpostors(): Array<PhysicsImpostor>;
  52294. /**
  52295. * Gets the impostor for a physics enabled object
  52296. * @param object defines the object impersonated by the impostor
  52297. * @returns the PhysicsImpostor or null if not found
  52298. */
  52299. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  52300. /**
  52301. * Gets the impostor for a physics body object
  52302. * @param body defines physics body used by the impostor
  52303. * @returns the PhysicsImpostor or null if not found
  52304. */
  52305. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  52306. /**
  52307. * Does a raycast in the physics world
  52308. * @param from when should the ray start?
  52309. * @param to when should the ray end?
  52310. * @returns PhysicsRaycastResult
  52311. */
  52312. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52313. }
  52314. }
  52315. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  52316. import { Nullable } from "babylonjs/types";
  52317. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  52318. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52319. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52320. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52321. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52322. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52323. /** @hidden */
  52324. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  52325. private _useDeltaForWorldStep;
  52326. world: any;
  52327. name: string;
  52328. private _physicsMaterials;
  52329. private _fixedTimeStep;
  52330. private _cannonRaycastResult;
  52331. private _raycastResult;
  52332. private _physicsBodysToRemoveAfterStep;
  52333. BJSCANNON: any;
  52334. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  52335. setGravity(gravity: Vector3): void;
  52336. setTimeStep(timeStep: number): void;
  52337. getTimeStep(): number;
  52338. executeStep(delta: number): void;
  52339. private _removeMarkedPhysicsBodiesFromWorld;
  52340. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52341. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52342. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52343. private _processChildMeshes;
  52344. removePhysicsBody(impostor: PhysicsImpostor): void;
  52345. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52346. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52347. private _addMaterial;
  52348. private _checkWithEpsilon;
  52349. private _createShape;
  52350. private _createHeightmap;
  52351. private _minus90X;
  52352. private _plus90X;
  52353. private _tmpPosition;
  52354. private _tmpDeltaPosition;
  52355. private _tmpUnityRotation;
  52356. private _updatePhysicsBodyTransformation;
  52357. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52358. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52359. isSupported(): boolean;
  52360. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52361. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52362. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52363. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52364. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52365. getBodyMass(impostor: PhysicsImpostor): number;
  52366. getBodyFriction(impostor: PhysicsImpostor): number;
  52367. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52368. getBodyRestitution(impostor: PhysicsImpostor): number;
  52369. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52370. sleepBody(impostor: PhysicsImpostor): void;
  52371. wakeUpBody(impostor: PhysicsImpostor): void;
  52372. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  52373. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52374. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52375. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52376. getRadius(impostor: PhysicsImpostor): number;
  52377. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52378. dispose(): void;
  52379. private _extendNamespace;
  52380. /**
  52381. * Does a raycast in the physics world
  52382. * @param from when should the ray start?
  52383. * @param to when should the ray end?
  52384. * @returns PhysicsRaycastResult
  52385. */
  52386. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52387. }
  52388. }
  52389. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  52390. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52391. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52392. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52393. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52394. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  52395. import { Nullable } from "babylonjs/types";
  52396. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52397. /** @hidden */
  52398. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  52399. world: any;
  52400. name: string;
  52401. BJSOIMO: any;
  52402. private _raycastResult;
  52403. constructor(iterations?: number, oimoInjection?: any);
  52404. setGravity(gravity: Vector3): void;
  52405. setTimeStep(timeStep: number): void;
  52406. getTimeStep(): number;
  52407. private _tmpImpostorsArray;
  52408. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52409. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52410. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52411. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52412. private _tmpPositionVector;
  52413. removePhysicsBody(impostor: PhysicsImpostor): void;
  52414. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52415. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52416. isSupported(): boolean;
  52417. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52418. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52419. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52420. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52421. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52422. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52423. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52424. getBodyMass(impostor: PhysicsImpostor): number;
  52425. getBodyFriction(impostor: PhysicsImpostor): number;
  52426. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52427. getBodyRestitution(impostor: PhysicsImpostor): number;
  52428. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52429. sleepBody(impostor: PhysicsImpostor): void;
  52430. wakeUpBody(impostor: PhysicsImpostor): void;
  52431. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52432. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  52433. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  52434. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52435. getRadius(impostor: PhysicsImpostor): number;
  52436. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52437. dispose(): void;
  52438. /**
  52439. * Does a raycast in the physics world
  52440. * @param from when should the ray start?
  52441. * @param to when should the ray end?
  52442. * @returns PhysicsRaycastResult
  52443. */
  52444. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52445. }
  52446. }
  52447. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  52448. import { Nullable } from "babylonjs/types";
  52449. import { Scene } from "babylonjs/scene";
  52450. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  52451. import { Color4 } from "babylonjs/Maths/math.color";
  52452. import { Mesh } from "babylonjs/Meshes/mesh";
  52453. /**
  52454. * Class containing static functions to help procedurally build meshes
  52455. */
  52456. export class RibbonBuilder {
  52457. /**
  52458. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52459. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52460. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52461. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52462. * * 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
  52463. * * 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
  52464. * * 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
  52465. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52466. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52467. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52468. * * 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
  52469. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52470. * * 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
  52471. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52472. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52473. * @param name defines the name of the mesh
  52474. * @param options defines the options used to create the mesh
  52475. * @param scene defines the hosting scene
  52476. * @returns the ribbon mesh
  52477. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52478. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52479. */
  52480. static CreateRibbon(name: string, options: {
  52481. pathArray: Vector3[][];
  52482. closeArray?: boolean;
  52483. closePath?: boolean;
  52484. offset?: number;
  52485. updatable?: boolean;
  52486. sideOrientation?: number;
  52487. frontUVs?: Vector4;
  52488. backUVs?: Vector4;
  52489. instance?: Mesh;
  52490. invertUV?: boolean;
  52491. uvs?: Vector2[];
  52492. colors?: Color4[];
  52493. }, scene?: Nullable<Scene>): Mesh;
  52494. }
  52495. }
  52496. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  52497. import { Nullable } from "babylonjs/types";
  52498. import { Scene } from "babylonjs/scene";
  52499. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  52500. import { Mesh } from "babylonjs/Meshes/mesh";
  52501. /**
  52502. * Class containing static functions to help procedurally build meshes
  52503. */
  52504. export class ShapeBuilder {
  52505. /**
  52506. * 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.
  52507. * * 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.
  52508. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52509. * * 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.
  52510. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52511. * * 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
  52512. * * 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
  52513. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52514. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52515. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52516. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52517. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52518. * @param name defines the name of the mesh
  52519. * @param options defines the options used to create the mesh
  52520. * @param scene defines the hosting scene
  52521. * @returns the extruded shape mesh
  52522. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52523. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52524. */
  52525. static ExtrudeShape(name: string, options: {
  52526. shape: Vector3[];
  52527. path: Vector3[];
  52528. scale?: number;
  52529. rotation?: number;
  52530. cap?: number;
  52531. updatable?: boolean;
  52532. sideOrientation?: number;
  52533. frontUVs?: Vector4;
  52534. backUVs?: Vector4;
  52535. instance?: Mesh;
  52536. invertUV?: boolean;
  52537. }, scene?: Nullable<Scene>): Mesh;
  52538. /**
  52539. * Creates an custom extruded shape mesh.
  52540. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52541. * * 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.
  52542. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52543. * * 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
  52544. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52545. * * 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
  52546. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52547. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52548. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52549. * * 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
  52550. * * 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
  52551. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52552. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52553. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52554. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52555. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52556. * @param name defines the name of the mesh
  52557. * @param options defines the options used to create the mesh
  52558. * @param scene defines the hosting scene
  52559. * @returns the custom extruded shape mesh
  52560. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52561. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52562. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52563. */
  52564. static ExtrudeShapeCustom(name: string, options: {
  52565. shape: Vector3[];
  52566. path: Vector3[];
  52567. scaleFunction?: any;
  52568. rotationFunction?: any;
  52569. ribbonCloseArray?: boolean;
  52570. ribbonClosePath?: boolean;
  52571. cap?: number;
  52572. updatable?: boolean;
  52573. sideOrientation?: number;
  52574. frontUVs?: Vector4;
  52575. backUVs?: Vector4;
  52576. instance?: Mesh;
  52577. invertUV?: boolean;
  52578. }, scene?: Nullable<Scene>): Mesh;
  52579. private static _ExtrudeShapeGeneric;
  52580. }
  52581. }
  52582. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  52583. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  52584. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52585. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52586. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52587. import { Nullable } from "babylonjs/types";
  52588. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52589. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52590. /**
  52591. * AmmoJS Physics plugin
  52592. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52593. * @see https://github.com/kripken/ammo.js/
  52594. */
  52595. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  52596. private _useDeltaForWorldStep;
  52597. /**
  52598. * Reference to the Ammo library
  52599. */
  52600. bjsAMMO: any;
  52601. /**
  52602. * Created ammoJS world which physics bodies are added to
  52603. */
  52604. world: any;
  52605. /**
  52606. * Name of the plugin
  52607. */
  52608. name: string;
  52609. private _timeStep;
  52610. private _fixedTimeStep;
  52611. private _maxSteps;
  52612. private _tmpQuaternion;
  52613. private _tmpAmmoTransform;
  52614. private _tmpAmmoQuaternion;
  52615. private _tmpAmmoConcreteContactResultCallback;
  52616. private _collisionConfiguration;
  52617. private _dispatcher;
  52618. private _overlappingPairCache;
  52619. private _solver;
  52620. private _softBodySolver;
  52621. private _tmpAmmoVectorA;
  52622. private _tmpAmmoVectorB;
  52623. private _tmpAmmoVectorC;
  52624. private _tmpAmmoVectorD;
  52625. private _tmpContactCallbackResult;
  52626. private _tmpAmmoVectorRCA;
  52627. private _tmpAmmoVectorRCB;
  52628. private _raycastResult;
  52629. private static readonly DISABLE_COLLISION_FLAG;
  52630. private static readonly KINEMATIC_FLAG;
  52631. private static readonly DISABLE_DEACTIVATION_FLAG;
  52632. /**
  52633. * Initializes the ammoJS plugin
  52634. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  52635. * @param ammoInjection can be used to inject your own ammo reference
  52636. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  52637. */
  52638. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  52639. /**
  52640. * Sets the gravity of the physics world (m/(s^2))
  52641. * @param gravity Gravity to set
  52642. */
  52643. setGravity(gravity: Vector3): void;
  52644. /**
  52645. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  52646. * @param timeStep timestep to use in seconds
  52647. */
  52648. setTimeStep(timeStep: number): void;
  52649. /**
  52650. * 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)
  52651. * @param fixedTimeStep fixedTimeStep to use in seconds
  52652. */
  52653. setFixedTimeStep(fixedTimeStep: number): void;
  52654. /**
  52655. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  52656. * @param maxSteps the maximum number of steps by the physics engine per frame
  52657. */
  52658. setMaxSteps(maxSteps: number): void;
  52659. /**
  52660. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  52661. * @returns the current timestep in seconds
  52662. */
  52663. getTimeStep(): number;
  52664. private _isImpostorInContact;
  52665. private _isImpostorPairInContact;
  52666. private _stepSimulation;
  52667. /**
  52668. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  52669. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  52670. * After the step the babylon meshes are set to the position of the physics imposters
  52671. * @param delta amount of time to step forward
  52672. * @param impostors array of imposters to update before/after the step
  52673. */
  52674. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52675. /**
  52676. * Update babylon mesh to match physics world object
  52677. * @param impostor imposter to match
  52678. */
  52679. private _afterSoftStep;
  52680. /**
  52681. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  52682. * @param impostor imposter to match
  52683. */
  52684. private _ropeStep;
  52685. /**
  52686. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  52687. * @param impostor imposter to match
  52688. */
  52689. private _softbodyOrClothStep;
  52690. private _tmpVector;
  52691. private _tmpMatrix;
  52692. /**
  52693. * Applies an impulse on the imposter
  52694. * @param impostor imposter to apply impulse to
  52695. * @param force amount of force to be applied to the imposter
  52696. * @param contactPoint the location to apply the impulse on the imposter
  52697. */
  52698. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52699. /**
  52700. * Applies a force on the imposter
  52701. * @param impostor imposter to apply force
  52702. * @param force amount of force to be applied to the imposter
  52703. * @param contactPoint the location to apply the force on the imposter
  52704. */
  52705. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52706. /**
  52707. * Creates a physics body using the plugin
  52708. * @param impostor the imposter to create the physics body on
  52709. */
  52710. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52711. /**
  52712. * Removes the physics body from the imposter and disposes of the body's memory
  52713. * @param impostor imposter to remove the physics body from
  52714. */
  52715. removePhysicsBody(impostor: PhysicsImpostor): void;
  52716. /**
  52717. * Generates a joint
  52718. * @param impostorJoint the imposter joint to create the joint with
  52719. */
  52720. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52721. /**
  52722. * Removes a joint
  52723. * @param impostorJoint the imposter joint to remove the joint from
  52724. */
  52725. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52726. private _addMeshVerts;
  52727. /**
  52728. * Initialise the soft body vertices to match its object's (mesh) vertices
  52729. * Softbody vertices (nodes) are in world space and to match this
  52730. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  52731. * @param impostor to create the softbody for
  52732. */
  52733. private _softVertexData;
  52734. /**
  52735. * Create an impostor's soft body
  52736. * @param impostor to create the softbody for
  52737. */
  52738. private _createSoftbody;
  52739. /**
  52740. * Create cloth for an impostor
  52741. * @param impostor to create the softbody for
  52742. */
  52743. private _createCloth;
  52744. /**
  52745. * Create rope for an impostor
  52746. * @param impostor to create the softbody for
  52747. */
  52748. private _createRope;
  52749. private _addHullVerts;
  52750. private _createShape;
  52751. /**
  52752. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  52753. * @param impostor imposter containing the physics body and babylon object
  52754. */
  52755. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52756. /**
  52757. * Sets the babylon object's position/rotation from the physics body's position/rotation
  52758. * @param impostor imposter containing the physics body and babylon object
  52759. * @param newPosition new position
  52760. * @param newRotation new rotation
  52761. */
  52762. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52763. /**
  52764. * If this plugin is supported
  52765. * @returns true if its supported
  52766. */
  52767. isSupported(): boolean;
  52768. /**
  52769. * Sets the linear velocity of the physics body
  52770. * @param impostor imposter to set the velocity on
  52771. * @param velocity velocity to set
  52772. */
  52773. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52774. /**
  52775. * Sets the angular velocity of the physics body
  52776. * @param impostor imposter to set the velocity on
  52777. * @param velocity velocity to set
  52778. */
  52779. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52780. /**
  52781. * gets the linear velocity
  52782. * @param impostor imposter to get linear velocity from
  52783. * @returns linear velocity
  52784. */
  52785. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52786. /**
  52787. * gets the angular velocity
  52788. * @param impostor imposter to get angular velocity from
  52789. * @returns angular velocity
  52790. */
  52791. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52792. /**
  52793. * Sets the mass of physics body
  52794. * @param impostor imposter to set the mass on
  52795. * @param mass mass to set
  52796. */
  52797. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52798. /**
  52799. * Gets the mass of the physics body
  52800. * @param impostor imposter to get the mass from
  52801. * @returns mass
  52802. */
  52803. getBodyMass(impostor: PhysicsImpostor): number;
  52804. /**
  52805. * Gets friction of the impostor
  52806. * @param impostor impostor to get friction from
  52807. * @returns friction value
  52808. */
  52809. getBodyFriction(impostor: PhysicsImpostor): number;
  52810. /**
  52811. * Sets friction of the impostor
  52812. * @param impostor impostor to set friction on
  52813. * @param friction friction value
  52814. */
  52815. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52816. /**
  52817. * Gets restitution of the impostor
  52818. * @param impostor impostor to get restitution from
  52819. * @returns restitution value
  52820. */
  52821. getBodyRestitution(impostor: PhysicsImpostor): number;
  52822. /**
  52823. * Sets resitution of the impostor
  52824. * @param impostor impostor to set resitution on
  52825. * @param restitution resitution value
  52826. */
  52827. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52828. /**
  52829. * Gets pressure inside the impostor
  52830. * @param impostor impostor to get pressure from
  52831. * @returns pressure value
  52832. */
  52833. getBodyPressure(impostor: PhysicsImpostor): number;
  52834. /**
  52835. * Sets pressure inside a soft body impostor
  52836. * Cloth and rope must remain 0 pressure
  52837. * @param impostor impostor to set pressure on
  52838. * @param pressure pressure value
  52839. */
  52840. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  52841. /**
  52842. * Gets stiffness of the impostor
  52843. * @param impostor impostor to get stiffness from
  52844. * @returns pressure value
  52845. */
  52846. getBodyStiffness(impostor: PhysicsImpostor): number;
  52847. /**
  52848. * Sets stiffness of the impostor
  52849. * @param impostor impostor to set stiffness on
  52850. * @param stiffness stiffness value from 0 to 1
  52851. */
  52852. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  52853. /**
  52854. * Gets velocityIterations of the impostor
  52855. * @param impostor impostor to get velocity iterations from
  52856. * @returns velocityIterations value
  52857. */
  52858. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  52859. /**
  52860. * Sets velocityIterations of the impostor
  52861. * @param impostor impostor to set velocity iterations on
  52862. * @param velocityIterations velocityIterations value
  52863. */
  52864. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  52865. /**
  52866. * Gets positionIterations of the impostor
  52867. * @param impostor impostor to get position iterations from
  52868. * @returns positionIterations value
  52869. */
  52870. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  52871. /**
  52872. * Sets positionIterations of the impostor
  52873. * @param impostor impostor to set position on
  52874. * @param positionIterations positionIterations value
  52875. */
  52876. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  52877. /**
  52878. * Append an anchor to a cloth object
  52879. * @param impostor is the cloth impostor to add anchor to
  52880. * @param otherImpostor is the rigid impostor to anchor to
  52881. * @param width ratio across width from 0 to 1
  52882. * @param height ratio up height from 0 to 1
  52883. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  52884. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  52885. */
  52886. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  52887. /**
  52888. * Append an hook to a rope object
  52889. * @param impostor is the rope impostor to add hook to
  52890. * @param otherImpostor is the rigid impostor to hook to
  52891. * @param length ratio along the rope from 0 to 1
  52892. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  52893. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  52894. */
  52895. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  52896. /**
  52897. * Sleeps the physics body and stops it from being active
  52898. * @param impostor impostor to sleep
  52899. */
  52900. sleepBody(impostor: PhysicsImpostor): void;
  52901. /**
  52902. * Activates the physics body
  52903. * @param impostor impostor to activate
  52904. */
  52905. wakeUpBody(impostor: PhysicsImpostor): void;
  52906. /**
  52907. * Updates the distance parameters of the joint
  52908. * @param joint joint to update
  52909. * @param maxDistance maximum distance of the joint
  52910. * @param minDistance minimum distance of the joint
  52911. */
  52912. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52913. /**
  52914. * Sets a motor on the joint
  52915. * @param joint joint to set motor on
  52916. * @param speed speed of the motor
  52917. * @param maxForce maximum force of the motor
  52918. * @param motorIndex index of the motor
  52919. */
  52920. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52921. /**
  52922. * Sets the motors limit
  52923. * @param joint joint to set limit on
  52924. * @param upperLimit upper limit
  52925. * @param lowerLimit lower limit
  52926. */
  52927. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52928. /**
  52929. * Syncs the position and rotation of a mesh with the impostor
  52930. * @param mesh mesh to sync
  52931. * @param impostor impostor to update the mesh with
  52932. */
  52933. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52934. /**
  52935. * Gets the radius of the impostor
  52936. * @param impostor impostor to get radius from
  52937. * @returns the radius
  52938. */
  52939. getRadius(impostor: PhysicsImpostor): number;
  52940. /**
  52941. * Gets the box size of the impostor
  52942. * @param impostor impostor to get box size from
  52943. * @param result the resulting box size
  52944. */
  52945. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52946. /**
  52947. * Disposes of the impostor
  52948. */
  52949. dispose(): void;
  52950. /**
  52951. * Does a raycast in the physics world
  52952. * @param from when should the ray start?
  52953. * @param to when should the ray end?
  52954. * @returns PhysicsRaycastResult
  52955. */
  52956. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52957. }
  52958. }
  52959. declare module "babylonjs/Probes/reflectionProbe" {
  52960. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52961. import { Vector3 } from "babylonjs/Maths/math.vector";
  52962. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52963. import { Nullable } from "babylonjs/types";
  52964. import { Scene } from "babylonjs/scene";
  52965. module "babylonjs/abstractScene" {
  52966. interface AbstractScene {
  52967. /**
  52968. * The list of reflection probes added to the scene
  52969. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  52970. */
  52971. reflectionProbes: Array<ReflectionProbe>;
  52972. /**
  52973. * Removes the given reflection probe from this scene.
  52974. * @param toRemove The reflection probe to remove
  52975. * @returns The index of the removed reflection probe
  52976. */
  52977. removeReflectionProbe(toRemove: ReflectionProbe): number;
  52978. /**
  52979. * Adds the given reflection probe to this scene.
  52980. * @param newReflectionProbe The reflection probe to add
  52981. */
  52982. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  52983. }
  52984. }
  52985. /**
  52986. * Class used to generate realtime reflection / refraction cube textures
  52987. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  52988. */
  52989. export class ReflectionProbe {
  52990. /** defines the name of the probe */
  52991. name: string;
  52992. private _scene;
  52993. private _renderTargetTexture;
  52994. private _projectionMatrix;
  52995. private _viewMatrix;
  52996. private _target;
  52997. private _add;
  52998. private _attachedMesh;
  52999. private _invertYAxis;
  53000. /** Gets or sets probe position (center of the cube map) */
  53001. position: Vector3;
  53002. /**
  53003. * Creates a new reflection probe
  53004. * @param name defines the name of the probe
  53005. * @param size defines the texture resolution (for each face)
  53006. * @param scene defines the hosting scene
  53007. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  53008. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  53009. */
  53010. constructor(
  53011. /** defines the name of the probe */
  53012. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  53013. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  53014. samples: number;
  53015. /** Gets or sets the refresh rate to use (on every frame by default) */
  53016. refreshRate: number;
  53017. /**
  53018. * Gets the hosting scene
  53019. * @returns a Scene
  53020. */
  53021. getScene(): Scene;
  53022. /** Gets the internal CubeTexture used to render to */
  53023. readonly cubeTexture: RenderTargetTexture;
  53024. /** Gets the list of meshes to render */
  53025. readonly renderList: Nullable<AbstractMesh[]>;
  53026. /**
  53027. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  53028. * @param mesh defines the mesh to attach to
  53029. */
  53030. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  53031. /**
  53032. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  53033. * @param renderingGroupId The rendering group id corresponding to its index
  53034. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  53035. */
  53036. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  53037. /**
  53038. * Clean all associated resources
  53039. */
  53040. dispose(): void;
  53041. /**
  53042. * Converts the reflection probe information to a readable string for debug purpose.
  53043. * @param fullDetails Supports for multiple levels of logging within scene loading
  53044. * @returns the human readable reflection probe info
  53045. */
  53046. toString(fullDetails?: boolean): string;
  53047. /**
  53048. * Get the class name of the relfection probe.
  53049. * @returns "ReflectionProbe"
  53050. */
  53051. getClassName(): string;
  53052. /**
  53053. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  53054. * @returns The JSON representation of the texture
  53055. */
  53056. serialize(): any;
  53057. /**
  53058. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  53059. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  53060. * @param scene Define the scene the parsed reflection probe should be instantiated in
  53061. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  53062. * @returns The parsed reflection probe if successful
  53063. */
  53064. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  53065. }
  53066. }
  53067. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  53068. /** @hidden */
  53069. export var _BabylonLoaderRegistered: boolean;
  53070. }
  53071. declare module "babylonjs/Loading/Plugins/index" {
  53072. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  53073. }
  53074. declare module "babylonjs/Loading/index" {
  53075. export * from "babylonjs/Loading/loadingScreen";
  53076. export * from "babylonjs/Loading/Plugins/index";
  53077. export * from "babylonjs/Loading/sceneLoader";
  53078. export * from "babylonjs/Loading/sceneLoaderFlags";
  53079. }
  53080. declare module "babylonjs/Materials/Background/index" {
  53081. export * from "babylonjs/Materials/Background/backgroundMaterial";
  53082. }
  53083. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  53084. import { Scene } from "babylonjs/scene";
  53085. import { Color3 } from "babylonjs/Maths/math.color";
  53086. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53087. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53088. /**
  53089. * The Physically based simple base material of BJS.
  53090. *
  53091. * This enables better naming and convention enforcements on top of the pbrMaterial.
  53092. * It is used as the base class for both the specGloss and metalRough conventions.
  53093. */
  53094. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  53095. /**
  53096. * Number of Simultaneous lights allowed on the material.
  53097. */
  53098. maxSimultaneousLights: number;
  53099. /**
  53100. * If sets to true, disables all the lights affecting the material.
  53101. */
  53102. disableLighting: boolean;
  53103. /**
  53104. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  53105. */
  53106. environmentTexture: BaseTexture;
  53107. /**
  53108. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  53109. */
  53110. invertNormalMapX: boolean;
  53111. /**
  53112. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  53113. */
  53114. invertNormalMapY: boolean;
  53115. /**
  53116. * Normal map used in the model.
  53117. */
  53118. normalTexture: BaseTexture;
  53119. /**
  53120. * Emissivie color used to self-illuminate the model.
  53121. */
  53122. emissiveColor: Color3;
  53123. /**
  53124. * Emissivie texture used to self-illuminate the model.
  53125. */
  53126. emissiveTexture: BaseTexture;
  53127. /**
  53128. * Occlusion Channel Strenght.
  53129. */
  53130. occlusionStrength: number;
  53131. /**
  53132. * Occlusion Texture of the material (adding extra occlusion effects).
  53133. */
  53134. occlusionTexture: BaseTexture;
  53135. /**
  53136. * Defines the alpha limits in alpha test mode.
  53137. */
  53138. alphaCutOff: number;
  53139. /**
  53140. * Gets the current double sided mode.
  53141. */
  53142. /**
  53143. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53144. */
  53145. doubleSided: boolean;
  53146. /**
  53147. * Stores the pre-calculated light information of a mesh in a texture.
  53148. */
  53149. lightmapTexture: BaseTexture;
  53150. /**
  53151. * If true, the light map contains occlusion information instead of lighting info.
  53152. */
  53153. useLightmapAsShadowmap: boolean;
  53154. /**
  53155. * Instantiates a new PBRMaterial instance.
  53156. *
  53157. * @param name The material name
  53158. * @param scene The scene the material will be use in.
  53159. */
  53160. constructor(name: string, scene: Scene);
  53161. getClassName(): string;
  53162. }
  53163. }
  53164. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  53165. import { Scene } from "babylonjs/scene";
  53166. import { Color3 } from "babylonjs/Maths/math.color";
  53167. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53168. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53169. /**
  53170. * The PBR material of BJS following the metal roughness convention.
  53171. *
  53172. * This fits to the PBR convention in the GLTF definition:
  53173. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  53174. */
  53175. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  53176. /**
  53177. * The base color has two different interpretations depending on the value of metalness.
  53178. * When the material is a metal, the base color is the specific measured reflectance value
  53179. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  53180. * of the material.
  53181. */
  53182. baseColor: Color3;
  53183. /**
  53184. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  53185. * well as opacity information in the alpha channel.
  53186. */
  53187. baseTexture: BaseTexture;
  53188. /**
  53189. * Specifies the metallic scalar value of the material.
  53190. * Can also be used to scale the metalness values of the metallic texture.
  53191. */
  53192. metallic: number;
  53193. /**
  53194. * Specifies the roughness scalar value of the material.
  53195. * Can also be used to scale the roughness values of the metallic texture.
  53196. */
  53197. roughness: number;
  53198. /**
  53199. * Texture containing both the metallic value in the B channel and the
  53200. * roughness value in the G channel to keep better precision.
  53201. */
  53202. metallicRoughnessTexture: BaseTexture;
  53203. /**
  53204. * Instantiates a new PBRMetalRoughnessMaterial instance.
  53205. *
  53206. * @param name The material name
  53207. * @param scene The scene the material will be use in.
  53208. */
  53209. constructor(name: string, scene: Scene);
  53210. /**
  53211. * Return the currrent class name of the material.
  53212. */
  53213. getClassName(): string;
  53214. /**
  53215. * Makes a duplicate of the current material.
  53216. * @param name - name to use for the new material.
  53217. */
  53218. clone(name: string): PBRMetallicRoughnessMaterial;
  53219. /**
  53220. * Serialize the material to a parsable JSON object.
  53221. */
  53222. serialize(): any;
  53223. /**
  53224. * Parses a JSON object correponding to the serialize function.
  53225. */
  53226. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  53227. }
  53228. }
  53229. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  53230. import { Scene } from "babylonjs/scene";
  53231. import { Color3 } from "babylonjs/Maths/math.color";
  53232. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53233. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53234. /**
  53235. * The PBR material of BJS following the specular glossiness convention.
  53236. *
  53237. * This fits to the PBR convention in the GLTF definition:
  53238. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  53239. */
  53240. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  53241. /**
  53242. * Specifies the diffuse color of the material.
  53243. */
  53244. diffuseColor: Color3;
  53245. /**
  53246. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  53247. * channel.
  53248. */
  53249. diffuseTexture: BaseTexture;
  53250. /**
  53251. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  53252. */
  53253. specularColor: Color3;
  53254. /**
  53255. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  53256. */
  53257. glossiness: number;
  53258. /**
  53259. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  53260. */
  53261. specularGlossinessTexture: BaseTexture;
  53262. /**
  53263. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  53264. *
  53265. * @param name The material name
  53266. * @param scene The scene the material will be use in.
  53267. */
  53268. constructor(name: string, scene: Scene);
  53269. /**
  53270. * Return the currrent class name of the material.
  53271. */
  53272. getClassName(): string;
  53273. /**
  53274. * Makes a duplicate of the current material.
  53275. * @param name - name to use for the new material.
  53276. */
  53277. clone(name: string): PBRSpecularGlossinessMaterial;
  53278. /**
  53279. * Serialize the material to a parsable JSON object.
  53280. */
  53281. serialize(): any;
  53282. /**
  53283. * Parses a JSON object correponding to the serialize function.
  53284. */
  53285. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  53286. }
  53287. }
  53288. declare module "babylonjs/Materials/PBR/index" {
  53289. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53290. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53291. export * from "babylonjs/Materials/PBR/pbrMaterial";
  53292. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  53293. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  53294. }
  53295. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  53296. import { Nullable } from "babylonjs/types";
  53297. import { Scene } from "babylonjs/scene";
  53298. import { Matrix } from "babylonjs/Maths/math.vector";
  53299. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53300. /**
  53301. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  53302. * It can help converting any input color in a desired output one. This can then be used to create effects
  53303. * from sepia, black and white to sixties or futuristic rendering...
  53304. *
  53305. * The only supported format is currently 3dl.
  53306. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  53307. */
  53308. export class ColorGradingTexture extends BaseTexture {
  53309. /**
  53310. * The current texture matrix. (will always be identity in color grading texture)
  53311. */
  53312. private _textureMatrix;
  53313. /**
  53314. * The texture URL.
  53315. */
  53316. url: string;
  53317. /**
  53318. * Empty line regex stored for GC.
  53319. */
  53320. private static _noneEmptyLineRegex;
  53321. private _engine;
  53322. /**
  53323. * Instantiates a ColorGradingTexture from the following parameters.
  53324. *
  53325. * @param url The location of the color gradind data (currently only supporting 3dl)
  53326. * @param scene The scene the texture will be used in
  53327. */
  53328. constructor(url: string, scene: Scene);
  53329. /**
  53330. * Returns the texture matrix used in most of the material.
  53331. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  53332. */
  53333. getTextureMatrix(): Matrix;
  53334. /**
  53335. * Occurs when the file being loaded is a .3dl LUT file.
  53336. */
  53337. private load3dlTexture;
  53338. /**
  53339. * Starts the loading process of the texture.
  53340. */
  53341. private loadTexture;
  53342. /**
  53343. * Clones the color gradind texture.
  53344. */
  53345. clone(): ColorGradingTexture;
  53346. /**
  53347. * Called during delayed load for textures.
  53348. */
  53349. delayLoad(): void;
  53350. /**
  53351. * Parses a color grading texture serialized by Babylon.
  53352. * @param parsedTexture The texture information being parsedTexture
  53353. * @param scene The scene to load the texture in
  53354. * @param rootUrl The root url of the data assets to load
  53355. * @return A color gradind texture
  53356. */
  53357. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  53358. /**
  53359. * Serializes the LUT texture to json format.
  53360. */
  53361. serialize(): any;
  53362. }
  53363. }
  53364. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  53365. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53366. import { Scene } from "babylonjs/scene";
  53367. import { Nullable } from "babylonjs/types";
  53368. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53369. /**
  53370. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  53371. */
  53372. export class EquiRectangularCubeTexture extends BaseTexture {
  53373. /** The six faces of the cube. */
  53374. private static _FacesMapping;
  53375. private _noMipmap;
  53376. private _onLoad;
  53377. private _onError;
  53378. /** The size of the cubemap. */
  53379. private _size;
  53380. /** The buffer of the image. */
  53381. private _buffer;
  53382. /** The width of the input image. */
  53383. private _width;
  53384. /** The height of the input image. */
  53385. private _height;
  53386. /** The URL to the image. */
  53387. url: string;
  53388. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  53389. coordinatesMode: number;
  53390. /**
  53391. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  53392. * @param url The location of the image
  53393. * @param scene The scene the texture will be used in
  53394. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53395. * @param noMipmap Forces to not generate the mipmap if true
  53396. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  53397. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  53398. * @param onLoad — defines a callback called when texture is loaded
  53399. * @param onError — defines a callback called if there is an error
  53400. */
  53401. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  53402. /**
  53403. * Load the image data, by putting the image on a canvas and extracting its buffer.
  53404. */
  53405. private loadImage;
  53406. /**
  53407. * Convert the image buffer into a cubemap and create a CubeTexture.
  53408. */
  53409. private loadTexture;
  53410. /**
  53411. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  53412. * @param buffer The ArrayBuffer that should be converted.
  53413. * @returns The buffer as Float32Array.
  53414. */
  53415. private getFloat32ArrayFromArrayBuffer;
  53416. /**
  53417. * Get the current class name of the texture useful for serialization or dynamic coding.
  53418. * @returns "EquiRectangularCubeTexture"
  53419. */
  53420. getClassName(): string;
  53421. /**
  53422. * Create a clone of the current EquiRectangularCubeTexture and return it.
  53423. * @returns A clone of the current EquiRectangularCubeTexture.
  53424. */
  53425. clone(): EquiRectangularCubeTexture;
  53426. }
  53427. }
  53428. declare module "babylonjs/Misc/tga" {
  53429. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53430. /**
  53431. * Based on jsTGALoader - Javascript loader for TGA file
  53432. * By Vincent Thibault
  53433. * @see http://blog.robrowser.com/javascript-tga-loader.html
  53434. */
  53435. export class TGATools {
  53436. private static _TYPE_INDEXED;
  53437. private static _TYPE_RGB;
  53438. private static _TYPE_GREY;
  53439. private static _TYPE_RLE_INDEXED;
  53440. private static _TYPE_RLE_RGB;
  53441. private static _TYPE_RLE_GREY;
  53442. private static _ORIGIN_MASK;
  53443. private static _ORIGIN_SHIFT;
  53444. private static _ORIGIN_BL;
  53445. private static _ORIGIN_BR;
  53446. private static _ORIGIN_UL;
  53447. private static _ORIGIN_UR;
  53448. /**
  53449. * Gets the header of a TGA file
  53450. * @param data defines the TGA data
  53451. * @returns the header
  53452. */
  53453. static GetTGAHeader(data: Uint8Array): any;
  53454. /**
  53455. * Uploads TGA content to a Babylon Texture
  53456. * @hidden
  53457. */
  53458. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  53459. /** @hidden */
  53460. 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;
  53461. /** @hidden */
  53462. 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;
  53463. /** @hidden */
  53464. 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;
  53465. /** @hidden */
  53466. 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;
  53467. /** @hidden */
  53468. 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;
  53469. /** @hidden */
  53470. 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;
  53471. }
  53472. }
  53473. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  53474. import { Nullable } from "babylonjs/types";
  53475. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53476. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53477. /**
  53478. * Implementation of the TGA Texture Loader.
  53479. * @hidden
  53480. */
  53481. export class _TGATextureLoader implements IInternalTextureLoader {
  53482. /**
  53483. * Defines wether the loader supports cascade loading the different faces.
  53484. */
  53485. readonly supportCascades: boolean;
  53486. /**
  53487. * This returns if the loader support the current file information.
  53488. * @param extension defines the file extension of the file being loaded
  53489. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53490. * @param fallback defines the fallback internal texture if any
  53491. * @param isBase64 defines whether the texture is encoded as a base64
  53492. * @param isBuffer defines whether the texture data are stored as a buffer
  53493. * @returns true if the loader can load the specified file
  53494. */
  53495. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53496. /**
  53497. * Transform the url before loading if required.
  53498. * @param rootUrl the url of the texture
  53499. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53500. * @returns the transformed texture
  53501. */
  53502. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53503. /**
  53504. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53505. * @param rootUrl the url of the texture
  53506. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53507. * @returns the fallback texture
  53508. */
  53509. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53510. /**
  53511. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53512. * @param data contains the texture data
  53513. * @param texture defines the BabylonJS internal texture
  53514. * @param createPolynomials will be true if polynomials have been requested
  53515. * @param onLoad defines the callback to trigger once the texture is ready
  53516. * @param onError defines the callback to trigger in case of error
  53517. */
  53518. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53519. /**
  53520. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53521. * @param data contains the texture data
  53522. * @param texture defines the BabylonJS internal texture
  53523. * @param callback defines the method to call once ready to upload
  53524. */
  53525. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53526. }
  53527. }
  53528. declare module "babylonjs/Misc/basis" {
  53529. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53530. /**
  53531. * Info about the .basis files
  53532. */
  53533. class BasisFileInfo {
  53534. /**
  53535. * If the file has alpha
  53536. */
  53537. hasAlpha: boolean;
  53538. /**
  53539. * Info about each image of the basis file
  53540. */
  53541. images: Array<{
  53542. levels: Array<{
  53543. width: number;
  53544. height: number;
  53545. transcodedPixels: ArrayBufferView;
  53546. }>;
  53547. }>;
  53548. }
  53549. /**
  53550. * Result of transcoding a basis file
  53551. */
  53552. class TranscodeResult {
  53553. /**
  53554. * Info about the .basis file
  53555. */
  53556. fileInfo: BasisFileInfo;
  53557. /**
  53558. * Format to use when loading the file
  53559. */
  53560. format: number;
  53561. }
  53562. /**
  53563. * Configuration options for the Basis transcoder
  53564. */
  53565. export class BasisTranscodeConfiguration {
  53566. /**
  53567. * Supported compression formats used to determine the supported output format of the transcoder
  53568. */
  53569. supportedCompressionFormats?: {
  53570. /**
  53571. * etc1 compression format
  53572. */
  53573. etc1?: boolean;
  53574. /**
  53575. * s3tc compression format
  53576. */
  53577. s3tc?: boolean;
  53578. /**
  53579. * pvrtc compression format
  53580. */
  53581. pvrtc?: boolean;
  53582. /**
  53583. * etc2 compression format
  53584. */
  53585. etc2?: boolean;
  53586. };
  53587. /**
  53588. * If mipmap levels should be loaded for transcoded images (Default: true)
  53589. */
  53590. loadMipmapLevels?: boolean;
  53591. /**
  53592. * Index of a single image to load (Default: all images)
  53593. */
  53594. loadSingleImage?: number;
  53595. }
  53596. /**
  53597. * Used to load .Basis files
  53598. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  53599. */
  53600. export class BasisTools {
  53601. private static _IgnoreSupportedFormats;
  53602. /**
  53603. * URL to use when loading the basis transcoder
  53604. */
  53605. static JSModuleURL: string;
  53606. /**
  53607. * URL to use when loading the wasm module for the transcoder
  53608. */
  53609. static WasmModuleURL: string;
  53610. /**
  53611. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  53612. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  53613. * @returns internal format corresponding to the Basis format
  53614. */
  53615. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  53616. private static _WorkerPromise;
  53617. private static _Worker;
  53618. private static _actionId;
  53619. private static _CreateWorkerAsync;
  53620. /**
  53621. * Transcodes a loaded image file to compressed pixel data
  53622. * @param imageData image data to transcode
  53623. * @param config configuration options for the transcoding
  53624. * @returns a promise resulting in the transcoded image
  53625. */
  53626. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  53627. /**
  53628. * Loads a texture from the transcode result
  53629. * @param texture texture load to
  53630. * @param transcodeResult the result of transcoding the basis file to load from
  53631. */
  53632. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  53633. }
  53634. }
  53635. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  53636. import { Nullable } from "babylonjs/types";
  53637. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53638. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53639. /**
  53640. * Loader for .basis file format
  53641. */
  53642. export class _BasisTextureLoader implements IInternalTextureLoader {
  53643. /**
  53644. * Defines whether the loader supports cascade loading the different faces.
  53645. */
  53646. readonly supportCascades: boolean;
  53647. /**
  53648. * This returns if the loader support the current file information.
  53649. * @param extension defines the file extension of the file being loaded
  53650. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53651. * @param fallback defines the fallback internal texture if any
  53652. * @param isBase64 defines whether the texture is encoded as a base64
  53653. * @param isBuffer defines whether the texture data are stored as a buffer
  53654. * @returns true if the loader can load the specified file
  53655. */
  53656. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53657. /**
  53658. * Transform the url before loading if required.
  53659. * @param rootUrl the url of the texture
  53660. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53661. * @returns the transformed texture
  53662. */
  53663. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53664. /**
  53665. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53666. * @param rootUrl the url of the texture
  53667. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53668. * @returns the fallback texture
  53669. */
  53670. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53671. /**
  53672. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  53673. * @param data contains the texture data
  53674. * @param texture defines the BabylonJS internal texture
  53675. * @param createPolynomials will be true if polynomials have been requested
  53676. * @param onLoad defines the callback to trigger once the texture is ready
  53677. * @param onError defines the callback to trigger in case of error
  53678. */
  53679. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53680. /**
  53681. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53682. * @param data contains the texture data
  53683. * @param texture defines the BabylonJS internal texture
  53684. * @param callback defines the method to call once ready to upload
  53685. */
  53686. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53687. }
  53688. }
  53689. declare module "babylonjs/Materials/Textures/Loaders/index" {
  53690. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  53691. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  53692. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  53693. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  53694. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  53695. }
  53696. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  53697. import { Scene } from "babylonjs/scene";
  53698. import { Texture } from "babylonjs/Materials/Textures/texture";
  53699. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  53700. /**
  53701. * 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.
  53702. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  53703. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  53704. */
  53705. export class CustomProceduralTexture extends ProceduralTexture {
  53706. private _animate;
  53707. private _time;
  53708. private _config;
  53709. private _texturePath;
  53710. /**
  53711. * Instantiates a new Custom Procedural Texture.
  53712. * 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.
  53713. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  53714. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  53715. * @param name Define the name of the texture
  53716. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  53717. * @param size Define the size of the texture to create
  53718. * @param scene Define the scene the texture belongs to
  53719. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  53720. * @param generateMipMaps Define if the texture should creates mip maps or not
  53721. */
  53722. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  53723. private _loadJson;
  53724. /**
  53725. * Is the texture ready to be used ? (rendered at least once)
  53726. * @returns true if ready, otherwise, false.
  53727. */
  53728. isReady(): boolean;
  53729. /**
  53730. * Render the texture to its associated render target.
  53731. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  53732. */
  53733. render(useCameraPostProcess?: boolean): void;
  53734. /**
  53735. * Update the list of dependant textures samplers in the shader.
  53736. */
  53737. updateTextures(): void;
  53738. /**
  53739. * Update the uniform values of the procedural texture in the shader.
  53740. */
  53741. updateShaderUniforms(): void;
  53742. /**
  53743. * Define if the texture animates or not.
  53744. */
  53745. animate: boolean;
  53746. }
  53747. }
  53748. declare module "babylonjs/Shaders/noise.fragment" {
  53749. /** @hidden */
  53750. export var noisePixelShader: {
  53751. name: string;
  53752. shader: string;
  53753. };
  53754. }
  53755. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  53756. import { Nullable } from "babylonjs/types";
  53757. import { Scene } from "babylonjs/scene";
  53758. import { Texture } from "babylonjs/Materials/Textures/texture";
  53759. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  53760. import "babylonjs/Shaders/noise.fragment";
  53761. /**
  53762. * Class used to generate noise procedural textures
  53763. */
  53764. export class NoiseProceduralTexture extends ProceduralTexture {
  53765. private _time;
  53766. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  53767. brightness: number;
  53768. /** Defines the number of octaves to process */
  53769. octaves: number;
  53770. /** Defines the level of persistence (0.8 by default) */
  53771. persistence: number;
  53772. /** Gets or sets animation speed factor (default is 1) */
  53773. animationSpeedFactor: number;
  53774. /**
  53775. * Creates a new NoiseProceduralTexture
  53776. * @param name defines the name fo the texture
  53777. * @param size defines the size of the texture (default is 256)
  53778. * @param scene defines the hosting scene
  53779. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  53780. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  53781. */
  53782. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  53783. private _updateShaderUniforms;
  53784. protected _getDefines(): string;
  53785. /** Generate the current state of the procedural texture */
  53786. render(useCameraPostProcess?: boolean): void;
  53787. /**
  53788. * Serializes this noise procedural texture
  53789. * @returns a serialized noise procedural texture object
  53790. */
  53791. serialize(): any;
  53792. /**
  53793. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  53794. * @param parsedTexture defines parsed texture data
  53795. * @param scene defines the current scene
  53796. * @param rootUrl defines the root URL containing noise procedural texture information
  53797. * @returns a parsed NoiseProceduralTexture
  53798. */
  53799. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  53800. }
  53801. }
  53802. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  53803. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  53804. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  53805. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  53806. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  53807. }
  53808. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  53809. import { Nullable } from "babylonjs/types";
  53810. import { Scene } from "babylonjs/scene";
  53811. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53812. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53813. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  53814. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53815. /**
  53816. * Raw cube texture where the raw buffers are passed in
  53817. */
  53818. export class RawCubeTexture extends CubeTexture {
  53819. /**
  53820. * Creates a cube texture where the raw buffers are passed in.
  53821. * @param scene defines the scene the texture is attached to
  53822. * @param data defines the array of data to use to create each face
  53823. * @param size defines the size of the textures
  53824. * @param format defines the format of the data
  53825. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  53826. * @param generateMipMaps defines if the engine should generate the mip levels
  53827. * @param invertY defines if data must be stored with Y axis inverted
  53828. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  53829. * @param compression defines the compression used (null by default)
  53830. */
  53831. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  53832. /**
  53833. * Updates the raw cube texture.
  53834. * @param data defines the data to store
  53835. * @param format defines the data format
  53836. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  53837. * @param invertY defines if data must be stored with Y axis inverted
  53838. * @param compression defines the compression used (null by default)
  53839. * @param level defines which level of the texture to update
  53840. */
  53841. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  53842. /**
  53843. * Updates a raw cube texture with RGBD encoded data.
  53844. * @param data defines the array of data [mipmap][face] to use to create each face
  53845. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  53846. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  53847. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  53848. * @returns a promsie that resolves when the operation is complete
  53849. */
  53850. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  53851. /**
  53852. * Clones the raw cube texture.
  53853. * @return a new cube texture
  53854. */
  53855. clone(): CubeTexture;
  53856. /** @hidden */
  53857. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  53858. }
  53859. }
  53860. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  53861. import { Scene } from "babylonjs/scene";
  53862. import { Texture } from "babylonjs/Materials/Textures/texture";
  53863. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53864. /**
  53865. * Class used to store 3D textures containing user data
  53866. */
  53867. export class RawTexture3D extends Texture {
  53868. /** Gets or sets the texture format to use */
  53869. format: number;
  53870. private _engine;
  53871. /**
  53872. * Create a new RawTexture3D
  53873. * @param data defines the data of the texture
  53874. * @param width defines the width of the texture
  53875. * @param height defines the height of the texture
  53876. * @param depth defines the depth of the texture
  53877. * @param format defines the texture format to use
  53878. * @param scene defines the hosting scene
  53879. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  53880. * @param invertY defines if texture must be stored with Y axis inverted
  53881. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  53882. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  53883. */
  53884. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  53885. /** Gets or sets the texture format to use */
  53886. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  53887. /**
  53888. * Update the texture with new data
  53889. * @param data defines the data to store in the texture
  53890. */
  53891. update(data: ArrayBufferView): void;
  53892. }
  53893. }
  53894. declare module "babylonjs/Materials/Textures/refractionTexture" {
  53895. import { Scene } from "babylonjs/scene";
  53896. import { Plane } from "babylonjs/Maths/math.plane";
  53897. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53898. /**
  53899. * Creates a refraction texture used by refraction channel of the standard material.
  53900. * It is like a mirror but to see through a material.
  53901. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53902. */
  53903. export class RefractionTexture extends RenderTargetTexture {
  53904. /**
  53905. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  53906. * 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.
  53907. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53908. */
  53909. refractionPlane: Plane;
  53910. /**
  53911. * Define how deep under the surface we should see.
  53912. */
  53913. depth: number;
  53914. /**
  53915. * Creates a refraction texture used by refraction channel of the standard material.
  53916. * It is like a mirror but to see through a material.
  53917. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53918. * @param name Define the texture name
  53919. * @param size Define the size of the underlying texture
  53920. * @param scene Define the scene the refraction belongs to
  53921. * @param generateMipMaps Define if we need to generate mips level for the refraction
  53922. */
  53923. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  53924. /**
  53925. * Clone the refraction texture.
  53926. * @returns the cloned texture
  53927. */
  53928. clone(): RefractionTexture;
  53929. /**
  53930. * Serialize the texture to a JSON representation you could use in Parse later on
  53931. * @returns the serialized JSON representation
  53932. */
  53933. serialize(): any;
  53934. }
  53935. }
  53936. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  53937. import { Nullable } from "babylonjs/types";
  53938. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53939. import { Matrix } from "babylonjs/Maths/math.vector";
  53940. import { Engine } from "babylonjs/Engines/engine";
  53941. import { Scene } from "babylonjs/scene";
  53942. /**
  53943. * Defines the options related to the creation of an HtmlElementTexture
  53944. */
  53945. export interface IHtmlElementTextureOptions {
  53946. /**
  53947. * Defines wether mip maps should be created or not.
  53948. */
  53949. generateMipMaps?: boolean;
  53950. /**
  53951. * Defines the sampling mode of the texture.
  53952. */
  53953. samplingMode?: number;
  53954. /**
  53955. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  53956. */
  53957. engine: Nullable<Engine>;
  53958. /**
  53959. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  53960. */
  53961. scene: Nullable<Scene>;
  53962. }
  53963. /**
  53964. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  53965. * To be as efficient as possible depending on your constraints nothing aside the first upload
  53966. * is automatically managed.
  53967. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  53968. * in your application.
  53969. *
  53970. * As the update is not automatic, you need to call them manually.
  53971. */
  53972. export class HtmlElementTexture extends BaseTexture {
  53973. /**
  53974. * The texture URL.
  53975. */
  53976. element: HTMLVideoElement | HTMLCanvasElement;
  53977. private static readonly DefaultOptions;
  53978. private _textureMatrix;
  53979. private _engine;
  53980. private _isVideo;
  53981. private _generateMipMaps;
  53982. private _samplingMode;
  53983. /**
  53984. * Instantiates a HtmlElementTexture from the following parameters.
  53985. *
  53986. * @param name Defines the name of the texture
  53987. * @param element Defines the video or canvas the texture is filled with
  53988. * @param options Defines the other none mandatory texture creation options
  53989. */
  53990. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  53991. private _createInternalTexture;
  53992. /**
  53993. * Returns the texture matrix used in most of the material.
  53994. */
  53995. getTextureMatrix(): Matrix;
  53996. /**
  53997. * Updates the content of the texture.
  53998. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  53999. */
  54000. update(invertY?: Nullable<boolean>): void;
  54001. }
  54002. }
  54003. declare module "babylonjs/Materials/Textures/index" {
  54004. export * from "babylonjs/Materials/Textures/baseTexture";
  54005. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  54006. export * from "babylonjs/Materials/Textures/cubeTexture";
  54007. export * from "babylonjs/Materials/Textures/dynamicTexture";
  54008. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  54009. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  54010. export * from "babylonjs/Materials/Textures/internalTexture";
  54011. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  54012. export * from "babylonjs/Materials/Textures/Loaders/index";
  54013. export * from "babylonjs/Materials/Textures/mirrorTexture";
  54014. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  54015. export * from "babylonjs/Materials/Textures/Procedurals/index";
  54016. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  54017. export * from "babylonjs/Materials/Textures/rawTexture";
  54018. export * from "babylonjs/Materials/Textures/rawTexture3D";
  54019. export * from "babylonjs/Materials/Textures/refractionTexture";
  54020. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  54021. export * from "babylonjs/Materials/Textures/texture";
  54022. export * from "babylonjs/Materials/Textures/videoTexture";
  54023. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  54024. }
  54025. declare module "babylonjs/Materials/Node/nodeMaterialBlockTargets" {
  54026. /**
  54027. * Enum used to define the target of a block
  54028. */
  54029. export enum NodeMaterialBlockTargets {
  54030. /** Vertex shader */
  54031. Vertex = 1,
  54032. /** Fragment shader */
  54033. Fragment = 2,
  54034. /** Neutral */
  54035. Neutral = 4,
  54036. /** Vertex and Fragment */
  54037. VertexAndFragment = 3
  54038. }
  54039. }
  54040. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes" {
  54041. /**
  54042. * Defines the kind of connection point for node based material
  54043. */
  54044. export enum NodeMaterialBlockConnectionPointTypes {
  54045. /** Float */
  54046. Float = 1,
  54047. /** Int */
  54048. Int = 2,
  54049. /** Vector2 */
  54050. Vector2 = 4,
  54051. /** Vector3 */
  54052. Vector3 = 8,
  54053. /** Vector4 */
  54054. Vector4 = 16,
  54055. /** Color3 */
  54056. Color3 = 32,
  54057. /** Color4 */
  54058. Color4 = 64,
  54059. /** Matrix */
  54060. Matrix = 128,
  54061. /** Detect type based on connection */
  54062. AutoDetect = 1024,
  54063. /** Output type that will be defined by input type */
  54064. BasedOnInput = 2048
  54065. }
  54066. }
  54067. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  54068. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54069. /**
  54070. * Root class for all node material optimizers
  54071. */
  54072. export class NodeMaterialOptimizer {
  54073. /**
  54074. * Function used to optimize a NodeMaterial graph
  54075. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  54076. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  54077. */
  54078. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  54079. }
  54080. }
  54081. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  54082. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54083. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54084. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54085. import { Scene } from "babylonjs/scene";
  54086. /**
  54087. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  54088. */
  54089. export class TransformBlock extends NodeMaterialBlock {
  54090. /**
  54091. * Defines the value to use to complement W value to transform it to a Vector4
  54092. */
  54093. complementW: number;
  54094. /**
  54095. * Defines the value to use to complement z value to transform it to a Vector4
  54096. */
  54097. complementZ: number;
  54098. /**
  54099. * Creates a new TransformBlock
  54100. * @param name defines the block name
  54101. */
  54102. constructor(name: string);
  54103. /**
  54104. * Gets the current class name
  54105. * @returns the class name
  54106. */
  54107. getClassName(): string;
  54108. /**
  54109. * Gets the vector input
  54110. */
  54111. readonly vector: NodeMaterialConnectionPoint;
  54112. /**
  54113. * Gets the output component
  54114. */
  54115. readonly output: NodeMaterialConnectionPoint;
  54116. /**
  54117. * Gets the matrix transform input
  54118. */
  54119. readonly transform: NodeMaterialConnectionPoint;
  54120. protected _buildBlock(state: NodeMaterialBuildState): this;
  54121. serialize(): any;
  54122. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54123. protected _dumpPropertiesCode(): string;
  54124. }
  54125. }
  54126. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  54127. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54128. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54129. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54130. /**
  54131. * Block used to output the vertex position
  54132. */
  54133. export class VertexOutputBlock extends NodeMaterialBlock {
  54134. /**
  54135. * Creates a new VertexOutputBlock
  54136. * @param name defines the block name
  54137. */
  54138. constructor(name: string);
  54139. /**
  54140. * Gets the current class name
  54141. * @returns the class name
  54142. */
  54143. getClassName(): string;
  54144. /**
  54145. * Gets the vector input component
  54146. */
  54147. readonly vector: NodeMaterialConnectionPoint;
  54148. protected _buildBlock(state: NodeMaterialBuildState): this;
  54149. }
  54150. }
  54151. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  54152. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54153. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54154. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54155. /**
  54156. * Block used to output the final color
  54157. */
  54158. export class FragmentOutputBlock extends NodeMaterialBlock {
  54159. /**
  54160. * Create a new FragmentOutputBlock
  54161. * @param name defines the block name
  54162. */
  54163. constructor(name: string);
  54164. /**
  54165. * Gets the current class name
  54166. * @returns the class name
  54167. */
  54168. getClassName(): string;
  54169. /**
  54170. * Gets the rgba input component
  54171. */
  54172. readonly rgba: NodeMaterialConnectionPoint;
  54173. /**
  54174. * Gets the rgb input component
  54175. */
  54176. readonly rgb: NodeMaterialConnectionPoint;
  54177. /**
  54178. * Gets the a input component
  54179. */
  54180. readonly a: NodeMaterialConnectionPoint;
  54181. protected _buildBlock(state: NodeMaterialBuildState): this;
  54182. }
  54183. }
  54184. declare module "babylonjs/Materials/Node/nodeMaterialWellKnownValues" {
  54185. /**
  54186. * Enum used to define well known values e.g. values automatically provided by the system
  54187. */
  54188. export enum NodeMaterialWellKnownValues {
  54189. /** World */
  54190. World = 1,
  54191. /** View */
  54192. View = 2,
  54193. /** Projection */
  54194. Projection = 3,
  54195. /** ViewProjection */
  54196. ViewProjection = 4,
  54197. /** WorldView */
  54198. WorldView = 5,
  54199. /** WorldViewProjection */
  54200. WorldViewProjection = 6,
  54201. /** CameraPosition */
  54202. CameraPosition = 7,
  54203. /** Fog Color */
  54204. FogColor = 8
  54205. }
  54206. }
  54207. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  54208. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54209. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54210. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54211. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54212. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54213. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54214. import { Effect } from "babylonjs/Materials/effect";
  54215. import { Mesh } from "babylonjs/Meshes/mesh";
  54216. import { Nullable } from "babylonjs/types";
  54217. import { Scene } from "babylonjs/scene";
  54218. /**
  54219. * Block used to read a reflection texture from a sampler
  54220. */
  54221. export class ReflectionTextureBlock extends NodeMaterialBlock {
  54222. private _define3DName;
  54223. private _defineCubicName;
  54224. private _defineExplicitName;
  54225. private _defineProjectionName;
  54226. private _defineLocalCubicName;
  54227. private _defineSphericalName;
  54228. private _definePlanarName;
  54229. private _defineEquirectangularName;
  54230. private _defineMirroredEquirectangularFixedName;
  54231. private _defineEquirectangularFixedName;
  54232. private _defineSkyboxName;
  54233. private _cubeSamplerName;
  54234. private _2DSamplerName;
  54235. private _positionUVWName;
  54236. private _directionWName;
  54237. private _reflectionCoordsName;
  54238. private _reflection2DCoordsName;
  54239. private _reflectionColorName;
  54240. private _reflectionMatrixName;
  54241. /**
  54242. * Gets or sets the texture associated with the node
  54243. */
  54244. texture: Nullable<BaseTexture>;
  54245. /**
  54246. * Create a new TextureBlock
  54247. * @param name defines the block name
  54248. */
  54249. constructor(name: string);
  54250. /**
  54251. * Gets the current class name
  54252. * @returns the class name
  54253. */
  54254. getClassName(): string;
  54255. /**
  54256. * Gets the world position input component
  54257. */
  54258. readonly position: NodeMaterialConnectionPoint;
  54259. /**
  54260. * Gets the world position input component
  54261. */
  54262. readonly worldPosition: NodeMaterialConnectionPoint;
  54263. /**
  54264. * Gets the world normal input component
  54265. */
  54266. readonly worldNormal: NodeMaterialConnectionPoint;
  54267. /**
  54268. * Gets the world input component
  54269. */
  54270. readonly world: NodeMaterialConnectionPoint;
  54271. /**
  54272. * Gets the camera (or eye) position component
  54273. */
  54274. readonly cameraPosition: NodeMaterialConnectionPoint;
  54275. /**
  54276. * Gets the view input component
  54277. */
  54278. readonly view: NodeMaterialConnectionPoint;
  54279. /**
  54280. * Gets the rgb output component
  54281. */
  54282. readonly rgb: NodeMaterialConnectionPoint;
  54283. /**
  54284. * Gets the r output component
  54285. */
  54286. readonly r: NodeMaterialConnectionPoint;
  54287. /**
  54288. * Gets the g output component
  54289. */
  54290. readonly g: NodeMaterialConnectionPoint;
  54291. /**
  54292. * Gets the b output component
  54293. */
  54294. readonly b: NodeMaterialConnectionPoint;
  54295. autoConfigure(material: NodeMaterial): void;
  54296. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54297. isReady(): boolean;
  54298. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54299. private _injectVertexCode;
  54300. private _writeOutput;
  54301. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54302. serialize(): any;
  54303. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54304. }
  54305. }
  54306. declare module "babylonjs/Materials/Node/nodeMaterial" {
  54307. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54308. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  54309. import { Scene } from "babylonjs/scene";
  54310. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54311. import { Matrix } from "babylonjs/Maths/math.vector";
  54312. import { Mesh } from "babylonjs/Meshes/mesh";
  54313. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54314. import { Observable } from "babylonjs/Misc/observable";
  54315. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54316. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  54317. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  54318. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  54319. import { Nullable } from "babylonjs/types";
  54320. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  54321. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  54322. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  54323. /**
  54324. * Interface used to configure the node material editor
  54325. */
  54326. export interface INodeMaterialEditorOptions {
  54327. /** Define the URl to load node editor script */
  54328. editorURL?: string;
  54329. }
  54330. /** @hidden */
  54331. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  54332. /** BONES */
  54333. NUM_BONE_INFLUENCERS: number;
  54334. BonesPerMesh: number;
  54335. BONETEXTURE: boolean;
  54336. /** MORPH TARGETS */
  54337. MORPHTARGETS: boolean;
  54338. MORPHTARGETS_NORMAL: boolean;
  54339. MORPHTARGETS_TANGENT: boolean;
  54340. MORPHTARGETS_UV: boolean;
  54341. NUM_MORPH_INFLUENCERS: number;
  54342. /** IMAGE PROCESSING */
  54343. IMAGEPROCESSING: boolean;
  54344. VIGNETTE: boolean;
  54345. VIGNETTEBLENDMODEMULTIPLY: boolean;
  54346. VIGNETTEBLENDMODEOPAQUE: boolean;
  54347. TONEMAPPING: boolean;
  54348. TONEMAPPING_ACES: boolean;
  54349. CONTRAST: boolean;
  54350. EXPOSURE: boolean;
  54351. COLORCURVES: boolean;
  54352. COLORGRADING: boolean;
  54353. COLORGRADING3D: boolean;
  54354. SAMPLER3DGREENDEPTH: boolean;
  54355. SAMPLER3DBGRMAP: boolean;
  54356. IMAGEPROCESSINGPOSTPROCESS: boolean;
  54357. constructor();
  54358. setValue(name: string, value: boolean): void;
  54359. }
  54360. /**
  54361. * Class used to configure NodeMaterial
  54362. */
  54363. export interface INodeMaterialOptions {
  54364. /**
  54365. * Defines if blocks should emit comments
  54366. */
  54367. emitComments: boolean;
  54368. }
  54369. /**
  54370. * Class used to create a node based material built by assembling shader blocks
  54371. */
  54372. export class NodeMaterial extends PushMaterial {
  54373. private static _BuildIdGenerator;
  54374. private _options;
  54375. private _vertexCompilationState;
  54376. private _fragmentCompilationState;
  54377. private _sharedData;
  54378. private _buildId;
  54379. private _buildWasSuccessful;
  54380. private _cachedWorldViewMatrix;
  54381. private _cachedWorldViewProjectionMatrix;
  54382. private _optimizers;
  54383. private _animationFrame;
  54384. /** Define the URl to load node editor script */
  54385. static EditorURL: string;
  54386. private BJSNODEMATERIALEDITOR;
  54387. /** Get the inspector from bundle or global */
  54388. private _getGlobalNodeMaterialEditor;
  54389. /**
  54390. * 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)
  54391. */
  54392. ignoreAlpha: boolean;
  54393. /**
  54394. * Defines the maximum number of lights that can be used in the material
  54395. */
  54396. maxSimultaneousLights: number;
  54397. /**
  54398. * Observable raised when the material is built
  54399. */
  54400. onBuildObservable: Observable<NodeMaterial>;
  54401. /**
  54402. * Gets or sets the root nodes of the material vertex shader
  54403. */
  54404. _vertexOutputNodes: NodeMaterialBlock[];
  54405. /**
  54406. * Gets or sets the root nodes of the material fragment (pixel) shader
  54407. */
  54408. _fragmentOutputNodes: NodeMaterialBlock[];
  54409. /** Gets or sets options to control the node material overall behavior */
  54410. options: INodeMaterialOptions;
  54411. /**
  54412. * Default configuration related to image processing available in the standard Material.
  54413. */
  54414. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54415. /**
  54416. * Gets the image processing configuration used either in this material.
  54417. */
  54418. /**
  54419. * Sets the Default image processing configuration used either in the this material.
  54420. *
  54421. * If sets to null, the scene one is in use.
  54422. */
  54423. imageProcessingConfiguration: ImageProcessingConfiguration;
  54424. /**
  54425. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  54426. */
  54427. attachedBlocks: NodeMaterialBlock[];
  54428. /**
  54429. * Create a new node based material
  54430. * @param name defines the material name
  54431. * @param scene defines the hosting scene
  54432. * @param options defines creation option
  54433. */
  54434. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  54435. /**
  54436. * Gets the current class name of the material e.g. "NodeMaterial"
  54437. * @returns the class name
  54438. */
  54439. getClassName(): string;
  54440. /**
  54441. * Keep track of the image processing observer to allow dispose and replace.
  54442. */
  54443. private _imageProcessingObserver;
  54444. /**
  54445. * Attaches a new image processing configuration to the Standard Material.
  54446. * @param configuration
  54447. */
  54448. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54449. /**
  54450. * Get a block by its name
  54451. * @param name defines the name of the block to retrieve
  54452. * @returns the required block or null if not found
  54453. */
  54454. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  54455. /**
  54456. * Get a block by its name
  54457. * @param predicate defines the predicate used to find the good candidate
  54458. * @returns the required block or null if not found
  54459. */
  54460. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  54461. /**
  54462. * Get an input block by its name
  54463. * @param predicate defines the predicate used to find the good candidate
  54464. * @returns the required input block or null if not found
  54465. */
  54466. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  54467. /**
  54468. * Gets the list of input blocks attached to this material
  54469. * @returns an array of InputBlocks
  54470. */
  54471. getInputBlocks(): InputBlock[];
  54472. /**
  54473. * Adds a new optimizer to the list of optimizers
  54474. * @param optimizer defines the optimizers to add
  54475. * @returns the current material
  54476. */
  54477. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  54478. /**
  54479. * Remove an optimizer from the list of optimizers
  54480. * @param optimizer defines the optimizers to remove
  54481. * @returns the current material
  54482. */
  54483. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  54484. /**
  54485. * Add a new block to the list of output nodes
  54486. * @param node defines the node to add
  54487. * @returns the current material
  54488. */
  54489. addOutputNode(node: NodeMaterialBlock): this;
  54490. /**
  54491. * Remove a block from the list of root nodes
  54492. * @param node defines the node to remove
  54493. * @returns the current material
  54494. */
  54495. removeOutputNode(node: NodeMaterialBlock): this;
  54496. private _addVertexOutputNode;
  54497. private _removeVertexOutputNode;
  54498. private _addFragmentOutputNode;
  54499. private _removeFragmentOutputNode;
  54500. /**
  54501. * Specifies if the material will require alpha blending
  54502. * @returns a boolean specifying if alpha blending is needed
  54503. */
  54504. needAlphaBlending(): boolean;
  54505. /**
  54506. * Specifies if this material should be rendered in alpha test mode
  54507. * @returns a boolean specifying if an alpha test is needed.
  54508. */
  54509. needAlphaTesting(): boolean;
  54510. private _initializeBlock;
  54511. private _resetDualBlocks;
  54512. /**
  54513. * Build the material and generates the inner effect
  54514. * @param verbose defines if the build should log activity
  54515. */
  54516. build(verbose?: boolean): void;
  54517. /**
  54518. * Runs an otpimization phase to try to improve the shader code
  54519. */
  54520. optimize(): void;
  54521. private _prepareDefinesForAttributes;
  54522. /**
  54523. * Get if the submesh is ready to be used and all its information available.
  54524. * Child classes can use it to update shaders
  54525. * @param mesh defines the mesh to check
  54526. * @param subMesh defines which submesh to check
  54527. * @param useInstances specifies that instances should be used
  54528. * @returns a boolean indicating that the submesh is ready or not
  54529. */
  54530. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54531. /**
  54532. * Get a string representing the shaders built by the current node graph
  54533. */
  54534. readonly compiledShaders: string;
  54535. /**
  54536. * Binds the world matrix to the material
  54537. * @param world defines the world transformation matrix
  54538. */
  54539. bindOnlyWorldMatrix(world: Matrix): void;
  54540. /**
  54541. * Binds the submesh to this material by preparing the effect and shader to draw
  54542. * @param world defines the world transformation matrix
  54543. * @param mesh defines the mesh containing the submesh
  54544. * @param subMesh defines the submesh to bind the material to
  54545. */
  54546. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54547. /**
  54548. * Gets the active textures from the material
  54549. * @returns an array of textures
  54550. */
  54551. getActiveTextures(): BaseTexture[];
  54552. /**
  54553. * Gets the list of texture blocks
  54554. * @returns an array of texture blocks
  54555. */
  54556. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  54557. /**
  54558. * Specifies if the material uses a texture
  54559. * @param texture defines the texture to check against the material
  54560. * @returns a boolean specifying if the material uses the texture
  54561. */
  54562. hasTexture(texture: BaseTexture): boolean;
  54563. /**
  54564. * Disposes the material
  54565. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  54566. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  54567. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  54568. */
  54569. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  54570. /** Creates the node editor window. */
  54571. private _createNodeEditor;
  54572. /**
  54573. * Launch the node material editor
  54574. * @param config Define the configuration of the editor
  54575. * @return a promise fulfilled when the node editor is visible
  54576. */
  54577. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  54578. /**
  54579. * Clear the current material
  54580. */
  54581. clear(): void;
  54582. /**
  54583. * Clear the current material and set it to a default state
  54584. */
  54585. setToDefault(): void;
  54586. /**
  54587. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  54588. * @param url defines the url to load from
  54589. * @returns a promise that will fullfil when the material is fully loaded
  54590. */
  54591. loadAsync(url: string): Promise<unknown>;
  54592. private _gatherBlocks;
  54593. /**
  54594. * Generate a string containing the code declaration required to create an equivalent of this material
  54595. * @returns a string
  54596. */
  54597. generateCode(): string;
  54598. /**
  54599. * Serializes this material in a JSON representation
  54600. * @returns the serialized material object
  54601. */
  54602. serialize(): any;
  54603. private _restoreConnections;
  54604. /**
  54605. * Clear the current graph and load a new one from a serialization object
  54606. * @param source defines the JSON representation of the material
  54607. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  54608. */
  54609. loadFromSerialization(source: any, rootUrl?: string): void;
  54610. /**
  54611. * Creates a node material from parsed material data
  54612. * @param source defines the JSON representation of the material
  54613. * @param scene defines the hosting scene
  54614. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  54615. * @returns a new node material
  54616. */
  54617. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  54618. /**
  54619. * Creates a new node material set to default basic configuration
  54620. * @param name defines the name of the material
  54621. * @param scene defines the hosting scene
  54622. * @returns a new NodeMaterial
  54623. */
  54624. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  54625. }
  54626. }
  54627. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  54628. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54629. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54630. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54631. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54632. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54633. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54634. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54635. import { Effect } from "babylonjs/Materials/effect";
  54636. import { Mesh } from "babylonjs/Meshes/mesh";
  54637. import { Nullable } from "babylonjs/types";
  54638. import { Scene } from "babylonjs/scene";
  54639. /**
  54640. * Block used to read a texture from a sampler
  54641. */
  54642. export class TextureBlock extends NodeMaterialBlock {
  54643. private _defineName;
  54644. private _samplerName;
  54645. private _transformedUVName;
  54646. private _textureTransformName;
  54647. private _textureInfoName;
  54648. private _mainUVName;
  54649. private _mainUVDefineName;
  54650. /**
  54651. * Gets or sets the texture associated with the node
  54652. */
  54653. texture: Nullable<BaseTexture>;
  54654. /**
  54655. * Create a new TextureBlock
  54656. * @param name defines the block name
  54657. */
  54658. constructor(name: string);
  54659. /**
  54660. * Gets the current class name
  54661. * @returns the class name
  54662. */
  54663. getClassName(): string;
  54664. /**
  54665. * Gets the uv input component
  54666. */
  54667. readonly uv: NodeMaterialConnectionPoint;
  54668. /**
  54669. * Gets the rgba output component
  54670. */
  54671. readonly rgba: NodeMaterialConnectionPoint;
  54672. /**
  54673. * Gets the rgb output component
  54674. */
  54675. readonly rgb: NodeMaterialConnectionPoint;
  54676. /**
  54677. * Gets the r output component
  54678. */
  54679. readonly r: NodeMaterialConnectionPoint;
  54680. /**
  54681. * Gets the g output component
  54682. */
  54683. readonly g: NodeMaterialConnectionPoint;
  54684. /**
  54685. * Gets the b output component
  54686. */
  54687. readonly b: NodeMaterialConnectionPoint;
  54688. /**
  54689. * Gets the a output component
  54690. */
  54691. readonly a: NodeMaterialConnectionPoint;
  54692. readonly target: NodeMaterialBlockTargets;
  54693. autoConfigure(material: NodeMaterial): void;
  54694. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54695. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54696. isReady(): boolean;
  54697. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54698. private readonly _isMixed;
  54699. private _injectVertexCode;
  54700. private _writeOutput;
  54701. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54702. protected _dumpPropertiesCode(): string;
  54703. serialize(): any;
  54704. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54705. }
  54706. }
  54707. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  54708. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54709. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54710. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  54711. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  54712. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  54713. /**
  54714. * Class used to store shared data between 2 NodeMaterialBuildState
  54715. */
  54716. export class NodeMaterialBuildStateSharedData {
  54717. /**
  54718. * Gets the list of emitted varyings
  54719. */
  54720. temps: string[];
  54721. /**
  54722. * Gets the list of emitted varyings
  54723. */
  54724. varyings: string[];
  54725. /**
  54726. * Gets the varying declaration string
  54727. */
  54728. varyingDeclaration: string;
  54729. /**
  54730. * Input blocks
  54731. */
  54732. inputBlocks: InputBlock[];
  54733. /**
  54734. * Input blocks
  54735. */
  54736. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  54737. /**
  54738. * Bindable blocks (Blocks that need to set data to the effect)
  54739. */
  54740. bindableBlocks: NodeMaterialBlock[];
  54741. /**
  54742. * List of blocks that can provide a compilation fallback
  54743. */
  54744. blocksWithFallbacks: NodeMaterialBlock[];
  54745. /**
  54746. * List of blocks that can provide a define update
  54747. */
  54748. blocksWithDefines: NodeMaterialBlock[];
  54749. /**
  54750. * List of blocks that can provide a repeatable content
  54751. */
  54752. repeatableContentBlocks: NodeMaterialBlock[];
  54753. /**
  54754. * List of blocks that can provide a dynamic list of uniforms
  54755. */
  54756. dynamicUniformBlocks: NodeMaterialBlock[];
  54757. /**
  54758. * List of blocks that can block the isReady function for the material
  54759. */
  54760. blockingBlocks: NodeMaterialBlock[];
  54761. /**
  54762. * Gets the list of animated inputs
  54763. */
  54764. animatedInputs: InputBlock[];
  54765. /**
  54766. * Build Id used to avoid multiple recompilations
  54767. */
  54768. buildId: number;
  54769. /** List of emitted variables */
  54770. variableNames: {
  54771. [key: string]: number;
  54772. };
  54773. /** List of emitted defines */
  54774. defineNames: {
  54775. [key: string]: number;
  54776. };
  54777. /** Should emit comments? */
  54778. emitComments: boolean;
  54779. /** Emit build activity */
  54780. verbose: boolean;
  54781. /**
  54782. * Gets the compilation hints emitted at compilation time
  54783. */
  54784. hints: {
  54785. needWorldViewMatrix: boolean;
  54786. needWorldViewProjectionMatrix: boolean;
  54787. needAlphaBlending: boolean;
  54788. needAlphaTesting: boolean;
  54789. };
  54790. /**
  54791. * List of compilation checks
  54792. */
  54793. checks: {
  54794. emitVertex: boolean;
  54795. emitFragment: boolean;
  54796. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  54797. };
  54798. /** Creates a new shared data */
  54799. constructor();
  54800. /**
  54801. * Emits console errors and exceptions if there is a failing check
  54802. */
  54803. emitErrors(): void;
  54804. }
  54805. }
  54806. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  54807. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54808. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54809. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  54810. /**
  54811. * Class used to store node based material build state
  54812. */
  54813. export class NodeMaterialBuildState {
  54814. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  54815. supportUniformBuffers: boolean;
  54816. /**
  54817. * Gets the list of emitted attributes
  54818. */
  54819. attributes: string[];
  54820. /**
  54821. * Gets the list of emitted uniforms
  54822. */
  54823. uniforms: string[];
  54824. /**
  54825. * Gets the list of emitted uniform buffers
  54826. */
  54827. uniformBuffers: string[];
  54828. /**
  54829. * Gets the list of emitted samplers
  54830. */
  54831. samplers: string[];
  54832. /**
  54833. * Gets the list of emitted functions
  54834. */
  54835. functions: {
  54836. [key: string]: string;
  54837. };
  54838. /**
  54839. * Gets the target of the compilation state
  54840. */
  54841. target: NodeMaterialBlockTargets;
  54842. /**
  54843. * Gets the list of emitted counters
  54844. */
  54845. counters: {
  54846. [key: string]: number;
  54847. };
  54848. /**
  54849. * Shared data between multiple NodeMaterialBuildState instances
  54850. */
  54851. sharedData: NodeMaterialBuildStateSharedData;
  54852. /** @hidden */
  54853. _vertexState: NodeMaterialBuildState;
  54854. /** @hidden */
  54855. _attributeDeclaration: string;
  54856. /** @hidden */
  54857. _uniformDeclaration: string;
  54858. /** @hidden */
  54859. _samplerDeclaration: string;
  54860. /** @hidden */
  54861. _varyingTransfer: string;
  54862. private _repeatableContentAnchorIndex;
  54863. /** @hidden */
  54864. _builtCompilationString: string;
  54865. /**
  54866. * Gets the emitted compilation strings
  54867. */
  54868. compilationString: string;
  54869. /**
  54870. * Finalize the compilation strings
  54871. * @param state defines the current compilation state
  54872. */
  54873. finalize(state: NodeMaterialBuildState): void;
  54874. /** @hidden */
  54875. readonly _repeatableContentAnchor: string;
  54876. /** @hidden */
  54877. _getFreeVariableName(prefix: string): string;
  54878. /** @hidden */
  54879. _getFreeDefineName(prefix: string): string;
  54880. /** @hidden */
  54881. _excludeVariableName(name: string): void;
  54882. /** @hidden */
  54883. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  54884. /** @hidden */
  54885. _emitFunction(name: string, code: string, comments: string): void;
  54886. /** @hidden */
  54887. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  54888. replaceStrings?: {
  54889. search: RegExp;
  54890. replace: string;
  54891. }[];
  54892. repeatKey?: string;
  54893. }): string;
  54894. /** @hidden */
  54895. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  54896. repeatKey?: string;
  54897. removeAttributes?: boolean;
  54898. removeUniforms?: boolean;
  54899. removeVaryings?: boolean;
  54900. removeIfDef?: boolean;
  54901. replaceStrings?: {
  54902. search: RegExp;
  54903. replace: string;
  54904. }[];
  54905. }, storeKey?: string): void;
  54906. /** @hidden */
  54907. _registerTempVariable(name: string): boolean;
  54908. /** @hidden */
  54909. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  54910. /** @hidden */
  54911. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  54912. }
  54913. }
  54914. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  54915. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54916. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54917. import { Nullable } from "babylonjs/types";
  54918. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54919. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54920. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  54921. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54922. import { Mesh } from "babylonjs/Meshes/mesh";
  54923. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54924. import { Scene } from "babylonjs/scene";
  54925. /**
  54926. * Defines a block that can be used inside a node based material
  54927. */
  54928. export class NodeMaterialBlock {
  54929. private _buildId;
  54930. private _buildTarget;
  54931. private _target;
  54932. private _isFinalMerger;
  54933. private _isInput;
  54934. /** @hidden */
  54935. _codeVariableName: string;
  54936. /** @hidden */
  54937. _inputs: NodeMaterialConnectionPoint[];
  54938. /** @hidden */
  54939. _outputs: NodeMaterialConnectionPoint[];
  54940. /**
  54941. * Gets or sets the name of the block
  54942. */
  54943. name: string;
  54944. /**
  54945. * Gets or sets the unique id of the node
  54946. */
  54947. uniqueId: number;
  54948. /**
  54949. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  54950. */
  54951. readonly isFinalMerger: boolean;
  54952. /**
  54953. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  54954. */
  54955. readonly isInput: boolean;
  54956. /**
  54957. * Gets or sets the build Id
  54958. */
  54959. buildId: number;
  54960. /**
  54961. * Gets or sets the target of the block
  54962. */
  54963. target: NodeMaterialBlockTargets;
  54964. /**
  54965. * Gets the list of input points
  54966. */
  54967. readonly inputs: NodeMaterialConnectionPoint[];
  54968. /** Gets the list of output points */
  54969. readonly outputs: NodeMaterialConnectionPoint[];
  54970. /**
  54971. * Find an input by its name
  54972. * @param name defines the name of the input to look for
  54973. * @returns the input or null if not found
  54974. */
  54975. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  54976. /**
  54977. * Find an output by its name
  54978. * @param name defines the name of the outputto look for
  54979. * @returns the output or null if not found
  54980. */
  54981. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  54982. /**
  54983. * Creates a new NodeMaterialBlock
  54984. * @param name defines the block name
  54985. * @param target defines the target of that block (Vertex by default)
  54986. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  54987. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  54988. */
  54989. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  54990. /**
  54991. * Initialize the block and prepare the context for build
  54992. * @param state defines the state that will be used for the build
  54993. */
  54994. initialize(state: NodeMaterialBuildState): void;
  54995. /**
  54996. * Bind data to effect. Will only be called for blocks with isBindable === true
  54997. * @param effect defines the effect to bind data to
  54998. * @param nodeMaterial defines the hosting NodeMaterial
  54999. * @param mesh defines the mesh that will be rendered
  55000. */
  55001. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55002. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  55003. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  55004. protected _writeFloat(value: number): string;
  55005. /**
  55006. * Gets the current class name e.g. "NodeMaterialBlock"
  55007. * @returns the class name
  55008. */
  55009. getClassName(): string;
  55010. /**
  55011. * Register a new input. Must be called inside a block constructor
  55012. * @param name defines the connection point name
  55013. * @param type defines the connection point type
  55014. * @param isOptional defines a boolean indicating that this input can be omitted
  55015. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  55016. * @returns the current block
  55017. */
  55018. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  55019. /**
  55020. * Register a new output. Must be called inside a block constructor
  55021. * @param name defines the connection point name
  55022. * @param type defines the connection point type
  55023. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  55024. * @returns the current block
  55025. */
  55026. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  55027. /**
  55028. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  55029. * @param forOutput defines an optional connection point to check compatibility with
  55030. * @returns the first available input or null
  55031. */
  55032. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  55033. /**
  55034. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  55035. * @param forBlock defines an optional block to check compatibility with
  55036. * @returns the first available input or null
  55037. */
  55038. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  55039. /**
  55040. * Gets the sibling of the given output
  55041. * @param current defines the current output
  55042. * @returns the next output in the list or null
  55043. */
  55044. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  55045. /**
  55046. * Connect current block with another block
  55047. * @param other defines the block to connect with
  55048. * @param options define the various options to help pick the right connections
  55049. * @returns the current block
  55050. */
  55051. connectTo(other: NodeMaterialBlock, options?: {
  55052. input?: string;
  55053. output?: string;
  55054. outputSwizzle?: string;
  55055. }): this | undefined;
  55056. protected _buildBlock(state: NodeMaterialBuildState): void;
  55057. /**
  55058. * Add uniforms, samplers and uniform buffers at compilation time
  55059. * @param state defines the state to update
  55060. * @param nodeMaterial defines the node material requesting the update
  55061. * @param defines defines the material defines to update
  55062. */
  55063. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55064. /**
  55065. * Add potential fallbacks if shader compilation fails
  55066. * @param mesh defines the mesh to be rendered
  55067. * @param fallbacks defines the current prioritized list of fallbacks
  55068. */
  55069. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  55070. /**
  55071. * Update defines for shader compilation
  55072. * @param mesh defines the mesh to be rendered
  55073. * @param nodeMaterial defines the node material requesting the update
  55074. * @param defines defines the material defines to update
  55075. * @param useInstances specifies that instances should be used
  55076. */
  55077. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55078. /**
  55079. * Initialize defines for shader compilation
  55080. * @param mesh defines the mesh to be rendered
  55081. * @param nodeMaterial defines the node material requesting the update
  55082. * @param defines defines the material defines to be prepared
  55083. * @param useInstances specifies that instances should be used
  55084. */
  55085. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55086. /**
  55087. * Lets the block try to connect some inputs automatically
  55088. * @param material defines the hosting NodeMaterial
  55089. */
  55090. autoConfigure(material: NodeMaterial): void;
  55091. /**
  55092. * Function called when a block is declared as repeatable content generator
  55093. * @param vertexShaderState defines the current compilation state for the vertex shader
  55094. * @param fragmentShaderState defines the current compilation state for the fragment shader
  55095. * @param mesh defines the mesh to be rendered
  55096. * @param defines defines the material defines to update
  55097. */
  55098. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  55099. /**
  55100. * Checks if the block is ready
  55101. * @param mesh defines the mesh to be rendered
  55102. * @param nodeMaterial defines the node material requesting the update
  55103. * @param defines defines the material defines to update
  55104. * @param useInstances specifies that instances should be used
  55105. * @returns true if the block is ready
  55106. */
  55107. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  55108. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  55109. private _processBuild;
  55110. /**
  55111. * Compile the current node and generate the shader code
  55112. * @param state defines the current compilation state (uniforms, samplers, current string)
  55113. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  55114. * @returns true if already built
  55115. */
  55116. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  55117. protected _inputRename(name: string): string;
  55118. protected _outputRename(name: string): string;
  55119. protected _dumpPropertiesCode(): string;
  55120. /** @hidden */
  55121. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  55122. /**
  55123. * Clone the current block to a new identical block
  55124. * @param scene defines the hosting scene
  55125. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55126. * @returns a copy of the current block
  55127. */
  55128. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  55129. /**
  55130. * Serializes this block in a JSON representation
  55131. * @returns the serialized block object
  55132. */
  55133. serialize(): any;
  55134. /** @hidden */
  55135. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55136. }
  55137. }
  55138. declare module "babylonjs/Materials/Node/NodeMaterialBlockConnectionPointMode" {
  55139. /**
  55140. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  55141. */
  55142. export enum NodeMaterialBlockConnectionPointMode {
  55143. /** Value is an uniform */
  55144. Uniform = 0,
  55145. /** Value is a mesh attribute */
  55146. Attribute = 1,
  55147. /** Value is a varying between vertex and fragment shaders */
  55148. Varying = 2,
  55149. /** Mode is undefined */
  55150. Undefined = 3
  55151. }
  55152. }
  55153. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  55154. /**
  55155. * Enum defining the type of animations supported by InputBlock
  55156. */
  55157. export enum AnimatedInputBlockTypes {
  55158. /** No animation */
  55159. None = 0,
  55160. /** Time based animation. Will only work for floats */
  55161. Time = 1
  55162. }
  55163. }
  55164. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  55165. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55166. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  55167. import { NodeMaterialWellKnownValues } from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  55168. import { Nullable } from "babylonjs/types";
  55169. import { Effect } from "babylonjs/Materials/effect";
  55170. import { Matrix } from "babylonjs/Maths/math.vector";
  55171. import { Scene } from "babylonjs/scene";
  55172. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55173. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55174. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  55175. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  55176. /**
  55177. * Block used to expose an input value
  55178. */
  55179. export class InputBlock extends NodeMaterialBlock {
  55180. private _mode;
  55181. private _associatedVariableName;
  55182. private _storedValue;
  55183. private _valueCallback;
  55184. private _type;
  55185. private _animationType;
  55186. /** @hidden */
  55187. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  55188. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  55189. visibleInInspector: boolean;
  55190. /**
  55191. * Gets or sets the connection point type (default is float)
  55192. */
  55193. readonly type: NodeMaterialBlockConnectionPointTypes;
  55194. /**
  55195. * Creates a new InputBlock
  55196. * @param name defines the block name
  55197. * @param target defines the target of that block (Vertex by default)
  55198. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  55199. */
  55200. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  55201. /**
  55202. * Gets the output component
  55203. */
  55204. readonly output: NodeMaterialConnectionPoint;
  55205. /**
  55206. * Set the source of this connection point to a vertex attribute
  55207. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  55208. * @returns the current connection point
  55209. */
  55210. setAsAttribute(attributeName?: string): InputBlock;
  55211. /**
  55212. * Set the source of this connection point to a well known value
  55213. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  55214. * @returns the current connection point
  55215. */
  55216. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): InputBlock;
  55217. /**
  55218. * Gets or sets the value of that point.
  55219. * Please note that this value will be ignored if valueCallback is defined
  55220. */
  55221. value: any;
  55222. /**
  55223. * Gets or sets a callback used to get the value of that point.
  55224. * Please note that setting this value will force the connection point to ignore the value property
  55225. */
  55226. valueCallback: () => any;
  55227. /**
  55228. * Gets or sets the associated variable name in the shader
  55229. */
  55230. associatedVariableName: string;
  55231. /** Gets or sets the type of animation applied to the input */
  55232. animationType: AnimatedInputBlockTypes;
  55233. /**
  55234. * Gets a boolean indicating that this connection point not defined yet
  55235. */
  55236. readonly isUndefined: boolean;
  55237. /**
  55238. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  55239. * In this case the connection point name must be the name of the uniform to use.
  55240. * Can only be set on inputs
  55241. */
  55242. isUniform: boolean;
  55243. /**
  55244. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  55245. * In this case the connection point name must be the name of the attribute to use
  55246. * Can only be set on inputs
  55247. */
  55248. isAttribute: boolean;
  55249. /**
  55250. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  55251. * Can only be set on exit points
  55252. */
  55253. isVarying: boolean;
  55254. /**
  55255. * Gets a boolean indicating that the current connection point is a well known value
  55256. */
  55257. readonly isWellKnownValue: boolean;
  55258. /**
  55259. * Gets or sets the current well known value or null if not defined as well know value
  55260. */
  55261. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  55262. /**
  55263. * Gets the current class name
  55264. * @returns the class name
  55265. */
  55266. getClassName(): string;
  55267. /**
  55268. * Animate the input if animationType !== None
  55269. * @param scene defines the rendering scene
  55270. */
  55271. animate(scene: Scene): void;
  55272. private _emitDefine;
  55273. /**
  55274. * Set the input block to its default value (based on its type)
  55275. */
  55276. setDefaultValue(): void;
  55277. protected _dumpPropertiesCode(): string;
  55278. private _emit;
  55279. /** @hidden */
  55280. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  55281. /** @hidden */
  55282. _transmit(effect: Effect, scene: Scene): void;
  55283. protected _buildBlock(state: NodeMaterialBuildState): void;
  55284. serialize(): any;
  55285. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55286. }
  55287. }
  55288. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  55289. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  55290. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  55291. import { Nullable } from "babylonjs/types";
  55292. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55293. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55294. /**
  55295. * Defines a connection point for a block
  55296. */
  55297. export class NodeMaterialConnectionPoint {
  55298. /** @hidden */
  55299. _ownerBlock: NodeMaterialBlock;
  55300. /** @hidden */
  55301. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  55302. private _endpoints;
  55303. private _associatedVariableName;
  55304. /** @hidden */
  55305. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  55306. /** @hidden */
  55307. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  55308. private _type;
  55309. /** @hidden */
  55310. _enforceAssociatedVariableName: boolean;
  55311. /**
  55312. * Gets or sets the additional types supported byt this connection point
  55313. */
  55314. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  55315. /**
  55316. * Gets or sets the associated variable name in the shader
  55317. */
  55318. associatedVariableName: string;
  55319. /**
  55320. * Gets or sets the connection point type (default is float)
  55321. */
  55322. type: NodeMaterialBlockConnectionPointTypes;
  55323. /**
  55324. * Gets or sets the connection point name
  55325. */
  55326. name: string;
  55327. /**
  55328. * Gets or sets a boolean indicating that this connection point can be omitted
  55329. */
  55330. isOptional: boolean;
  55331. /**
  55332. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  55333. */
  55334. define: string;
  55335. /** Gets or sets the target of that connection point */
  55336. target: NodeMaterialBlockTargets;
  55337. /**
  55338. * Gets a boolean indicating that the current point is connected
  55339. */
  55340. readonly isConnected: boolean;
  55341. /**
  55342. * Gets a boolean indicating that the current point is connected to an input block
  55343. */
  55344. readonly isConnectedToInputBlock: boolean;
  55345. /**
  55346. * Gets a the connected input block (if any)
  55347. */
  55348. readonly connectInputBlock: Nullable<InputBlock>;
  55349. /** Get the other side of the connection (if any) */
  55350. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  55351. /** Get the block that owns this connection point */
  55352. readonly ownerBlock: NodeMaterialBlock;
  55353. /** Get the block connected on the other side of this connection (if any) */
  55354. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  55355. /** Get the block connected on the endpoints of this connection (if any) */
  55356. readonly connectedBlocks: Array<NodeMaterialBlock>;
  55357. /** Gets the list of connected endpoints */
  55358. readonly endpoints: NodeMaterialConnectionPoint[];
  55359. /** Gets a boolean indicating if that output point is connected to at least one input */
  55360. readonly hasEndpoints: boolean;
  55361. /**
  55362. * Creates a new connection point
  55363. * @param name defines the connection point name
  55364. * @param ownerBlock defines the block hosting this connection point
  55365. */
  55366. constructor(name: string, ownerBlock: NodeMaterialBlock);
  55367. /**
  55368. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  55369. * @returns the class name
  55370. */
  55371. getClassName(): string;
  55372. /**
  55373. * Gets an boolean indicating if the current point can be connected to another point
  55374. * @param connectionPoint defines the other connection point
  55375. * @returns true if the connection is possible
  55376. */
  55377. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  55378. /**
  55379. * Connect this point to another connection point
  55380. * @param connectionPoint defines the other connection point
  55381. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  55382. * @returns the current connection point
  55383. */
  55384. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  55385. /**
  55386. * Disconnect this point from one of his endpoint
  55387. * @param endpoint defines the other connection point
  55388. * @returns the current connection point
  55389. */
  55390. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  55391. /**
  55392. * Serializes this point in a JSON representation
  55393. * @returns the serialized point object
  55394. */
  55395. serialize(): any;
  55396. }
  55397. }
  55398. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  55399. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55400. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55401. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55402. import { Mesh } from "babylonjs/Meshes/mesh";
  55403. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  55404. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55405. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55406. /**
  55407. * Block used to add support for vertex skinning (bones)
  55408. */
  55409. export class BonesBlock extends NodeMaterialBlock {
  55410. /**
  55411. * Creates a new BonesBlock
  55412. * @param name defines the block name
  55413. */
  55414. constructor(name: string);
  55415. /**
  55416. * Initialize the block and prepare the context for build
  55417. * @param state defines the state that will be used for the build
  55418. */
  55419. initialize(state: NodeMaterialBuildState): void;
  55420. /**
  55421. * Gets the current class name
  55422. * @returns the class name
  55423. */
  55424. getClassName(): string;
  55425. /**
  55426. * Gets the matrix indices input component
  55427. */
  55428. readonly matricesIndices: NodeMaterialConnectionPoint;
  55429. /**
  55430. * Gets the matrix weights input component
  55431. */
  55432. readonly matricesWeights: NodeMaterialConnectionPoint;
  55433. /**
  55434. * Gets the extra matrix indices input component
  55435. */
  55436. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  55437. /**
  55438. * Gets the extra matrix weights input component
  55439. */
  55440. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  55441. /**
  55442. * Gets the world input component
  55443. */
  55444. readonly world: NodeMaterialConnectionPoint;
  55445. /**
  55446. * Gets the output component
  55447. */
  55448. readonly output: NodeMaterialConnectionPoint;
  55449. autoConfigure(material: NodeMaterial): void;
  55450. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  55451. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55452. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55453. protected _buildBlock(state: NodeMaterialBuildState): this;
  55454. }
  55455. }
  55456. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  55457. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55458. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55459. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55460. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55461. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55462. /**
  55463. * Block used to add support for instances
  55464. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  55465. */
  55466. export class InstancesBlock extends NodeMaterialBlock {
  55467. /**
  55468. * Creates a new InstancesBlock
  55469. * @param name defines the block name
  55470. */
  55471. constructor(name: string);
  55472. /**
  55473. * Gets the current class name
  55474. * @returns the class name
  55475. */
  55476. getClassName(): string;
  55477. /**
  55478. * Gets the first world row input component
  55479. */
  55480. readonly world0: NodeMaterialConnectionPoint;
  55481. /**
  55482. * Gets the second world row input component
  55483. */
  55484. readonly world1: NodeMaterialConnectionPoint;
  55485. /**
  55486. * Gets the third world row input component
  55487. */
  55488. readonly world2: NodeMaterialConnectionPoint;
  55489. /**
  55490. * Gets the forth world row input component
  55491. */
  55492. readonly world3: NodeMaterialConnectionPoint;
  55493. /**
  55494. * Gets the world input component
  55495. */
  55496. readonly world: NodeMaterialConnectionPoint;
  55497. /**
  55498. * Gets the output component
  55499. */
  55500. readonly output: NodeMaterialConnectionPoint;
  55501. autoConfigure(material: NodeMaterial): void;
  55502. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55503. protected _buildBlock(state: NodeMaterialBuildState): this;
  55504. }
  55505. }
  55506. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  55507. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55508. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55509. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55510. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55511. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55512. import { Effect } from "babylonjs/Materials/effect";
  55513. import { Mesh } from "babylonjs/Meshes/mesh";
  55514. /**
  55515. * Block used to add morph targets support to vertex shader
  55516. */
  55517. export class MorphTargetsBlock extends NodeMaterialBlock {
  55518. private _repeatableContentAnchor;
  55519. private _repeatebleContentGenerated;
  55520. /**
  55521. * Create a new MorphTargetsBlock
  55522. * @param name defines the block name
  55523. */
  55524. constructor(name: string);
  55525. /**
  55526. * Gets the current class name
  55527. * @returns the class name
  55528. */
  55529. getClassName(): string;
  55530. /**
  55531. * Gets the position input component
  55532. */
  55533. readonly position: NodeMaterialConnectionPoint;
  55534. /**
  55535. * Gets the normal input component
  55536. */
  55537. readonly normal: NodeMaterialConnectionPoint;
  55538. /**
  55539. * Gets the tangent input component
  55540. */
  55541. readonly tangent: NodeMaterialConnectionPoint;
  55542. /**
  55543. * Gets the tangent input component
  55544. */
  55545. readonly uv: NodeMaterialConnectionPoint;
  55546. /**
  55547. * Gets the position output component
  55548. */
  55549. readonly positionOutput: NodeMaterialConnectionPoint;
  55550. /**
  55551. * Gets the normal output component
  55552. */
  55553. readonly normalOutput: NodeMaterialConnectionPoint;
  55554. /**
  55555. * Gets the tangent output component
  55556. */
  55557. readonly tangentOutput: NodeMaterialConnectionPoint;
  55558. /**
  55559. * Gets the tangent output component
  55560. */
  55561. readonly uvOutput: NodeMaterialConnectionPoint;
  55562. initialize(state: NodeMaterialBuildState): void;
  55563. autoConfigure(material: NodeMaterial): void;
  55564. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55565. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55566. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  55567. protected _buildBlock(state: NodeMaterialBuildState): this;
  55568. }
  55569. }
  55570. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  55571. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  55572. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  55573. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  55574. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  55575. }
  55576. declare module "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock" {
  55577. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55578. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55579. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55580. import { Scene } from "babylonjs/scene";
  55581. /**
  55582. * Block used to add an alpha test in the fragment shader
  55583. */
  55584. export class AlphaTestBlock extends NodeMaterialBlock {
  55585. /**
  55586. * Gets or sets the alpha value where alpha testing happens
  55587. */
  55588. alphaCutOff: number;
  55589. /**
  55590. * Create a new AlphaTestBlock
  55591. * @param name defines the block name
  55592. */
  55593. constructor(name: string);
  55594. /**
  55595. * Gets the current class name
  55596. * @returns the class name
  55597. */
  55598. getClassName(): string;
  55599. /**
  55600. * Gets the color input component
  55601. */
  55602. readonly color: NodeMaterialConnectionPoint;
  55603. /**
  55604. * Gets the alpha input component
  55605. */
  55606. readonly alpha: NodeMaterialConnectionPoint;
  55607. protected _buildBlock(state: NodeMaterialBuildState): this;
  55608. protected _dumpPropertiesCode(): string;
  55609. serialize(): any;
  55610. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55611. }
  55612. }
  55613. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  55614. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55615. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55616. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55617. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55618. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55619. import { Effect } from "babylonjs/Materials/effect";
  55620. import { Mesh } from "babylonjs/Meshes/mesh";
  55621. /**
  55622. * Block used to add image processing support to fragment shader
  55623. */
  55624. export class ImageProcessingBlock extends NodeMaterialBlock {
  55625. /**
  55626. * Create a new ImageProcessingBlock
  55627. * @param name defines the block name
  55628. */
  55629. constructor(name: string);
  55630. /**
  55631. * Gets the current class name
  55632. * @returns the class name
  55633. */
  55634. getClassName(): string;
  55635. /**
  55636. * Gets the color input component
  55637. */
  55638. readonly color: NodeMaterialConnectionPoint;
  55639. /**
  55640. * Gets the output component
  55641. */
  55642. readonly output: NodeMaterialConnectionPoint;
  55643. /**
  55644. * Initialize the block and prepare the context for build
  55645. * @param state defines the state that will be used for the build
  55646. */
  55647. initialize(state: NodeMaterialBuildState): void;
  55648. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  55649. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55650. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55651. protected _buildBlock(state: NodeMaterialBuildState): this;
  55652. }
  55653. }
  55654. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  55655. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  55656. export * from "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock";
  55657. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  55658. }
  55659. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  55660. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55661. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55662. import { Mesh } from "babylonjs/Meshes/mesh";
  55663. import { Effect } from "babylonjs/Materials/effect";
  55664. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55665. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55666. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55667. /**
  55668. * Block used to add support for scene fog
  55669. */
  55670. export class FogBlock extends NodeMaterialBlock {
  55671. private _fogDistanceName;
  55672. private _fogParameters;
  55673. /**
  55674. * Create a new FogBlock
  55675. * @param name defines the block name
  55676. */
  55677. constructor(name: string);
  55678. /**
  55679. * Gets the current class name
  55680. * @returns the class name
  55681. */
  55682. getClassName(): string;
  55683. /**
  55684. * Gets the world position input component
  55685. */
  55686. readonly worldPosition: NodeMaterialConnectionPoint;
  55687. /**
  55688. * Gets the view input component
  55689. */
  55690. readonly view: NodeMaterialConnectionPoint;
  55691. /**
  55692. * Gets the color input component
  55693. */
  55694. readonly input: NodeMaterialConnectionPoint;
  55695. /**
  55696. * Gets the fog color input component
  55697. */
  55698. readonly fogColor: NodeMaterialConnectionPoint;
  55699. /**
  55700. * Gets the output component
  55701. */
  55702. readonly output: NodeMaterialConnectionPoint;
  55703. autoConfigure(material: NodeMaterial): void;
  55704. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55705. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55706. protected _buildBlock(state: NodeMaterialBuildState): this;
  55707. }
  55708. }
  55709. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  55710. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55711. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55712. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55713. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55714. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55715. import { Effect } from "babylonjs/Materials/effect";
  55716. import { Mesh } from "babylonjs/Meshes/mesh";
  55717. import { Light } from "babylonjs/Lights/light";
  55718. import { Nullable } from "babylonjs/types";
  55719. import { Scene } from "babylonjs/scene";
  55720. /**
  55721. * Block used to add light in the fragment shader
  55722. */
  55723. export class LightBlock extends NodeMaterialBlock {
  55724. private _lightId;
  55725. /**
  55726. * Gets or sets the light associated with this block
  55727. */
  55728. light: Nullable<Light>;
  55729. /**
  55730. * Create a new LightBlock
  55731. * @param name defines the block name
  55732. */
  55733. constructor(name: string);
  55734. /**
  55735. * Gets the current class name
  55736. * @returns the class name
  55737. */
  55738. getClassName(): string;
  55739. /**
  55740. * Gets the world position input component
  55741. */
  55742. readonly worldPosition: NodeMaterialConnectionPoint;
  55743. /**
  55744. * Gets the world normal input component
  55745. */
  55746. readonly worldNormal: NodeMaterialConnectionPoint;
  55747. /**
  55748. * Gets the camera (or eye) position component
  55749. */
  55750. readonly cameraPosition: NodeMaterialConnectionPoint;
  55751. /**
  55752. * Gets the diffuse output component
  55753. */
  55754. readonly diffuseOutput: NodeMaterialConnectionPoint;
  55755. /**
  55756. * Gets the specular output component
  55757. */
  55758. readonly specularOutput: NodeMaterialConnectionPoint;
  55759. autoConfigure(material: NodeMaterial): void;
  55760. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55761. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55762. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55763. private _injectVertexCode;
  55764. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55765. serialize(): any;
  55766. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55767. }
  55768. }
  55769. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  55770. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  55771. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  55772. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55773. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55774. }
  55775. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  55776. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55777. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  55778. }
  55779. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  55780. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55781. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55782. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55783. /**
  55784. * Block used to multiply 2 values
  55785. */
  55786. export class MultiplyBlock extends NodeMaterialBlock {
  55787. /**
  55788. * Creates a new MultiplyBlock
  55789. * @param name defines the block name
  55790. */
  55791. constructor(name: string);
  55792. /**
  55793. * Gets the current class name
  55794. * @returns the class name
  55795. */
  55796. getClassName(): string;
  55797. /**
  55798. * Gets the left operand input component
  55799. */
  55800. readonly left: NodeMaterialConnectionPoint;
  55801. /**
  55802. * Gets the right operand input component
  55803. */
  55804. readonly right: NodeMaterialConnectionPoint;
  55805. /**
  55806. * Gets the output component
  55807. */
  55808. readonly output: NodeMaterialConnectionPoint;
  55809. protected _buildBlock(state: NodeMaterialBuildState): this;
  55810. }
  55811. }
  55812. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  55813. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55814. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55815. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55816. /**
  55817. * Block used to add 2 vectors
  55818. */
  55819. export class AddBlock extends NodeMaterialBlock {
  55820. /**
  55821. * Creates a new AddBlock
  55822. * @param name defines the block name
  55823. */
  55824. constructor(name: string);
  55825. /**
  55826. * Gets the current class name
  55827. * @returns the class name
  55828. */
  55829. getClassName(): string;
  55830. /**
  55831. * Gets the left operand input component
  55832. */
  55833. readonly left: NodeMaterialConnectionPoint;
  55834. /**
  55835. * Gets the right operand input component
  55836. */
  55837. readonly right: NodeMaterialConnectionPoint;
  55838. /**
  55839. * Gets the output component
  55840. */
  55841. readonly output: NodeMaterialConnectionPoint;
  55842. protected _buildBlock(state: NodeMaterialBuildState): this;
  55843. }
  55844. }
  55845. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  55846. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55847. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55848. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55849. /**
  55850. * Block used to scale a vector by a float
  55851. */
  55852. export class ScaleBlock extends NodeMaterialBlock {
  55853. /**
  55854. * Creates a new ScaleBlock
  55855. * @param name defines the block name
  55856. */
  55857. constructor(name: string);
  55858. /**
  55859. * Gets the current class name
  55860. * @returns the class name
  55861. */
  55862. getClassName(): string;
  55863. /**
  55864. * Gets the input component
  55865. */
  55866. readonly input: NodeMaterialConnectionPoint;
  55867. /**
  55868. * Gets the factor input component
  55869. */
  55870. readonly factor: NodeMaterialConnectionPoint;
  55871. /**
  55872. * Gets the output component
  55873. */
  55874. readonly output: NodeMaterialConnectionPoint;
  55875. protected _buildBlock(state: NodeMaterialBuildState): this;
  55876. }
  55877. }
  55878. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  55879. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55880. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55881. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55882. import { Scene } from "babylonjs/scene";
  55883. /**
  55884. * Block used to clamp a float
  55885. */
  55886. export class ClampBlock extends NodeMaterialBlock {
  55887. /** Gets or sets the minimum range */
  55888. minimum: number;
  55889. /** Gets or sets the maximum range */
  55890. maximum: number;
  55891. /**
  55892. * Creates a new ClampBlock
  55893. * @param name defines the block name
  55894. */
  55895. constructor(name: string);
  55896. /**
  55897. * Gets the current class name
  55898. * @returns the class name
  55899. */
  55900. getClassName(): string;
  55901. /**
  55902. * Gets the value input component
  55903. */
  55904. readonly value: NodeMaterialConnectionPoint;
  55905. /**
  55906. * Gets the output component
  55907. */
  55908. readonly output: NodeMaterialConnectionPoint;
  55909. protected _buildBlock(state: NodeMaterialBuildState): this;
  55910. protected _dumpPropertiesCode(): string;
  55911. serialize(): any;
  55912. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55913. }
  55914. }
  55915. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  55916. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55917. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55918. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55919. /**
  55920. * Block used to apply a cross product between 2 vectors
  55921. */
  55922. export class CrossBlock extends NodeMaterialBlock {
  55923. /**
  55924. * Creates a new CrossBlock
  55925. * @param name defines the block name
  55926. */
  55927. constructor(name: string);
  55928. /**
  55929. * Gets the current class name
  55930. * @returns the class name
  55931. */
  55932. getClassName(): string;
  55933. /**
  55934. * Gets the left operand input component
  55935. */
  55936. readonly left: NodeMaterialConnectionPoint;
  55937. /**
  55938. * Gets the right operand input component
  55939. */
  55940. readonly right: NodeMaterialConnectionPoint;
  55941. /**
  55942. * Gets the output component
  55943. */
  55944. readonly output: NodeMaterialConnectionPoint;
  55945. protected _buildBlock(state: NodeMaterialBuildState): this;
  55946. }
  55947. }
  55948. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  55949. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55950. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55951. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55952. /**
  55953. * Block used to apply a dot product between 2 vectors
  55954. */
  55955. export class DotBlock extends NodeMaterialBlock {
  55956. /**
  55957. * Creates a new DotBlock
  55958. * @param name defines the block name
  55959. */
  55960. constructor(name: string);
  55961. /**
  55962. * Gets the current class name
  55963. * @returns the class name
  55964. */
  55965. getClassName(): string;
  55966. /**
  55967. * Gets the left operand input component
  55968. */
  55969. readonly left: NodeMaterialConnectionPoint;
  55970. /**
  55971. * Gets the right operand input component
  55972. */
  55973. readonly right: NodeMaterialConnectionPoint;
  55974. /**
  55975. * Gets the output component
  55976. */
  55977. readonly output: NodeMaterialConnectionPoint;
  55978. protected _buildBlock(state: NodeMaterialBuildState): this;
  55979. }
  55980. }
  55981. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  55982. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55983. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55984. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55985. import { Vector2 } from "babylonjs/Maths/math.vector";
  55986. import { Scene } from "babylonjs/scene";
  55987. /**
  55988. * Block used to remap a float from a range to a new one
  55989. */
  55990. export class RemapBlock extends NodeMaterialBlock {
  55991. /**
  55992. * Gets or sets the source range
  55993. */
  55994. sourceRange: Vector2;
  55995. /**
  55996. * Gets or sets the target range
  55997. */
  55998. targetRange: Vector2;
  55999. /**
  56000. * Creates a new RemapBlock
  56001. * @param name defines the block name
  56002. */
  56003. constructor(name: string);
  56004. /**
  56005. * Gets the current class name
  56006. * @returns the class name
  56007. */
  56008. getClassName(): string;
  56009. /**
  56010. * Gets the input component
  56011. */
  56012. readonly input: NodeMaterialConnectionPoint;
  56013. /**
  56014. * Gets the output component
  56015. */
  56016. readonly output: NodeMaterialConnectionPoint;
  56017. protected _buildBlock(state: NodeMaterialBuildState): this;
  56018. protected _dumpPropertiesCode(): string;
  56019. serialize(): any;
  56020. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56021. }
  56022. }
  56023. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  56024. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56025. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56026. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56027. /**
  56028. * Block used to normalize a vector
  56029. */
  56030. export class NormalizeBlock extends NodeMaterialBlock {
  56031. /**
  56032. * Creates a new NormalizeBlock
  56033. * @param name defines the block name
  56034. */
  56035. constructor(name: string);
  56036. /**
  56037. * Gets the current class name
  56038. * @returns the class name
  56039. */
  56040. getClassName(): string;
  56041. /**
  56042. * Gets the input component
  56043. */
  56044. readonly input: NodeMaterialConnectionPoint;
  56045. /**
  56046. * Gets the output component
  56047. */
  56048. readonly output: NodeMaterialConnectionPoint;
  56049. protected _buildBlock(state: NodeMaterialBuildState): this;
  56050. }
  56051. }
  56052. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  56053. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56054. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56055. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56056. /**
  56057. * Operations supported by the Trigonometry block
  56058. */
  56059. export enum TrigonometryBlockOperations {
  56060. /** Cos */
  56061. Cos = 0,
  56062. /** Sin */
  56063. Sin = 1,
  56064. /** Abs */
  56065. Abs = 2,
  56066. /** Exp */
  56067. Exp = 3,
  56068. /** Exp2 */
  56069. Exp2 = 4,
  56070. /** Round */
  56071. Round = 5,
  56072. /** Floor */
  56073. Floor = 6,
  56074. /** Ceiling */
  56075. Ceiling = 7
  56076. }
  56077. /**
  56078. * Block used to apply trigonometry operation to floats
  56079. */
  56080. export class TrigonometryBlock extends NodeMaterialBlock {
  56081. /**
  56082. * Gets or sets the operation applied by the block
  56083. */
  56084. operation: TrigonometryBlockOperations;
  56085. /**
  56086. * Creates a new TrigonometryBlock
  56087. * @param name defines the block name
  56088. */
  56089. constructor(name: string);
  56090. /**
  56091. * Gets the current class name
  56092. * @returns the class name
  56093. */
  56094. getClassName(): string;
  56095. /**
  56096. * Gets the input component
  56097. */
  56098. readonly input: NodeMaterialConnectionPoint;
  56099. /**
  56100. * Gets the output component
  56101. */
  56102. readonly output: NodeMaterialConnectionPoint;
  56103. protected _buildBlock(state: NodeMaterialBuildState): this;
  56104. }
  56105. }
  56106. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  56107. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56108. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56109. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56110. /**
  56111. * Block used to create a Color3/4 out of individual inputs (one for each component)
  56112. */
  56113. export class ColorMergerBlock extends NodeMaterialBlock {
  56114. /**
  56115. * Create a new ColorMergerBlock
  56116. * @param name defines the block name
  56117. */
  56118. constructor(name: string);
  56119. /**
  56120. * Gets the current class name
  56121. * @returns the class name
  56122. */
  56123. getClassName(): string;
  56124. /**
  56125. * Gets the r component (input)
  56126. */
  56127. readonly r: NodeMaterialConnectionPoint;
  56128. /**
  56129. * Gets the g component (input)
  56130. */
  56131. readonly g: NodeMaterialConnectionPoint;
  56132. /**
  56133. * Gets the b component (input)
  56134. */
  56135. readonly b: NodeMaterialConnectionPoint;
  56136. /**
  56137. * Gets the a component (input)
  56138. */
  56139. readonly a: NodeMaterialConnectionPoint;
  56140. /**
  56141. * Gets the rgba component (output)
  56142. */
  56143. readonly rgba: NodeMaterialConnectionPoint;
  56144. /**
  56145. * Gets the rgb component (output)
  56146. */
  56147. readonly rgb: NodeMaterialConnectionPoint;
  56148. protected _buildBlock(state: NodeMaterialBuildState): this;
  56149. }
  56150. }
  56151. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  56152. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56153. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56154. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56155. /**
  56156. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  56157. */
  56158. export class VectorMergerBlock extends NodeMaterialBlock {
  56159. /**
  56160. * Create a new VectorMergerBlock
  56161. * @param name defines the block name
  56162. */
  56163. constructor(name: string);
  56164. /**
  56165. * Gets the current class name
  56166. * @returns the class name
  56167. */
  56168. getClassName(): string;
  56169. /**
  56170. * Gets the x component (input)
  56171. */
  56172. readonly x: NodeMaterialConnectionPoint;
  56173. /**
  56174. * Gets the y component (input)
  56175. */
  56176. readonly y: NodeMaterialConnectionPoint;
  56177. /**
  56178. * Gets the z component (input)
  56179. */
  56180. readonly z: NodeMaterialConnectionPoint;
  56181. /**
  56182. * Gets the w component (input)
  56183. */
  56184. readonly w: NodeMaterialConnectionPoint;
  56185. /**
  56186. * Gets the xyzw component (output)
  56187. */
  56188. readonly xyzw: NodeMaterialConnectionPoint;
  56189. /**
  56190. * Gets the xyz component (output)
  56191. */
  56192. readonly xyz: NodeMaterialConnectionPoint;
  56193. /**
  56194. * Gets the xy component (output)
  56195. */
  56196. readonly xy: NodeMaterialConnectionPoint;
  56197. protected _buildBlock(state: NodeMaterialBuildState): this;
  56198. }
  56199. }
  56200. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  56201. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56202. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56203. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56204. /**
  56205. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  56206. */
  56207. export class ColorSplitterBlock extends NodeMaterialBlock {
  56208. /**
  56209. * Create a new ColorSplitterBlock
  56210. * @param name defines the block name
  56211. */
  56212. constructor(name: string);
  56213. /**
  56214. * Gets the current class name
  56215. * @returns the class name
  56216. */
  56217. getClassName(): string;
  56218. /**
  56219. * Gets the rgba component (input)
  56220. */
  56221. readonly rgba: NodeMaterialConnectionPoint;
  56222. /**
  56223. * Gets the rgb component (input)
  56224. */
  56225. readonly rgbIn: NodeMaterialConnectionPoint;
  56226. /**
  56227. * Gets the rgb component (output)
  56228. */
  56229. readonly rgbOut: NodeMaterialConnectionPoint;
  56230. /**
  56231. * Gets the r component (output)
  56232. */
  56233. readonly r: NodeMaterialConnectionPoint;
  56234. /**
  56235. * Gets the g component (output)
  56236. */
  56237. readonly g: NodeMaterialConnectionPoint;
  56238. /**
  56239. * Gets the b component (output)
  56240. */
  56241. readonly b: NodeMaterialConnectionPoint;
  56242. /**
  56243. * Gets the a component (output)
  56244. */
  56245. readonly a: NodeMaterialConnectionPoint;
  56246. protected _inputRename(name: string): string;
  56247. protected _outputRename(name: string): string;
  56248. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56249. }
  56250. }
  56251. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  56252. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56253. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56254. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56255. /**
  56256. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  56257. */
  56258. export class VectorSplitterBlock extends NodeMaterialBlock {
  56259. /**
  56260. * Create a new VectorSplitterBlock
  56261. * @param name defines the block name
  56262. */
  56263. constructor(name: string);
  56264. /**
  56265. * Gets the current class name
  56266. * @returns the class name
  56267. */
  56268. getClassName(): string;
  56269. /**
  56270. * Gets the xyzw component (input)
  56271. */
  56272. readonly xyzw: NodeMaterialConnectionPoint;
  56273. /**
  56274. * Gets the xyz component (input)
  56275. */
  56276. readonly xyzIn: NodeMaterialConnectionPoint;
  56277. /**
  56278. * Gets the xy component (input)
  56279. */
  56280. readonly xyIn: NodeMaterialConnectionPoint;
  56281. /**
  56282. * Gets the xyz component (output)
  56283. */
  56284. readonly xyzOut: NodeMaterialConnectionPoint;
  56285. /**
  56286. * Gets the xy component (output)
  56287. */
  56288. readonly xyOut: NodeMaterialConnectionPoint;
  56289. /**
  56290. * Gets the x component (output)
  56291. */
  56292. readonly x: NodeMaterialConnectionPoint;
  56293. /**
  56294. * Gets the y component (output)
  56295. */
  56296. readonly y: NodeMaterialConnectionPoint;
  56297. /**
  56298. * Gets the z component (output)
  56299. */
  56300. readonly z: NodeMaterialConnectionPoint;
  56301. /**
  56302. * Gets the w component (output)
  56303. */
  56304. readonly w: NodeMaterialConnectionPoint;
  56305. protected _inputRename(name: string): string;
  56306. protected _outputRename(name: string): string;
  56307. protected _buildBlock(state: NodeMaterialBuildState): this;
  56308. }
  56309. }
  56310. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  56311. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56312. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56313. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56314. /**
  56315. * Block used to lerp 2 values
  56316. */
  56317. export class LerpBlock extends NodeMaterialBlock {
  56318. /**
  56319. * Creates a new LerpBlock
  56320. * @param name defines the block name
  56321. */
  56322. constructor(name: string);
  56323. /**
  56324. * Gets the current class name
  56325. * @returns the class name
  56326. */
  56327. getClassName(): string;
  56328. /**
  56329. * Gets the left operand input component
  56330. */
  56331. readonly left: NodeMaterialConnectionPoint;
  56332. /**
  56333. * Gets the right operand input component
  56334. */
  56335. readonly right: NodeMaterialConnectionPoint;
  56336. /**
  56337. * Gets the gradient operand input component
  56338. */
  56339. readonly gradient: NodeMaterialConnectionPoint;
  56340. /**
  56341. * Gets the output component
  56342. */
  56343. readonly output: NodeMaterialConnectionPoint;
  56344. protected _buildBlock(state: NodeMaterialBuildState): this;
  56345. }
  56346. }
  56347. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  56348. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56349. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56350. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56351. /**
  56352. * Block used to divide 2 vectors
  56353. */
  56354. export class DivideBlock extends NodeMaterialBlock {
  56355. /**
  56356. * Creates a new DivideBlock
  56357. * @param name defines the block name
  56358. */
  56359. constructor(name: string);
  56360. /**
  56361. * Gets the current class name
  56362. * @returns the class name
  56363. */
  56364. getClassName(): string;
  56365. /**
  56366. * Gets the left operand input component
  56367. */
  56368. readonly left: NodeMaterialConnectionPoint;
  56369. /**
  56370. * Gets the right operand input component
  56371. */
  56372. readonly right: NodeMaterialConnectionPoint;
  56373. /**
  56374. * Gets the output component
  56375. */
  56376. readonly output: NodeMaterialConnectionPoint;
  56377. protected _buildBlock(state: NodeMaterialBuildState): this;
  56378. }
  56379. }
  56380. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  56381. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56382. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56383. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56384. /**
  56385. * Block used to subtract 2 vectors
  56386. */
  56387. export class SubtractBlock extends NodeMaterialBlock {
  56388. /**
  56389. * Creates a new SubtractBlock
  56390. * @param name defines the block name
  56391. */
  56392. constructor(name: string);
  56393. /**
  56394. * Gets the current class name
  56395. * @returns the class name
  56396. */
  56397. getClassName(): string;
  56398. /**
  56399. * Gets the left operand input component
  56400. */
  56401. readonly left: NodeMaterialConnectionPoint;
  56402. /**
  56403. * Gets the right operand input component
  56404. */
  56405. readonly right: NodeMaterialConnectionPoint;
  56406. /**
  56407. * Gets the output component
  56408. */
  56409. readonly output: NodeMaterialConnectionPoint;
  56410. protected _buildBlock(state: NodeMaterialBuildState): this;
  56411. }
  56412. }
  56413. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  56414. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56415. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56416. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56417. /**
  56418. * Block used to step a value
  56419. */
  56420. export class StepBlock extends NodeMaterialBlock {
  56421. /**
  56422. * Creates a new AddBlock
  56423. * @param name defines the block name
  56424. */
  56425. constructor(name: string);
  56426. /**
  56427. * Gets the current class name
  56428. * @returns the class name
  56429. */
  56430. getClassName(): string;
  56431. /**
  56432. * Gets the value operand input component
  56433. */
  56434. readonly value: NodeMaterialConnectionPoint;
  56435. /**
  56436. * Gets the edge operand input component
  56437. */
  56438. readonly edge: NodeMaterialConnectionPoint;
  56439. /**
  56440. * Gets the output component
  56441. */
  56442. readonly output: NodeMaterialConnectionPoint;
  56443. protected _buildBlock(state: NodeMaterialBuildState): this;
  56444. }
  56445. }
  56446. declare module "babylonjs/Materials/Node/Blocks/oppositeBlock" {
  56447. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56448. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56449. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56450. /**
  56451. * Block used to get the opposite of a value
  56452. */
  56453. export class OppositeBlock extends NodeMaterialBlock {
  56454. /**
  56455. * Creates a new OppositeBlock
  56456. * @param name defines the block name
  56457. */
  56458. constructor(name: string);
  56459. /**
  56460. * Gets the current class name
  56461. * @returns the class name
  56462. */
  56463. getClassName(): string;
  56464. /**
  56465. * Gets the input component
  56466. */
  56467. readonly input: NodeMaterialConnectionPoint;
  56468. /**
  56469. * Gets the output component
  56470. */
  56471. readonly output: NodeMaterialConnectionPoint;
  56472. protected _buildBlock(state: NodeMaterialBuildState): this;
  56473. }
  56474. }
  56475. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  56476. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56477. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56478. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56479. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  56480. /**
  56481. * Block used to get the view direction
  56482. */
  56483. export class ViewDirectionBlock extends NodeMaterialBlock {
  56484. /**
  56485. * Creates a new ViewDirectionBlock
  56486. * @param name defines the block name
  56487. */
  56488. constructor(name: string);
  56489. /**
  56490. * Gets the current class name
  56491. * @returns the class name
  56492. */
  56493. getClassName(): string;
  56494. /**
  56495. * Gets the world position component
  56496. */
  56497. readonly worldPosition: NodeMaterialConnectionPoint;
  56498. /**
  56499. * Gets the camera position component
  56500. */
  56501. readonly cameraPosition: NodeMaterialConnectionPoint;
  56502. /**
  56503. * Gets the output component
  56504. */
  56505. readonly output: NodeMaterialConnectionPoint;
  56506. autoConfigure(material: NodeMaterial): void;
  56507. protected _buildBlock(state: NodeMaterialBuildState): this;
  56508. }
  56509. }
  56510. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  56511. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56512. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56513. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56514. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  56515. /**
  56516. * Block used to compute fresnel value
  56517. */
  56518. export class FresnelBlock extends NodeMaterialBlock {
  56519. /**
  56520. * Create a new FresnelBlock
  56521. * @param name defines the block name
  56522. */
  56523. constructor(name: string);
  56524. /**
  56525. * Gets the current class name
  56526. * @returns the class name
  56527. */
  56528. getClassName(): string;
  56529. /**
  56530. * Gets the world normal input component
  56531. */
  56532. readonly worldNormal: NodeMaterialConnectionPoint;
  56533. /**
  56534. * Gets the view direction input component
  56535. */
  56536. readonly viewDirection: NodeMaterialConnectionPoint;
  56537. /**
  56538. * Gets the bias input component
  56539. */
  56540. readonly bias: NodeMaterialConnectionPoint;
  56541. /**
  56542. * Gets the camera (or eye) position component
  56543. */
  56544. readonly power: NodeMaterialConnectionPoint;
  56545. /**
  56546. * Gets the fresnel output component
  56547. */
  56548. readonly fresnel: NodeMaterialConnectionPoint;
  56549. autoConfigure(material: NodeMaterial): void;
  56550. protected _buildBlock(state: NodeMaterialBuildState): this;
  56551. }
  56552. }
  56553. declare module "babylonjs/Materials/Node/Blocks/index" {
  56554. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  56555. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  56556. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  56557. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  56558. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  56559. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  56560. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  56561. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  56562. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  56563. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  56564. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  56565. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  56566. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  56567. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  56568. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  56569. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  56570. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  56571. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  56572. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  56573. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  56574. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  56575. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  56576. export * from "babylonjs/Materials/Node/Blocks/oppositeBlock";
  56577. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  56578. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  56579. }
  56580. declare module "babylonjs/Materials/Node/Optimizers/index" {
  56581. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  56582. }
  56583. declare module "babylonjs/Materials/Node/index" {
  56584. export * from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  56585. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  56586. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56587. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  56588. export * from "babylonjs/Materials/Node/nodeMaterial";
  56589. export * from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  56590. export * from "babylonjs/Materials/Node/Blocks/index";
  56591. export * from "babylonjs/Materials/Node/Optimizers/index";
  56592. }
  56593. declare module "babylonjs/Materials/effectRenderer" {
  56594. import { Nullable } from "babylonjs/types";
  56595. import { Texture } from "babylonjs/Materials/Textures/texture";
  56596. import { Engine } from "babylonjs/Engines/engine";
  56597. import { Viewport } from "babylonjs/Maths/math.viewport";
  56598. import { Observable } from "babylonjs/Misc/observable";
  56599. import { Effect } from "babylonjs/Materials/effect";
  56600. import "babylonjs/Shaders/postprocess.vertex";
  56601. /**
  56602. * Effect Render Options
  56603. */
  56604. export interface IEffectRendererOptions {
  56605. /**
  56606. * Defines the vertices positions.
  56607. */
  56608. positions?: number[];
  56609. /**
  56610. * Defines the indices.
  56611. */
  56612. indices?: number[];
  56613. }
  56614. /**
  56615. * Helper class to render one or more effects
  56616. */
  56617. export class EffectRenderer {
  56618. private engine;
  56619. private static _DefaultOptions;
  56620. private _vertexBuffers;
  56621. private _indexBuffer;
  56622. private _ringBufferIndex;
  56623. private _ringScreenBuffer;
  56624. private _fullscreenViewport;
  56625. private _getNextFrameBuffer;
  56626. /**
  56627. * Creates an effect renderer
  56628. * @param engine the engine to use for rendering
  56629. * @param options defines the options of the effect renderer
  56630. */
  56631. constructor(engine: Engine, options?: IEffectRendererOptions);
  56632. /**
  56633. * Sets the current viewport in normalized coordinates 0-1
  56634. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  56635. */
  56636. setViewport(viewport?: Viewport): void;
  56637. /**
  56638. * Sets the current effect wrapper to use during draw.
  56639. * The effect needs to be ready before calling this api.
  56640. * This also sets the default full screen position attribute.
  56641. * @param effectWrapper Defines the effect to draw with
  56642. */
  56643. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  56644. /**
  56645. * Draws a full screen quad.
  56646. */
  56647. draw(): void;
  56648. /**
  56649. * renders one or more effects to a specified texture
  56650. * @param effectWrappers list of effects to renderer
  56651. * @param outputTexture texture to draw to, if null it will render to the screen
  56652. */
  56653. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  56654. /**
  56655. * Disposes of the effect renderer
  56656. */
  56657. dispose(): void;
  56658. }
  56659. /**
  56660. * Options to create an EffectWrapper
  56661. */
  56662. interface EffectWrapperCreationOptions {
  56663. /**
  56664. * Engine to use to create the effect
  56665. */
  56666. engine: Engine;
  56667. /**
  56668. * Fragment shader for the effect
  56669. */
  56670. fragmentShader: string;
  56671. /**
  56672. * Vertex shader for the effect
  56673. */
  56674. vertexShader?: string;
  56675. /**
  56676. * Attributes to use in the shader
  56677. */
  56678. attributeNames?: Array<string>;
  56679. /**
  56680. * Uniforms to use in the shader
  56681. */
  56682. uniformNames?: Array<string>;
  56683. /**
  56684. * Texture sampler names to use in the shader
  56685. */
  56686. samplerNames?: Array<string>;
  56687. /**
  56688. * The friendly name of the effect displayed in Spector.
  56689. */
  56690. name?: string;
  56691. }
  56692. /**
  56693. * Wraps an effect to be used for rendering
  56694. */
  56695. export class EffectWrapper {
  56696. /**
  56697. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  56698. */
  56699. onApplyObservable: Observable<{}>;
  56700. /**
  56701. * The underlying effect
  56702. */
  56703. effect: Effect;
  56704. /**
  56705. * Creates an effect to be renderer
  56706. * @param creationOptions options to create the effect
  56707. */
  56708. constructor(creationOptions: EffectWrapperCreationOptions);
  56709. /**
  56710. * Disposes of the effect wrapper
  56711. */
  56712. dispose(): void;
  56713. }
  56714. }
  56715. declare module "babylonjs/Materials/index" {
  56716. export * from "babylonjs/Materials/Background/index";
  56717. export * from "babylonjs/Materials/colorCurves";
  56718. export * from "babylonjs/Materials/effect";
  56719. export * from "babylonjs/Materials/fresnelParameters";
  56720. export * from "babylonjs/Materials/imageProcessingConfiguration";
  56721. export * from "babylonjs/Materials/material";
  56722. export * from "babylonjs/Materials/materialDefines";
  56723. export * from "babylonjs/Materials/materialHelper";
  56724. export * from "babylonjs/Materials/multiMaterial";
  56725. export * from "babylonjs/Materials/PBR/index";
  56726. export * from "babylonjs/Materials/pushMaterial";
  56727. export * from "babylonjs/Materials/shaderMaterial";
  56728. export * from "babylonjs/Materials/standardMaterial";
  56729. export * from "babylonjs/Materials/Textures/index";
  56730. export * from "babylonjs/Materials/uniformBuffer";
  56731. export * from "babylonjs/Materials/materialFlags";
  56732. export * from "babylonjs/Materials/Node/index";
  56733. export * from "babylonjs/Materials/effectRenderer";
  56734. }
  56735. declare module "babylonjs/Maths/index" {
  56736. export * from "babylonjs/Maths/math.scalar";
  56737. export * from "babylonjs/Maths/math";
  56738. export * from "babylonjs/Maths/sphericalPolynomial";
  56739. }
  56740. declare module "babylonjs/Misc/workerPool" {
  56741. import { IDisposable } from "babylonjs/scene";
  56742. /**
  56743. * Helper class to push actions to a pool of workers.
  56744. */
  56745. export class WorkerPool implements IDisposable {
  56746. private _workerInfos;
  56747. private _pendingActions;
  56748. /**
  56749. * Constructor
  56750. * @param workers Array of workers to use for actions
  56751. */
  56752. constructor(workers: Array<Worker>);
  56753. /**
  56754. * Terminates all workers and clears any pending actions.
  56755. */
  56756. dispose(): void;
  56757. /**
  56758. * Pushes an action to the worker pool. If all the workers are active, the action will be
  56759. * pended until a worker has completed its action.
  56760. * @param action The action to perform. Call onComplete when the action is complete.
  56761. */
  56762. push(action: (worker: Worker, onComplete: () => void) => void): void;
  56763. private _execute;
  56764. }
  56765. }
  56766. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  56767. import { IDisposable } from "babylonjs/scene";
  56768. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  56769. /**
  56770. * Configuration for Draco compression
  56771. */
  56772. export interface IDracoCompressionConfiguration {
  56773. /**
  56774. * Configuration for the decoder.
  56775. */
  56776. decoder: {
  56777. /**
  56778. * The url to the WebAssembly module.
  56779. */
  56780. wasmUrl?: string;
  56781. /**
  56782. * The url to the WebAssembly binary.
  56783. */
  56784. wasmBinaryUrl?: string;
  56785. /**
  56786. * The url to the fallback JavaScript module.
  56787. */
  56788. fallbackUrl?: string;
  56789. };
  56790. }
  56791. /**
  56792. * Draco compression (https://google.github.io/draco/)
  56793. *
  56794. * This class wraps the Draco module.
  56795. *
  56796. * **Encoder**
  56797. *
  56798. * The encoder is not currently implemented.
  56799. *
  56800. * **Decoder**
  56801. *
  56802. * 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.
  56803. *
  56804. * To update the configuration, use the following code:
  56805. * ```javascript
  56806. * DracoCompression.Configuration = {
  56807. * decoder: {
  56808. * wasmUrl: "<url to the WebAssembly library>",
  56809. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  56810. * fallbackUrl: "<url to the fallback JavaScript library>",
  56811. * }
  56812. * };
  56813. * ```
  56814. *
  56815. * 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.
  56816. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  56817. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  56818. *
  56819. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  56820. * ```javascript
  56821. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  56822. * ```
  56823. *
  56824. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  56825. */
  56826. export class DracoCompression implements IDisposable {
  56827. private _workerPoolPromise?;
  56828. private _decoderModulePromise?;
  56829. /**
  56830. * The configuration. Defaults to the following urls:
  56831. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  56832. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  56833. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  56834. */
  56835. static Configuration: IDracoCompressionConfiguration;
  56836. /**
  56837. * Returns true if the decoder configuration is available.
  56838. */
  56839. static readonly DecoderAvailable: boolean;
  56840. /**
  56841. * Default number of workers to create when creating the draco compression object.
  56842. */
  56843. static DefaultNumWorkers: number;
  56844. private static GetDefaultNumWorkers;
  56845. private static _Default;
  56846. /**
  56847. * Default instance for the draco compression object.
  56848. */
  56849. static readonly Default: DracoCompression;
  56850. /**
  56851. * Constructor
  56852. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  56853. */
  56854. constructor(numWorkers?: number);
  56855. /**
  56856. * Stop all async operations and release resources.
  56857. */
  56858. dispose(): void;
  56859. /**
  56860. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  56861. * @returns a promise that resolves when ready
  56862. */
  56863. whenReadyAsync(): Promise<void>;
  56864. /**
  56865. * Decode Draco compressed mesh data to vertex data.
  56866. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  56867. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  56868. * @returns A promise that resolves with the decoded vertex data
  56869. */
  56870. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  56871. [kind: string]: number;
  56872. }): Promise<VertexData>;
  56873. }
  56874. }
  56875. declare module "babylonjs/Meshes/Compression/index" {
  56876. export * from "babylonjs/Meshes/Compression/dracoCompression";
  56877. }
  56878. declare module "babylonjs/Meshes/csg" {
  56879. import { Nullable } from "babylonjs/types";
  56880. import { Scene } from "babylonjs/scene";
  56881. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56882. import { Mesh } from "babylonjs/Meshes/mesh";
  56883. import { Material } from "babylonjs/Materials/material";
  56884. /**
  56885. * Class for building Constructive Solid Geometry
  56886. */
  56887. export class CSG {
  56888. private polygons;
  56889. /**
  56890. * The world matrix
  56891. */
  56892. matrix: Matrix;
  56893. /**
  56894. * Stores the position
  56895. */
  56896. position: Vector3;
  56897. /**
  56898. * Stores the rotation
  56899. */
  56900. rotation: Vector3;
  56901. /**
  56902. * Stores the rotation quaternion
  56903. */
  56904. rotationQuaternion: Nullable<Quaternion>;
  56905. /**
  56906. * Stores the scaling vector
  56907. */
  56908. scaling: Vector3;
  56909. /**
  56910. * Convert the Mesh to CSG
  56911. * @param mesh The Mesh to convert to CSG
  56912. * @returns A new CSG from the Mesh
  56913. */
  56914. static FromMesh(mesh: Mesh): CSG;
  56915. /**
  56916. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  56917. * @param polygons Polygons used to construct a CSG solid
  56918. */
  56919. private static FromPolygons;
  56920. /**
  56921. * Clones, or makes a deep copy, of the CSG
  56922. * @returns A new CSG
  56923. */
  56924. clone(): CSG;
  56925. /**
  56926. * Unions this CSG with another CSG
  56927. * @param csg The CSG to union against this CSG
  56928. * @returns The unioned CSG
  56929. */
  56930. union(csg: CSG): CSG;
  56931. /**
  56932. * Unions this CSG with another CSG in place
  56933. * @param csg The CSG to union against this CSG
  56934. */
  56935. unionInPlace(csg: CSG): void;
  56936. /**
  56937. * Subtracts this CSG with another CSG
  56938. * @param csg The CSG to subtract against this CSG
  56939. * @returns A new CSG
  56940. */
  56941. subtract(csg: CSG): CSG;
  56942. /**
  56943. * Subtracts this CSG with another CSG in place
  56944. * @param csg The CSG to subtact against this CSG
  56945. */
  56946. subtractInPlace(csg: CSG): void;
  56947. /**
  56948. * Intersect this CSG with another CSG
  56949. * @param csg The CSG to intersect against this CSG
  56950. * @returns A new CSG
  56951. */
  56952. intersect(csg: CSG): CSG;
  56953. /**
  56954. * Intersects this CSG with another CSG in place
  56955. * @param csg The CSG to intersect against this CSG
  56956. */
  56957. intersectInPlace(csg: CSG): void;
  56958. /**
  56959. * Return a new CSG solid with solid and empty space switched. This solid is
  56960. * not modified.
  56961. * @returns A new CSG solid with solid and empty space switched
  56962. */
  56963. inverse(): CSG;
  56964. /**
  56965. * Inverses the CSG in place
  56966. */
  56967. inverseInPlace(): void;
  56968. /**
  56969. * This is used to keep meshes transformations so they can be restored
  56970. * when we build back a Babylon Mesh
  56971. * NB : All CSG operations are performed in world coordinates
  56972. * @param csg The CSG to copy the transform attributes from
  56973. * @returns This CSG
  56974. */
  56975. copyTransformAttributes(csg: CSG): CSG;
  56976. /**
  56977. * Build Raw mesh from CSG
  56978. * Coordinates here are in world space
  56979. * @param name The name of the mesh geometry
  56980. * @param scene The Scene
  56981. * @param keepSubMeshes Specifies if the submeshes should be kept
  56982. * @returns A new Mesh
  56983. */
  56984. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  56985. /**
  56986. * Build Mesh from CSG taking material and transforms into account
  56987. * @param name The name of the Mesh
  56988. * @param material The material of the Mesh
  56989. * @param scene The Scene
  56990. * @param keepSubMeshes Specifies if submeshes should be kept
  56991. * @returns The new Mesh
  56992. */
  56993. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  56994. }
  56995. }
  56996. declare module "babylonjs/Meshes/trailMesh" {
  56997. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56998. import { Mesh } from "babylonjs/Meshes/mesh";
  56999. import { Scene } from "babylonjs/scene";
  57000. /**
  57001. * Class used to create a trail following a mesh
  57002. */
  57003. export class TrailMesh extends Mesh {
  57004. private _generator;
  57005. private _autoStart;
  57006. private _running;
  57007. private _diameter;
  57008. private _length;
  57009. private _sectionPolygonPointsCount;
  57010. private _sectionVectors;
  57011. private _sectionNormalVectors;
  57012. private _beforeRenderObserver;
  57013. /**
  57014. * @constructor
  57015. * @param name The value used by scene.getMeshByName() to do a lookup.
  57016. * @param generator The mesh to generate a trail.
  57017. * @param scene The scene to add this mesh to.
  57018. * @param diameter Diameter of trailing mesh. Default is 1.
  57019. * @param length Length of trailing mesh. Default is 60.
  57020. * @param autoStart Automatically start trailing mesh. Default true.
  57021. */
  57022. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  57023. /**
  57024. * "TrailMesh"
  57025. * @returns "TrailMesh"
  57026. */
  57027. getClassName(): string;
  57028. private _createMesh;
  57029. /**
  57030. * Start trailing mesh.
  57031. */
  57032. start(): void;
  57033. /**
  57034. * Stop trailing mesh.
  57035. */
  57036. stop(): void;
  57037. /**
  57038. * Update trailing mesh geometry.
  57039. */
  57040. update(): void;
  57041. /**
  57042. * Returns a new TrailMesh object.
  57043. * @param name is a string, the name given to the new mesh
  57044. * @param newGenerator use new generator object for cloned trail mesh
  57045. * @returns a new mesh
  57046. */
  57047. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  57048. /**
  57049. * Serializes this trail mesh
  57050. * @param serializationObject object to write serialization to
  57051. */
  57052. serialize(serializationObject: any): void;
  57053. /**
  57054. * Parses a serialized trail mesh
  57055. * @param parsedMesh the serialized mesh
  57056. * @param scene the scene to create the trail mesh in
  57057. * @returns the created trail mesh
  57058. */
  57059. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  57060. }
  57061. }
  57062. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  57063. import { Nullable } from "babylonjs/types";
  57064. import { Scene } from "babylonjs/scene";
  57065. import { Vector4 } from "babylonjs/Maths/math.vector";
  57066. import { Color4 } from "babylonjs/Maths/math.color";
  57067. import { Mesh } from "babylonjs/Meshes/mesh";
  57068. /**
  57069. * Class containing static functions to help procedurally build meshes
  57070. */
  57071. export class TiledBoxBuilder {
  57072. /**
  57073. * Creates a box mesh
  57074. * 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)
  57075. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57076. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57077. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57078. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57079. * @param name defines the name of the mesh
  57080. * @param options defines the options used to create the mesh
  57081. * @param scene defines the hosting scene
  57082. * @returns the box mesh
  57083. */
  57084. static CreateTiledBox(name: string, options: {
  57085. pattern?: number;
  57086. width?: number;
  57087. height?: number;
  57088. depth?: number;
  57089. tileSize?: number;
  57090. tileWidth?: number;
  57091. tileHeight?: number;
  57092. alignHorizontal?: number;
  57093. alignVertical?: number;
  57094. faceUV?: Vector4[];
  57095. faceColors?: Color4[];
  57096. sideOrientation?: number;
  57097. updatable?: boolean;
  57098. }, scene?: Nullable<Scene>): Mesh;
  57099. }
  57100. }
  57101. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  57102. import { Vector4 } from "babylonjs/Maths/math.vector";
  57103. import { Mesh } from "babylonjs/Meshes/mesh";
  57104. /**
  57105. * Class containing static functions to help procedurally build meshes
  57106. */
  57107. export class TorusKnotBuilder {
  57108. /**
  57109. * Creates a torus knot mesh
  57110. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  57111. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  57112. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  57113. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  57114. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57115. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57116. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57117. * @param name defines the name of the mesh
  57118. * @param options defines the options used to create the mesh
  57119. * @param scene defines the hosting scene
  57120. * @returns the torus knot mesh
  57121. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  57122. */
  57123. static CreateTorusKnot(name: string, options: {
  57124. radius?: number;
  57125. tube?: number;
  57126. radialSegments?: number;
  57127. tubularSegments?: number;
  57128. p?: number;
  57129. q?: number;
  57130. updatable?: boolean;
  57131. sideOrientation?: number;
  57132. frontUVs?: Vector4;
  57133. backUVs?: Vector4;
  57134. }, scene: any): Mesh;
  57135. }
  57136. }
  57137. declare module "babylonjs/Meshes/polygonMesh" {
  57138. import { Scene } from "babylonjs/scene";
  57139. import { Vector2 } from "babylonjs/Maths/math.vector";
  57140. import { Mesh } from "babylonjs/Meshes/mesh";
  57141. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  57142. import { Path2 } from "babylonjs/Maths/math.path";
  57143. /**
  57144. * Polygon
  57145. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  57146. */
  57147. export class Polygon {
  57148. /**
  57149. * Creates a rectangle
  57150. * @param xmin bottom X coord
  57151. * @param ymin bottom Y coord
  57152. * @param xmax top X coord
  57153. * @param ymax top Y coord
  57154. * @returns points that make the resulting rectation
  57155. */
  57156. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  57157. /**
  57158. * Creates a circle
  57159. * @param radius radius of circle
  57160. * @param cx scale in x
  57161. * @param cy scale in y
  57162. * @param numberOfSides number of sides that make up the circle
  57163. * @returns points that make the resulting circle
  57164. */
  57165. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  57166. /**
  57167. * Creates a polygon from input string
  57168. * @param input Input polygon data
  57169. * @returns the parsed points
  57170. */
  57171. static Parse(input: string): Vector2[];
  57172. /**
  57173. * Starts building a polygon from x and y coordinates
  57174. * @param x x coordinate
  57175. * @param y y coordinate
  57176. * @returns the started path2
  57177. */
  57178. static StartingAt(x: number, y: number): Path2;
  57179. }
  57180. /**
  57181. * Builds a polygon
  57182. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  57183. */
  57184. export class PolygonMeshBuilder {
  57185. private _points;
  57186. private _outlinepoints;
  57187. private _holes;
  57188. private _name;
  57189. private _scene;
  57190. private _epoints;
  57191. private _eholes;
  57192. private _addToepoint;
  57193. /**
  57194. * Babylon reference to the earcut plugin.
  57195. */
  57196. bjsEarcut: any;
  57197. /**
  57198. * Creates a PolygonMeshBuilder
  57199. * @param name name of the builder
  57200. * @param contours Path of the polygon
  57201. * @param scene scene to add to when creating the mesh
  57202. * @param earcutInjection can be used to inject your own earcut reference
  57203. */
  57204. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  57205. /**
  57206. * Adds a whole within the polygon
  57207. * @param hole Array of points defining the hole
  57208. * @returns this
  57209. */
  57210. addHole(hole: Vector2[]): PolygonMeshBuilder;
  57211. /**
  57212. * Creates the polygon
  57213. * @param updatable If the mesh should be updatable
  57214. * @param depth The depth of the mesh created
  57215. * @returns the created mesh
  57216. */
  57217. build(updatable?: boolean, depth?: number): Mesh;
  57218. /**
  57219. * Creates the polygon
  57220. * @param depth The depth of the mesh created
  57221. * @returns the created VertexData
  57222. */
  57223. buildVertexData(depth?: number): VertexData;
  57224. /**
  57225. * Adds a side to the polygon
  57226. * @param positions points that make the polygon
  57227. * @param normals normals of the polygon
  57228. * @param uvs uvs of the polygon
  57229. * @param indices indices of the polygon
  57230. * @param bounds bounds of the polygon
  57231. * @param points points of the polygon
  57232. * @param depth depth of the polygon
  57233. * @param flip flip of the polygon
  57234. */
  57235. private addSide;
  57236. }
  57237. }
  57238. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  57239. import { Scene } from "babylonjs/scene";
  57240. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  57241. import { Color4 } from "babylonjs/Maths/math.color";
  57242. import { Mesh } from "babylonjs/Meshes/mesh";
  57243. import { Nullable } from "babylonjs/types";
  57244. /**
  57245. * Class containing static functions to help procedurally build meshes
  57246. */
  57247. export class PolygonBuilder {
  57248. /**
  57249. * Creates a polygon mesh
  57250. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  57251. * * 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
  57252. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  57253. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57254. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  57255. * * Remember you can only change the shape positions, not their number when updating a polygon
  57256. * @param name defines the name of the mesh
  57257. * @param options defines the options used to create the mesh
  57258. * @param scene defines the hosting scene
  57259. * @param earcutInjection can be used to inject your own earcut reference
  57260. * @returns the polygon mesh
  57261. */
  57262. static CreatePolygon(name: string, options: {
  57263. shape: Vector3[];
  57264. holes?: Vector3[][];
  57265. depth?: number;
  57266. faceUV?: Vector4[];
  57267. faceColors?: Color4[];
  57268. updatable?: boolean;
  57269. sideOrientation?: number;
  57270. frontUVs?: Vector4;
  57271. backUVs?: Vector4;
  57272. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  57273. /**
  57274. * Creates an extruded polygon mesh, with depth in the Y direction.
  57275. * * 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)
  57276. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57277. * @param name defines the name of the mesh
  57278. * @param options defines the options used to create the mesh
  57279. * @param scene defines the hosting scene
  57280. * @param earcutInjection can be used to inject your own earcut reference
  57281. * @returns the polygon mesh
  57282. */
  57283. static ExtrudePolygon(name: string, options: {
  57284. shape: Vector3[];
  57285. holes?: Vector3[][];
  57286. depth?: number;
  57287. faceUV?: Vector4[];
  57288. faceColors?: Color4[];
  57289. updatable?: boolean;
  57290. sideOrientation?: number;
  57291. frontUVs?: Vector4;
  57292. backUVs?: Vector4;
  57293. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  57294. }
  57295. }
  57296. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  57297. import { Scene } from "babylonjs/scene";
  57298. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  57299. import { Mesh } from "babylonjs/Meshes/mesh";
  57300. import { Nullable } from "babylonjs/types";
  57301. /**
  57302. * Class containing static functions to help procedurally build meshes
  57303. */
  57304. export class LatheBuilder {
  57305. /**
  57306. * Creates lathe mesh.
  57307. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  57308. * * 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
  57309. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  57310. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  57311. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  57312. * * 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
  57313. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  57314. * * 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
  57315. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57316. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57317. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57318. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57319. * @param name defines the name of the mesh
  57320. * @param options defines the options used to create the mesh
  57321. * @param scene defines the hosting scene
  57322. * @returns the lathe mesh
  57323. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  57324. */
  57325. static CreateLathe(name: string, options: {
  57326. shape: Vector3[];
  57327. radius?: number;
  57328. tessellation?: number;
  57329. clip?: number;
  57330. arc?: number;
  57331. closed?: boolean;
  57332. updatable?: boolean;
  57333. sideOrientation?: number;
  57334. frontUVs?: Vector4;
  57335. backUVs?: Vector4;
  57336. cap?: number;
  57337. invertUV?: boolean;
  57338. }, scene?: Nullable<Scene>): Mesh;
  57339. }
  57340. }
  57341. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  57342. import { Nullable } from "babylonjs/types";
  57343. import { Scene } from "babylonjs/scene";
  57344. import { Vector4 } from "babylonjs/Maths/math.vector";
  57345. import { Mesh } from "babylonjs/Meshes/mesh";
  57346. /**
  57347. * Class containing static functions to help procedurally build meshes
  57348. */
  57349. export class TiledPlaneBuilder {
  57350. /**
  57351. * Creates a tiled plane mesh
  57352. * * The parameter `pattern` will, depending on value, do nothing or
  57353. * * * flip (reflect about central vertical) alternate tiles across and up
  57354. * * * flip every tile on alternate rows
  57355. * * * rotate (180 degs) alternate tiles across and up
  57356. * * * rotate every tile on alternate rows
  57357. * * * flip and rotate alternate tiles across and up
  57358. * * * flip and rotate every tile on alternate rows
  57359. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  57360. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  57361. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57362. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  57363. * * 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)
  57364. * * 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)
  57365. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  57366. * @param name defines the name of the mesh
  57367. * @param options defines the options used to create the mesh
  57368. * @param scene defines the hosting scene
  57369. * @returns the box mesh
  57370. */
  57371. static CreateTiledPlane(name: string, options: {
  57372. pattern?: number;
  57373. tileSize?: number;
  57374. tileWidth?: number;
  57375. tileHeight?: number;
  57376. size?: number;
  57377. width?: number;
  57378. height?: number;
  57379. alignHorizontal?: number;
  57380. alignVertical?: number;
  57381. sideOrientation?: number;
  57382. frontUVs?: Vector4;
  57383. backUVs?: Vector4;
  57384. updatable?: boolean;
  57385. }, scene?: Nullable<Scene>): Mesh;
  57386. }
  57387. }
  57388. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  57389. import { Nullable } from "babylonjs/types";
  57390. import { Scene } from "babylonjs/scene";
  57391. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  57392. import { Mesh } from "babylonjs/Meshes/mesh";
  57393. /**
  57394. * Class containing static functions to help procedurally build meshes
  57395. */
  57396. export class TubeBuilder {
  57397. /**
  57398. * Creates a tube mesh.
  57399. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57400. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  57401. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  57402. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  57403. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  57404. * * 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)
  57405. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  57406. * * 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
  57407. * * 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
  57408. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57409. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57410. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57411. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57412. * @param name defines the name of the mesh
  57413. * @param options defines the options used to create the mesh
  57414. * @param scene defines the hosting scene
  57415. * @returns the tube mesh
  57416. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57417. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  57418. */
  57419. static CreateTube(name: string, options: {
  57420. path: Vector3[];
  57421. radius?: number;
  57422. tessellation?: number;
  57423. radiusFunction?: {
  57424. (i: number, distance: number): number;
  57425. };
  57426. cap?: number;
  57427. arc?: number;
  57428. updatable?: boolean;
  57429. sideOrientation?: number;
  57430. frontUVs?: Vector4;
  57431. backUVs?: Vector4;
  57432. instance?: Mesh;
  57433. invertUV?: boolean;
  57434. }, scene?: Nullable<Scene>): Mesh;
  57435. }
  57436. }
  57437. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  57438. import { Scene } from "babylonjs/scene";
  57439. import { Vector4 } from "babylonjs/Maths/math.vector";
  57440. import { Mesh } from "babylonjs/Meshes/mesh";
  57441. import { Nullable } from "babylonjs/types";
  57442. /**
  57443. * Class containing static functions to help procedurally build meshes
  57444. */
  57445. export class IcoSphereBuilder {
  57446. /**
  57447. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  57448. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  57449. * * 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`)
  57450. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  57451. * * 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
  57452. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57453. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57454. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57455. * @param name defines the name of the mesh
  57456. * @param options defines the options used to create the mesh
  57457. * @param scene defines the hosting scene
  57458. * @returns the icosahedron mesh
  57459. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  57460. */
  57461. static CreateIcoSphere(name: string, options: {
  57462. radius?: number;
  57463. radiusX?: number;
  57464. radiusY?: number;
  57465. radiusZ?: number;
  57466. flat?: boolean;
  57467. subdivisions?: number;
  57468. sideOrientation?: number;
  57469. frontUVs?: Vector4;
  57470. backUVs?: Vector4;
  57471. updatable?: boolean;
  57472. }, scene?: Nullable<Scene>): Mesh;
  57473. }
  57474. }
  57475. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  57476. import { Vector3 } from "babylonjs/Maths/math.vector";
  57477. import { Mesh } from "babylonjs/Meshes/mesh";
  57478. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57479. /**
  57480. * Class containing static functions to help procedurally build meshes
  57481. */
  57482. export class DecalBuilder {
  57483. /**
  57484. * Creates a decal mesh.
  57485. * 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
  57486. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  57487. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  57488. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  57489. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  57490. * @param name defines the name of the mesh
  57491. * @param sourceMesh defines the mesh where the decal must be applied
  57492. * @param options defines the options used to create the mesh
  57493. * @param scene defines the hosting scene
  57494. * @returns the decal mesh
  57495. * @see https://doc.babylonjs.com/how_to/decals
  57496. */
  57497. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  57498. position?: Vector3;
  57499. normal?: Vector3;
  57500. size?: Vector3;
  57501. angle?: number;
  57502. }): Mesh;
  57503. }
  57504. }
  57505. declare module "babylonjs/Meshes/meshBuilder" {
  57506. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  57507. import { Nullable } from "babylonjs/types";
  57508. import { Scene } from "babylonjs/scene";
  57509. import { Mesh } from "babylonjs/Meshes/mesh";
  57510. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  57511. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  57512. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57513. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  57514. import { Plane } from "babylonjs/Maths/math.plane";
  57515. /**
  57516. * Class containing static functions to help procedurally build meshes
  57517. */
  57518. export class MeshBuilder {
  57519. /**
  57520. * Creates a box mesh
  57521. * * The parameter `size` sets the size (float) of each box side (default 1)
  57522. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  57523. * * 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)
  57524. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57525. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57526. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57527. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57528. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  57529. * @param name defines the name of the mesh
  57530. * @param options defines the options used to create the mesh
  57531. * @param scene defines the hosting scene
  57532. * @returns the box mesh
  57533. */
  57534. static CreateBox(name: string, options: {
  57535. size?: number;
  57536. width?: number;
  57537. height?: number;
  57538. depth?: number;
  57539. faceUV?: Vector4[];
  57540. faceColors?: Color4[];
  57541. sideOrientation?: number;
  57542. frontUVs?: Vector4;
  57543. backUVs?: Vector4;
  57544. updatable?: boolean;
  57545. }, scene?: Nullable<Scene>): Mesh;
  57546. /**
  57547. * Creates a tiled box mesh
  57548. * * faceTiles sets the pattern, tile size and number of tiles for a face
  57549. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57550. * @param name defines the name of the mesh
  57551. * @param options defines the options used to create the mesh
  57552. * @param scene defines the hosting scene
  57553. * @returns the tiled box mesh
  57554. */
  57555. static CreateTiledBox(name: string, options: {
  57556. pattern?: number;
  57557. size?: number;
  57558. width?: number;
  57559. height?: number;
  57560. depth: number;
  57561. tileSize?: number;
  57562. tileWidth?: number;
  57563. tileHeight?: number;
  57564. faceUV?: Vector4[];
  57565. faceColors?: Color4[];
  57566. alignHorizontal?: number;
  57567. alignVertical?: number;
  57568. sideOrientation?: number;
  57569. updatable?: boolean;
  57570. }, scene?: Nullable<Scene>): Mesh;
  57571. /**
  57572. * Creates a sphere mesh
  57573. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  57574. * * 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`)
  57575. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  57576. * * 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
  57577. * * 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)
  57578. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57579. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57580. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57581. * @param name defines the name of the mesh
  57582. * @param options defines the options used to create the mesh
  57583. * @param scene defines the hosting scene
  57584. * @returns the sphere mesh
  57585. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  57586. */
  57587. static CreateSphere(name: string, options: {
  57588. segments?: number;
  57589. diameter?: number;
  57590. diameterX?: number;
  57591. diameterY?: number;
  57592. diameterZ?: number;
  57593. arc?: number;
  57594. slice?: number;
  57595. sideOrientation?: number;
  57596. frontUVs?: Vector4;
  57597. backUVs?: Vector4;
  57598. updatable?: boolean;
  57599. }, scene?: Nullable<Scene>): Mesh;
  57600. /**
  57601. * Creates a plane polygonal mesh. By default, this is a disc
  57602. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  57603. * * 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
  57604. * * 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
  57605. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57606. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57607. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57608. * @param name defines the name of the mesh
  57609. * @param options defines the options used to create the mesh
  57610. * @param scene defines the hosting scene
  57611. * @returns the plane polygonal mesh
  57612. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  57613. */
  57614. static CreateDisc(name: string, options: {
  57615. radius?: number;
  57616. tessellation?: number;
  57617. arc?: number;
  57618. updatable?: boolean;
  57619. sideOrientation?: number;
  57620. frontUVs?: Vector4;
  57621. backUVs?: Vector4;
  57622. }, scene?: Nullable<Scene>): Mesh;
  57623. /**
  57624. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  57625. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  57626. * * 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`)
  57627. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  57628. * * 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
  57629. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57630. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57631. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57632. * @param name defines the name of the mesh
  57633. * @param options defines the options used to create the mesh
  57634. * @param scene defines the hosting scene
  57635. * @returns the icosahedron mesh
  57636. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  57637. */
  57638. static CreateIcoSphere(name: string, options: {
  57639. radius?: number;
  57640. radiusX?: number;
  57641. radiusY?: number;
  57642. radiusZ?: number;
  57643. flat?: boolean;
  57644. subdivisions?: number;
  57645. sideOrientation?: number;
  57646. frontUVs?: Vector4;
  57647. backUVs?: Vector4;
  57648. updatable?: boolean;
  57649. }, scene?: Nullable<Scene>): Mesh;
  57650. /**
  57651. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57652. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  57653. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  57654. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  57655. * * 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
  57656. * * 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
  57657. * * 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
  57658. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57659. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57660. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57661. * * 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
  57662. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  57663. * * 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
  57664. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  57665. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57666. * @param name defines the name of the mesh
  57667. * @param options defines the options used to create the mesh
  57668. * @param scene defines the hosting scene
  57669. * @returns the ribbon mesh
  57670. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  57671. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57672. */
  57673. static CreateRibbon(name: string, options: {
  57674. pathArray: Vector3[][];
  57675. closeArray?: boolean;
  57676. closePath?: boolean;
  57677. offset?: number;
  57678. updatable?: boolean;
  57679. sideOrientation?: number;
  57680. frontUVs?: Vector4;
  57681. backUVs?: Vector4;
  57682. instance?: Mesh;
  57683. invertUV?: boolean;
  57684. uvs?: Vector2[];
  57685. colors?: Color4[];
  57686. }, scene?: Nullable<Scene>): Mesh;
  57687. /**
  57688. * Creates a cylinder or a cone mesh
  57689. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  57690. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  57691. * * 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.
  57692. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  57693. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  57694. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  57695. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  57696. * * 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).
  57697. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  57698. * * 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).
  57699. * * 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
  57700. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  57701. * * 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
  57702. * * 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.
  57703. * * If `enclose` is false, a ring surface is one element.
  57704. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  57705. * * 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
  57706. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57707. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57708. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57709. * @param name defines the name of the mesh
  57710. * @param options defines the options used to create the mesh
  57711. * @param scene defines the hosting scene
  57712. * @returns the cylinder mesh
  57713. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  57714. */
  57715. static CreateCylinder(name: string, options: {
  57716. height?: number;
  57717. diameterTop?: number;
  57718. diameterBottom?: number;
  57719. diameter?: number;
  57720. tessellation?: number;
  57721. subdivisions?: number;
  57722. arc?: number;
  57723. faceColors?: Color4[];
  57724. faceUV?: Vector4[];
  57725. updatable?: boolean;
  57726. hasRings?: boolean;
  57727. enclose?: boolean;
  57728. cap?: number;
  57729. sideOrientation?: number;
  57730. frontUVs?: Vector4;
  57731. backUVs?: Vector4;
  57732. }, scene?: Nullable<Scene>): Mesh;
  57733. /**
  57734. * Creates a torus mesh
  57735. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  57736. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  57737. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  57738. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57739. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57740. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57741. * @param name defines the name of the mesh
  57742. * @param options defines the options used to create the mesh
  57743. * @param scene defines the hosting scene
  57744. * @returns the torus mesh
  57745. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  57746. */
  57747. static CreateTorus(name: string, options: {
  57748. diameter?: number;
  57749. thickness?: number;
  57750. tessellation?: number;
  57751. updatable?: boolean;
  57752. sideOrientation?: number;
  57753. frontUVs?: Vector4;
  57754. backUVs?: Vector4;
  57755. }, scene?: Nullable<Scene>): Mesh;
  57756. /**
  57757. * Creates a torus knot mesh
  57758. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  57759. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  57760. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  57761. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  57762. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57763. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57764. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57765. * @param name defines the name of the mesh
  57766. * @param options defines the options used to create the mesh
  57767. * @param scene defines the hosting scene
  57768. * @returns the torus knot mesh
  57769. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  57770. */
  57771. static CreateTorusKnot(name: string, options: {
  57772. radius?: number;
  57773. tube?: number;
  57774. radialSegments?: number;
  57775. tubularSegments?: number;
  57776. p?: number;
  57777. q?: number;
  57778. updatable?: boolean;
  57779. sideOrientation?: number;
  57780. frontUVs?: Vector4;
  57781. backUVs?: Vector4;
  57782. }, scene?: Nullable<Scene>): Mesh;
  57783. /**
  57784. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  57785. * * 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
  57786. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  57787. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  57788. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  57789. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  57790. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  57791. * * 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
  57792. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  57793. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57794. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  57795. * @param name defines the name of the new line system
  57796. * @param options defines the options used to create the line system
  57797. * @param scene defines the hosting scene
  57798. * @returns a new line system mesh
  57799. */
  57800. static CreateLineSystem(name: string, options: {
  57801. lines: Vector3[][];
  57802. updatable?: boolean;
  57803. instance?: Nullable<LinesMesh>;
  57804. colors?: Nullable<Color4[][]>;
  57805. useVertexAlpha?: boolean;
  57806. }, scene: Nullable<Scene>): LinesMesh;
  57807. /**
  57808. * Creates a line mesh
  57809. * 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
  57810. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  57811. * * The parameter `points` is an array successive Vector3
  57812. * * 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
  57813. * * The optional parameter `colors` is an array of successive Color4, one per line point
  57814. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  57815. * * When updating an instance, remember that only point positions can change, not the number of points
  57816. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57817. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  57818. * @param name defines the name of the new line system
  57819. * @param options defines the options used to create the line system
  57820. * @param scene defines the hosting scene
  57821. * @returns a new line mesh
  57822. */
  57823. static CreateLines(name: string, options: {
  57824. points: Vector3[];
  57825. updatable?: boolean;
  57826. instance?: Nullable<LinesMesh>;
  57827. colors?: Color4[];
  57828. useVertexAlpha?: boolean;
  57829. }, scene?: Nullable<Scene>): LinesMesh;
  57830. /**
  57831. * Creates a dashed line mesh
  57832. * * 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
  57833. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  57834. * * The parameter `points` is an array successive Vector3
  57835. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  57836. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  57837. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  57838. * * 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
  57839. * * When updating an instance, remember that only point positions can change, not the number of points
  57840. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57841. * @param name defines the name of the mesh
  57842. * @param options defines the options used to create the mesh
  57843. * @param scene defines the hosting scene
  57844. * @returns the dashed line mesh
  57845. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  57846. */
  57847. static CreateDashedLines(name: string, options: {
  57848. points: Vector3[];
  57849. dashSize?: number;
  57850. gapSize?: number;
  57851. dashNb?: number;
  57852. updatable?: boolean;
  57853. instance?: LinesMesh;
  57854. }, scene?: Nullable<Scene>): LinesMesh;
  57855. /**
  57856. * 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.
  57857. * * 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.
  57858. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57859. * * 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.
  57860. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  57861. * * 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
  57862. * * 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
  57863. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  57864. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57865. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57866. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  57867. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57868. * @param name defines the name of the mesh
  57869. * @param options defines the options used to create the mesh
  57870. * @param scene defines the hosting scene
  57871. * @returns the extruded shape mesh
  57872. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57873. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57874. */
  57875. static ExtrudeShape(name: string, options: {
  57876. shape: Vector3[];
  57877. path: Vector3[];
  57878. scale?: number;
  57879. rotation?: number;
  57880. cap?: number;
  57881. updatable?: boolean;
  57882. sideOrientation?: number;
  57883. frontUVs?: Vector4;
  57884. backUVs?: Vector4;
  57885. instance?: Mesh;
  57886. invertUV?: boolean;
  57887. }, scene?: Nullable<Scene>): Mesh;
  57888. /**
  57889. * Creates an custom extruded shape mesh.
  57890. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  57891. * * 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.
  57892. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57893. * * 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
  57894. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  57895. * * 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
  57896. * * It must returns a float value that will be the scale value applied to the shape on each path point
  57897. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  57898. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  57899. * * 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
  57900. * * 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
  57901. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  57902. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57903. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57904. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57905. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57906. * @param name defines the name of the mesh
  57907. * @param options defines the options used to create the mesh
  57908. * @param scene defines the hosting scene
  57909. * @returns the custom extruded shape mesh
  57910. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  57911. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57912. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57913. */
  57914. static ExtrudeShapeCustom(name: string, options: {
  57915. shape: Vector3[];
  57916. path: Vector3[];
  57917. scaleFunction?: any;
  57918. rotationFunction?: any;
  57919. ribbonCloseArray?: boolean;
  57920. ribbonClosePath?: boolean;
  57921. cap?: number;
  57922. updatable?: boolean;
  57923. sideOrientation?: number;
  57924. frontUVs?: Vector4;
  57925. backUVs?: Vector4;
  57926. instance?: Mesh;
  57927. invertUV?: boolean;
  57928. }, scene?: Nullable<Scene>): Mesh;
  57929. /**
  57930. * Creates lathe mesh.
  57931. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  57932. * * 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
  57933. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  57934. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  57935. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  57936. * * 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
  57937. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  57938. * * 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
  57939. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57940. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57941. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57942. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57943. * @param name defines the name of the mesh
  57944. * @param options defines the options used to create the mesh
  57945. * @param scene defines the hosting scene
  57946. * @returns the lathe mesh
  57947. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  57948. */
  57949. static CreateLathe(name: string, options: {
  57950. shape: Vector3[];
  57951. radius?: number;
  57952. tessellation?: number;
  57953. clip?: number;
  57954. arc?: number;
  57955. closed?: boolean;
  57956. updatable?: boolean;
  57957. sideOrientation?: number;
  57958. frontUVs?: Vector4;
  57959. backUVs?: Vector4;
  57960. cap?: number;
  57961. invertUV?: boolean;
  57962. }, scene?: Nullable<Scene>): Mesh;
  57963. /**
  57964. * Creates a tiled plane mesh
  57965. * * You can set a limited pattern arrangement with the tiles
  57966. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57967. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57968. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57969. * @param name defines the name of the mesh
  57970. * @param options defines the options used to create the mesh
  57971. * @param scene defines the hosting scene
  57972. * @returns the plane mesh
  57973. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  57974. */
  57975. static CreateTiledPlane(name: string, options: {
  57976. pattern?: number;
  57977. tileSize?: number;
  57978. tileWidth?: number;
  57979. tileHeight?: number;
  57980. size?: number;
  57981. width?: number;
  57982. height?: number;
  57983. alignHorizontal?: number;
  57984. alignVertical?: number;
  57985. sideOrientation?: number;
  57986. frontUVs?: Vector4;
  57987. backUVs?: Vector4;
  57988. updatable?: boolean;
  57989. }, scene?: Nullable<Scene>): Mesh;
  57990. /**
  57991. * Creates a plane mesh
  57992. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  57993. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  57994. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  57995. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57996. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57997. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57998. * @param name defines the name of the mesh
  57999. * @param options defines the options used to create the mesh
  58000. * @param scene defines the hosting scene
  58001. * @returns the plane mesh
  58002. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  58003. */
  58004. static CreatePlane(name: string, options: {
  58005. size?: number;
  58006. width?: number;
  58007. height?: number;
  58008. sideOrientation?: number;
  58009. frontUVs?: Vector4;
  58010. backUVs?: Vector4;
  58011. updatable?: boolean;
  58012. sourcePlane?: Plane;
  58013. }, scene?: Nullable<Scene>): Mesh;
  58014. /**
  58015. * Creates a ground mesh
  58016. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  58017. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  58018. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58019. * @param name defines the name of the mesh
  58020. * @param options defines the options used to create the mesh
  58021. * @param scene defines the hosting scene
  58022. * @returns the ground mesh
  58023. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  58024. */
  58025. static CreateGround(name: string, options: {
  58026. width?: number;
  58027. height?: number;
  58028. subdivisions?: number;
  58029. subdivisionsX?: number;
  58030. subdivisionsY?: number;
  58031. updatable?: boolean;
  58032. }, scene?: Nullable<Scene>): Mesh;
  58033. /**
  58034. * Creates a tiled ground mesh
  58035. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  58036. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  58037. * * 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
  58038. * * 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
  58039. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58040. * @param name defines the name of the mesh
  58041. * @param options defines the options used to create the mesh
  58042. * @param scene defines the hosting scene
  58043. * @returns the tiled ground mesh
  58044. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  58045. */
  58046. static CreateTiledGround(name: string, options: {
  58047. xmin: number;
  58048. zmin: number;
  58049. xmax: number;
  58050. zmax: number;
  58051. subdivisions?: {
  58052. w: number;
  58053. h: number;
  58054. };
  58055. precision?: {
  58056. w: number;
  58057. h: number;
  58058. };
  58059. updatable?: boolean;
  58060. }, scene?: Nullable<Scene>): Mesh;
  58061. /**
  58062. * Creates a ground mesh from a height map
  58063. * * The parameter `url` sets the URL of the height map image resource.
  58064. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  58065. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  58066. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  58067. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  58068. * * 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.
  58069. * * 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).
  58070. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  58071. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58072. * @param name defines the name of the mesh
  58073. * @param url defines the url to the height map
  58074. * @param options defines the options used to create the mesh
  58075. * @param scene defines the hosting scene
  58076. * @returns the ground mesh
  58077. * @see https://doc.babylonjs.com/babylon101/height_map
  58078. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  58079. */
  58080. static CreateGroundFromHeightMap(name: string, url: string, options: {
  58081. width?: number;
  58082. height?: number;
  58083. subdivisions?: number;
  58084. minHeight?: number;
  58085. maxHeight?: number;
  58086. colorFilter?: Color3;
  58087. alphaFilter?: number;
  58088. updatable?: boolean;
  58089. onReady?: (mesh: GroundMesh) => void;
  58090. }, scene?: Nullable<Scene>): GroundMesh;
  58091. /**
  58092. * Creates a polygon mesh
  58093. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  58094. * * 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
  58095. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  58096. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58097. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  58098. * * Remember you can only change the shape positions, not their number when updating a polygon
  58099. * @param name defines the name of the mesh
  58100. * @param options defines the options used to create the mesh
  58101. * @param scene defines the hosting scene
  58102. * @param earcutInjection can be used to inject your own earcut reference
  58103. * @returns the polygon mesh
  58104. */
  58105. static CreatePolygon(name: string, options: {
  58106. shape: Vector3[];
  58107. holes?: Vector3[][];
  58108. depth?: number;
  58109. faceUV?: Vector4[];
  58110. faceColors?: Color4[];
  58111. updatable?: boolean;
  58112. sideOrientation?: number;
  58113. frontUVs?: Vector4;
  58114. backUVs?: Vector4;
  58115. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58116. /**
  58117. * Creates an extruded polygon mesh, with depth in the Y direction.
  58118. * * 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)
  58119. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58120. * @param name defines the name of the mesh
  58121. * @param options defines the options used to create the mesh
  58122. * @param scene defines the hosting scene
  58123. * @param earcutInjection can be used to inject your own earcut reference
  58124. * @returns the polygon mesh
  58125. */
  58126. static ExtrudePolygon(name: string, options: {
  58127. shape: Vector3[];
  58128. holes?: Vector3[][];
  58129. depth?: number;
  58130. faceUV?: Vector4[];
  58131. faceColors?: Color4[];
  58132. updatable?: boolean;
  58133. sideOrientation?: number;
  58134. frontUVs?: Vector4;
  58135. backUVs?: Vector4;
  58136. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58137. /**
  58138. * Creates a tube mesh.
  58139. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58140. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  58141. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  58142. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  58143. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  58144. * * 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)
  58145. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  58146. * * 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
  58147. * * 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
  58148. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58149. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58150. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58151. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58152. * @param name defines the name of the mesh
  58153. * @param options defines the options used to create the mesh
  58154. * @param scene defines the hosting scene
  58155. * @returns the tube mesh
  58156. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58157. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  58158. */
  58159. static CreateTube(name: string, options: {
  58160. path: Vector3[];
  58161. radius?: number;
  58162. tessellation?: number;
  58163. radiusFunction?: {
  58164. (i: number, distance: number): number;
  58165. };
  58166. cap?: number;
  58167. arc?: number;
  58168. updatable?: boolean;
  58169. sideOrientation?: number;
  58170. frontUVs?: Vector4;
  58171. backUVs?: Vector4;
  58172. instance?: Mesh;
  58173. invertUV?: boolean;
  58174. }, scene?: Nullable<Scene>): Mesh;
  58175. /**
  58176. * Creates a polyhedron mesh
  58177. * * 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
  58178. * * The parameter `size` (positive float, default 1) sets the polygon size
  58179. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  58180. * * 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`
  58181. * * 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
  58182. * * 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)`)
  58183. * * 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
  58184. * * 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
  58185. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58186. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58187. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58188. * @param name defines the name of the mesh
  58189. * @param options defines the options used to create the mesh
  58190. * @param scene defines the hosting scene
  58191. * @returns the polyhedron mesh
  58192. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  58193. */
  58194. static CreatePolyhedron(name: string, options: {
  58195. type?: number;
  58196. size?: number;
  58197. sizeX?: number;
  58198. sizeY?: number;
  58199. sizeZ?: number;
  58200. custom?: any;
  58201. faceUV?: Vector4[];
  58202. faceColors?: Color4[];
  58203. flat?: boolean;
  58204. updatable?: boolean;
  58205. sideOrientation?: number;
  58206. frontUVs?: Vector4;
  58207. backUVs?: Vector4;
  58208. }, scene?: Nullable<Scene>): Mesh;
  58209. /**
  58210. * Creates a decal mesh.
  58211. * 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
  58212. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  58213. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  58214. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  58215. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  58216. * @param name defines the name of the mesh
  58217. * @param sourceMesh defines the mesh where the decal must be applied
  58218. * @param options defines the options used to create the mesh
  58219. * @param scene defines the hosting scene
  58220. * @returns the decal mesh
  58221. * @see https://doc.babylonjs.com/how_to/decals
  58222. */
  58223. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  58224. position?: Vector3;
  58225. normal?: Vector3;
  58226. size?: Vector3;
  58227. angle?: number;
  58228. }): Mesh;
  58229. }
  58230. }
  58231. declare module "babylonjs/Meshes/meshSimplification" {
  58232. import { Mesh } from "babylonjs/Meshes/mesh";
  58233. /**
  58234. * A simplifier interface for future simplification implementations
  58235. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58236. */
  58237. export interface ISimplifier {
  58238. /**
  58239. * Simplification of a given mesh according to the given settings.
  58240. * Since this requires computation, it is assumed that the function runs async.
  58241. * @param settings The settings of the simplification, including quality and distance
  58242. * @param successCallback A callback that will be called after the mesh was simplified.
  58243. * @param errorCallback in case of an error, this callback will be called. optional.
  58244. */
  58245. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  58246. }
  58247. /**
  58248. * Expected simplification settings.
  58249. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  58250. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58251. */
  58252. export interface ISimplificationSettings {
  58253. /**
  58254. * Gets or sets the expected quality
  58255. */
  58256. quality: number;
  58257. /**
  58258. * Gets or sets the distance when this optimized version should be used
  58259. */
  58260. distance: number;
  58261. /**
  58262. * Gets an already optimized mesh
  58263. */
  58264. optimizeMesh?: boolean;
  58265. }
  58266. /**
  58267. * Class used to specify simplification options
  58268. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58269. */
  58270. export class SimplificationSettings implements ISimplificationSettings {
  58271. /** expected quality */
  58272. quality: number;
  58273. /** distance when this optimized version should be used */
  58274. distance: number;
  58275. /** already optimized mesh */
  58276. optimizeMesh?: boolean | undefined;
  58277. /**
  58278. * Creates a SimplificationSettings
  58279. * @param quality expected quality
  58280. * @param distance distance when this optimized version should be used
  58281. * @param optimizeMesh already optimized mesh
  58282. */
  58283. constructor(
  58284. /** expected quality */
  58285. quality: number,
  58286. /** distance when this optimized version should be used */
  58287. distance: number,
  58288. /** already optimized mesh */
  58289. optimizeMesh?: boolean | undefined);
  58290. }
  58291. /**
  58292. * Interface used to define a simplification task
  58293. */
  58294. export interface ISimplificationTask {
  58295. /**
  58296. * Array of settings
  58297. */
  58298. settings: Array<ISimplificationSettings>;
  58299. /**
  58300. * Simplification type
  58301. */
  58302. simplificationType: SimplificationType;
  58303. /**
  58304. * Mesh to simplify
  58305. */
  58306. mesh: Mesh;
  58307. /**
  58308. * Callback called on success
  58309. */
  58310. successCallback?: () => void;
  58311. /**
  58312. * Defines if parallel processing can be used
  58313. */
  58314. parallelProcessing: boolean;
  58315. }
  58316. /**
  58317. * Queue used to order the simplification tasks
  58318. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58319. */
  58320. export class SimplificationQueue {
  58321. private _simplificationArray;
  58322. /**
  58323. * Gets a boolean indicating that the process is still running
  58324. */
  58325. running: boolean;
  58326. /**
  58327. * Creates a new queue
  58328. */
  58329. constructor();
  58330. /**
  58331. * Adds a new simplification task
  58332. * @param task defines a task to add
  58333. */
  58334. addTask(task: ISimplificationTask): void;
  58335. /**
  58336. * Execute next task
  58337. */
  58338. executeNext(): void;
  58339. /**
  58340. * Execute a simplification task
  58341. * @param task defines the task to run
  58342. */
  58343. runSimplification(task: ISimplificationTask): void;
  58344. private getSimplifier;
  58345. }
  58346. /**
  58347. * The implemented types of simplification
  58348. * At the moment only Quadratic Error Decimation is implemented
  58349. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58350. */
  58351. export enum SimplificationType {
  58352. /** Quadratic error decimation */
  58353. QUADRATIC = 0
  58354. }
  58355. }
  58356. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  58357. import { Scene } from "babylonjs/scene";
  58358. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  58359. import { ISceneComponent } from "babylonjs/sceneComponent";
  58360. module "babylonjs/scene" {
  58361. interface Scene {
  58362. /** @hidden (Backing field) */
  58363. _simplificationQueue: SimplificationQueue;
  58364. /**
  58365. * Gets or sets the simplification queue attached to the scene
  58366. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58367. */
  58368. simplificationQueue: SimplificationQueue;
  58369. }
  58370. }
  58371. module "babylonjs/Meshes/mesh" {
  58372. interface Mesh {
  58373. /**
  58374. * Simplify the mesh according to the given array of settings.
  58375. * Function will return immediately and will simplify async
  58376. * @param settings a collection of simplification settings
  58377. * @param parallelProcessing should all levels calculate parallel or one after the other
  58378. * @param simplificationType the type of simplification to run
  58379. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  58380. * @returns the current mesh
  58381. */
  58382. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  58383. }
  58384. }
  58385. /**
  58386. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  58387. * created in a scene
  58388. */
  58389. export class SimplicationQueueSceneComponent implements ISceneComponent {
  58390. /**
  58391. * The component name helpfull to identify the component in the list of scene components.
  58392. */
  58393. readonly name: string;
  58394. /**
  58395. * The scene the component belongs to.
  58396. */
  58397. scene: Scene;
  58398. /**
  58399. * Creates a new instance of the component for the given scene
  58400. * @param scene Defines the scene to register the component in
  58401. */
  58402. constructor(scene: Scene);
  58403. /**
  58404. * Registers the component in a given scene
  58405. */
  58406. register(): void;
  58407. /**
  58408. * Rebuilds the elements related to this component in case of
  58409. * context lost for instance.
  58410. */
  58411. rebuild(): void;
  58412. /**
  58413. * Disposes the component and the associated ressources
  58414. */
  58415. dispose(): void;
  58416. private _beforeCameraUpdate;
  58417. }
  58418. }
  58419. declare module "babylonjs/Meshes/Builders/index" {
  58420. export * from "babylonjs/Meshes/Builders/boxBuilder";
  58421. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  58422. export * from "babylonjs/Meshes/Builders/discBuilder";
  58423. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  58424. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  58425. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  58426. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  58427. export * from "babylonjs/Meshes/Builders/torusBuilder";
  58428. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  58429. export * from "babylonjs/Meshes/Builders/linesBuilder";
  58430. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  58431. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  58432. export * from "babylonjs/Meshes/Builders/latheBuilder";
  58433. export * from "babylonjs/Meshes/Builders/planeBuilder";
  58434. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  58435. export * from "babylonjs/Meshes/Builders/groundBuilder";
  58436. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  58437. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  58438. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  58439. export * from "babylonjs/Meshes/Builders/decalBuilder";
  58440. }
  58441. declare module "babylonjs/Meshes/index" {
  58442. export * from "babylonjs/Meshes/abstractMesh";
  58443. export * from "babylonjs/Meshes/buffer";
  58444. export * from "babylonjs/Meshes/Compression/index";
  58445. export * from "babylonjs/Meshes/csg";
  58446. export * from "babylonjs/Meshes/geometry";
  58447. export * from "babylonjs/Meshes/groundMesh";
  58448. export * from "babylonjs/Meshes/trailMesh";
  58449. export * from "babylonjs/Meshes/instancedMesh";
  58450. export * from "babylonjs/Meshes/linesMesh";
  58451. export * from "babylonjs/Meshes/mesh";
  58452. export * from "babylonjs/Meshes/mesh.vertexData";
  58453. export * from "babylonjs/Meshes/meshBuilder";
  58454. export * from "babylonjs/Meshes/meshSimplification";
  58455. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  58456. export * from "babylonjs/Meshes/polygonMesh";
  58457. export * from "babylonjs/Meshes/subMesh";
  58458. export * from "babylonjs/Meshes/meshLODLevel";
  58459. export * from "babylonjs/Meshes/transformNode";
  58460. export * from "babylonjs/Meshes/Builders/index";
  58461. export * from "babylonjs/Meshes/dataBuffer";
  58462. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  58463. }
  58464. declare module "babylonjs/Morph/index" {
  58465. export * from "babylonjs/Morph/morphTarget";
  58466. export * from "babylonjs/Morph/morphTargetManager";
  58467. }
  58468. declare module "babylonjs/Navigation/INavigationEngine" {
  58469. import { TransformNode } from "babylonjs/Meshes/transformNode";
  58470. import { Vector3 } from "babylonjs/Maths/math";
  58471. import { Mesh } from "babylonjs/Meshes/mesh";
  58472. import { Scene } from "babylonjs/scene";
  58473. /**
  58474. * Navigation plugin interface to add navigation constrained by a navigation mesh
  58475. */
  58476. export interface INavigationEnginePlugin {
  58477. /**
  58478. * plugin name
  58479. */
  58480. name: string;
  58481. /**
  58482. * Creates a navigation mesh
  58483. * @param meshes array of all the geometry used to compute the navigatio mesh
  58484. * @param parameters bunch of parameters used to filter geometry
  58485. */
  58486. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  58487. /**
  58488. * Create a navigation mesh debug mesh
  58489. * @param scene is where the mesh will be added
  58490. * @returns debug display mesh
  58491. */
  58492. createDebugNavMesh(scene: Scene): Mesh;
  58493. /**
  58494. * Get a navigation mesh constrained position, closest to the parameter position
  58495. * @param position world position
  58496. * @returns the closest point to position constrained by the navigation mesh
  58497. */
  58498. getClosestPoint(position: Vector3): Vector3;
  58499. /**
  58500. * Get a navigation mesh constrained position, within a particular radius
  58501. * @param position world position
  58502. * @param maxRadius the maximum distance to the constrained world position
  58503. * @returns the closest point to position constrained by the navigation mesh
  58504. */
  58505. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  58506. /**
  58507. * Compute the final position from a segment made of destination-position
  58508. * @param position world position
  58509. * @param destination world position
  58510. * @returns the resulting point along the navmesh
  58511. */
  58512. moveAlong(position: Vector3, destination: Vector3): Vector3;
  58513. /**
  58514. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  58515. * @param start world position
  58516. * @param end world position
  58517. * @returns array containing world position composing the path
  58518. */
  58519. computePath(start: Vector3, end: Vector3): Vector3[];
  58520. /**
  58521. * If this plugin is supported
  58522. * @returns true if plugin is supported
  58523. */
  58524. isSupported(): boolean;
  58525. /**
  58526. * Create a new Crowd so you can add agents
  58527. * @param maxAgents the maximum agent count in the crowd
  58528. * @param maxAgentRadius the maximum radius an agent can have
  58529. * @param scene to attach the crowd to
  58530. * @returns the crowd you can add agents to
  58531. */
  58532. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  58533. /**
  58534. * Release all resources
  58535. */
  58536. dispose(): void;
  58537. }
  58538. /**
  58539. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  58540. */
  58541. export interface ICrowd {
  58542. /**
  58543. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  58544. * You can attach anything to that node. The node position is updated in the scene update tick.
  58545. * @param pos world position that will be constrained by the navigation mesh
  58546. * @param parameters agent parameters
  58547. * @param transform hooked to the agent that will be update by the scene
  58548. * @returns agent index
  58549. */
  58550. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  58551. /**
  58552. * Returns the agent position in world space
  58553. * @param index agent index returned by addAgent
  58554. * @returns world space position
  58555. */
  58556. getAgentPosition(index: number): Vector3;
  58557. /**
  58558. * Gets the agent velocity in world space
  58559. * @param index agent index returned by addAgent
  58560. * @returns world space velocity
  58561. */
  58562. getAgentVelocity(index: number): Vector3;
  58563. /**
  58564. * remove a particular agent previously created
  58565. * @param index agent index returned by addAgent
  58566. */
  58567. removeAgent(index: number): void;
  58568. /**
  58569. * get the list of all agents attached to this crowd
  58570. * @returns list of agent indices
  58571. */
  58572. getAgents(): number[];
  58573. /**
  58574. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  58575. * @param deltaTime in seconds
  58576. */
  58577. update(deltaTime: number): void;
  58578. /**
  58579. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  58580. * @param index agent index returned by addAgent
  58581. * @param destination targeted world position
  58582. */
  58583. agentGoto(index: number, destination: Vector3): void;
  58584. /**
  58585. * Release all resources
  58586. */
  58587. dispose(): void;
  58588. }
  58589. /**
  58590. * Configures an agent
  58591. */
  58592. export interface IAgentParameters {
  58593. /**
  58594. * Agent radius. [Limit: >= 0]
  58595. */
  58596. radius: number;
  58597. /**
  58598. * Agent height. [Limit: > 0]
  58599. */
  58600. height: number;
  58601. /**
  58602. * Maximum allowed acceleration. [Limit: >= 0]
  58603. */
  58604. maxAcceleration: number;
  58605. /**
  58606. * Maximum allowed speed. [Limit: >= 0]
  58607. */
  58608. maxSpeed: number;
  58609. /**
  58610. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  58611. */
  58612. collisionQueryRange: number;
  58613. /**
  58614. * The path visibility optimization range. [Limit: > 0]
  58615. */
  58616. pathOptimizationRange: number;
  58617. /**
  58618. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  58619. */
  58620. separationWeight: number;
  58621. }
  58622. /**
  58623. * Configures the navigation mesh creation
  58624. */
  58625. export interface INavMeshParameters {
  58626. /**
  58627. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  58628. */
  58629. cs: number;
  58630. /**
  58631. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  58632. */
  58633. ch: number;
  58634. /**
  58635. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  58636. */
  58637. walkableSlopeAngle: number;
  58638. /**
  58639. * Minimum floor to 'ceiling' height that will still allow the floor area to
  58640. * be considered walkable. [Limit: >= 3] [Units: vx]
  58641. */
  58642. walkableHeight: number;
  58643. /**
  58644. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  58645. */
  58646. walkableClimb: number;
  58647. /**
  58648. * The distance to erode/shrink the walkable area of the heightfield away from
  58649. * obstructions. [Limit: >=0] [Units: vx]
  58650. */
  58651. walkableRadius: number;
  58652. /**
  58653. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  58654. */
  58655. maxEdgeLen: number;
  58656. /**
  58657. * The maximum distance a simplfied contour's border edges should deviate
  58658. * the original raw contour. [Limit: >=0] [Units: vx]
  58659. */
  58660. maxSimplificationError: number;
  58661. /**
  58662. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  58663. */
  58664. minRegionArea: number;
  58665. /**
  58666. * Any regions with a span count smaller than this value will, if possible,
  58667. * be merged with larger regions. [Limit: >=0] [Units: vx]
  58668. */
  58669. mergeRegionArea: number;
  58670. /**
  58671. * The maximum number of vertices allowed for polygons generated during the
  58672. * contour to polygon conversion process. [Limit: >= 3]
  58673. */
  58674. maxVertsPerPoly: number;
  58675. /**
  58676. * Sets the sampling distance to use when generating the detail mesh.
  58677. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  58678. */
  58679. detailSampleDist: number;
  58680. /**
  58681. * The maximum distance the detail mesh surface should deviate from heightfield
  58682. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  58683. */
  58684. detailSampleMaxError: number;
  58685. }
  58686. }
  58687. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  58688. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  58689. import { Mesh } from "babylonjs/Meshes/mesh";
  58690. import { Scene } from "babylonjs/scene";
  58691. import { Vector3 } from "babylonjs/Maths/math";
  58692. import { TransformNode } from "babylonjs/Meshes/transformNode";
  58693. /**
  58694. * RecastJS navigation plugin
  58695. */
  58696. export class RecastJSPlugin implements INavigationEnginePlugin {
  58697. /**
  58698. * Reference to the Recast library
  58699. */
  58700. bjsRECAST: any;
  58701. /**
  58702. * plugin name
  58703. */
  58704. name: string;
  58705. /**
  58706. * the first navmesh created. We might extend this to support multiple navmeshes
  58707. */
  58708. navMesh: any;
  58709. /**
  58710. * Initializes the recastJS plugin
  58711. * @param recastInjection can be used to inject your own recast reference
  58712. */
  58713. constructor(recastInjection?: any);
  58714. /**
  58715. * Creates a navigation mesh
  58716. * @param meshes array of all the geometry used to compute the navigatio mesh
  58717. * @param parameters bunch of parameters used to filter geometry
  58718. */
  58719. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  58720. /**
  58721. * Create a navigation mesh debug mesh
  58722. * @param scene is where the mesh will be added
  58723. * @returns debug display mesh
  58724. */
  58725. createDebugNavMesh(scene: Scene): Mesh;
  58726. /**
  58727. * Get a navigation mesh constrained position, closest to the parameter position
  58728. * @param position world position
  58729. * @returns the closest point to position constrained by the navigation mesh
  58730. */
  58731. getClosestPoint(position: Vector3): Vector3;
  58732. /**
  58733. * Get a navigation mesh constrained position, within a particular radius
  58734. * @param position world position
  58735. * @param maxRadius the maximum distance to the constrained world position
  58736. * @returns the closest point to position constrained by the navigation mesh
  58737. */
  58738. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  58739. /**
  58740. * Compute the final position from a segment made of destination-position
  58741. * @param position world position
  58742. * @param destination world position
  58743. * @returns the resulting point along the navmesh
  58744. */
  58745. moveAlong(position: Vector3, destination: Vector3): Vector3;
  58746. /**
  58747. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  58748. * @param start world position
  58749. * @param end world position
  58750. * @returns array containing world position composing the path
  58751. */
  58752. computePath(start: Vector3, end: Vector3): Vector3[];
  58753. /**
  58754. * Create a new Crowd so you can add agents
  58755. * @param maxAgents the maximum agent count in the crowd
  58756. * @param maxAgentRadius the maximum radius an agent can have
  58757. * @param scene to attach the crowd to
  58758. * @returns the crowd you can add agents to
  58759. */
  58760. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  58761. /**
  58762. * Disposes
  58763. */
  58764. dispose(): void;
  58765. /**
  58766. * If this plugin is supported
  58767. * @returns true if plugin is supported
  58768. */
  58769. isSupported(): boolean;
  58770. }
  58771. /**
  58772. * Recast detour crowd implementation
  58773. */
  58774. export class RecastJSCrowd implements ICrowd {
  58775. /**
  58776. * Recast/detour plugin
  58777. */
  58778. bjsRECASTPlugin: RecastJSPlugin;
  58779. /**
  58780. * Link to the detour crowd
  58781. */
  58782. recastCrowd: any;
  58783. /**
  58784. * One transform per agent
  58785. */
  58786. transforms: TransformNode[];
  58787. /**
  58788. * All agents created
  58789. */
  58790. agents: number[];
  58791. /**
  58792. * Link to the scene is kept to unregister the crowd from the scene
  58793. */
  58794. private _scene;
  58795. /**
  58796. * Observer for crowd updates
  58797. */
  58798. private _onBeforeAnimationsObserver;
  58799. /**
  58800. * Constructor
  58801. * @param plugin recastJS plugin
  58802. * @param maxAgents the maximum agent count in the crowd
  58803. * @param maxAgentRadius the maximum radius an agent can have
  58804. * @param scene to attach the crowd to
  58805. * @returns the crowd you can add agents to
  58806. */
  58807. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  58808. /**
  58809. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  58810. * You can attach anything to that node. The node position is updated in the scene update tick.
  58811. * @param pos world position that will be constrained by the navigation mesh
  58812. * @param parameters agent parameters
  58813. * @param transform hooked to the agent that will be update by the scene
  58814. * @returns agent index
  58815. */
  58816. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  58817. /**
  58818. * Returns the agent position in world space
  58819. * @param index agent index returned by addAgent
  58820. * @returns world space position
  58821. */
  58822. getAgentPosition(index: number): Vector3;
  58823. /**
  58824. * Returns the agent velocity in world space
  58825. * @param index agent index returned by addAgent
  58826. * @returns world space velocity
  58827. */
  58828. getAgentVelocity(index: number): Vector3;
  58829. /**
  58830. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  58831. * @param index agent index returned by addAgent
  58832. * @param destination targeted world position
  58833. */
  58834. agentGoto(index: number, destination: Vector3): void;
  58835. /**
  58836. * remove a particular agent previously created
  58837. * @param index agent index returned by addAgent
  58838. */
  58839. removeAgent(index: number): void;
  58840. /**
  58841. * get the list of all agents attached to this crowd
  58842. * @returns list of agent indices
  58843. */
  58844. getAgents(): number[];
  58845. /**
  58846. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  58847. * @param deltaTime in seconds
  58848. */
  58849. update(deltaTime: number): void;
  58850. /**
  58851. * Release all resources
  58852. */
  58853. dispose(): void;
  58854. }
  58855. }
  58856. declare module "babylonjs/Navigation/Plugins/index" {
  58857. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  58858. }
  58859. declare module "babylonjs/Navigation/index" {
  58860. export * from "babylonjs/Navigation/INavigationEngine";
  58861. export * from "babylonjs/Navigation/Plugins/index";
  58862. }
  58863. declare module "babylonjs/Offline/database" {
  58864. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  58865. /**
  58866. * Class used to enable access to IndexedDB
  58867. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  58868. */
  58869. export class Database implements IOfflineProvider {
  58870. private _callbackManifestChecked;
  58871. private _currentSceneUrl;
  58872. private _db;
  58873. private _enableSceneOffline;
  58874. private _enableTexturesOffline;
  58875. private _manifestVersionFound;
  58876. private _mustUpdateRessources;
  58877. private _hasReachedQuota;
  58878. private _isSupported;
  58879. private _idbFactory;
  58880. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  58881. private static IsUASupportingBlobStorage;
  58882. /**
  58883. * Gets a boolean indicating if Database storate is enabled (off by default)
  58884. */
  58885. static IDBStorageEnabled: boolean;
  58886. /**
  58887. * Gets a boolean indicating if scene must be saved in the database
  58888. */
  58889. readonly enableSceneOffline: boolean;
  58890. /**
  58891. * Gets a boolean indicating if textures must be saved in the database
  58892. */
  58893. readonly enableTexturesOffline: boolean;
  58894. /**
  58895. * Creates a new Database
  58896. * @param urlToScene defines the url to load the scene
  58897. * @param callbackManifestChecked defines the callback to use when manifest is checked
  58898. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  58899. */
  58900. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  58901. private static _ParseURL;
  58902. private static _ReturnFullUrlLocation;
  58903. private _checkManifestFile;
  58904. /**
  58905. * Open the database and make it available
  58906. * @param successCallback defines the callback to call on success
  58907. * @param errorCallback defines the callback to call on error
  58908. */
  58909. open(successCallback: () => void, errorCallback: () => void): void;
  58910. /**
  58911. * Loads an image from the database
  58912. * @param url defines the url to load from
  58913. * @param image defines the target DOM image
  58914. */
  58915. loadImage(url: string, image: HTMLImageElement): void;
  58916. private _loadImageFromDBAsync;
  58917. private _saveImageIntoDBAsync;
  58918. private _checkVersionFromDB;
  58919. private _loadVersionFromDBAsync;
  58920. private _saveVersionIntoDBAsync;
  58921. /**
  58922. * Loads a file from database
  58923. * @param url defines the URL to load from
  58924. * @param sceneLoaded defines a callback to call on success
  58925. * @param progressCallBack defines a callback to call when progress changed
  58926. * @param errorCallback defines a callback to call on error
  58927. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  58928. */
  58929. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  58930. private _loadFileAsync;
  58931. private _saveFileAsync;
  58932. /**
  58933. * Validates if xhr data is correct
  58934. * @param xhr defines the request to validate
  58935. * @param dataType defines the expected data type
  58936. * @returns true if data is correct
  58937. */
  58938. private static _ValidateXHRData;
  58939. }
  58940. }
  58941. declare module "babylonjs/Offline/index" {
  58942. export * from "babylonjs/Offline/database";
  58943. export * from "babylonjs/Offline/IOfflineProvider";
  58944. }
  58945. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  58946. /** @hidden */
  58947. export var gpuUpdateParticlesPixelShader: {
  58948. name: string;
  58949. shader: string;
  58950. };
  58951. }
  58952. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  58953. /** @hidden */
  58954. export var gpuUpdateParticlesVertexShader: {
  58955. name: string;
  58956. shader: string;
  58957. };
  58958. }
  58959. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  58960. /** @hidden */
  58961. export var clipPlaneFragmentDeclaration2: {
  58962. name: string;
  58963. shader: string;
  58964. };
  58965. }
  58966. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  58967. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  58968. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  58969. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58970. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  58971. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  58972. /** @hidden */
  58973. export var gpuRenderParticlesPixelShader: {
  58974. name: string;
  58975. shader: string;
  58976. };
  58977. }
  58978. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  58979. /** @hidden */
  58980. export var clipPlaneVertexDeclaration2: {
  58981. name: string;
  58982. shader: string;
  58983. };
  58984. }
  58985. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  58986. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  58987. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  58988. /** @hidden */
  58989. export var gpuRenderParticlesVertexShader: {
  58990. name: string;
  58991. shader: string;
  58992. };
  58993. }
  58994. declare module "babylonjs/Particles/gpuParticleSystem" {
  58995. import { Nullable } from "babylonjs/types";
  58996. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  58997. import { Observable } from "babylonjs/Misc/observable";
  58998. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  58999. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  59000. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  59001. import { Scene, IDisposable } from "babylonjs/scene";
  59002. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  59003. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  59004. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  59005. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  59006. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  59007. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  59008. /**
  59009. * This represents a GPU particle system in Babylon
  59010. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  59011. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  59012. */
  59013. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  59014. /**
  59015. * The layer mask we are rendering the particles through.
  59016. */
  59017. layerMask: number;
  59018. private _capacity;
  59019. private _activeCount;
  59020. private _currentActiveCount;
  59021. private _accumulatedCount;
  59022. private _renderEffect;
  59023. private _updateEffect;
  59024. private _buffer0;
  59025. private _buffer1;
  59026. private _spriteBuffer;
  59027. private _updateVAO;
  59028. private _renderVAO;
  59029. private _targetIndex;
  59030. private _sourceBuffer;
  59031. private _targetBuffer;
  59032. private _engine;
  59033. private _currentRenderId;
  59034. private _started;
  59035. private _stopped;
  59036. private _timeDelta;
  59037. private _randomTexture;
  59038. private _randomTexture2;
  59039. private _attributesStrideSize;
  59040. private _updateEffectOptions;
  59041. private _randomTextureSize;
  59042. private _actualFrame;
  59043. private readonly _rawTextureWidth;
  59044. /**
  59045. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  59046. */
  59047. static readonly IsSupported: boolean;
  59048. /**
  59049. * An event triggered when the system is disposed.
  59050. */
  59051. onDisposeObservable: Observable<GPUParticleSystem>;
  59052. /**
  59053. * Gets the maximum number of particles active at the same time.
  59054. * @returns The max number of active particles.
  59055. */
  59056. getCapacity(): number;
  59057. /**
  59058. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  59059. * to override the particles.
  59060. */
  59061. forceDepthWrite: boolean;
  59062. /**
  59063. * Gets or set the number of active particles
  59064. */
  59065. activeParticleCount: number;
  59066. private _preWarmDone;
  59067. /**
  59068. * Is this system ready to be used/rendered
  59069. * @return true if the system is ready
  59070. */
  59071. isReady(): boolean;
  59072. /**
  59073. * Gets if the system has been started. (Note: this will still be true after stop is called)
  59074. * @returns True if it has been started, otherwise false.
  59075. */
  59076. isStarted(): boolean;
  59077. /**
  59078. * Starts the particle system and begins to emit
  59079. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  59080. */
  59081. start(delay?: number): void;
  59082. /**
  59083. * Stops the particle system.
  59084. */
  59085. stop(): void;
  59086. /**
  59087. * Remove all active particles
  59088. */
  59089. reset(): void;
  59090. /**
  59091. * Returns the string "GPUParticleSystem"
  59092. * @returns a string containing the class name
  59093. */
  59094. getClassName(): string;
  59095. private _colorGradientsTexture;
  59096. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  59097. /**
  59098. * Adds a new color gradient
  59099. * @param gradient defines the gradient to use (between 0 and 1)
  59100. * @param color1 defines the color to affect to the specified gradient
  59101. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  59102. * @returns the current particle system
  59103. */
  59104. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  59105. /**
  59106. * Remove a specific color gradient
  59107. * @param gradient defines the gradient to remove
  59108. * @returns the current particle system
  59109. */
  59110. removeColorGradient(gradient: number): GPUParticleSystem;
  59111. private _angularSpeedGradientsTexture;
  59112. private _sizeGradientsTexture;
  59113. private _velocityGradientsTexture;
  59114. private _limitVelocityGradientsTexture;
  59115. private _dragGradientsTexture;
  59116. private _addFactorGradient;
  59117. /**
  59118. * Adds a new size gradient
  59119. * @param gradient defines the gradient to use (between 0 and 1)
  59120. * @param factor defines the size factor to affect to the specified gradient
  59121. * @returns the current particle system
  59122. */
  59123. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  59124. /**
  59125. * Remove a specific size gradient
  59126. * @param gradient defines the gradient to remove
  59127. * @returns the current particle system
  59128. */
  59129. removeSizeGradient(gradient: number): GPUParticleSystem;
  59130. /**
  59131. * Adds a new angular speed gradient
  59132. * @param gradient defines the gradient to use (between 0 and 1)
  59133. * @param factor defines the angular speed to affect to the specified gradient
  59134. * @returns the current particle system
  59135. */
  59136. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  59137. /**
  59138. * Remove a specific angular speed gradient
  59139. * @param gradient defines the gradient to remove
  59140. * @returns the current particle system
  59141. */
  59142. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  59143. /**
  59144. * Adds a new velocity gradient
  59145. * @param gradient defines the gradient to use (between 0 and 1)
  59146. * @param factor defines the velocity to affect to the specified gradient
  59147. * @returns the current particle system
  59148. */
  59149. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  59150. /**
  59151. * Remove a specific velocity gradient
  59152. * @param gradient defines the gradient to remove
  59153. * @returns the current particle system
  59154. */
  59155. removeVelocityGradient(gradient: number): GPUParticleSystem;
  59156. /**
  59157. * Adds a new limit velocity gradient
  59158. * @param gradient defines the gradient to use (between 0 and 1)
  59159. * @param factor defines the limit velocity value to affect to the specified gradient
  59160. * @returns the current particle system
  59161. */
  59162. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  59163. /**
  59164. * Remove a specific limit velocity gradient
  59165. * @param gradient defines the gradient to remove
  59166. * @returns the current particle system
  59167. */
  59168. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  59169. /**
  59170. * Adds a new drag gradient
  59171. * @param gradient defines the gradient to use (between 0 and 1)
  59172. * @param factor defines the drag value to affect to the specified gradient
  59173. * @returns the current particle system
  59174. */
  59175. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  59176. /**
  59177. * Remove a specific drag gradient
  59178. * @param gradient defines the gradient to remove
  59179. * @returns the current particle system
  59180. */
  59181. removeDragGradient(gradient: number): GPUParticleSystem;
  59182. /**
  59183. * Not supported by GPUParticleSystem
  59184. * @param gradient defines the gradient to use (between 0 and 1)
  59185. * @param factor defines the emit rate value to affect to the specified gradient
  59186. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  59187. * @returns the current particle system
  59188. */
  59189. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  59190. /**
  59191. * Not supported by GPUParticleSystem
  59192. * @param gradient defines the gradient to remove
  59193. * @returns the current particle system
  59194. */
  59195. removeEmitRateGradient(gradient: number): IParticleSystem;
  59196. /**
  59197. * Not supported by GPUParticleSystem
  59198. * @param gradient defines the gradient to use (between 0 and 1)
  59199. * @param factor defines the start size value to affect to the specified gradient
  59200. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  59201. * @returns the current particle system
  59202. */
  59203. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  59204. /**
  59205. * Not supported by GPUParticleSystem
  59206. * @param gradient defines the gradient to remove
  59207. * @returns the current particle system
  59208. */
  59209. removeStartSizeGradient(gradient: number): IParticleSystem;
  59210. /**
  59211. * Not supported by GPUParticleSystem
  59212. * @param gradient defines the gradient to use (between 0 and 1)
  59213. * @param min defines the color remap minimal range
  59214. * @param max defines the color remap maximal range
  59215. * @returns the current particle system
  59216. */
  59217. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  59218. /**
  59219. * Not supported by GPUParticleSystem
  59220. * @param gradient defines the gradient to remove
  59221. * @returns the current particle system
  59222. */
  59223. removeColorRemapGradient(): IParticleSystem;
  59224. /**
  59225. * Not supported by GPUParticleSystem
  59226. * @param gradient defines the gradient to use (between 0 and 1)
  59227. * @param min defines the alpha remap minimal range
  59228. * @param max defines the alpha remap maximal range
  59229. * @returns the current particle system
  59230. */
  59231. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  59232. /**
  59233. * Not supported by GPUParticleSystem
  59234. * @param gradient defines the gradient to remove
  59235. * @returns the current particle system
  59236. */
  59237. removeAlphaRemapGradient(): IParticleSystem;
  59238. /**
  59239. * Not supported by GPUParticleSystem
  59240. * @param gradient defines the gradient to use (between 0 and 1)
  59241. * @param color defines the color to affect to the specified gradient
  59242. * @returns the current particle system
  59243. */
  59244. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  59245. /**
  59246. * Not supported by GPUParticleSystem
  59247. * @param gradient defines the gradient to remove
  59248. * @returns the current particle system
  59249. */
  59250. removeRampGradient(): IParticleSystem;
  59251. /**
  59252. * Not supported by GPUParticleSystem
  59253. * @returns the list of ramp gradients
  59254. */
  59255. getRampGradients(): Nullable<Array<Color3Gradient>>;
  59256. /**
  59257. * Not supported by GPUParticleSystem
  59258. * Gets or sets a boolean indicating that ramp gradients must be used
  59259. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  59260. */
  59261. useRampGradients: boolean;
  59262. /**
  59263. * Not supported by GPUParticleSystem
  59264. * @param gradient defines the gradient to use (between 0 and 1)
  59265. * @param factor defines the life time factor to affect to the specified gradient
  59266. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  59267. * @returns the current particle system
  59268. */
  59269. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  59270. /**
  59271. * Not supported by GPUParticleSystem
  59272. * @param gradient defines the gradient to remove
  59273. * @returns the current particle system
  59274. */
  59275. removeLifeTimeGradient(gradient: number): IParticleSystem;
  59276. /**
  59277. * Instantiates a GPU particle system.
  59278. * 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.
  59279. * @param name The name of the particle system
  59280. * @param options The options used to create the system
  59281. * @param scene The scene the particle system belongs to
  59282. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  59283. */
  59284. constructor(name: string, options: Partial<{
  59285. capacity: number;
  59286. randomTextureSize: number;
  59287. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  59288. protected _reset(): void;
  59289. private _createUpdateVAO;
  59290. private _createRenderVAO;
  59291. private _initialize;
  59292. /** @hidden */
  59293. _recreateUpdateEffect(): void;
  59294. /** @hidden */
  59295. _recreateRenderEffect(): void;
  59296. /**
  59297. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  59298. * @param preWarm defines if we are in the pre-warmimg phase
  59299. */
  59300. animate(preWarm?: boolean): void;
  59301. private _createFactorGradientTexture;
  59302. private _createSizeGradientTexture;
  59303. private _createAngularSpeedGradientTexture;
  59304. private _createVelocityGradientTexture;
  59305. private _createLimitVelocityGradientTexture;
  59306. private _createDragGradientTexture;
  59307. private _createColorGradientTexture;
  59308. /**
  59309. * Renders the particle system in its current state
  59310. * @param preWarm defines if the system should only update the particles but not render them
  59311. * @returns the current number of particles
  59312. */
  59313. render(preWarm?: boolean): number;
  59314. /**
  59315. * Rebuilds the particle system
  59316. */
  59317. rebuild(): void;
  59318. private _releaseBuffers;
  59319. private _releaseVAOs;
  59320. /**
  59321. * Disposes the particle system and free the associated resources
  59322. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  59323. */
  59324. dispose(disposeTexture?: boolean): void;
  59325. /**
  59326. * Clones the particle system.
  59327. * @param name The name of the cloned object
  59328. * @param newEmitter The new emitter to use
  59329. * @returns the cloned particle system
  59330. */
  59331. clone(name: string, newEmitter: any): GPUParticleSystem;
  59332. /**
  59333. * Serializes the particle system to a JSON object.
  59334. * @returns the JSON object
  59335. */
  59336. serialize(): any;
  59337. /**
  59338. * Parses a JSON object to create a GPU particle system.
  59339. * @param parsedParticleSystem The JSON object to parse
  59340. * @param scene The scene to create the particle system in
  59341. * @param rootUrl The root url to use to load external dependencies like texture
  59342. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  59343. * @returns the parsed GPU particle system
  59344. */
  59345. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  59346. }
  59347. }
  59348. declare module "babylonjs/Particles/particleSystemSet" {
  59349. import { Nullable } from "babylonjs/types";
  59350. import { Color3 } from "babylonjs/Maths/math.color";
  59351. import { TransformNode } from "babylonjs/Meshes/transformNode";
  59352. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59353. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  59354. import { Scene, IDisposable } from "babylonjs/scene";
  59355. /**
  59356. * Represents a set of particle systems working together to create a specific effect
  59357. */
  59358. export class ParticleSystemSet implements IDisposable {
  59359. private _emitterCreationOptions;
  59360. private _emitterNode;
  59361. /**
  59362. * Gets the particle system list
  59363. */
  59364. systems: IParticleSystem[];
  59365. /**
  59366. * Gets the emitter node used with this set
  59367. */
  59368. readonly emitterNode: Nullable<TransformNode>;
  59369. /**
  59370. * Creates a new emitter mesh as a sphere
  59371. * @param options defines the options used to create the sphere
  59372. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  59373. * @param scene defines the hosting scene
  59374. */
  59375. setEmitterAsSphere(options: {
  59376. diameter: number;
  59377. segments: number;
  59378. color: Color3;
  59379. }, renderingGroupId: number, scene: Scene): void;
  59380. /**
  59381. * Starts all particle systems of the set
  59382. * @param emitter defines an optional mesh to use as emitter for the particle systems
  59383. */
  59384. start(emitter?: AbstractMesh): void;
  59385. /**
  59386. * Release all associated resources
  59387. */
  59388. dispose(): void;
  59389. /**
  59390. * Serialize the set into a JSON compatible object
  59391. * @returns a JSON compatible representation of the set
  59392. */
  59393. serialize(): any;
  59394. /**
  59395. * Parse a new ParticleSystemSet from a serialized source
  59396. * @param data defines a JSON compatible representation of the set
  59397. * @param scene defines the hosting scene
  59398. * @param gpu defines if we want GPU particles or CPU particles
  59399. * @returns a new ParticleSystemSet
  59400. */
  59401. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  59402. }
  59403. }
  59404. declare module "babylonjs/Particles/particleHelper" {
  59405. import { Nullable } from "babylonjs/types";
  59406. import { Scene } from "babylonjs/scene";
  59407. import { Vector3 } from "babylonjs/Maths/math.vector";
  59408. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59409. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  59410. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  59411. /**
  59412. * This class is made for on one-liner static method to help creating particle system set.
  59413. */
  59414. export class ParticleHelper {
  59415. /**
  59416. * Gets or sets base Assets URL
  59417. */
  59418. static BaseAssetsUrl: string;
  59419. /**
  59420. * Create a default particle system that you can tweak
  59421. * @param emitter defines the emitter to use
  59422. * @param capacity defines the system capacity (default is 500 particles)
  59423. * @param scene defines the hosting scene
  59424. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  59425. * @returns the new Particle system
  59426. */
  59427. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  59428. /**
  59429. * This is the main static method (one-liner) of this helper to create different particle systems
  59430. * @param type This string represents the type to the particle system to create
  59431. * @param scene The scene where the particle system should live
  59432. * @param gpu If the system will use gpu
  59433. * @returns the ParticleSystemSet created
  59434. */
  59435. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  59436. /**
  59437. * Static function used to export a particle system to a ParticleSystemSet variable.
  59438. * Please note that the emitter shape is not exported
  59439. * @param systems defines the particle systems to export
  59440. * @returns the created particle system set
  59441. */
  59442. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  59443. }
  59444. }
  59445. declare module "babylonjs/Particles/particleSystemComponent" {
  59446. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  59447. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  59448. import "babylonjs/Shaders/particles.vertex";
  59449. module "babylonjs/Engines/engine" {
  59450. interface Engine {
  59451. /**
  59452. * Create an effect to use with particle systems.
  59453. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  59454. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  59455. * @param uniformsNames defines a list of attribute names
  59456. * @param samplers defines an array of string used to represent textures
  59457. * @param defines defines the string containing the defines to use to compile the shaders
  59458. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  59459. * @param onCompiled defines a function to call when the effect creation is successful
  59460. * @param onError defines a function to call when the effect creation has failed
  59461. * @returns the new Effect
  59462. */
  59463. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  59464. }
  59465. }
  59466. module "babylonjs/Meshes/mesh" {
  59467. interface Mesh {
  59468. /**
  59469. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  59470. * @returns an array of IParticleSystem
  59471. */
  59472. getEmittedParticleSystems(): IParticleSystem[];
  59473. /**
  59474. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  59475. * @returns an array of IParticleSystem
  59476. */
  59477. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  59478. }
  59479. }
  59480. /**
  59481. * @hidden
  59482. */
  59483. export var _IDoNeedToBeInTheBuild: number;
  59484. }
  59485. declare module "babylonjs/Particles/index" {
  59486. export * from "babylonjs/Particles/baseParticleSystem";
  59487. export * from "babylonjs/Particles/EmitterTypes/index";
  59488. export * from "babylonjs/Particles/gpuParticleSystem";
  59489. export * from "babylonjs/Particles/IParticleSystem";
  59490. export * from "babylonjs/Particles/particle";
  59491. export * from "babylonjs/Particles/particleHelper";
  59492. export * from "babylonjs/Particles/particleSystem";
  59493. export * from "babylonjs/Particles/particleSystemComponent";
  59494. export * from "babylonjs/Particles/particleSystemSet";
  59495. export * from "babylonjs/Particles/solidParticle";
  59496. export * from "babylonjs/Particles/solidParticleSystem";
  59497. export * from "babylonjs/Particles/subEmitter";
  59498. }
  59499. declare module "babylonjs/Physics/physicsEngineComponent" {
  59500. import { Nullable } from "babylonjs/types";
  59501. import { Observable, Observer } from "babylonjs/Misc/observable";
  59502. import { Vector3 } from "babylonjs/Maths/math.vector";
  59503. import { Mesh } from "babylonjs/Meshes/mesh";
  59504. import { ISceneComponent } from "babylonjs/sceneComponent";
  59505. import { Scene } from "babylonjs/scene";
  59506. import { Node } from "babylonjs/node";
  59507. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  59508. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  59509. module "babylonjs/scene" {
  59510. interface Scene {
  59511. /** @hidden (Backing field) */
  59512. _physicsEngine: Nullable<IPhysicsEngine>;
  59513. /**
  59514. * Gets the current physics engine
  59515. * @returns a IPhysicsEngine or null if none attached
  59516. */
  59517. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  59518. /**
  59519. * Enables physics to the current scene
  59520. * @param gravity defines the scene's gravity for the physics engine
  59521. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  59522. * @return a boolean indicating if the physics engine was initialized
  59523. */
  59524. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  59525. /**
  59526. * Disables and disposes the physics engine associated with the scene
  59527. */
  59528. disablePhysicsEngine(): void;
  59529. /**
  59530. * Gets a boolean indicating if there is an active physics engine
  59531. * @returns a boolean indicating if there is an active physics engine
  59532. */
  59533. isPhysicsEnabled(): boolean;
  59534. /**
  59535. * Deletes a physics compound impostor
  59536. * @param compound defines the compound to delete
  59537. */
  59538. deleteCompoundImpostor(compound: any): void;
  59539. /**
  59540. * An event triggered when physic simulation is about to be run
  59541. */
  59542. onBeforePhysicsObservable: Observable<Scene>;
  59543. /**
  59544. * An event triggered when physic simulation has been done
  59545. */
  59546. onAfterPhysicsObservable: Observable<Scene>;
  59547. }
  59548. }
  59549. module "babylonjs/Meshes/abstractMesh" {
  59550. interface AbstractMesh {
  59551. /** @hidden */
  59552. _physicsImpostor: Nullable<PhysicsImpostor>;
  59553. /**
  59554. * Gets or sets impostor used for physic simulation
  59555. * @see http://doc.babylonjs.com/features/physics_engine
  59556. */
  59557. physicsImpostor: Nullable<PhysicsImpostor>;
  59558. /**
  59559. * Gets the current physics impostor
  59560. * @see http://doc.babylonjs.com/features/physics_engine
  59561. * @returns a physics impostor or null
  59562. */
  59563. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  59564. /** Apply a physic impulse to the mesh
  59565. * @param force defines the force to apply
  59566. * @param contactPoint defines where to apply the force
  59567. * @returns the current mesh
  59568. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  59569. */
  59570. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  59571. /**
  59572. * Creates a physic joint between two meshes
  59573. * @param otherMesh defines the other mesh to use
  59574. * @param pivot1 defines the pivot to use on this mesh
  59575. * @param pivot2 defines the pivot to use on the other mesh
  59576. * @param options defines additional options (can be plugin dependent)
  59577. * @returns the current mesh
  59578. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  59579. */
  59580. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  59581. /** @hidden */
  59582. _disposePhysicsObserver: Nullable<Observer<Node>>;
  59583. }
  59584. }
  59585. /**
  59586. * Defines the physics engine scene component responsible to manage a physics engine
  59587. */
  59588. export class PhysicsEngineSceneComponent implements ISceneComponent {
  59589. /**
  59590. * The component name helpful to identify the component in the list of scene components.
  59591. */
  59592. readonly name: string;
  59593. /**
  59594. * The scene the component belongs to.
  59595. */
  59596. scene: Scene;
  59597. /**
  59598. * Creates a new instance of the component for the given scene
  59599. * @param scene Defines the scene to register the component in
  59600. */
  59601. constructor(scene: Scene);
  59602. /**
  59603. * Registers the component in a given scene
  59604. */
  59605. register(): void;
  59606. /**
  59607. * Rebuilds the elements related to this component in case of
  59608. * context lost for instance.
  59609. */
  59610. rebuild(): void;
  59611. /**
  59612. * Disposes the component and the associated ressources
  59613. */
  59614. dispose(): void;
  59615. }
  59616. }
  59617. declare module "babylonjs/Physics/physicsHelper" {
  59618. import { Nullable } from "babylonjs/types";
  59619. import { Vector3 } from "babylonjs/Maths/math.vector";
  59620. import { Mesh } from "babylonjs/Meshes/mesh";
  59621. import { Scene } from "babylonjs/scene";
  59622. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  59623. /**
  59624. * A helper for physics simulations
  59625. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59626. */
  59627. export class PhysicsHelper {
  59628. private _scene;
  59629. private _physicsEngine;
  59630. /**
  59631. * Initializes the Physics helper
  59632. * @param scene Babylon.js scene
  59633. */
  59634. constructor(scene: Scene);
  59635. /**
  59636. * Applies a radial explosion impulse
  59637. * @param origin the origin of the explosion
  59638. * @param radiusOrEventOptions the radius or the options of radial explosion
  59639. * @param strength the explosion strength
  59640. * @param falloff possible options: Constant & Linear. Defaults to Constant
  59641. * @returns A physics radial explosion event, or null
  59642. */
  59643. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  59644. /**
  59645. * Applies a radial explosion force
  59646. * @param origin the origin of the explosion
  59647. * @param radiusOrEventOptions the radius or the options of radial explosion
  59648. * @param strength the explosion strength
  59649. * @param falloff possible options: Constant & Linear. Defaults to Constant
  59650. * @returns A physics radial explosion event, or null
  59651. */
  59652. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  59653. /**
  59654. * Creates a gravitational field
  59655. * @param origin the origin of the explosion
  59656. * @param radiusOrEventOptions the radius or the options of radial explosion
  59657. * @param strength the explosion strength
  59658. * @param falloff possible options: Constant & Linear. Defaults to Constant
  59659. * @returns A physics gravitational field event, or null
  59660. */
  59661. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  59662. /**
  59663. * Creates a physics updraft event
  59664. * @param origin the origin of the updraft
  59665. * @param radiusOrEventOptions the radius or the options of the updraft
  59666. * @param strength the strength of the updraft
  59667. * @param height the height of the updraft
  59668. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  59669. * @returns A physics updraft event, or null
  59670. */
  59671. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  59672. /**
  59673. * Creates a physics vortex event
  59674. * @param origin the of the vortex
  59675. * @param radiusOrEventOptions the radius or the options of the vortex
  59676. * @param strength the strength of the vortex
  59677. * @param height the height of the vortex
  59678. * @returns a Physics vortex event, or null
  59679. * A physics vortex event or null
  59680. */
  59681. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  59682. }
  59683. /**
  59684. * Represents a physics radial explosion event
  59685. */
  59686. class PhysicsRadialExplosionEvent {
  59687. private _scene;
  59688. private _options;
  59689. private _sphere;
  59690. private _dataFetched;
  59691. /**
  59692. * Initializes a radial explosioin event
  59693. * @param _scene BabylonJS scene
  59694. * @param _options The options for the vortex event
  59695. */
  59696. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  59697. /**
  59698. * Returns the data related to the radial explosion event (sphere).
  59699. * @returns The radial explosion event data
  59700. */
  59701. getData(): PhysicsRadialExplosionEventData;
  59702. /**
  59703. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  59704. * @param impostor A physics imposter
  59705. * @param origin the origin of the explosion
  59706. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  59707. */
  59708. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  59709. /**
  59710. * Triggers affecterd impostors callbacks
  59711. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  59712. */
  59713. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  59714. /**
  59715. * Disposes the sphere.
  59716. * @param force Specifies if the sphere should be disposed by force
  59717. */
  59718. dispose(force?: boolean): void;
  59719. /*** Helpers ***/
  59720. private _prepareSphere;
  59721. private _intersectsWithSphere;
  59722. }
  59723. /**
  59724. * Represents a gravitational field event
  59725. */
  59726. class PhysicsGravitationalFieldEvent {
  59727. private _physicsHelper;
  59728. private _scene;
  59729. private _origin;
  59730. private _options;
  59731. private _tickCallback;
  59732. private _sphere;
  59733. private _dataFetched;
  59734. /**
  59735. * Initializes the physics gravitational field event
  59736. * @param _physicsHelper A physics helper
  59737. * @param _scene BabylonJS scene
  59738. * @param _origin The origin position of the gravitational field event
  59739. * @param _options The options for the vortex event
  59740. */
  59741. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  59742. /**
  59743. * Returns the data related to the gravitational field event (sphere).
  59744. * @returns A gravitational field event
  59745. */
  59746. getData(): PhysicsGravitationalFieldEventData;
  59747. /**
  59748. * Enables the gravitational field.
  59749. */
  59750. enable(): void;
  59751. /**
  59752. * Disables the gravitational field.
  59753. */
  59754. disable(): void;
  59755. /**
  59756. * Disposes the sphere.
  59757. * @param force The force to dispose from the gravitational field event
  59758. */
  59759. dispose(force?: boolean): void;
  59760. private _tick;
  59761. }
  59762. /**
  59763. * Represents a physics updraft event
  59764. */
  59765. class PhysicsUpdraftEvent {
  59766. private _scene;
  59767. private _origin;
  59768. private _options;
  59769. private _physicsEngine;
  59770. private _originTop;
  59771. private _originDirection;
  59772. private _tickCallback;
  59773. private _cylinder;
  59774. private _cylinderPosition;
  59775. private _dataFetched;
  59776. /**
  59777. * Initializes the physics updraft event
  59778. * @param _scene BabylonJS scene
  59779. * @param _origin The origin position of the updraft
  59780. * @param _options The options for the updraft event
  59781. */
  59782. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  59783. /**
  59784. * Returns the data related to the updraft event (cylinder).
  59785. * @returns A physics updraft event
  59786. */
  59787. getData(): PhysicsUpdraftEventData;
  59788. /**
  59789. * Enables the updraft.
  59790. */
  59791. enable(): void;
  59792. /**
  59793. * Disables the updraft.
  59794. */
  59795. disable(): void;
  59796. /**
  59797. * Disposes the cylinder.
  59798. * @param force Specifies if the updraft should be disposed by force
  59799. */
  59800. dispose(force?: boolean): void;
  59801. private getImpostorHitData;
  59802. private _tick;
  59803. /*** Helpers ***/
  59804. private _prepareCylinder;
  59805. private _intersectsWithCylinder;
  59806. }
  59807. /**
  59808. * Represents a physics vortex event
  59809. */
  59810. class PhysicsVortexEvent {
  59811. private _scene;
  59812. private _origin;
  59813. private _options;
  59814. private _physicsEngine;
  59815. private _originTop;
  59816. private _tickCallback;
  59817. private _cylinder;
  59818. private _cylinderPosition;
  59819. private _dataFetched;
  59820. /**
  59821. * Initializes the physics vortex event
  59822. * @param _scene The BabylonJS scene
  59823. * @param _origin The origin position of the vortex
  59824. * @param _options The options for the vortex event
  59825. */
  59826. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  59827. /**
  59828. * Returns the data related to the vortex event (cylinder).
  59829. * @returns The physics vortex event data
  59830. */
  59831. getData(): PhysicsVortexEventData;
  59832. /**
  59833. * Enables the vortex.
  59834. */
  59835. enable(): void;
  59836. /**
  59837. * Disables the cortex.
  59838. */
  59839. disable(): void;
  59840. /**
  59841. * Disposes the sphere.
  59842. * @param force
  59843. */
  59844. dispose(force?: boolean): void;
  59845. private getImpostorHitData;
  59846. private _tick;
  59847. /*** Helpers ***/
  59848. private _prepareCylinder;
  59849. private _intersectsWithCylinder;
  59850. }
  59851. /**
  59852. * Options fot the radial explosion event
  59853. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59854. */
  59855. export class PhysicsRadialExplosionEventOptions {
  59856. /**
  59857. * The radius of the sphere for the radial explosion.
  59858. */
  59859. radius: number;
  59860. /**
  59861. * The strenth of the explosion.
  59862. */
  59863. strength: number;
  59864. /**
  59865. * The strenght of the force in correspondence to the distance of the affected object
  59866. */
  59867. falloff: PhysicsRadialImpulseFalloff;
  59868. /**
  59869. * Sphere options for the radial explosion.
  59870. */
  59871. sphere: {
  59872. segments: number;
  59873. diameter: number;
  59874. };
  59875. /**
  59876. * Sphere options for the radial explosion.
  59877. */
  59878. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  59879. }
  59880. /**
  59881. * Options fot the updraft event
  59882. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59883. */
  59884. export class PhysicsUpdraftEventOptions {
  59885. /**
  59886. * The radius of the cylinder for the vortex
  59887. */
  59888. radius: number;
  59889. /**
  59890. * The strenth of the updraft.
  59891. */
  59892. strength: number;
  59893. /**
  59894. * The height of the cylinder for the updraft.
  59895. */
  59896. height: number;
  59897. /**
  59898. * The mode for the the updraft.
  59899. */
  59900. updraftMode: PhysicsUpdraftMode;
  59901. }
  59902. /**
  59903. * Options fot the vortex event
  59904. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59905. */
  59906. export class PhysicsVortexEventOptions {
  59907. /**
  59908. * The radius of the cylinder for the vortex
  59909. */
  59910. radius: number;
  59911. /**
  59912. * The strenth of the vortex.
  59913. */
  59914. strength: number;
  59915. /**
  59916. * The height of the cylinder for the vortex.
  59917. */
  59918. height: number;
  59919. /**
  59920. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  59921. */
  59922. centripetalForceThreshold: number;
  59923. /**
  59924. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  59925. */
  59926. centripetalForceMultiplier: number;
  59927. /**
  59928. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  59929. */
  59930. centrifugalForceMultiplier: number;
  59931. /**
  59932. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  59933. */
  59934. updraftForceMultiplier: number;
  59935. }
  59936. /**
  59937. * The strenght of the force in correspondence to the distance of the affected object
  59938. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59939. */
  59940. export enum PhysicsRadialImpulseFalloff {
  59941. /** Defines that impulse is constant in strength across it's whole radius */
  59942. Constant = 0,
  59943. /** Defines that impulse gets weaker if it's further from the origin */
  59944. Linear = 1
  59945. }
  59946. /**
  59947. * The strength of the force in correspondence to the distance of the affected object
  59948. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59949. */
  59950. export enum PhysicsUpdraftMode {
  59951. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  59952. Center = 0,
  59953. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  59954. Perpendicular = 1
  59955. }
  59956. /**
  59957. * Interface for a physics hit data
  59958. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59959. */
  59960. export interface PhysicsHitData {
  59961. /**
  59962. * The force applied at the contact point
  59963. */
  59964. force: Vector3;
  59965. /**
  59966. * The contact point
  59967. */
  59968. contactPoint: Vector3;
  59969. /**
  59970. * The distance from the origin to the contact point
  59971. */
  59972. distanceFromOrigin: number;
  59973. }
  59974. /**
  59975. * Interface for radial explosion event data
  59976. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59977. */
  59978. export interface PhysicsRadialExplosionEventData {
  59979. /**
  59980. * A sphere used for the radial explosion event
  59981. */
  59982. sphere: Mesh;
  59983. }
  59984. /**
  59985. * Interface for gravitational field event data
  59986. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59987. */
  59988. export interface PhysicsGravitationalFieldEventData {
  59989. /**
  59990. * A sphere mesh used for the gravitational field event
  59991. */
  59992. sphere: Mesh;
  59993. }
  59994. /**
  59995. * Interface for updraft event data
  59996. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59997. */
  59998. export interface PhysicsUpdraftEventData {
  59999. /**
  60000. * A cylinder used for the updraft event
  60001. */
  60002. cylinder: Mesh;
  60003. }
  60004. /**
  60005. * Interface for vortex event data
  60006. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60007. */
  60008. export interface PhysicsVortexEventData {
  60009. /**
  60010. * A cylinder used for the vortex event
  60011. */
  60012. cylinder: Mesh;
  60013. }
  60014. /**
  60015. * Interface for an affected physics impostor
  60016. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60017. */
  60018. export interface PhysicsAffectedImpostorWithData {
  60019. /**
  60020. * The impostor affected by the effect
  60021. */
  60022. impostor: PhysicsImpostor;
  60023. /**
  60024. * The data about the hit/horce from the explosion
  60025. */
  60026. hitData: PhysicsHitData;
  60027. }
  60028. }
  60029. declare module "babylonjs/Physics/Plugins/index" {
  60030. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  60031. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  60032. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  60033. }
  60034. declare module "babylonjs/Physics/index" {
  60035. export * from "babylonjs/Physics/IPhysicsEngine";
  60036. export * from "babylonjs/Physics/physicsEngine";
  60037. export * from "babylonjs/Physics/physicsEngineComponent";
  60038. export * from "babylonjs/Physics/physicsHelper";
  60039. export * from "babylonjs/Physics/physicsImpostor";
  60040. export * from "babylonjs/Physics/physicsJoint";
  60041. export * from "babylonjs/Physics/Plugins/index";
  60042. }
  60043. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  60044. /** @hidden */
  60045. export var blackAndWhitePixelShader: {
  60046. name: string;
  60047. shader: string;
  60048. };
  60049. }
  60050. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  60051. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60052. import { Camera } from "babylonjs/Cameras/camera";
  60053. import { Engine } from "babylonjs/Engines/engine";
  60054. import "babylonjs/Shaders/blackAndWhite.fragment";
  60055. /**
  60056. * Post process used to render in black and white
  60057. */
  60058. export class BlackAndWhitePostProcess extends PostProcess {
  60059. /**
  60060. * Linear about to convert he result to black and white (default: 1)
  60061. */
  60062. degree: number;
  60063. /**
  60064. * Creates a black and white post process
  60065. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  60066. * @param name The name of the effect.
  60067. * @param options The required width/height ratio to downsize to before computing the render pass.
  60068. * @param camera The camera to apply the render pass to.
  60069. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60070. * @param engine The engine which the post process will be applied. (default: current engine)
  60071. * @param reusable If the post process can be reused on the same frame. (default: false)
  60072. */
  60073. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60074. }
  60075. }
  60076. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  60077. import { Nullable } from "babylonjs/types";
  60078. import { Camera } from "babylonjs/Cameras/camera";
  60079. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60080. import { Engine } from "babylonjs/Engines/engine";
  60081. /**
  60082. * This represents a set of one or more post processes in Babylon.
  60083. * A post process can be used to apply a shader to a texture after it is rendered.
  60084. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60085. */
  60086. export class PostProcessRenderEffect {
  60087. private _postProcesses;
  60088. private _getPostProcesses;
  60089. private _singleInstance;
  60090. private _cameras;
  60091. private _indicesForCamera;
  60092. /**
  60093. * Name of the effect
  60094. * @hidden
  60095. */
  60096. _name: string;
  60097. /**
  60098. * Instantiates a post process render effect.
  60099. * A post process can be used to apply a shader to a texture after it is rendered.
  60100. * @param engine The engine the effect is tied to
  60101. * @param name The name of the effect
  60102. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  60103. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  60104. */
  60105. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  60106. /**
  60107. * Checks if all the post processes in the effect are supported.
  60108. */
  60109. readonly isSupported: boolean;
  60110. /**
  60111. * Updates the current state of the effect
  60112. * @hidden
  60113. */
  60114. _update(): void;
  60115. /**
  60116. * Attaches the effect on cameras
  60117. * @param cameras The camera to attach to.
  60118. * @hidden
  60119. */
  60120. _attachCameras(cameras: Camera): void;
  60121. /**
  60122. * Attaches the effect on cameras
  60123. * @param cameras The camera to attach to.
  60124. * @hidden
  60125. */
  60126. _attachCameras(cameras: Camera[]): void;
  60127. /**
  60128. * Detaches the effect on cameras
  60129. * @param cameras The camera to detatch from.
  60130. * @hidden
  60131. */
  60132. _detachCameras(cameras: Camera): void;
  60133. /**
  60134. * Detatches the effect on cameras
  60135. * @param cameras The camera to detatch from.
  60136. * @hidden
  60137. */
  60138. _detachCameras(cameras: Camera[]): void;
  60139. /**
  60140. * Enables the effect on given cameras
  60141. * @param cameras The camera to enable.
  60142. * @hidden
  60143. */
  60144. _enable(cameras: Camera): void;
  60145. /**
  60146. * Enables the effect on given cameras
  60147. * @param cameras The camera to enable.
  60148. * @hidden
  60149. */
  60150. _enable(cameras: Nullable<Camera[]>): void;
  60151. /**
  60152. * Disables the effect on the given cameras
  60153. * @param cameras The camera to disable.
  60154. * @hidden
  60155. */
  60156. _disable(cameras: Camera): void;
  60157. /**
  60158. * Disables the effect on the given cameras
  60159. * @param cameras The camera to disable.
  60160. * @hidden
  60161. */
  60162. _disable(cameras: Nullable<Camera[]>): void;
  60163. /**
  60164. * Gets a list of the post processes contained in the effect.
  60165. * @param camera The camera to get the post processes on.
  60166. * @returns The list of the post processes in the effect.
  60167. */
  60168. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  60169. }
  60170. }
  60171. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  60172. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60173. /** @hidden */
  60174. export var extractHighlightsPixelShader: {
  60175. name: string;
  60176. shader: string;
  60177. };
  60178. }
  60179. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  60180. import { Nullable } from "babylonjs/types";
  60181. import { Camera } from "babylonjs/Cameras/camera";
  60182. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60183. import { Engine } from "babylonjs/Engines/engine";
  60184. import "babylonjs/Shaders/extractHighlights.fragment";
  60185. /**
  60186. * 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.
  60187. */
  60188. export class ExtractHighlightsPostProcess extends PostProcess {
  60189. /**
  60190. * The luminance threshold, pixels below this value will be set to black.
  60191. */
  60192. threshold: number;
  60193. /** @hidden */
  60194. _exposure: number;
  60195. /**
  60196. * Post process which has the input texture to be used when performing highlight extraction
  60197. * @hidden
  60198. */
  60199. _inputPostProcess: Nullable<PostProcess>;
  60200. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60201. }
  60202. }
  60203. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  60204. /** @hidden */
  60205. export var bloomMergePixelShader: {
  60206. name: string;
  60207. shader: string;
  60208. };
  60209. }
  60210. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  60211. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60212. import { Nullable } from "babylonjs/types";
  60213. import { Engine } from "babylonjs/Engines/engine";
  60214. import { Camera } from "babylonjs/Cameras/camera";
  60215. import "babylonjs/Shaders/bloomMerge.fragment";
  60216. /**
  60217. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  60218. */
  60219. export class BloomMergePostProcess extends PostProcess {
  60220. /** Weight of the bloom to be added to the original input. */
  60221. weight: number;
  60222. /**
  60223. * Creates a new instance of @see BloomMergePostProcess
  60224. * @param name The name of the effect.
  60225. * @param originalFromInput Post process which's input will be used for the merge.
  60226. * @param blurred Blurred highlights post process which's output will be used.
  60227. * @param weight Weight of the bloom to be added to the original input.
  60228. * @param options The required width/height ratio to downsize to before computing the render pass.
  60229. * @param camera The camera to apply the render pass to.
  60230. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60231. * @param engine The engine which the post process will be applied. (default: current engine)
  60232. * @param reusable If the post process can be reused on the same frame. (default: false)
  60233. * @param textureType Type of textures used when performing the post process. (default: 0)
  60234. * @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)
  60235. */
  60236. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  60237. /** Weight of the bloom to be added to the original input. */
  60238. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60239. }
  60240. }
  60241. declare module "babylonjs/PostProcesses/bloomEffect" {
  60242. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  60243. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60244. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  60245. import { Camera } from "babylonjs/Cameras/camera";
  60246. import { Scene } from "babylonjs/scene";
  60247. /**
  60248. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  60249. */
  60250. export class BloomEffect extends PostProcessRenderEffect {
  60251. private bloomScale;
  60252. /**
  60253. * @hidden Internal
  60254. */
  60255. _effects: Array<PostProcess>;
  60256. /**
  60257. * @hidden Internal
  60258. */
  60259. _downscale: ExtractHighlightsPostProcess;
  60260. private _blurX;
  60261. private _blurY;
  60262. private _merge;
  60263. /**
  60264. * The luminance threshold to find bright areas of the image to bloom.
  60265. */
  60266. threshold: number;
  60267. /**
  60268. * The strength of the bloom.
  60269. */
  60270. weight: number;
  60271. /**
  60272. * Specifies the size of the bloom blur kernel, relative to the final output size
  60273. */
  60274. kernel: number;
  60275. /**
  60276. * Creates a new instance of @see BloomEffect
  60277. * @param scene The scene the effect belongs to.
  60278. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  60279. * @param bloomKernel The size of the kernel to be used when applying the blur.
  60280. * @param bloomWeight The the strength of bloom.
  60281. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  60282. * @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)
  60283. */
  60284. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  60285. /**
  60286. * Disposes each of the internal effects for a given camera.
  60287. * @param camera The camera to dispose the effect on.
  60288. */
  60289. disposeEffects(camera: Camera): void;
  60290. /**
  60291. * @hidden Internal
  60292. */
  60293. _updateEffects(): void;
  60294. /**
  60295. * Internal
  60296. * @returns if all the contained post processes are ready.
  60297. * @hidden
  60298. */
  60299. _isReady(): boolean;
  60300. }
  60301. }
  60302. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  60303. /** @hidden */
  60304. export var chromaticAberrationPixelShader: {
  60305. name: string;
  60306. shader: string;
  60307. };
  60308. }
  60309. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  60310. import { Vector2 } from "babylonjs/Maths/math.vector";
  60311. import { Nullable } from "babylonjs/types";
  60312. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60313. import { Camera } from "babylonjs/Cameras/camera";
  60314. import { Engine } from "babylonjs/Engines/engine";
  60315. import "babylonjs/Shaders/chromaticAberration.fragment";
  60316. /**
  60317. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  60318. */
  60319. export class ChromaticAberrationPostProcess extends PostProcess {
  60320. /**
  60321. * The amount of seperation of rgb channels (default: 30)
  60322. */
  60323. aberrationAmount: number;
  60324. /**
  60325. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  60326. */
  60327. radialIntensity: number;
  60328. /**
  60329. * 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))
  60330. */
  60331. direction: Vector2;
  60332. /**
  60333. * 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))
  60334. */
  60335. centerPosition: Vector2;
  60336. /**
  60337. * Creates a new instance ChromaticAberrationPostProcess
  60338. * @param name The name of the effect.
  60339. * @param screenWidth The width of the screen to apply the effect on.
  60340. * @param screenHeight The height of the screen to apply the effect on.
  60341. * @param options The required width/height ratio to downsize to before computing the render pass.
  60342. * @param camera The camera to apply the render pass to.
  60343. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60344. * @param engine The engine which the post process will be applied. (default: current engine)
  60345. * @param reusable If the post process can be reused on the same frame. (default: false)
  60346. * @param textureType Type of textures used when performing the post process. (default: 0)
  60347. * @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)
  60348. */
  60349. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60350. }
  60351. }
  60352. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  60353. /** @hidden */
  60354. export var circleOfConfusionPixelShader: {
  60355. name: string;
  60356. shader: string;
  60357. };
  60358. }
  60359. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  60360. import { Nullable } from "babylonjs/types";
  60361. import { Engine } from "babylonjs/Engines/engine";
  60362. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60363. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60364. import { Camera } from "babylonjs/Cameras/camera";
  60365. import "babylonjs/Shaders/circleOfConfusion.fragment";
  60366. /**
  60367. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  60368. */
  60369. export class CircleOfConfusionPostProcess extends PostProcess {
  60370. /**
  60371. * 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.
  60372. */
  60373. lensSize: number;
  60374. /**
  60375. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  60376. */
  60377. fStop: number;
  60378. /**
  60379. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  60380. */
  60381. focusDistance: number;
  60382. /**
  60383. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  60384. */
  60385. focalLength: number;
  60386. private _depthTexture;
  60387. /**
  60388. * Creates a new instance CircleOfConfusionPostProcess
  60389. * @param name The name of the effect.
  60390. * @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.
  60391. * @param options The required width/height ratio to downsize to before computing the render pass.
  60392. * @param camera The camera to apply the render pass to.
  60393. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60394. * @param engine The engine which the post process will be applied. (default: current engine)
  60395. * @param reusable If the post process can be reused on the same frame. (default: false)
  60396. * @param textureType Type of textures used when performing the post process. (default: 0)
  60397. * @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)
  60398. */
  60399. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60400. /**
  60401. * 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.
  60402. */
  60403. depthTexture: RenderTargetTexture;
  60404. }
  60405. }
  60406. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  60407. /** @hidden */
  60408. export var colorCorrectionPixelShader: {
  60409. name: string;
  60410. shader: string;
  60411. };
  60412. }
  60413. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  60414. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60415. import { Engine } from "babylonjs/Engines/engine";
  60416. import { Camera } from "babylonjs/Cameras/camera";
  60417. import "babylonjs/Shaders/colorCorrection.fragment";
  60418. /**
  60419. *
  60420. * This post-process allows the modification of rendered colors by using
  60421. * a 'look-up table' (LUT). This effect is also called Color Grading.
  60422. *
  60423. * The object needs to be provided an url to a texture containing the color
  60424. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  60425. * Use an image editing software to tweak the LUT to match your needs.
  60426. *
  60427. * For an example of a color LUT, see here:
  60428. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  60429. * For explanations on color grading, see here:
  60430. * @see http://udn.epicgames.com/Three/ColorGrading.html
  60431. *
  60432. */
  60433. export class ColorCorrectionPostProcess extends PostProcess {
  60434. private _colorTableTexture;
  60435. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60436. }
  60437. }
  60438. declare module "babylonjs/Shaders/convolution.fragment" {
  60439. /** @hidden */
  60440. export var convolutionPixelShader: {
  60441. name: string;
  60442. shader: string;
  60443. };
  60444. }
  60445. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  60446. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60447. import { Nullable } from "babylonjs/types";
  60448. import { Camera } from "babylonjs/Cameras/camera";
  60449. import { Engine } from "babylonjs/Engines/engine";
  60450. import "babylonjs/Shaders/convolution.fragment";
  60451. /**
  60452. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  60453. * input texture to perform effects such as edge detection or sharpening
  60454. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  60455. */
  60456. export class ConvolutionPostProcess extends PostProcess {
  60457. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  60458. kernel: number[];
  60459. /**
  60460. * Creates a new instance ConvolutionPostProcess
  60461. * @param name The name of the effect.
  60462. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  60463. * @param options The required width/height ratio to downsize to before computing the render pass.
  60464. * @param camera The camera to apply the render pass to.
  60465. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60466. * @param engine The engine which the post process will be applied. (default: current engine)
  60467. * @param reusable If the post process can be reused on the same frame. (default: false)
  60468. * @param textureType Type of textures used when performing the post process. (default: 0)
  60469. */
  60470. constructor(name: string,
  60471. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  60472. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  60473. /**
  60474. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60475. */
  60476. static EdgeDetect0Kernel: number[];
  60477. /**
  60478. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60479. */
  60480. static EdgeDetect1Kernel: number[];
  60481. /**
  60482. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60483. */
  60484. static EdgeDetect2Kernel: number[];
  60485. /**
  60486. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60487. */
  60488. static SharpenKernel: number[];
  60489. /**
  60490. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60491. */
  60492. static EmbossKernel: number[];
  60493. /**
  60494. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60495. */
  60496. static GaussianKernel: number[];
  60497. }
  60498. }
  60499. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  60500. import { Nullable } from "babylonjs/types";
  60501. import { Vector2 } from "babylonjs/Maths/math.vector";
  60502. import { Camera } from "babylonjs/Cameras/camera";
  60503. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60504. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  60505. import { Engine } from "babylonjs/Engines/engine";
  60506. import { Scene } from "babylonjs/scene";
  60507. /**
  60508. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  60509. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  60510. * based on samples that have a large difference in distance than the center pixel.
  60511. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  60512. */
  60513. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  60514. direction: Vector2;
  60515. /**
  60516. * Creates a new instance CircleOfConfusionPostProcess
  60517. * @param name The name of the effect.
  60518. * @param scene The scene the effect belongs to.
  60519. * @param direction The direction the blur should be applied.
  60520. * @param kernel The size of the kernel used to blur.
  60521. * @param options The required width/height ratio to downsize to before computing the render pass.
  60522. * @param camera The camera to apply the render pass to.
  60523. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  60524. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  60525. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60526. * @param engine The engine which the post process will be applied. (default: current engine)
  60527. * @param reusable If the post process can be reused on the same frame. (default: false)
  60528. * @param textureType Type of textures used when performing the post process. (default: 0)
  60529. * @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)
  60530. */
  60531. 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);
  60532. }
  60533. }
  60534. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  60535. /** @hidden */
  60536. export var depthOfFieldMergePixelShader: {
  60537. name: string;
  60538. shader: string;
  60539. };
  60540. }
  60541. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  60542. import { Nullable } from "babylonjs/types";
  60543. import { Camera } from "babylonjs/Cameras/camera";
  60544. import { Effect } from "babylonjs/Materials/effect";
  60545. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60546. import { Engine } from "babylonjs/Engines/engine";
  60547. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  60548. /**
  60549. * Options to be set when merging outputs from the default pipeline.
  60550. */
  60551. export class DepthOfFieldMergePostProcessOptions {
  60552. /**
  60553. * The original image to merge on top of
  60554. */
  60555. originalFromInput: PostProcess;
  60556. /**
  60557. * Parameters to perform the merge of the depth of field effect
  60558. */
  60559. depthOfField?: {
  60560. circleOfConfusion: PostProcess;
  60561. blurSteps: Array<PostProcess>;
  60562. };
  60563. /**
  60564. * Parameters to perform the merge of bloom effect
  60565. */
  60566. bloom?: {
  60567. blurred: PostProcess;
  60568. weight: number;
  60569. };
  60570. }
  60571. /**
  60572. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  60573. */
  60574. export class DepthOfFieldMergePostProcess extends PostProcess {
  60575. private blurSteps;
  60576. /**
  60577. * Creates a new instance of DepthOfFieldMergePostProcess
  60578. * @param name The name of the effect.
  60579. * @param originalFromInput Post process which's input will be used for the merge.
  60580. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  60581. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  60582. * @param options The required width/height ratio to downsize to before computing the render pass.
  60583. * @param camera The camera to apply the render pass to.
  60584. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60585. * @param engine The engine which the post process will be applied. (default: current engine)
  60586. * @param reusable If the post process can be reused on the same frame. (default: false)
  60587. * @param textureType Type of textures used when performing the post process. (default: 0)
  60588. * @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)
  60589. */
  60590. 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);
  60591. /**
  60592. * Updates the effect with the current post process compile time values and recompiles the shader.
  60593. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  60594. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  60595. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  60596. * @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
  60597. * @param onCompiled Called when the shader has been compiled.
  60598. * @param onError Called if there is an error when compiling a shader.
  60599. */
  60600. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  60601. }
  60602. }
  60603. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  60604. import { Nullable } from "babylonjs/types";
  60605. import { Camera } from "babylonjs/Cameras/camera";
  60606. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60607. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60608. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  60609. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  60610. import { Scene } from "babylonjs/scene";
  60611. /**
  60612. * Specifies the level of max blur that should be applied when using the depth of field effect
  60613. */
  60614. export enum DepthOfFieldEffectBlurLevel {
  60615. /**
  60616. * Subtle blur
  60617. */
  60618. Low = 0,
  60619. /**
  60620. * Medium blur
  60621. */
  60622. Medium = 1,
  60623. /**
  60624. * Large blur
  60625. */
  60626. High = 2
  60627. }
  60628. /**
  60629. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  60630. */
  60631. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  60632. private _circleOfConfusion;
  60633. /**
  60634. * @hidden Internal, blurs from high to low
  60635. */
  60636. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  60637. private _depthOfFieldBlurY;
  60638. private _dofMerge;
  60639. /**
  60640. * @hidden Internal post processes in depth of field effect
  60641. */
  60642. _effects: Array<PostProcess>;
  60643. /**
  60644. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  60645. */
  60646. focalLength: number;
  60647. /**
  60648. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  60649. */
  60650. fStop: number;
  60651. /**
  60652. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  60653. */
  60654. focusDistance: number;
  60655. /**
  60656. * 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.
  60657. */
  60658. lensSize: number;
  60659. /**
  60660. * Creates a new instance DepthOfFieldEffect
  60661. * @param scene The scene the effect belongs to.
  60662. * @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.
  60663. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  60664. * @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)
  60665. */
  60666. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  60667. /**
  60668. * Get the current class name of the current effet
  60669. * @returns "DepthOfFieldEffect"
  60670. */
  60671. getClassName(): string;
  60672. /**
  60673. * 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.
  60674. */
  60675. depthTexture: RenderTargetTexture;
  60676. /**
  60677. * Disposes each of the internal effects for a given camera.
  60678. * @param camera The camera to dispose the effect on.
  60679. */
  60680. disposeEffects(camera: Camera): void;
  60681. /**
  60682. * @hidden Internal
  60683. */
  60684. _updateEffects(): void;
  60685. /**
  60686. * Internal
  60687. * @returns if all the contained post processes are ready.
  60688. * @hidden
  60689. */
  60690. _isReady(): boolean;
  60691. }
  60692. }
  60693. declare module "babylonjs/Shaders/displayPass.fragment" {
  60694. /** @hidden */
  60695. export var displayPassPixelShader: {
  60696. name: string;
  60697. shader: string;
  60698. };
  60699. }
  60700. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  60701. import { Nullable } from "babylonjs/types";
  60702. import { Camera } from "babylonjs/Cameras/camera";
  60703. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60704. import { Engine } from "babylonjs/Engines/engine";
  60705. import "babylonjs/Shaders/displayPass.fragment";
  60706. /**
  60707. * DisplayPassPostProcess which produces an output the same as it's input
  60708. */
  60709. export class DisplayPassPostProcess extends PostProcess {
  60710. /**
  60711. * Creates the DisplayPassPostProcess
  60712. * @param name The name of the effect.
  60713. * @param options The required width/height ratio to downsize to before computing the render pass.
  60714. * @param camera The camera to apply the render pass to.
  60715. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60716. * @param engine The engine which the post process will be applied. (default: current engine)
  60717. * @param reusable If the post process can be reused on the same frame. (default: false)
  60718. */
  60719. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60720. }
  60721. }
  60722. declare module "babylonjs/Shaders/filter.fragment" {
  60723. /** @hidden */
  60724. export var filterPixelShader: {
  60725. name: string;
  60726. shader: string;
  60727. };
  60728. }
  60729. declare module "babylonjs/PostProcesses/filterPostProcess" {
  60730. import { Nullable } from "babylonjs/types";
  60731. import { Matrix } from "babylonjs/Maths/math.vector";
  60732. import { Camera } from "babylonjs/Cameras/camera";
  60733. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60734. import { Engine } from "babylonjs/Engines/engine";
  60735. import "babylonjs/Shaders/filter.fragment";
  60736. /**
  60737. * Applies a kernel filter to the image
  60738. */
  60739. export class FilterPostProcess extends PostProcess {
  60740. /** The matrix to be applied to the image */
  60741. kernelMatrix: Matrix;
  60742. /**
  60743. *
  60744. * @param name The name of the effect.
  60745. * @param kernelMatrix The matrix to be applied to the image
  60746. * @param options The required width/height ratio to downsize to before computing the render pass.
  60747. * @param camera The camera to apply the render pass to.
  60748. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60749. * @param engine The engine which the post process will be applied. (default: current engine)
  60750. * @param reusable If the post process can be reused on the same frame. (default: false)
  60751. */
  60752. constructor(name: string,
  60753. /** The matrix to be applied to the image */
  60754. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60755. }
  60756. }
  60757. declare module "babylonjs/Shaders/fxaa.fragment" {
  60758. /** @hidden */
  60759. export var fxaaPixelShader: {
  60760. name: string;
  60761. shader: string;
  60762. };
  60763. }
  60764. declare module "babylonjs/Shaders/fxaa.vertex" {
  60765. /** @hidden */
  60766. export var fxaaVertexShader: {
  60767. name: string;
  60768. shader: string;
  60769. };
  60770. }
  60771. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  60772. import { Nullable } from "babylonjs/types";
  60773. import { Camera } from "babylonjs/Cameras/camera";
  60774. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60775. import { Engine } from "babylonjs/Engines/engine";
  60776. import "babylonjs/Shaders/fxaa.fragment";
  60777. import "babylonjs/Shaders/fxaa.vertex";
  60778. /**
  60779. * Fxaa post process
  60780. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  60781. */
  60782. export class FxaaPostProcess extends PostProcess {
  60783. /** @hidden */
  60784. texelWidth: number;
  60785. /** @hidden */
  60786. texelHeight: number;
  60787. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  60788. private _getDefines;
  60789. }
  60790. }
  60791. declare module "babylonjs/Shaders/grain.fragment" {
  60792. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60793. /** @hidden */
  60794. export var grainPixelShader: {
  60795. name: string;
  60796. shader: string;
  60797. };
  60798. }
  60799. declare module "babylonjs/PostProcesses/grainPostProcess" {
  60800. import { Nullable } from "babylonjs/types";
  60801. import { Camera } from "babylonjs/Cameras/camera";
  60802. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60803. import { Engine } from "babylonjs/Engines/engine";
  60804. import "babylonjs/Shaders/grain.fragment";
  60805. /**
  60806. * The GrainPostProcess adds noise to the image at mid luminance levels
  60807. */
  60808. export class GrainPostProcess extends PostProcess {
  60809. /**
  60810. * The intensity of the grain added (default: 30)
  60811. */
  60812. intensity: number;
  60813. /**
  60814. * If the grain should be randomized on every frame
  60815. */
  60816. animated: boolean;
  60817. /**
  60818. * Creates a new instance of @see GrainPostProcess
  60819. * @param name The name of the effect.
  60820. * @param options The required width/height ratio to downsize to before computing the render pass.
  60821. * @param camera The camera to apply the render pass to.
  60822. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60823. * @param engine The engine which the post process will be applied. (default: current engine)
  60824. * @param reusable If the post process can be reused on the same frame. (default: false)
  60825. * @param textureType Type of textures used when performing the post process. (default: 0)
  60826. * @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)
  60827. */
  60828. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60829. }
  60830. }
  60831. declare module "babylonjs/Shaders/highlights.fragment" {
  60832. /** @hidden */
  60833. export var highlightsPixelShader: {
  60834. name: string;
  60835. shader: string;
  60836. };
  60837. }
  60838. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  60839. import { Nullable } from "babylonjs/types";
  60840. import { Camera } from "babylonjs/Cameras/camera";
  60841. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60842. import { Engine } from "babylonjs/Engines/engine";
  60843. import "babylonjs/Shaders/highlights.fragment";
  60844. /**
  60845. * Extracts highlights from the image
  60846. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  60847. */
  60848. export class HighlightsPostProcess extends PostProcess {
  60849. /**
  60850. * Extracts highlights from the image
  60851. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  60852. * @param name The name of the effect.
  60853. * @param options The required width/height ratio to downsize to before computing the render pass.
  60854. * @param camera The camera to apply the render pass to.
  60855. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60856. * @param engine The engine which the post process will be applied. (default: current engine)
  60857. * @param reusable If the post process can be reused on the same frame. (default: false)
  60858. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  60859. */
  60860. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  60861. }
  60862. }
  60863. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  60864. /** @hidden */
  60865. export var mrtFragmentDeclaration: {
  60866. name: string;
  60867. shader: string;
  60868. };
  60869. }
  60870. declare module "babylonjs/Shaders/geometry.fragment" {
  60871. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  60872. /** @hidden */
  60873. export var geometryPixelShader: {
  60874. name: string;
  60875. shader: string;
  60876. };
  60877. }
  60878. declare module "babylonjs/Shaders/geometry.vertex" {
  60879. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60880. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60881. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60882. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60883. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60884. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60885. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60886. /** @hidden */
  60887. export var geometryVertexShader: {
  60888. name: string;
  60889. shader: string;
  60890. };
  60891. }
  60892. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  60893. import { Matrix } from "babylonjs/Maths/math.vector";
  60894. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60895. import { Mesh } from "babylonjs/Meshes/mesh";
  60896. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  60897. import { Effect } from "babylonjs/Materials/effect";
  60898. import { Scene } from "babylonjs/scene";
  60899. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60900. import "babylonjs/Shaders/geometry.fragment";
  60901. import "babylonjs/Shaders/geometry.vertex";
  60902. /** @hidden */
  60903. interface ISavedTransformationMatrix {
  60904. world: Matrix;
  60905. viewProjection: Matrix;
  60906. }
  60907. /**
  60908. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  60909. */
  60910. export class GeometryBufferRenderer {
  60911. /**
  60912. * Constant used to retrieve the position texture index in the G-Buffer textures array
  60913. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  60914. */
  60915. static readonly POSITION_TEXTURE_TYPE: number;
  60916. /**
  60917. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  60918. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  60919. */
  60920. static readonly VELOCITY_TEXTURE_TYPE: number;
  60921. /**
  60922. * Dictionary used to store the previous transformation matrices of each rendered mesh
  60923. * in order to compute objects velocities when enableVelocity is set to "true"
  60924. * @hidden
  60925. */
  60926. _previousTransformationMatrices: {
  60927. [index: number]: ISavedTransformationMatrix;
  60928. };
  60929. /**
  60930. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  60931. * in order to compute objects velocities when enableVelocity is set to "true"
  60932. * @hidden
  60933. */
  60934. _previousBonesTransformationMatrices: {
  60935. [index: number]: Float32Array;
  60936. };
  60937. /**
  60938. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  60939. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  60940. */
  60941. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  60942. private _scene;
  60943. private _multiRenderTarget;
  60944. private _ratio;
  60945. private _enablePosition;
  60946. private _enableVelocity;
  60947. private _positionIndex;
  60948. private _velocityIndex;
  60949. protected _effect: Effect;
  60950. protected _cachedDefines: string;
  60951. /**
  60952. * Set the render list (meshes to be rendered) used in the G buffer.
  60953. */
  60954. renderList: Mesh[];
  60955. /**
  60956. * Gets wether or not G buffer are supported by the running hardware.
  60957. * This requires draw buffer supports
  60958. */
  60959. readonly isSupported: boolean;
  60960. /**
  60961. * Returns the index of the given texture type in the G-Buffer textures array
  60962. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  60963. * @returns the index of the given texture type in the G-Buffer textures array
  60964. */
  60965. getTextureIndex(textureType: number): number;
  60966. /**
  60967. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  60968. */
  60969. /**
  60970. * Sets whether or not objects positions are enabled for the G buffer.
  60971. */
  60972. enablePosition: boolean;
  60973. /**
  60974. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  60975. */
  60976. /**
  60977. * Sets wether or not objects velocities are enabled for the G buffer.
  60978. */
  60979. enableVelocity: boolean;
  60980. /**
  60981. * Gets the scene associated with the buffer.
  60982. */
  60983. readonly scene: Scene;
  60984. /**
  60985. * Gets the ratio used by the buffer during its creation.
  60986. * How big is the buffer related to the main canvas.
  60987. */
  60988. readonly ratio: number;
  60989. /** @hidden */
  60990. static _SceneComponentInitialization: (scene: Scene) => void;
  60991. /**
  60992. * Creates a new G Buffer for the scene
  60993. * @param scene The scene the buffer belongs to
  60994. * @param ratio How big is the buffer related to the main canvas.
  60995. */
  60996. constructor(scene: Scene, ratio?: number);
  60997. /**
  60998. * Checks wether everything is ready to render a submesh to the G buffer.
  60999. * @param subMesh the submesh to check readiness for
  61000. * @param useInstances is the mesh drawn using instance or not
  61001. * @returns true if ready otherwise false
  61002. */
  61003. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61004. /**
  61005. * Gets the current underlying G Buffer.
  61006. * @returns the buffer
  61007. */
  61008. getGBuffer(): MultiRenderTarget;
  61009. /**
  61010. * Gets the number of samples used to render the buffer (anti aliasing).
  61011. */
  61012. /**
  61013. * Sets the number of samples used to render the buffer (anti aliasing).
  61014. */
  61015. samples: number;
  61016. /**
  61017. * Disposes the renderer and frees up associated resources.
  61018. */
  61019. dispose(): void;
  61020. protected _createRenderTargets(): void;
  61021. private _copyBonesTransformationMatrices;
  61022. }
  61023. }
  61024. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  61025. import { Nullable } from "babylonjs/types";
  61026. import { Scene } from "babylonjs/scene";
  61027. import { ISceneComponent } from "babylonjs/sceneComponent";
  61028. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  61029. module "babylonjs/scene" {
  61030. interface Scene {
  61031. /** @hidden (Backing field) */
  61032. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  61033. /**
  61034. * Gets or Sets the current geometry buffer associated to the scene.
  61035. */
  61036. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  61037. /**
  61038. * Enables a GeometryBufferRender and associates it with the scene
  61039. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  61040. * @returns the GeometryBufferRenderer
  61041. */
  61042. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  61043. /**
  61044. * Disables the GeometryBufferRender associated with the scene
  61045. */
  61046. disableGeometryBufferRenderer(): void;
  61047. }
  61048. }
  61049. /**
  61050. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  61051. * in several rendering techniques.
  61052. */
  61053. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  61054. /**
  61055. * The component name helpful to identify the component in the list of scene components.
  61056. */
  61057. readonly name: string;
  61058. /**
  61059. * The scene the component belongs to.
  61060. */
  61061. scene: Scene;
  61062. /**
  61063. * Creates a new instance of the component for the given scene
  61064. * @param scene Defines the scene to register the component in
  61065. */
  61066. constructor(scene: Scene);
  61067. /**
  61068. * Registers the component in a given scene
  61069. */
  61070. register(): void;
  61071. /**
  61072. * Rebuilds the elements related to this component in case of
  61073. * context lost for instance.
  61074. */
  61075. rebuild(): void;
  61076. /**
  61077. * Disposes the component and the associated ressources
  61078. */
  61079. dispose(): void;
  61080. private _gatherRenderTargets;
  61081. }
  61082. }
  61083. declare module "babylonjs/Shaders/motionBlur.fragment" {
  61084. /** @hidden */
  61085. export var motionBlurPixelShader: {
  61086. name: string;
  61087. shader: string;
  61088. };
  61089. }
  61090. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  61091. import { Nullable } from "babylonjs/types";
  61092. import { Camera } from "babylonjs/Cameras/camera";
  61093. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61094. import { Scene } from "babylonjs/scene";
  61095. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61096. import "babylonjs/Animations/animatable";
  61097. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  61098. import "babylonjs/Shaders/motionBlur.fragment";
  61099. import { Engine } from "babylonjs/Engines/engine";
  61100. /**
  61101. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  61102. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  61103. * As an example, all you have to do is to create the post-process:
  61104. * var mb = new BABYLON.MotionBlurPostProcess(
  61105. * 'mb', // The name of the effect.
  61106. * scene, // The scene containing the objects to blur according to their velocity.
  61107. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  61108. * camera // The camera to apply the render pass to.
  61109. * );
  61110. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  61111. */
  61112. export class MotionBlurPostProcess extends PostProcess {
  61113. /**
  61114. * Defines how much the image is blurred by the movement. Default value is equal to 1
  61115. */
  61116. motionStrength: number;
  61117. /**
  61118. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  61119. */
  61120. /**
  61121. * Sets the number of iterations to be used for motion blur quality
  61122. */
  61123. motionBlurSamples: number;
  61124. private _motionBlurSamples;
  61125. private _geometryBufferRenderer;
  61126. /**
  61127. * Creates a new instance MotionBlurPostProcess
  61128. * @param name The name of the effect.
  61129. * @param scene The scene containing the objects to blur according to their velocity.
  61130. * @param options The required width/height ratio to downsize to before computing the render pass.
  61131. * @param camera The camera to apply the render pass to.
  61132. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61133. * @param engine The engine which the post process will be applied. (default: current engine)
  61134. * @param reusable If the post process can be reused on the same frame. (default: false)
  61135. * @param textureType Type of textures used when performing the post process. (default: 0)
  61136. * @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)
  61137. */
  61138. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61139. /**
  61140. * Excludes the given skinned mesh from computing bones velocities.
  61141. * 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.
  61142. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  61143. */
  61144. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  61145. /**
  61146. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  61147. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  61148. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  61149. */
  61150. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  61151. /**
  61152. * Disposes the post process.
  61153. * @param camera The camera to dispose the post process on.
  61154. */
  61155. dispose(camera?: Camera): void;
  61156. }
  61157. }
  61158. declare module "babylonjs/Shaders/refraction.fragment" {
  61159. /** @hidden */
  61160. export var refractionPixelShader: {
  61161. name: string;
  61162. shader: string;
  61163. };
  61164. }
  61165. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  61166. import { Color3 } from "babylonjs/Maths/math.color";
  61167. import { Camera } from "babylonjs/Cameras/camera";
  61168. import { Texture } from "babylonjs/Materials/Textures/texture";
  61169. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61170. import { Engine } from "babylonjs/Engines/engine";
  61171. import "babylonjs/Shaders/refraction.fragment";
  61172. /**
  61173. * Post process which applies a refractin texture
  61174. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  61175. */
  61176. export class RefractionPostProcess extends PostProcess {
  61177. /** the base color of the refraction (used to taint the rendering) */
  61178. color: Color3;
  61179. /** simulated refraction depth */
  61180. depth: number;
  61181. /** the coefficient of the base color (0 to remove base color tainting) */
  61182. colorLevel: number;
  61183. private _refTexture;
  61184. private _ownRefractionTexture;
  61185. /**
  61186. * Gets or sets the refraction texture
  61187. * Please note that you are responsible for disposing the texture if you set it manually
  61188. */
  61189. refractionTexture: Texture;
  61190. /**
  61191. * Initializes the RefractionPostProcess
  61192. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  61193. * @param name The name of the effect.
  61194. * @param refractionTextureUrl Url of the refraction texture to use
  61195. * @param color the base color of the refraction (used to taint the rendering)
  61196. * @param depth simulated refraction depth
  61197. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  61198. * @param camera The camera to apply the render pass to.
  61199. * @param options The required width/height ratio to downsize to before computing the render pass.
  61200. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61201. * @param engine The engine which the post process will be applied. (default: current engine)
  61202. * @param reusable If the post process can be reused on the same frame. (default: false)
  61203. */
  61204. constructor(name: string, refractionTextureUrl: string,
  61205. /** the base color of the refraction (used to taint the rendering) */
  61206. color: Color3,
  61207. /** simulated refraction depth */
  61208. depth: number,
  61209. /** the coefficient of the base color (0 to remove base color tainting) */
  61210. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61211. /**
  61212. * Disposes of the post process
  61213. * @param camera Camera to dispose post process on
  61214. */
  61215. dispose(camera: Camera): void;
  61216. }
  61217. }
  61218. declare module "babylonjs/Shaders/sharpen.fragment" {
  61219. /** @hidden */
  61220. export var sharpenPixelShader: {
  61221. name: string;
  61222. shader: string;
  61223. };
  61224. }
  61225. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  61226. import { Nullable } from "babylonjs/types";
  61227. import { Camera } from "babylonjs/Cameras/camera";
  61228. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61229. import "babylonjs/Shaders/sharpen.fragment";
  61230. import { Engine } from "babylonjs/Engines/engine";
  61231. /**
  61232. * The SharpenPostProcess applies a sharpen kernel to every pixel
  61233. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  61234. */
  61235. export class SharpenPostProcess extends PostProcess {
  61236. /**
  61237. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  61238. */
  61239. colorAmount: number;
  61240. /**
  61241. * How much sharpness should be applied (default: 0.3)
  61242. */
  61243. edgeAmount: number;
  61244. /**
  61245. * Creates a new instance ConvolutionPostProcess
  61246. * @param name The name of the effect.
  61247. * @param options The required width/height ratio to downsize to before computing the render pass.
  61248. * @param camera The camera to apply the render pass to.
  61249. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61250. * @param engine The engine which the post process will be applied. (default: current engine)
  61251. * @param reusable If the post process can be reused on the same frame. (default: false)
  61252. * @param textureType Type of textures used when performing the post process. (default: 0)
  61253. * @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)
  61254. */
  61255. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61256. }
  61257. }
  61258. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  61259. import { Nullable } from "babylonjs/types";
  61260. import { Camera } from "babylonjs/Cameras/camera";
  61261. import { Engine } from "babylonjs/Engines/engine";
  61262. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  61263. import { IInspectable } from "babylonjs/Misc/iInspectable";
  61264. /**
  61265. * PostProcessRenderPipeline
  61266. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61267. */
  61268. export class PostProcessRenderPipeline {
  61269. private engine;
  61270. private _renderEffects;
  61271. private _renderEffectsForIsolatedPass;
  61272. /**
  61273. * List of inspectable custom properties (used by the Inspector)
  61274. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  61275. */
  61276. inspectableCustomProperties: IInspectable[];
  61277. /**
  61278. * @hidden
  61279. */
  61280. protected _cameras: Camera[];
  61281. /** @hidden */
  61282. _name: string;
  61283. /**
  61284. * Gets pipeline name
  61285. */
  61286. readonly name: string;
  61287. /**
  61288. * Initializes a PostProcessRenderPipeline
  61289. * @param engine engine to add the pipeline to
  61290. * @param name name of the pipeline
  61291. */
  61292. constructor(engine: Engine, name: string);
  61293. /**
  61294. * Gets the class name
  61295. * @returns "PostProcessRenderPipeline"
  61296. */
  61297. getClassName(): string;
  61298. /**
  61299. * If all the render effects in the pipeline are supported
  61300. */
  61301. readonly isSupported: boolean;
  61302. /**
  61303. * Adds an effect to the pipeline
  61304. * @param renderEffect the effect to add
  61305. */
  61306. addEffect(renderEffect: PostProcessRenderEffect): void;
  61307. /** @hidden */
  61308. _rebuild(): void;
  61309. /** @hidden */
  61310. _enableEffect(renderEffectName: string, cameras: Camera): void;
  61311. /** @hidden */
  61312. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  61313. /** @hidden */
  61314. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  61315. /** @hidden */
  61316. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  61317. /** @hidden */
  61318. _attachCameras(cameras: Camera, unique: boolean): void;
  61319. /** @hidden */
  61320. _attachCameras(cameras: Camera[], unique: boolean): void;
  61321. /** @hidden */
  61322. _detachCameras(cameras: Camera): void;
  61323. /** @hidden */
  61324. _detachCameras(cameras: Nullable<Camera[]>): void;
  61325. /** @hidden */
  61326. _update(): void;
  61327. /** @hidden */
  61328. _reset(): void;
  61329. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  61330. /**
  61331. * Disposes of the pipeline
  61332. */
  61333. dispose(): void;
  61334. }
  61335. }
  61336. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  61337. import { Camera } from "babylonjs/Cameras/camera";
  61338. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  61339. /**
  61340. * PostProcessRenderPipelineManager class
  61341. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61342. */
  61343. export class PostProcessRenderPipelineManager {
  61344. private _renderPipelines;
  61345. /**
  61346. * Initializes a PostProcessRenderPipelineManager
  61347. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61348. */
  61349. constructor();
  61350. /**
  61351. * Gets the list of supported render pipelines
  61352. */
  61353. readonly supportedPipelines: PostProcessRenderPipeline[];
  61354. /**
  61355. * Adds a pipeline to the manager
  61356. * @param renderPipeline The pipeline to add
  61357. */
  61358. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  61359. /**
  61360. * Attaches a camera to the pipeline
  61361. * @param renderPipelineName The name of the pipeline to attach to
  61362. * @param cameras the camera to attach
  61363. * @param unique if the camera can be attached multiple times to the pipeline
  61364. */
  61365. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  61366. /**
  61367. * Detaches a camera from the pipeline
  61368. * @param renderPipelineName The name of the pipeline to detach from
  61369. * @param cameras the camera to detach
  61370. */
  61371. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  61372. /**
  61373. * Enables an effect by name on a pipeline
  61374. * @param renderPipelineName the name of the pipeline to enable the effect in
  61375. * @param renderEffectName the name of the effect to enable
  61376. * @param cameras the cameras that the effect should be enabled on
  61377. */
  61378. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  61379. /**
  61380. * Disables an effect by name on a pipeline
  61381. * @param renderPipelineName the name of the pipeline to disable the effect in
  61382. * @param renderEffectName the name of the effect to disable
  61383. * @param cameras the cameras that the effect should be disabled on
  61384. */
  61385. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  61386. /**
  61387. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  61388. */
  61389. update(): void;
  61390. /** @hidden */
  61391. _rebuild(): void;
  61392. /**
  61393. * Disposes of the manager and pipelines
  61394. */
  61395. dispose(): void;
  61396. }
  61397. }
  61398. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  61399. import { ISceneComponent } from "babylonjs/sceneComponent";
  61400. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  61401. import { Scene } from "babylonjs/scene";
  61402. module "babylonjs/scene" {
  61403. interface Scene {
  61404. /** @hidden (Backing field) */
  61405. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  61406. /**
  61407. * Gets the postprocess render pipeline manager
  61408. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61409. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  61410. */
  61411. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  61412. }
  61413. }
  61414. /**
  61415. * Defines the Render Pipeline scene component responsible to rendering pipelines
  61416. */
  61417. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  61418. /**
  61419. * The component name helpfull to identify the component in the list of scene components.
  61420. */
  61421. readonly name: string;
  61422. /**
  61423. * The scene the component belongs to.
  61424. */
  61425. scene: Scene;
  61426. /**
  61427. * Creates a new instance of the component for the given scene
  61428. * @param scene Defines the scene to register the component in
  61429. */
  61430. constructor(scene: Scene);
  61431. /**
  61432. * Registers the component in a given scene
  61433. */
  61434. register(): void;
  61435. /**
  61436. * Rebuilds the elements related to this component in case of
  61437. * context lost for instance.
  61438. */
  61439. rebuild(): void;
  61440. /**
  61441. * Disposes the component and the associated ressources
  61442. */
  61443. dispose(): void;
  61444. private _gatherRenderTargets;
  61445. }
  61446. }
  61447. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  61448. import { Nullable } from "babylonjs/types";
  61449. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  61450. import { Camera } from "babylonjs/Cameras/camera";
  61451. import { IDisposable } from "babylonjs/scene";
  61452. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  61453. import { Scene } from "babylonjs/scene";
  61454. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  61455. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  61456. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  61457. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  61458. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  61459. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  61460. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  61461. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  61462. import { Animation } from "babylonjs/Animations/animation";
  61463. /**
  61464. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  61465. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  61466. */
  61467. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  61468. private _scene;
  61469. private _camerasToBeAttached;
  61470. /**
  61471. * ID of the sharpen post process,
  61472. */
  61473. private readonly SharpenPostProcessId;
  61474. /**
  61475. * @ignore
  61476. * ID of the image processing post process;
  61477. */
  61478. readonly ImageProcessingPostProcessId: string;
  61479. /**
  61480. * @ignore
  61481. * ID of the Fast Approximate Anti-Aliasing post process;
  61482. */
  61483. readonly FxaaPostProcessId: string;
  61484. /**
  61485. * ID of the chromatic aberration post process,
  61486. */
  61487. private readonly ChromaticAberrationPostProcessId;
  61488. /**
  61489. * ID of the grain post process
  61490. */
  61491. private readonly GrainPostProcessId;
  61492. /**
  61493. * Sharpen post process which will apply a sharpen convolution to enhance edges
  61494. */
  61495. sharpen: SharpenPostProcess;
  61496. private _sharpenEffect;
  61497. private bloom;
  61498. /**
  61499. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  61500. */
  61501. depthOfField: DepthOfFieldEffect;
  61502. /**
  61503. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  61504. */
  61505. fxaa: FxaaPostProcess;
  61506. /**
  61507. * Image post processing pass used to perform operations such as tone mapping or color grading.
  61508. */
  61509. imageProcessing: ImageProcessingPostProcess;
  61510. /**
  61511. * Chromatic aberration post process which will shift rgb colors in the image
  61512. */
  61513. chromaticAberration: ChromaticAberrationPostProcess;
  61514. private _chromaticAberrationEffect;
  61515. /**
  61516. * Grain post process which add noise to the image
  61517. */
  61518. grain: GrainPostProcess;
  61519. private _grainEffect;
  61520. /**
  61521. * Glow post process which adds a glow to emissive areas of the image
  61522. */
  61523. private _glowLayer;
  61524. /**
  61525. * Animations which can be used to tweak settings over a period of time
  61526. */
  61527. animations: Animation[];
  61528. private _imageProcessingConfigurationObserver;
  61529. private _sharpenEnabled;
  61530. private _bloomEnabled;
  61531. private _depthOfFieldEnabled;
  61532. private _depthOfFieldBlurLevel;
  61533. private _fxaaEnabled;
  61534. private _imageProcessingEnabled;
  61535. private _defaultPipelineTextureType;
  61536. private _bloomScale;
  61537. private _chromaticAberrationEnabled;
  61538. private _grainEnabled;
  61539. private _buildAllowed;
  61540. /**
  61541. * Gets active scene
  61542. */
  61543. readonly scene: Scene;
  61544. /**
  61545. * Enable or disable the sharpen process from the pipeline
  61546. */
  61547. sharpenEnabled: boolean;
  61548. private _resizeObserver;
  61549. private _hardwareScaleLevel;
  61550. private _bloomKernel;
  61551. /**
  61552. * Specifies the size of the bloom blur kernel, relative to the final output size
  61553. */
  61554. bloomKernel: number;
  61555. /**
  61556. * Specifies the weight of the bloom in the final rendering
  61557. */
  61558. private _bloomWeight;
  61559. /**
  61560. * Specifies the luma threshold for the area that will be blurred by the bloom
  61561. */
  61562. private _bloomThreshold;
  61563. private _hdr;
  61564. /**
  61565. * The strength of the bloom.
  61566. */
  61567. bloomWeight: number;
  61568. /**
  61569. * The strength of the bloom.
  61570. */
  61571. bloomThreshold: number;
  61572. /**
  61573. * The scale of the bloom, lower value will provide better performance.
  61574. */
  61575. bloomScale: number;
  61576. /**
  61577. * Enable or disable the bloom from the pipeline
  61578. */
  61579. bloomEnabled: boolean;
  61580. private _rebuildBloom;
  61581. /**
  61582. * If the depth of field is enabled.
  61583. */
  61584. depthOfFieldEnabled: boolean;
  61585. /**
  61586. * Blur level of the depth of field effect. (Higher blur will effect performance)
  61587. */
  61588. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  61589. /**
  61590. * If the anti aliasing is enabled.
  61591. */
  61592. fxaaEnabled: boolean;
  61593. private _samples;
  61594. /**
  61595. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  61596. */
  61597. samples: number;
  61598. /**
  61599. * If image processing is enabled.
  61600. */
  61601. imageProcessingEnabled: boolean;
  61602. /**
  61603. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  61604. */
  61605. glowLayerEnabled: boolean;
  61606. /**
  61607. * Gets the glow layer (or null if not defined)
  61608. */
  61609. readonly glowLayer: Nullable<GlowLayer>;
  61610. /**
  61611. * Enable or disable the chromaticAberration process from the pipeline
  61612. */
  61613. chromaticAberrationEnabled: boolean;
  61614. /**
  61615. * Enable or disable the grain process from the pipeline
  61616. */
  61617. grainEnabled: boolean;
  61618. /**
  61619. * @constructor
  61620. * @param name - The rendering pipeline name (default: "")
  61621. * @param hdr - If high dynamic range textures should be used (default: true)
  61622. * @param scene - The scene linked to this pipeline (default: the last created scene)
  61623. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  61624. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  61625. */
  61626. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  61627. /**
  61628. * Get the class name
  61629. * @returns "DefaultRenderingPipeline"
  61630. */
  61631. getClassName(): string;
  61632. /**
  61633. * Force the compilation of the entire pipeline.
  61634. */
  61635. prepare(): void;
  61636. private _hasCleared;
  61637. private _prevPostProcess;
  61638. private _prevPrevPostProcess;
  61639. private _setAutoClearAndTextureSharing;
  61640. private _depthOfFieldSceneObserver;
  61641. private _buildPipeline;
  61642. private _disposePostProcesses;
  61643. /**
  61644. * Adds a camera to the pipeline
  61645. * @param camera the camera to be added
  61646. */
  61647. addCamera(camera: Camera): void;
  61648. /**
  61649. * Removes a camera from the pipeline
  61650. * @param camera the camera to remove
  61651. */
  61652. removeCamera(camera: Camera): void;
  61653. /**
  61654. * Dispose of the pipeline and stop all post processes
  61655. */
  61656. dispose(): void;
  61657. /**
  61658. * Serialize the rendering pipeline (Used when exporting)
  61659. * @returns the serialized object
  61660. */
  61661. serialize(): any;
  61662. /**
  61663. * Parse the serialized pipeline
  61664. * @param source Source pipeline.
  61665. * @param scene The scene to load the pipeline to.
  61666. * @param rootUrl The URL of the serialized pipeline.
  61667. * @returns An instantiated pipeline from the serialized object.
  61668. */
  61669. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  61670. }
  61671. }
  61672. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  61673. /** @hidden */
  61674. export var lensHighlightsPixelShader: {
  61675. name: string;
  61676. shader: string;
  61677. };
  61678. }
  61679. declare module "babylonjs/Shaders/depthOfField.fragment" {
  61680. /** @hidden */
  61681. export var depthOfFieldPixelShader: {
  61682. name: string;
  61683. shader: string;
  61684. };
  61685. }
  61686. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  61687. import { Camera } from "babylonjs/Cameras/camera";
  61688. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  61689. import { Scene } from "babylonjs/scene";
  61690. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  61691. import "babylonjs/Shaders/chromaticAberration.fragment";
  61692. import "babylonjs/Shaders/lensHighlights.fragment";
  61693. import "babylonjs/Shaders/depthOfField.fragment";
  61694. /**
  61695. * BABYLON.JS Chromatic Aberration GLSL Shader
  61696. * Author: Olivier Guyot
  61697. * Separates very slightly R, G and B colors on the edges of the screen
  61698. * Inspired by Francois Tarlier & Martins Upitis
  61699. */
  61700. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  61701. /**
  61702. * @ignore
  61703. * The chromatic aberration PostProcess id in the pipeline
  61704. */
  61705. LensChromaticAberrationEffect: string;
  61706. /**
  61707. * @ignore
  61708. * The highlights enhancing PostProcess id in the pipeline
  61709. */
  61710. HighlightsEnhancingEffect: string;
  61711. /**
  61712. * @ignore
  61713. * The depth-of-field PostProcess id in the pipeline
  61714. */
  61715. LensDepthOfFieldEffect: string;
  61716. private _scene;
  61717. private _depthTexture;
  61718. private _grainTexture;
  61719. private _chromaticAberrationPostProcess;
  61720. private _highlightsPostProcess;
  61721. private _depthOfFieldPostProcess;
  61722. private _edgeBlur;
  61723. private _grainAmount;
  61724. private _chromaticAberration;
  61725. private _distortion;
  61726. private _highlightsGain;
  61727. private _highlightsThreshold;
  61728. private _dofDistance;
  61729. private _dofAperture;
  61730. private _dofDarken;
  61731. private _dofPentagon;
  61732. private _blurNoise;
  61733. /**
  61734. * @constructor
  61735. *
  61736. * Effect parameters are as follow:
  61737. * {
  61738. * chromatic_aberration: number; // from 0 to x (1 for realism)
  61739. * edge_blur: number; // from 0 to x (1 for realism)
  61740. * distortion: number; // from 0 to x (1 for realism)
  61741. * grain_amount: number; // from 0 to 1
  61742. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  61743. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  61744. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  61745. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  61746. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  61747. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  61748. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  61749. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  61750. * }
  61751. * Note: if an effect parameter is unset, effect is disabled
  61752. *
  61753. * @param name The rendering pipeline name
  61754. * @param parameters - An object containing all parameters (see above)
  61755. * @param scene The scene linked to this pipeline
  61756. * @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)
  61757. * @param cameras The array of cameras that the rendering pipeline will be attached to
  61758. */
  61759. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  61760. /**
  61761. * Get the class name
  61762. * @returns "LensRenderingPipeline"
  61763. */
  61764. getClassName(): string;
  61765. /**
  61766. * Gets associated scene
  61767. */
  61768. readonly scene: Scene;
  61769. /**
  61770. * Gets or sets the edge blur
  61771. */
  61772. edgeBlur: number;
  61773. /**
  61774. * Gets or sets the grain amount
  61775. */
  61776. grainAmount: number;
  61777. /**
  61778. * Gets or sets the chromatic aberration amount
  61779. */
  61780. chromaticAberration: number;
  61781. /**
  61782. * Gets or sets the depth of field aperture
  61783. */
  61784. dofAperture: number;
  61785. /**
  61786. * Gets or sets the edge distortion
  61787. */
  61788. edgeDistortion: number;
  61789. /**
  61790. * Gets or sets the depth of field distortion
  61791. */
  61792. dofDistortion: number;
  61793. /**
  61794. * Gets or sets the darken out of focus amount
  61795. */
  61796. darkenOutOfFocus: number;
  61797. /**
  61798. * Gets or sets a boolean indicating if blur noise is enabled
  61799. */
  61800. blurNoise: boolean;
  61801. /**
  61802. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  61803. */
  61804. pentagonBokeh: boolean;
  61805. /**
  61806. * Gets or sets the highlight grain amount
  61807. */
  61808. highlightsGain: number;
  61809. /**
  61810. * Gets or sets the highlight threshold
  61811. */
  61812. highlightsThreshold: number;
  61813. /**
  61814. * Sets the amount of blur at the edges
  61815. * @param amount blur amount
  61816. */
  61817. setEdgeBlur(amount: number): void;
  61818. /**
  61819. * Sets edge blur to 0
  61820. */
  61821. disableEdgeBlur(): void;
  61822. /**
  61823. * Sets the amout of grain
  61824. * @param amount Amount of grain
  61825. */
  61826. setGrainAmount(amount: number): void;
  61827. /**
  61828. * Set grain amount to 0
  61829. */
  61830. disableGrain(): void;
  61831. /**
  61832. * Sets the chromatic aberration amount
  61833. * @param amount amount of chromatic aberration
  61834. */
  61835. setChromaticAberration(amount: number): void;
  61836. /**
  61837. * Sets chromatic aberration amount to 0
  61838. */
  61839. disableChromaticAberration(): void;
  61840. /**
  61841. * Sets the EdgeDistortion amount
  61842. * @param amount amount of EdgeDistortion
  61843. */
  61844. setEdgeDistortion(amount: number): void;
  61845. /**
  61846. * Sets edge distortion to 0
  61847. */
  61848. disableEdgeDistortion(): void;
  61849. /**
  61850. * Sets the FocusDistance amount
  61851. * @param amount amount of FocusDistance
  61852. */
  61853. setFocusDistance(amount: number): void;
  61854. /**
  61855. * Disables depth of field
  61856. */
  61857. disableDepthOfField(): void;
  61858. /**
  61859. * Sets the Aperture amount
  61860. * @param amount amount of Aperture
  61861. */
  61862. setAperture(amount: number): void;
  61863. /**
  61864. * Sets the DarkenOutOfFocus amount
  61865. * @param amount amount of DarkenOutOfFocus
  61866. */
  61867. setDarkenOutOfFocus(amount: number): void;
  61868. private _pentagonBokehIsEnabled;
  61869. /**
  61870. * Creates a pentagon bokeh effect
  61871. */
  61872. enablePentagonBokeh(): void;
  61873. /**
  61874. * Disables the pentagon bokeh effect
  61875. */
  61876. disablePentagonBokeh(): void;
  61877. /**
  61878. * Enables noise blur
  61879. */
  61880. enableNoiseBlur(): void;
  61881. /**
  61882. * Disables noise blur
  61883. */
  61884. disableNoiseBlur(): void;
  61885. /**
  61886. * Sets the HighlightsGain amount
  61887. * @param amount amount of HighlightsGain
  61888. */
  61889. setHighlightsGain(amount: number): void;
  61890. /**
  61891. * Sets the HighlightsThreshold amount
  61892. * @param amount amount of HighlightsThreshold
  61893. */
  61894. setHighlightsThreshold(amount: number): void;
  61895. /**
  61896. * Disables highlights
  61897. */
  61898. disableHighlights(): void;
  61899. /**
  61900. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  61901. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  61902. */
  61903. dispose(disableDepthRender?: boolean): void;
  61904. private _createChromaticAberrationPostProcess;
  61905. private _createHighlightsPostProcess;
  61906. private _createDepthOfFieldPostProcess;
  61907. private _createGrainTexture;
  61908. }
  61909. }
  61910. declare module "babylonjs/Shaders/ssao2.fragment" {
  61911. /** @hidden */
  61912. export var ssao2PixelShader: {
  61913. name: string;
  61914. shader: string;
  61915. };
  61916. }
  61917. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  61918. /** @hidden */
  61919. export var ssaoCombinePixelShader: {
  61920. name: string;
  61921. shader: string;
  61922. };
  61923. }
  61924. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  61925. import { Camera } from "babylonjs/Cameras/camera";
  61926. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  61927. import { Scene } from "babylonjs/scene";
  61928. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  61929. import "babylonjs/Shaders/ssao2.fragment";
  61930. import "babylonjs/Shaders/ssaoCombine.fragment";
  61931. /**
  61932. * Render pipeline to produce ssao effect
  61933. */
  61934. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  61935. /**
  61936. * @ignore
  61937. * The PassPostProcess id in the pipeline that contains the original scene color
  61938. */
  61939. SSAOOriginalSceneColorEffect: string;
  61940. /**
  61941. * @ignore
  61942. * The SSAO PostProcess id in the pipeline
  61943. */
  61944. SSAORenderEffect: string;
  61945. /**
  61946. * @ignore
  61947. * The horizontal blur PostProcess id in the pipeline
  61948. */
  61949. SSAOBlurHRenderEffect: string;
  61950. /**
  61951. * @ignore
  61952. * The vertical blur PostProcess id in the pipeline
  61953. */
  61954. SSAOBlurVRenderEffect: string;
  61955. /**
  61956. * @ignore
  61957. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  61958. */
  61959. SSAOCombineRenderEffect: string;
  61960. /**
  61961. * The output strength of the SSAO post-process. Default value is 1.0.
  61962. */
  61963. totalStrength: number;
  61964. /**
  61965. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  61966. */
  61967. maxZ: number;
  61968. /**
  61969. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  61970. */
  61971. minZAspect: number;
  61972. private _samples;
  61973. /**
  61974. * Number of samples used for the SSAO calculations. Default value is 8
  61975. */
  61976. samples: number;
  61977. private _textureSamples;
  61978. /**
  61979. * Number of samples to use for antialiasing
  61980. */
  61981. textureSamples: number;
  61982. /**
  61983. * Ratio object used for SSAO ratio and blur ratio
  61984. */
  61985. private _ratio;
  61986. /**
  61987. * Dynamically generated sphere sampler.
  61988. */
  61989. private _sampleSphere;
  61990. /**
  61991. * Blur filter offsets
  61992. */
  61993. private _samplerOffsets;
  61994. private _expensiveBlur;
  61995. /**
  61996. * If bilateral blur should be used
  61997. */
  61998. expensiveBlur: boolean;
  61999. /**
  62000. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  62001. */
  62002. radius: number;
  62003. /**
  62004. * The base color of the SSAO post-process
  62005. * The final result is "base + ssao" between [0, 1]
  62006. */
  62007. base: number;
  62008. /**
  62009. * Support test.
  62010. */
  62011. static readonly IsSupported: boolean;
  62012. private _scene;
  62013. private _depthTexture;
  62014. private _normalTexture;
  62015. private _randomTexture;
  62016. private _originalColorPostProcess;
  62017. private _ssaoPostProcess;
  62018. private _blurHPostProcess;
  62019. private _blurVPostProcess;
  62020. private _ssaoCombinePostProcess;
  62021. private _firstUpdate;
  62022. /**
  62023. * Gets active scene
  62024. */
  62025. readonly scene: Scene;
  62026. /**
  62027. * @constructor
  62028. * @param name The rendering pipeline name
  62029. * @param scene The scene linked to this pipeline
  62030. * @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 }
  62031. * @param cameras The array of cameras that the rendering pipeline will be attached to
  62032. */
  62033. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  62034. /**
  62035. * Get the class name
  62036. * @returns "SSAO2RenderingPipeline"
  62037. */
  62038. getClassName(): string;
  62039. /**
  62040. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  62041. */
  62042. dispose(disableGeometryBufferRenderer?: boolean): void;
  62043. private _createBlurPostProcess;
  62044. /** @hidden */
  62045. _rebuild(): void;
  62046. private _bits;
  62047. private _radicalInverse_VdC;
  62048. private _hammersley;
  62049. private _hemisphereSample_uniform;
  62050. private _generateHemisphere;
  62051. private _createSSAOPostProcess;
  62052. private _createSSAOCombinePostProcess;
  62053. private _createRandomTexture;
  62054. /**
  62055. * Serialize the rendering pipeline (Used when exporting)
  62056. * @returns the serialized object
  62057. */
  62058. serialize(): any;
  62059. /**
  62060. * Parse the serialized pipeline
  62061. * @param source Source pipeline.
  62062. * @param scene The scene to load the pipeline to.
  62063. * @param rootUrl The URL of the serialized pipeline.
  62064. * @returns An instantiated pipeline from the serialized object.
  62065. */
  62066. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  62067. }
  62068. }
  62069. declare module "babylonjs/Shaders/ssao.fragment" {
  62070. /** @hidden */
  62071. export var ssaoPixelShader: {
  62072. name: string;
  62073. shader: string;
  62074. };
  62075. }
  62076. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  62077. import { Camera } from "babylonjs/Cameras/camera";
  62078. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62079. import { Scene } from "babylonjs/scene";
  62080. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62081. import "babylonjs/Shaders/ssao.fragment";
  62082. import "babylonjs/Shaders/ssaoCombine.fragment";
  62083. /**
  62084. * Render pipeline to produce ssao effect
  62085. */
  62086. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  62087. /**
  62088. * @ignore
  62089. * The PassPostProcess id in the pipeline that contains the original scene color
  62090. */
  62091. SSAOOriginalSceneColorEffect: string;
  62092. /**
  62093. * @ignore
  62094. * The SSAO PostProcess id in the pipeline
  62095. */
  62096. SSAORenderEffect: string;
  62097. /**
  62098. * @ignore
  62099. * The horizontal blur PostProcess id in the pipeline
  62100. */
  62101. SSAOBlurHRenderEffect: string;
  62102. /**
  62103. * @ignore
  62104. * The vertical blur PostProcess id in the pipeline
  62105. */
  62106. SSAOBlurVRenderEffect: string;
  62107. /**
  62108. * @ignore
  62109. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  62110. */
  62111. SSAOCombineRenderEffect: string;
  62112. /**
  62113. * The output strength of the SSAO post-process. Default value is 1.0.
  62114. */
  62115. totalStrength: number;
  62116. /**
  62117. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  62118. */
  62119. radius: number;
  62120. /**
  62121. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  62122. * Must not be equal to fallOff and superior to fallOff.
  62123. * Default value is 0.0075
  62124. */
  62125. area: number;
  62126. /**
  62127. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  62128. * Must not be equal to area and inferior to area.
  62129. * Default value is 0.000001
  62130. */
  62131. fallOff: number;
  62132. /**
  62133. * The base color of the SSAO post-process
  62134. * The final result is "base + ssao" between [0, 1]
  62135. */
  62136. base: number;
  62137. private _scene;
  62138. private _depthTexture;
  62139. private _randomTexture;
  62140. private _originalColorPostProcess;
  62141. private _ssaoPostProcess;
  62142. private _blurHPostProcess;
  62143. private _blurVPostProcess;
  62144. private _ssaoCombinePostProcess;
  62145. private _firstUpdate;
  62146. /**
  62147. * Gets active scene
  62148. */
  62149. readonly scene: Scene;
  62150. /**
  62151. * @constructor
  62152. * @param name - The rendering pipeline name
  62153. * @param scene - The scene linked to this pipeline
  62154. * @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 }
  62155. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  62156. */
  62157. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  62158. /**
  62159. * Get the class name
  62160. * @returns "SSAORenderingPipeline"
  62161. */
  62162. getClassName(): string;
  62163. /**
  62164. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  62165. */
  62166. dispose(disableDepthRender?: boolean): void;
  62167. private _createBlurPostProcess;
  62168. /** @hidden */
  62169. _rebuild(): void;
  62170. private _createSSAOPostProcess;
  62171. private _createSSAOCombinePostProcess;
  62172. private _createRandomTexture;
  62173. }
  62174. }
  62175. declare module "babylonjs/Shaders/standard.fragment" {
  62176. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  62177. /** @hidden */
  62178. export var standardPixelShader: {
  62179. name: string;
  62180. shader: string;
  62181. };
  62182. }
  62183. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  62184. import { Nullable } from "babylonjs/types";
  62185. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  62186. import { Camera } from "babylonjs/Cameras/camera";
  62187. import { Texture } from "babylonjs/Materials/Textures/texture";
  62188. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62189. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62190. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  62191. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  62192. import { IDisposable } from "babylonjs/scene";
  62193. import { SpotLight } from "babylonjs/Lights/spotLight";
  62194. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  62195. import { Scene } from "babylonjs/scene";
  62196. import { Animation } from "babylonjs/Animations/animation";
  62197. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62198. import "babylonjs/Shaders/standard.fragment";
  62199. /**
  62200. * Standard rendering pipeline
  62201. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  62202. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  62203. */
  62204. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  62205. /**
  62206. * Public members
  62207. */
  62208. /**
  62209. * Post-process which contains the original scene color before the pipeline applies all the effects
  62210. */
  62211. originalPostProcess: Nullable<PostProcess>;
  62212. /**
  62213. * Post-process used to down scale an image x4
  62214. */
  62215. downSampleX4PostProcess: Nullable<PostProcess>;
  62216. /**
  62217. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  62218. */
  62219. brightPassPostProcess: Nullable<PostProcess>;
  62220. /**
  62221. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  62222. */
  62223. blurHPostProcesses: PostProcess[];
  62224. /**
  62225. * Post-process array storing all the vertical blur post-processes used by the pipeline
  62226. */
  62227. blurVPostProcesses: PostProcess[];
  62228. /**
  62229. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  62230. */
  62231. textureAdderPostProcess: Nullable<PostProcess>;
  62232. /**
  62233. * Post-process used to create volumetric lighting effect
  62234. */
  62235. volumetricLightPostProcess: Nullable<PostProcess>;
  62236. /**
  62237. * Post-process used to smooth the previous volumetric light post-process on the X axis
  62238. */
  62239. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  62240. /**
  62241. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  62242. */
  62243. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  62244. /**
  62245. * Post-process used to merge the volumetric light effect and the real scene color
  62246. */
  62247. volumetricLightMergePostProces: Nullable<PostProcess>;
  62248. /**
  62249. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  62250. */
  62251. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  62252. /**
  62253. * Base post-process used to calculate the average luminance of the final image for HDR
  62254. */
  62255. luminancePostProcess: Nullable<PostProcess>;
  62256. /**
  62257. * Post-processes used to create down sample post-processes in order to get
  62258. * the average luminance of the final image for HDR
  62259. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  62260. */
  62261. luminanceDownSamplePostProcesses: PostProcess[];
  62262. /**
  62263. * Post-process used to create a HDR effect (light adaptation)
  62264. */
  62265. hdrPostProcess: Nullable<PostProcess>;
  62266. /**
  62267. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  62268. */
  62269. textureAdderFinalPostProcess: Nullable<PostProcess>;
  62270. /**
  62271. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  62272. */
  62273. lensFlareFinalPostProcess: Nullable<PostProcess>;
  62274. /**
  62275. * Post-process used to merge the final HDR post-process and the real scene color
  62276. */
  62277. hdrFinalPostProcess: Nullable<PostProcess>;
  62278. /**
  62279. * Post-process used to create a lens flare effect
  62280. */
  62281. lensFlarePostProcess: Nullable<PostProcess>;
  62282. /**
  62283. * Post-process that merges the result of the lens flare post-process and the real scene color
  62284. */
  62285. lensFlareComposePostProcess: Nullable<PostProcess>;
  62286. /**
  62287. * Post-process used to create a motion blur effect
  62288. */
  62289. motionBlurPostProcess: Nullable<PostProcess>;
  62290. /**
  62291. * Post-process used to create a depth of field effect
  62292. */
  62293. depthOfFieldPostProcess: Nullable<PostProcess>;
  62294. /**
  62295. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  62296. */
  62297. fxaaPostProcess: Nullable<FxaaPostProcess>;
  62298. /**
  62299. * Represents the brightness threshold in order to configure the illuminated surfaces
  62300. */
  62301. brightThreshold: number;
  62302. /**
  62303. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  62304. */
  62305. blurWidth: number;
  62306. /**
  62307. * Sets if the blur for highlighted surfaces must be only horizontal
  62308. */
  62309. horizontalBlur: boolean;
  62310. /**
  62311. * Gets the overall exposure used by the pipeline
  62312. */
  62313. /**
  62314. * Sets the overall exposure used by the pipeline
  62315. */
  62316. exposure: number;
  62317. /**
  62318. * Texture used typically to simulate "dirty" on camera lens
  62319. */
  62320. lensTexture: Nullable<Texture>;
  62321. /**
  62322. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  62323. */
  62324. volumetricLightCoefficient: number;
  62325. /**
  62326. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  62327. */
  62328. volumetricLightPower: number;
  62329. /**
  62330. * Used the set the blur intensity to smooth the volumetric lights
  62331. */
  62332. volumetricLightBlurScale: number;
  62333. /**
  62334. * Light (spot or directional) used to generate the volumetric lights rays
  62335. * The source light must have a shadow generate so the pipeline can get its
  62336. * depth map
  62337. */
  62338. sourceLight: Nullable<SpotLight | DirectionalLight>;
  62339. /**
  62340. * For eye adaptation, represents the minimum luminance the eye can see
  62341. */
  62342. hdrMinimumLuminance: number;
  62343. /**
  62344. * For eye adaptation, represents the decrease luminance speed
  62345. */
  62346. hdrDecreaseRate: number;
  62347. /**
  62348. * For eye adaptation, represents the increase luminance speed
  62349. */
  62350. hdrIncreaseRate: number;
  62351. /**
  62352. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  62353. */
  62354. /**
  62355. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  62356. */
  62357. hdrAutoExposure: boolean;
  62358. /**
  62359. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  62360. */
  62361. lensColorTexture: Nullable<Texture>;
  62362. /**
  62363. * The overall strengh for the lens flare effect
  62364. */
  62365. lensFlareStrength: number;
  62366. /**
  62367. * Dispersion coefficient for lens flare ghosts
  62368. */
  62369. lensFlareGhostDispersal: number;
  62370. /**
  62371. * Main lens flare halo width
  62372. */
  62373. lensFlareHaloWidth: number;
  62374. /**
  62375. * Based on the lens distortion effect, defines how much the lens flare result
  62376. * is distorted
  62377. */
  62378. lensFlareDistortionStrength: number;
  62379. /**
  62380. * Configures the blur intensity used for for lens flare (halo)
  62381. */
  62382. lensFlareBlurWidth: number;
  62383. /**
  62384. * Lens star texture must be used to simulate rays on the flares and is available
  62385. * in the documentation
  62386. */
  62387. lensStarTexture: Nullable<Texture>;
  62388. /**
  62389. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  62390. * flare effect by taking account of the dirt texture
  62391. */
  62392. lensFlareDirtTexture: Nullable<Texture>;
  62393. /**
  62394. * Represents the focal length for the depth of field effect
  62395. */
  62396. depthOfFieldDistance: number;
  62397. /**
  62398. * Represents the blur intensity for the blurred part of the depth of field effect
  62399. */
  62400. depthOfFieldBlurWidth: number;
  62401. /**
  62402. * Gets how much the image is blurred by the movement while using the motion blur post-process
  62403. */
  62404. /**
  62405. * Sets how much the image is blurred by the movement while using the motion blur post-process
  62406. */
  62407. motionStrength: number;
  62408. /**
  62409. * Gets wether or not the motion blur post-process is object based or screen based.
  62410. */
  62411. /**
  62412. * Sets wether or not the motion blur post-process should be object based or screen based
  62413. */
  62414. objectBasedMotionBlur: boolean;
  62415. /**
  62416. * List of animations for the pipeline (IAnimatable implementation)
  62417. */
  62418. animations: Animation[];
  62419. /**
  62420. * Private members
  62421. */
  62422. private _scene;
  62423. private _currentDepthOfFieldSource;
  62424. private _basePostProcess;
  62425. private _fixedExposure;
  62426. private _currentExposure;
  62427. private _hdrAutoExposure;
  62428. private _hdrCurrentLuminance;
  62429. private _motionStrength;
  62430. private _isObjectBasedMotionBlur;
  62431. private _floatTextureType;
  62432. private _camerasToBeAttached;
  62433. private _ratio;
  62434. private _bloomEnabled;
  62435. private _depthOfFieldEnabled;
  62436. private _vlsEnabled;
  62437. private _lensFlareEnabled;
  62438. private _hdrEnabled;
  62439. private _motionBlurEnabled;
  62440. private _fxaaEnabled;
  62441. private _motionBlurSamples;
  62442. private _volumetricLightStepsCount;
  62443. private _samples;
  62444. /**
  62445. * @ignore
  62446. * Specifies if the bloom pipeline is enabled
  62447. */
  62448. BloomEnabled: boolean;
  62449. /**
  62450. * @ignore
  62451. * Specifies if the depth of field pipeline is enabed
  62452. */
  62453. DepthOfFieldEnabled: boolean;
  62454. /**
  62455. * @ignore
  62456. * Specifies if the lens flare pipeline is enabed
  62457. */
  62458. LensFlareEnabled: boolean;
  62459. /**
  62460. * @ignore
  62461. * Specifies if the HDR pipeline is enabled
  62462. */
  62463. HDREnabled: boolean;
  62464. /**
  62465. * @ignore
  62466. * Specifies if the volumetric lights scattering effect is enabled
  62467. */
  62468. VLSEnabled: boolean;
  62469. /**
  62470. * @ignore
  62471. * Specifies if the motion blur effect is enabled
  62472. */
  62473. MotionBlurEnabled: boolean;
  62474. /**
  62475. * Specifies if anti-aliasing is enabled
  62476. */
  62477. fxaaEnabled: boolean;
  62478. /**
  62479. * Specifies the number of steps used to calculate the volumetric lights
  62480. * Typically in interval [50, 200]
  62481. */
  62482. volumetricLightStepsCount: number;
  62483. /**
  62484. * Specifies the number of samples used for the motion blur effect
  62485. * Typically in interval [16, 64]
  62486. */
  62487. motionBlurSamples: number;
  62488. /**
  62489. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  62490. */
  62491. samples: number;
  62492. /**
  62493. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  62494. * @constructor
  62495. * @param name The rendering pipeline name
  62496. * @param scene The scene linked to this pipeline
  62497. * @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)
  62498. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  62499. * @param cameras The array of cameras that the rendering pipeline will be attached to
  62500. */
  62501. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  62502. private _buildPipeline;
  62503. private _createDownSampleX4PostProcess;
  62504. private _createBrightPassPostProcess;
  62505. private _createBlurPostProcesses;
  62506. private _createTextureAdderPostProcess;
  62507. private _createVolumetricLightPostProcess;
  62508. private _createLuminancePostProcesses;
  62509. private _createHdrPostProcess;
  62510. private _createLensFlarePostProcess;
  62511. private _createDepthOfFieldPostProcess;
  62512. private _createMotionBlurPostProcess;
  62513. private _getDepthTexture;
  62514. private _disposePostProcesses;
  62515. /**
  62516. * Dispose of the pipeline and stop all post processes
  62517. */
  62518. dispose(): void;
  62519. /**
  62520. * Serialize the rendering pipeline (Used when exporting)
  62521. * @returns the serialized object
  62522. */
  62523. serialize(): any;
  62524. /**
  62525. * Parse the serialized pipeline
  62526. * @param source Source pipeline.
  62527. * @param scene The scene to load the pipeline to.
  62528. * @param rootUrl The URL of the serialized pipeline.
  62529. * @returns An instantiated pipeline from the serialized object.
  62530. */
  62531. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  62532. /**
  62533. * Luminance steps
  62534. */
  62535. static LuminanceSteps: number;
  62536. }
  62537. }
  62538. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  62539. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  62540. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  62541. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  62542. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  62543. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  62544. }
  62545. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  62546. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  62547. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  62548. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62549. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  62550. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62551. }
  62552. declare module "babylonjs/Shaders/tonemap.fragment" {
  62553. /** @hidden */
  62554. export var tonemapPixelShader: {
  62555. name: string;
  62556. shader: string;
  62557. };
  62558. }
  62559. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  62560. import { Camera } from "babylonjs/Cameras/camera";
  62561. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62562. import "babylonjs/Shaders/tonemap.fragment";
  62563. import { Engine } from "babylonjs/Engines/engine";
  62564. /** Defines operator used for tonemapping */
  62565. export enum TonemappingOperator {
  62566. /** Hable */
  62567. Hable = 0,
  62568. /** Reinhard */
  62569. Reinhard = 1,
  62570. /** HejiDawson */
  62571. HejiDawson = 2,
  62572. /** Photographic */
  62573. Photographic = 3
  62574. }
  62575. /**
  62576. * Defines a post process to apply tone mapping
  62577. */
  62578. export class TonemapPostProcess extends PostProcess {
  62579. private _operator;
  62580. /** Defines the required exposure adjustement */
  62581. exposureAdjustment: number;
  62582. /**
  62583. * Creates a new TonemapPostProcess
  62584. * @param name defines the name of the postprocess
  62585. * @param _operator defines the operator to use
  62586. * @param exposureAdjustment defines the required exposure adjustement
  62587. * @param camera defines the camera to use (can be null)
  62588. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  62589. * @param engine defines the hosting engine (can be ignore if camera is set)
  62590. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  62591. */
  62592. constructor(name: string, _operator: TonemappingOperator,
  62593. /** Defines the required exposure adjustement */
  62594. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  62595. }
  62596. }
  62597. declare module "babylonjs/Shaders/depth.vertex" {
  62598. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62599. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62600. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62601. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62602. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62603. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62604. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62605. /** @hidden */
  62606. export var depthVertexShader: {
  62607. name: string;
  62608. shader: string;
  62609. };
  62610. }
  62611. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  62612. /** @hidden */
  62613. export var volumetricLightScatteringPixelShader: {
  62614. name: string;
  62615. shader: string;
  62616. };
  62617. }
  62618. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  62619. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62620. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62621. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62622. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62623. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62624. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62625. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62626. /** @hidden */
  62627. export var volumetricLightScatteringPassVertexShader: {
  62628. name: string;
  62629. shader: string;
  62630. };
  62631. }
  62632. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  62633. /** @hidden */
  62634. export var volumetricLightScatteringPassPixelShader: {
  62635. name: string;
  62636. shader: string;
  62637. };
  62638. }
  62639. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  62640. import { Vector3 } from "babylonjs/Maths/math.vector";
  62641. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62642. import { Mesh } from "babylonjs/Meshes/mesh";
  62643. import { Camera } from "babylonjs/Cameras/camera";
  62644. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62645. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62646. import { Scene } from "babylonjs/scene";
  62647. import "babylonjs/Meshes/Builders/planeBuilder";
  62648. import "babylonjs/Shaders/depth.vertex";
  62649. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  62650. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  62651. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  62652. import { Engine } from "babylonjs/Engines/engine";
  62653. /**
  62654. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  62655. */
  62656. export class VolumetricLightScatteringPostProcess extends PostProcess {
  62657. private _volumetricLightScatteringPass;
  62658. private _volumetricLightScatteringRTT;
  62659. private _viewPort;
  62660. private _screenCoordinates;
  62661. private _cachedDefines;
  62662. /**
  62663. * If not undefined, the mesh position is computed from the attached node position
  62664. */
  62665. attachedNode: {
  62666. position: Vector3;
  62667. };
  62668. /**
  62669. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  62670. */
  62671. customMeshPosition: Vector3;
  62672. /**
  62673. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  62674. */
  62675. useCustomMeshPosition: boolean;
  62676. /**
  62677. * If the post-process should inverse the light scattering direction
  62678. */
  62679. invert: boolean;
  62680. /**
  62681. * The internal mesh used by the post-process
  62682. */
  62683. mesh: Mesh;
  62684. /**
  62685. * @hidden
  62686. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  62687. */
  62688. useDiffuseColor: boolean;
  62689. /**
  62690. * Array containing the excluded meshes not rendered in the internal pass
  62691. */
  62692. excludedMeshes: AbstractMesh[];
  62693. /**
  62694. * Controls the overall intensity of the post-process
  62695. */
  62696. exposure: number;
  62697. /**
  62698. * Dissipates each sample's contribution in range [0, 1]
  62699. */
  62700. decay: number;
  62701. /**
  62702. * Controls the overall intensity of each sample
  62703. */
  62704. weight: number;
  62705. /**
  62706. * Controls the density of each sample
  62707. */
  62708. density: number;
  62709. /**
  62710. * @constructor
  62711. * @param name The post-process name
  62712. * @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)
  62713. * @param camera The camera that the post-process will be attached to
  62714. * @param mesh The mesh used to create the light scattering
  62715. * @param samples The post-process quality, default 100
  62716. * @param samplingModeThe post-process filtering mode
  62717. * @param engine The babylon engine
  62718. * @param reusable If the post-process is reusable
  62719. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  62720. */
  62721. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  62722. /**
  62723. * Returns the string "VolumetricLightScatteringPostProcess"
  62724. * @returns "VolumetricLightScatteringPostProcess"
  62725. */
  62726. getClassName(): string;
  62727. private _isReady;
  62728. /**
  62729. * Sets the new light position for light scattering effect
  62730. * @param position The new custom light position
  62731. */
  62732. setCustomMeshPosition(position: Vector3): void;
  62733. /**
  62734. * Returns the light position for light scattering effect
  62735. * @return Vector3 The custom light position
  62736. */
  62737. getCustomMeshPosition(): Vector3;
  62738. /**
  62739. * Disposes the internal assets and detaches the post-process from the camera
  62740. */
  62741. dispose(camera: Camera): void;
  62742. /**
  62743. * Returns the render target texture used by the post-process
  62744. * @return the render target texture used by the post-process
  62745. */
  62746. getPass(): RenderTargetTexture;
  62747. private _meshExcluded;
  62748. private _createPass;
  62749. private _updateMeshScreenCoordinates;
  62750. /**
  62751. * Creates a default mesh for the Volumeric Light Scattering post-process
  62752. * @param name The mesh name
  62753. * @param scene The scene where to create the mesh
  62754. * @return the default mesh
  62755. */
  62756. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  62757. }
  62758. }
  62759. declare module "babylonjs/PostProcesses/index" {
  62760. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  62761. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  62762. export * from "babylonjs/PostProcesses/bloomEffect";
  62763. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  62764. export * from "babylonjs/PostProcesses/blurPostProcess";
  62765. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  62766. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  62767. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  62768. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  62769. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  62770. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  62771. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  62772. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  62773. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  62774. export * from "babylonjs/PostProcesses/filterPostProcess";
  62775. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  62776. export * from "babylonjs/PostProcesses/grainPostProcess";
  62777. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  62778. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  62779. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  62780. export * from "babylonjs/PostProcesses/passPostProcess";
  62781. export * from "babylonjs/PostProcesses/postProcess";
  62782. export * from "babylonjs/PostProcesses/postProcessManager";
  62783. export * from "babylonjs/PostProcesses/refractionPostProcess";
  62784. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  62785. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  62786. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  62787. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  62788. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  62789. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  62790. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  62791. }
  62792. declare module "babylonjs/Probes/index" {
  62793. export * from "babylonjs/Probes/reflectionProbe";
  62794. }
  62795. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  62796. import { Scene } from "babylonjs/scene";
  62797. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62798. import { SmartArray } from "babylonjs/Misc/smartArray";
  62799. import { ISceneComponent } from "babylonjs/sceneComponent";
  62800. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  62801. import "babylonjs/Meshes/Builders/boxBuilder";
  62802. import "babylonjs/Shaders/color.fragment";
  62803. import "babylonjs/Shaders/color.vertex";
  62804. import { Color3 } from "babylonjs/Maths/math.color";
  62805. module "babylonjs/scene" {
  62806. interface Scene {
  62807. /** @hidden (Backing field) */
  62808. _boundingBoxRenderer: BoundingBoxRenderer;
  62809. /** @hidden (Backing field) */
  62810. _forceShowBoundingBoxes: boolean;
  62811. /**
  62812. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  62813. */
  62814. forceShowBoundingBoxes: boolean;
  62815. /**
  62816. * Gets the bounding box renderer associated with the scene
  62817. * @returns a BoundingBoxRenderer
  62818. */
  62819. getBoundingBoxRenderer(): BoundingBoxRenderer;
  62820. }
  62821. }
  62822. module "babylonjs/Meshes/abstractMesh" {
  62823. interface AbstractMesh {
  62824. /** @hidden (Backing field) */
  62825. _showBoundingBox: boolean;
  62826. /**
  62827. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  62828. */
  62829. showBoundingBox: boolean;
  62830. }
  62831. }
  62832. /**
  62833. * Component responsible of rendering the bounding box of the meshes in a scene.
  62834. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  62835. */
  62836. export class BoundingBoxRenderer implements ISceneComponent {
  62837. /**
  62838. * The component name helpfull to identify the component in the list of scene components.
  62839. */
  62840. readonly name: string;
  62841. /**
  62842. * The scene the component belongs to.
  62843. */
  62844. scene: Scene;
  62845. /**
  62846. * Color of the bounding box lines placed in front of an object
  62847. */
  62848. frontColor: Color3;
  62849. /**
  62850. * Color of the bounding box lines placed behind an object
  62851. */
  62852. backColor: Color3;
  62853. /**
  62854. * Defines if the renderer should show the back lines or not
  62855. */
  62856. showBackLines: boolean;
  62857. /**
  62858. * @hidden
  62859. */
  62860. renderList: SmartArray<BoundingBox>;
  62861. private _colorShader;
  62862. private _vertexBuffers;
  62863. private _indexBuffer;
  62864. private _fillIndexBuffer;
  62865. private _fillIndexData;
  62866. /**
  62867. * Instantiates a new bounding box renderer in a scene.
  62868. * @param scene the scene the renderer renders in
  62869. */
  62870. constructor(scene: Scene);
  62871. /**
  62872. * Registers the component in a given scene
  62873. */
  62874. register(): void;
  62875. private _evaluateSubMesh;
  62876. private _activeMesh;
  62877. private _prepareRessources;
  62878. private _createIndexBuffer;
  62879. /**
  62880. * Rebuilds the elements related to this component in case of
  62881. * context lost for instance.
  62882. */
  62883. rebuild(): void;
  62884. /**
  62885. * @hidden
  62886. */
  62887. reset(): void;
  62888. /**
  62889. * Render the bounding boxes of a specific rendering group
  62890. * @param renderingGroupId defines the rendering group to render
  62891. */
  62892. render(renderingGroupId: number): void;
  62893. /**
  62894. * In case of occlusion queries, we can render the occlusion bounding box through this method
  62895. * @param mesh Define the mesh to render the occlusion bounding box for
  62896. */
  62897. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  62898. /**
  62899. * Dispose and release the resources attached to this renderer.
  62900. */
  62901. dispose(): void;
  62902. }
  62903. }
  62904. declare module "babylonjs/Shaders/depth.fragment" {
  62905. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  62906. /** @hidden */
  62907. export var depthPixelShader: {
  62908. name: string;
  62909. shader: string;
  62910. };
  62911. }
  62912. declare module "babylonjs/Rendering/depthRenderer" {
  62913. import { Nullable } from "babylonjs/types";
  62914. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62915. import { Scene } from "babylonjs/scene";
  62916. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62917. import { Camera } from "babylonjs/Cameras/camera";
  62918. import "babylonjs/Shaders/depth.fragment";
  62919. import "babylonjs/Shaders/depth.vertex";
  62920. /**
  62921. * This represents a depth renderer in Babylon.
  62922. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  62923. */
  62924. export class DepthRenderer {
  62925. private _scene;
  62926. private _depthMap;
  62927. private _effect;
  62928. private readonly _storeNonLinearDepth;
  62929. private readonly _clearColor;
  62930. /** Get if the depth renderer is using packed depth or not */
  62931. readonly isPacked: boolean;
  62932. private _cachedDefines;
  62933. private _camera;
  62934. /**
  62935. * Specifiess that the depth renderer will only be used within
  62936. * the camera it is created for.
  62937. * This can help forcing its rendering during the camera processing.
  62938. */
  62939. useOnlyInActiveCamera: boolean;
  62940. /** @hidden */
  62941. static _SceneComponentInitialization: (scene: Scene) => void;
  62942. /**
  62943. * Instantiates a depth renderer
  62944. * @param scene The scene the renderer belongs to
  62945. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  62946. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  62947. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  62948. */
  62949. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  62950. /**
  62951. * Creates the depth rendering effect and checks if the effect is ready.
  62952. * @param subMesh The submesh to be used to render the depth map of
  62953. * @param useInstances If multiple world instances should be used
  62954. * @returns if the depth renderer is ready to render the depth map
  62955. */
  62956. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62957. /**
  62958. * Gets the texture which the depth map will be written to.
  62959. * @returns The depth map texture
  62960. */
  62961. getDepthMap(): RenderTargetTexture;
  62962. /**
  62963. * Disposes of the depth renderer.
  62964. */
  62965. dispose(): void;
  62966. }
  62967. }
  62968. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  62969. import { Nullable } from "babylonjs/types";
  62970. import { Scene } from "babylonjs/scene";
  62971. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  62972. import { Camera } from "babylonjs/Cameras/camera";
  62973. import { ISceneComponent } from "babylonjs/sceneComponent";
  62974. module "babylonjs/scene" {
  62975. interface Scene {
  62976. /** @hidden (Backing field) */
  62977. _depthRenderer: {
  62978. [id: string]: DepthRenderer;
  62979. };
  62980. /**
  62981. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  62982. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  62983. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  62984. * @returns the created depth renderer
  62985. */
  62986. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  62987. /**
  62988. * Disables a depth renderer for a given camera
  62989. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  62990. */
  62991. disableDepthRenderer(camera?: Nullable<Camera>): void;
  62992. }
  62993. }
  62994. /**
  62995. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  62996. * in several rendering techniques.
  62997. */
  62998. export class DepthRendererSceneComponent implements ISceneComponent {
  62999. /**
  63000. * The component name helpfull to identify the component in the list of scene components.
  63001. */
  63002. readonly name: string;
  63003. /**
  63004. * The scene the component belongs to.
  63005. */
  63006. scene: Scene;
  63007. /**
  63008. * Creates a new instance of the component for the given scene
  63009. * @param scene Defines the scene to register the component in
  63010. */
  63011. constructor(scene: Scene);
  63012. /**
  63013. * Registers the component in a given scene
  63014. */
  63015. register(): void;
  63016. /**
  63017. * Rebuilds the elements related to this component in case of
  63018. * context lost for instance.
  63019. */
  63020. rebuild(): void;
  63021. /**
  63022. * Disposes the component and the associated ressources
  63023. */
  63024. dispose(): void;
  63025. private _gatherRenderTargets;
  63026. private _gatherActiveCameraRenderTargets;
  63027. }
  63028. }
  63029. declare module "babylonjs/Shaders/outline.fragment" {
  63030. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  63031. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  63032. /** @hidden */
  63033. export var outlinePixelShader: {
  63034. name: string;
  63035. shader: string;
  63036. };
  63037. }
  63038. declare module "babylonjs/Shaders/outline.vertex" {
  63039. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63040. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63041. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63042. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63043. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  63044. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63045. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63046. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63047. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  63048. /** @hidden */
  63049. export var outlineVertexShader: {
  63050. name: string;
  63051. shader: string;
  63052. };
  63053. }
  63054. declare module "babylonjs/Rendering/outlineRenderer" {
  63055. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63056. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  63057. import { Scene } from "babylonjs/scene";
  63058. import { ISceneComponent } from "babylonjs/sceneComponent";
  63059. import "babylonjs/Shaders/outline.fragment";
  63060. import "babylonjs/Shaders/outline.vertex";
  63061. module "babylonjs/scene" {
  63062. interface Scene {
  63063. /** @hidden */
  63064. _outlineRenderer: OutlineRenderer;
  63065. /**
  63066. * Gets the outline renderer associated with the scene
  63067. * @returns a OutlineRenderer
  63068. */
  63069. getOutlineRenderer(): OutlineRenderer;
  63070. }
  63071. }
  63072. module "babylonjs/Meshes/abstractMesh" {
  63073. interface AbstractMesh {
  63074. /** @hidden (Backing field) */
  63075. _renderOutline: boolean;
  63076. /**
  63077. * Gets or sets a boolean indicating if the outline must be rendered as well
  63078. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  63079. */
  63080. renderOutline: boolean;
  63081. /** @hidden (Backing field) */
  63082. _renderOverlay: boolean;
  63083. /**
  63084. * Gets or sets a boolean indicating if the overlay must be rendered as well
  63085. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  63086. */
  63087. renderOverlay: boolean;
  63088. }
  63089. }
  63090. /**
  63091. * This class is responsible to draw bothe outline/overlay of meshes.
  63092. * It should not be used directly but through the available method on mesh.
  63093. */
  63094. export class OutlineRenderer implements ISceneComponent {
  63095. /**
  63096. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  63097. */
  63098. private static _StencilReference;
  63099. /**
  63100. * The name of the component. Each component must have a unique name.
  63101. */
  63102. name: string;
  63103. /**
  63104. * The scene the component belongs to.
  63105. */
  63106. scene: Scene;
  63107. /**
  63108. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  63109. */
  63110. zOffset: number;
  63111. private _engine;
  63112. private _effect;
  63113. private _cachedDefines;
  63114. private _savedDepthWrite;
  63115. /**
  63116. * Instantiates a new outline renderer. (There could be only one per scene).
  63117. * @param scene Defines the scene it belongs to
  63118. */
  63119. constructor(scene: Scene);
  63120. /**
  63121. * Register the component to one instance of a scene.
  63122. */
  63123. register(): void;
  63124. /**
  63125. * Rebuilds the elements related to this component in case of
  63126. * context lost for instance.
  63127. */
  63128. rebuild(): void;
  63129. /**
  63130. * Disposes the component and the associated ressources.
  63131. */
  63132. dispose(): void;
  63133. /**
  63134. * Renders the outline in the canvas.
  63135. * @param subMesh Defines the sumesh to render
  63136. * @param batch Defines the batch of meshes in case of instances
  63137. * @param useOverlay Defines if the rendering is for the overlay or the outline
  63138. */
  63139. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  63140. /**
  63141. * Returns whether or not the outline renderer is ready for a given submesh.
  63142. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  63143. * @param subMesh Defines the submesh to check readyness for
  63144. * @param useInstances Defines wheter wee are trying to render instances or not
  63145. * @returns true if ready otherwise false
  63146. */
  63147. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63148. private _beforeRenderingMesh;
  63149. private _afterRenderingMesh;
  63150. }
  63151. }
  63152. declare module "babylonjs/Rendering/index" {
  63153. export * from "babylonjs/Rendering/boundingBoxRenderer";
  63154. export * from "babylonjs/Rendering/depthRenderer";
  63155. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  63156. export * from "babylonjs/Rendering/edgesRenderer";
  63157. export * from "babylonjs/Rendering/geometryBufferRenderer";
  63158. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  63159. export * from "babylonjs/Rendering/outlineRenderer";
  63160. export * from "babylonjs/Rendering/renderingGroup";
  63161. export * from "babylonjs/Rendering/renderingManager";
  63162. export * from "babylonjs/Rendering/utilityLayerRenderer";
  63163. }
  63164. declare module "babylonjs/Sprites/spritePackedManager" {
  63165. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  63166. import { Scene } from "babylonjs/scene";
  63167. /**
  63168. * Class used to manage multiple sprites of different sizes on the same spritesheet
  63169. * @see http://doc.babylonjs.com/babylon101/sprites
  63170. */
  63171. export class SpritePackedManager extends SpriteManager {
  63172. /** defines the packed manager's name */
  63173. name: string;
  63174. /**
  63175. * Creates a new sprite manager from a packed sprite sheet
  63176. * @param name defines the manager's name
  63177. * @param imgUrl defines the sprite sheet url
  63178. * @param capacity defines the maximum allowed number of sprites
  63179. * @param scene defines the hosting scene
  63180. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  63181. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  63182. * @param samplingMode defines the smapling mode to use with spritesheet
  63183. * @param fromPacked set to true; do not alter
  63184. */
  63185. constructor(
  63186. /** defines the packed manager's name */
  63187. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  63188. }
  63189. }
  63190. declare module "babylonjs/Sprites/index" {
  63191. export * from "babylonjs/Sprites/sprite";
  63192. export * from "babylonjs/Sprites/spriteManager";
  63193. export * from "babylonjs/Sprites/spritePackedManager";
  63194. export * from "babylonjs/Sprites/spriteSceneComponent";
  63195. }
  63196. declare module "babylonjs/Misc/assetsManager" {
  63197. import { Scene } from "babylonjs/scene";
  63198. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63199. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  63200. import { Skeleton } from "babylonjs/Bones/skeleton";
  63201. import { Observable } from "babylonjs/Misc/observable";
  63202. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63203. import { Texture } from "babylonjs/Materials/Textures/texture";
  63204. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  63205. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  63206. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  63207. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  63208. /**
  63209. * Defines the list of states available for a task inside a AssetsManager
  63210. */
  63211. export enum AssetTaskState {
  63212. /**
  63213. * Initialization
  63214. */
  63215. INIT = 0,
  63216. /**
  63217. * Running
  63218. */
  63219. RUNNING = 1,
  63220. /**
  63221. * Done
  63222. */
  63223. DONE = 2,
  63224. /**
  63225. * Error
  63226. */
  63227. ERROR = 3
  63228. }
  63229. /**
  63230. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  63231. */
  63232. export abstract class AbstractAssetTask {
  63233. /**
  63234. * Task name
  63235. */ name: string;
  63236. /**
  63237. * Callback called when the task is successful
  63238. */
  63239. onSuccess: (task: any) => void;
  63240. /**
  63241. * Callback called when the task is not successful
  63242. */
  63243. onError: (task: any, message?: string, exception?: any) => void;
  63244. /**
  63245. * Creates a new AssetsManager
  63246. * @param name defines the name of the task
  63247. */
  63248. constructor(
  63249. /**
  63250. * Task name
  63251. */ name: string);
  63252. private _isCompleted;
  63253. private _taskState;
  63254. private _errorObject;
  63255. /**
  63256. * Get if the task is completed
  63257. */
  63258. readonly isCompleted: boolean;
  63259. /**
  63260. * Gets the current state of the task
  63261. */
  63262. readonly taskState: AssetTaskState;
  63263. /**
  63264. * Gets the current error object (if task is in error)
  63265. */
  63266. readonly errorObject: {
  63267. message?: string;
  63268. exception?: any;
  63269. };
  63270. /**
  63271. * Internal only
  63272. * @hidden
  63273. */
  63274. _setErrorObject(message?: string, exception?: any): void;
  63275. /**
  63276. * Execute the current task
  63277. * @param scene defines the scene where you want your assets to be loaded
  63278. * @param onSuccess is a callback called when the task is successfully executed
  63279. * @param onError is a callback called if an error occurs
  63280. */
  63281. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63282. /**
  63283. * Execute the current task
  63284. * @param scene defines the scene where you want your assets to be loaded
  63285. * @param onSuccess is a callback called when the task is successfully executed
  63286. * @param onError is a callback called if an error occurs
  63287. */
  63288. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63289. /**
  63290. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  63291. * This can be used with failed tasks that have the reason for failure fixed.
  63292. */
  63293. reset(): void;
  63294. private onErrorCallback;
  63295. private onDoneCallback;
  63296. }
  63297. /**
  63298. * Define the interface used by progress events raised during assets loading
  63299. */
  63300. export interface IAssetsProgressEvent {
  63301. /**
  63302. * Defines the number of remaining tasks to process
  63303. */
  63304. remainingCount: number;
  63305. /**
  63306. * Defines the total number of tasks
  63307. */
  63308. totalCount: number;
  63309. /**
  63310. * Defines the task that was just processed
  63311. */
  63312. task: AbstractAssetTask;
  63313. }
  63314. /**
  63315. * Class used to share progress information about assets loading
  63316. */
  63317. export class AssetsProgressEvent implements IAssetsProgressEvent {
  63318. /**
  63319. * Defines the number of remaining tasks to process
  63320. */
  63321. remainingCount: number;
  63322. /**
  63323. * Defines the total number of tasks
  63324. */
  63325. totalCount: number;
  63326. /**
  63327. * Defines the task that was just processed
  63328. */
  63329. task: AbstractAssetTask;
  63330. /**
  63331. * Creates a AssetsProgressEvent
  63332. * @param remainingCount defines the number of remaining tasks to process
  63333. * @param totalCount defines the total number of tasks
  63334. * @param task defines the task that was just processed
  63335. */
  63336. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  63337. }
  63338. /**
  63339. * Define a task used by AssetsManager to load meshes
  63340. */
  63341. export class MeshAssetTask extends AbstractAssetTask {
  63342. /**
  63343. * Defines the name of the task
  63344. */
  63345. name: string;
  63346. /**
  63347. * Defines the list of mesh's names you want to load
  63348. */
  63349. meshesNames: any;
  63350. /**
  63351. * Defines the root url to use as a base to load your meshes and associated resources
  63352. */
  63353. rootUrl: string;
  63354. /**
  63355. * Defines the filename of the scene to load from
  63356. */
  63357. sceneFilename: string;
  63358. /**
  63359. * Gets the list of loaded meshes
  63360. */
  63361. loadedMeshes: Array<AbstractMesh>;
  63362. /**
  63363. * Gets the list of loaded particle systems
  63364. */
  63365. loadedParticleSystems: Array<IParticleSystem>;
  63366. /**
  63367. * Gets the list of loaded skeletons
  63368. */
  63369. loadedSkeletons: Array<Skeleton>;
  63370. /**
  63371. * Gets the list of loaded animation groups
  63372. */
  63373. loadedAnimationGroups: Array<AnimationGroup>;
  63374. /**
  63375. * Callback called when the task is successful
  63376. */
  63377. onSuccess: (task: MeshAssetTask) => void;
  63378. /**
  63379. * Callback called when the task is successful
  63380. */
  63381. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  63382. /**
  63383. * Creates a new MeshAssetTask
  63384. * @param name defines the name of the task
  63385. * @param meshesNames defines the list of mesh's names you want to load
  63386. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  63387. * @param sceneFilename defines the filename of the scene to load from
  63388. */
  63389. constructor(
  63390. /**
  63391. * Defines the name of the task
  63392. */
  63393. name: string,
  63394. /**
  63395. * Defines the list of mesh's names you want to load
  63396. */
  63397. meshesNames: any,
  63398. /**
  63399. * Defines the root url to use as a base to load your meshes and associated resources
  63400. */
  63401. rootUrl: string,
  63402. /**
  63403. * Defines the filename of the scene to load from
  63404. */
  63405. sceneFilename: string);
  63406. /**
  63407. * Execute the current task
  63408. * @param scene defines the scene where you want your assets to be loaded
  63409. * @param onSuccess is a callback called when the task is successfully executed
  63410. * @param onError is a callback called if an error occurs
  63411. */
  63412. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63413. }
  63414. /**
  63415. * Define a task used by AssetsManager to load text content
  63416. */
  63417. export class TextFileAssetTask extends AbstractAssetTask {
  63418. /**
  63419. * Defines the name of the task
  63420. */
  63421. name: string;
  63422. /**
  63423. * Defines the location of the file to load
  63424. */
  63425. url: string;
  63426. /**
  63427. * Gets the loaded text string
  63428. */
  63429. text: string;
  63430. /**
  63431. * Callback called when the task is successful
  63432. */
  63433. onSuccess: (task: TextFileAssetTask) => void;
  63434. /**
  63435. * Callback called when the task is successful
  63436. */
  63437. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  63438. /**
  63439. * Creates a new TextFileAssetTask object
  63440. * @param name defines the name of the task
  63441. * @param url defines the location of the file to load
  63442. */
  63443. constructor(
  63444. /**
  63445. * Defines the name of the task
  63446. */
  63447. name: string,
  63448. /**
  63449. * Defines the location of the file to load
  63450. */
  63451. url: string);
  63452. /**
  63453. * Execute the current task
  63454. * @param scene defines the scene where you want your assets to be loaded
  63455. * @param onSuccess is a callback called when the task is successfully executed
  63456. * @param onError is a callback called if an error occurs
  63457. */
  63458. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63459. }
  63460. /**
  63461. * Define a task used by AssetsManager to load binary data
  63462. */
  63463. export class BinaryFileAssetTask extends AbstractAssetTask {
  63464. /**
  63465. * Defines the name of the task
  63466. */
  63467. name: string;
  63468. /**
  63469. * Defines the location of the file to load
  63470. */
  63471. url: string;
  63472. /**
  63473. * Gets the lodaded data (as an array buffer)
  63474. */
  63475. data: ArrayBuffer;
  63476. /**
  63477. * Callback called when the task is successful
  63478. */
  63479. onSuccess: (task: BinaryFileAssetTask) => void;
  63480. /**
  63481. * Callback called when the task is successful
  63482. */
  63483. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  63484. /**
  63485. * Creates a new BinaryFileAssetTask object
  63486. * @param name defines the name of the new task
  63487. * @param url defines the location of the file to load
  63488. */
  63489. constructor(
  63490. /**
  63491. * Defines the name of the task
  63492. */
  63493. name: string,
  63494. /**
  63495. * Defines the location of the file to load
  63496. */
  63497. url: string);
  63498. /**
  63499. * Execute the current task
  63500. * @param scene defines the scene where you want your assets to be loaded
  63501. * @param onSuccess is a callback called when the task is successfully executed
  63502. * @param onError is a callback called if an error occurs
  63503. */
  63504. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63505. }
  63506. /**
  63507. * Define a task used by AssetsManager to load images
  63508. */
  63509. export class ImageAssetTask extends AbstractAssetTask {
  63510. /**
  63511. * Defines the name of the task
  63512. */
  63513. name: string;
  63514. /**
  63515. * Defines the location of the image to load
  63516. */
  63517. url: string;
  63518. /**
  63519. * Gets the loaded images
  63520. */
  63521. image: HTMLImageElement;
  63522. /**
  63523. * Callback called when the task is successful
  63524. */
  63525. onSuccess: (task: ImageAssetTask) => void;
  63526. /**
  63527. * Callback called when the task is successful
  63528. */
  63529. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  63530. /**
  63531. * Creates a new ImageAssetTask
  63532. * @param name defines the name of the task
  63533. * @param url defines the location of the image to load
  63534. */
  63535. constructor(
  63536. /**
  63537. * Defines the name of the task
  63538. */
  63539. name: string,
  63540. /**
  63541. * Defines the location of the image to load
  63542. */
  63543. url: string);
  63544. /**
  63545. * Execute the current task
  63546. * @param scene defines the scene where you want your assets to be loaded
  63547. * @param onSuccess is a callback called when the task is successfully executed
  63548. * @param onError is a callback called if an error occurs
  63549. */
  63550. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63551. }
  63552. /**
  63553. * Defines the interface used by texture loading tasks
  63554. */
  63555. export interface ITextureAssetTask<TEX extends BaseTexture> {
  63556. /**
  63557. * Gets the loaded texture
  63558. */
  63559. texture: TEX;
  63560. }
  63561. /**
  63562. * Define a task used by AssetsManager to load 2D textures
  63563. */
  63564. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  63565. /**
  63566. * Defines the name of the task
  63567. */
  63568. name: string;
  63569. /**
  63570. * Defines the location of the file to load
  63571. */
  63572. url: string;
  63573. /**
  63574. * Defines if mipmap should not be generated (default is false)
  63575. */
  63576. noMipmap?: boolean | undefined;
  63577. /**
  63578. * Defines if texture must be inverted on Y axis (default is false)
  63579. */
  63580. invertY?: boolean | undefined;
  63581. /**
  63582. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  63583. */
  63584. samplingMode: number;
  63585. /**
  63586. * Gets the loaded texture
  63587. */
  63588. texture: Texture;
  63589. /**
  63590. * Callback called when the task is successful
  63591. */
  63592. onSuccess: (task: TextureAssetTask) => void;
  63593. /**
  63594. * Callback called when the task is successful
  63595. */
  63596. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  63597. /**
  63598. * Creates a new TextureAssetTask object
  63599. * @param name defines the name of the task
  63600. * @param url defines the location of the file to load
  63601. * @param noMipmap defines if mipmap should not be generated (default is false)
  63602. * @param invertY defines if texture must be inverted on Y axis (default is false)
  63603. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  63604. */
  63605. constructor(
  63606. /**
  63607. * Defines the name of the task
  63608. */
  63609. name: string,
  63610. /**
  63611. * Defines the location of the file to load
  63612. */
  63613. url: string,
  63614. /**
  63615. * Defines if mipmap should not be generated (default is false)
  63616. */
  63617. noMipmap?: boolean | undefined,
  63618. /**
  63619. * Defines if texture must be inverted on Y axis (default is false)
  63620. */
  63621. invertY?: boolean | undefined,
  63622. /**
  63623. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  63624. */
  63625. samplingMode?: number);
  63626. /**
  63627. * Execute the current task
  63628. * @param scene defines the scene where you want your assets to be loaded
  63629. * @param onSuccess is a callback called when the task is successfully executed
  63630. * @param onError is a callback called if an error occurs
  63631. */
  63632. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63633. }
  63634. /**
  63635. * Define a task used by AssetsManager to load cube textures
  63636. */
  63637. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  63638. /**
  63639. * Defines the name of the task
  63640. */
  63641. name: string;
  63642. /**
  63643. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  63644. */
  63645. url: string;
  63646. /**
  63647. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  63648. */
  63649. extensions?: string[] | undefined;
  63650. /**
  63651. * Defines if mipmaps should not be generated (default is false)
  63652. */
  63653. noMipmap?: boolean | undefined;
  63654. /**
  63655. * Defines the explicit list of files (undefined by default)
  63656. */
  63657. files?: string[] | undefined;
  63658. /**
  63659. * Gets the loaded texture
  63660. */
  63661. texture: CubeTexture;
  63662. /**
  63663. * Callback called when the task is successful
  63664. */
  63665. onSuccess: (task: CubeTextureAssetTask) => void;
  63666. /**
  63667. * Callback called when the task is successful
  63668. */
  63669. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  63670. /**
  63671. * Creates a new CubeTextureAssetTask
  63672. * @param name defines the name of the task
  63673. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  63674. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  63675. * @param noMipmap defines if mipmaps should not be generated (default is false)
  63676. * @param files defines the explicit list of files (undefined by default)
  63677. */
  63678. constructor(
  63679. /**
  63680. * Defines the name of the task
  63681. */
  63682. name: string,
  63683. /**
  63684. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  63685. */
  63686. url: string,
  63687. /**
  63688. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  63689. */
  63690. extensions?: string[] | undefined,
  63691. /**
  63692. * Defines if mipmaps should not be generated (default is false)
  63693. */
  63694. noMipmap?: boolean | undefined,
  63695. /**
  63696. * Defines the explicit list of files (undefined by default)
  63697. */
  63698. files?: string[] | undefined);
  63699. /**
  63700. * Execute the current task
  63701. * @param scene defines the scene where you want your assets to be loaded
  63702. * @param onSuccess is a callback called when the task is successfully executed
  63703. * @param onError is a callback called if an error occurs
  63704. */
  63705. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63706. }
  63707. /**
  63708. * Define a task used by AssetsManager to load HDR cube textures
  63709. */
  63710. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  63711. /**
  63712. * Defines the name of the task
  63713. */
  63714. name: string;
  63715. /**
  63716. * Defines the location of the file to load
  63717. */
  63718. url: string;
  63719. /**
  63720. * Defines the desired size (the more it increases the longer the generation will be)
  63721. */
  63722. size: number;
  63723. /**
  63724. * Defines if mipmaps should not be generated (default is false)
  63725. */
  63726. noMipmap: boolean;
  63727. /**
  63728. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  63729. */
  63730. generateHarmonics: boolean;
  63731. /**
  63732. * 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)
  63733. */
  63734. gammaSpace: boolean;
  63735. /**
  63736. * Internal Use Only
  63737. */
  63738. reserved: boolean;
  63739. /**
  63740. * Gets the loaded texture
  63741. */
  63742. texture: HDRCubeTexture;
  63743. /**
  63744. * Callback called when the task is successful
  63745. */
  63746. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  63747. /**
  63748. * Callback called when the task is successful
  63749. */
  63750. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  63751. /**
  63752. * Creates a new HDRCubeTextureAssetTask object
  63753. * @param name defines the name of the task
  63754. * @param url defines the location of the file to load
  63755. * @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.
  63756. * @param noMipmap defines if mipmaps should not be generated (default is false)
  63757. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  63758. * @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)
  63759. * @param reserved Internal use only
  63760. */
  63761. constructor(
  63762. /**
  63763. * Defines the name of the task
  63764. */
  63765. name: string,
  63766. /**
  63767. * Defines the location of the file to load
  63768. */
  63769. url: string,
  63770. /**
  63771. * Defines the desired size (the more it increases the longer the generation will be)
  63772. */
  63773. size: number,
  63774. /**
  63775. * Defines if mipmaps should not be generated (default is false)
  63776. */
  63777. noMipmap?: boolean,
  63778. /**
  63779. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  63780. */
  63781. generateHarmonics?: boolean,
  63782. /**
  63783. * 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)
  63784. */
  63785. gammaSpace?: boolean,
  63786. /**
  63787. * Internal Use Only
  63788. */
  63789. reserved?: boolean);
  63790. /**
  63791. * Execute the current task
  63792. * @param scene defines the scene where you want your assets to be loaded
  63793. * @param onSuccess is a callback called when the task is successfully executed
  63794. * @param onError is a callback called if an error occurs
  63795. */
  63796. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63797. }
  63798. /**
  63799. * Define a task used by AssetsManager to load Equirectangular cube textures
  63800. */
  63801. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  63802. /**
  63803. * Defines the name of the task
  63804. */
  63805. name: string;
  63806. /**
  63807. * Defines the location of the file to load
  63808. */
  63809. url: string;
  63810. /**
  63811. * Defines the desired size (the more it increases the longer the generation will be)
  63812. */
  63813. size: number;
  63814. /**
  63815. * Defines if mipmaps should not be generated (default is false)
  63816. */
  63817. noMipmap: boolean;
  63818. /**
  63819. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  63820. * but the standard material would require them in Gamma space) (default is true)
  63821. */
  63822. gammaSpace: boolean;
  63823. /**
  63824. * Gets the loaded texture
  63825. */
  63826. texture: EquiRectangularCubeTexture;
  63827. /**
  63828. * Callback called when the task is successful
  63829. */
  63830. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  63831. /**
  63832. * Callback called when the task is successful
  63833. */
  63834. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  63835. /**
  63836. * Creates a new EquiRectangularCubeTextureAssetTask object
  63837. * @param name defines the name of the task
  63838. * @param url defines the location of the file to load
  63839. * @param size defines the desired size (the more it increases the longer the generation will be)
  63840. * If the size is omitted this implies you are using a preprocessed cubemap.
  63841. * @param noMipmap defines if mipmaps should not be generated (default is false)
  63842. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  63843. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  63844. * (default is true)
  63845. */
  63846. constructor(
  63847. /**
  63848. * Defines the name of the task
  63849. */
  63850. name: string,
  63851. /**
  63852. * Defines the location of the file to load
  63853. */
  63854. url: string,
  63855. /**
  63856. * Defines the desired size (the more it increases the longer the generation will be)
  63857. */
  63858. size: number,
  63859. /**
  63860. * Defines if mipmaps should not be generated (default is false)
  63861. */
  63862. noMipmap?: boolean,
  63863. /**
  63864. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  63865. * but the standard material would require them in Gamma space) (default is true)
  63866. */
  63867. gammaSpace?: boolean);
  63868. /**
  63869. * Execute the current task
  63870. * @param scene defines the scene where you want your assets to be loaded
  63871. * @param onSuccess is a callback called when the task is successfully executed
  63872. * @param onError is a callback called if an error occurs
  63873. */
  63874. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63875. }
  63876. /**
  63877. * This class can be used to easily import assets into a scene
  63878. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  63879. */
  63880. export class AssetsManager {
  63881. private _scene;
  63882. private _isLoading;
  63883. protected _tasks: AbstractAssetTask[];
  63884. protected _waitingTasksCount: number;
  63885. protected _totalTasksCount: number;
  63886. /**
  63887. * Callback called when all tasks are processed
  63888. */
  63889. onFinish: (tasks: AbstractAssetTask[]) => void;
  63890. /**
  63891. * Callback called when a task is successful
  63892. */
  63893. onTaskSuccess: (task: AbstractAssetTask) => void;
  63894. /**
  63895. * Callback called when a task had an error
  63896. */
  63897. onTaskError: (task: AbstractAssetTask) => void;
  63898. /**
  63899. * Callback called when a task is done (whatever the result is)
  63900. */
  63901. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  63902. /**
  63903. * Observable called when all tasks are processed
  63904. */
  63905. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  63906. /**
  63907. * Observable called when a task had an error
  63908. */
  63909. onTaskErrorObservable: Observable<AbstractAssetTask>;
  63910. /**
  63911. * Observable called when all tasks were executed
  63912. */
  63913. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  63914. /**
  63915. * Observable called when a task is done (whatever the result is)
  63916. */
  63917. onProgressObservable: Observable<IAssetsProgressEvent>;
  63918. /**
  63919. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  63920. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  63921. */
  63922. useDefaultLoadingScreen: boolean;
  63923. /**
  63924. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  63925. * when all assets have been downloaded.
  63926. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  63927. */
  63928. autoHideLoadingUI: boolean;
  63929. /**
  63930. * Creates a new AssetsManager
  63931. * @param scene defines the scene to work on
  63932. */
  63933. constructor(scene: Scene);
  63934. /**
  63935. * Add a MeshAssetTask to the list of active tasks
  63936. * @param taskName defines the name of the new task
  63937. * @param meshesNames defines the name of meshes to load
  63938. * @param rootUrl defines the root url to use to locate files
  63939. * @param sceneFilename defines the filename of the scene file
  63940. * @returns a new MeshAssetTask object
  63941. */
  63942. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  63943. /**
  63944. * Add a TextFileAssetTask to the list of active tasks
  63945. * @param taskName defines the name of the new task
  63946. * @param url defines the url of the file to load
  63947. * @returns a new TextFileAssetTask object
  63948. */
  63949. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  63950. /**
  63951. * Add a BinaryFileAssetTask to the list of active tasks
  63952. * @param taskName defines the name of the new task
  63953. * @param url defines the url of the file to load
  63954. * @returns a new BinaryFileAssetTask object
  63955. */
  63956. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  63957. /**
  63958. * Add a ImageAssetTask to the list of active tasks
  63959. * @param taskName defines the name of the new task
  63960. * @param url defines the url of the file to load
  63961. * @returns a new ImageAssetTask object
  63962. */
  63963. addImageTask(taskName: string, url: string): ImageAssetTask;
  63964. /**
  63965. * Add a TextureAssetTask to the list of active tasks
  63966. * @param taskName defines the name of the new task
  63967. * @param url defines the url of the file to load
  63968. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  63969. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  63970. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63971. * @returns a new TextureAssetTask object
  63972. */
  63973. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  63974. /**
  63975. * Add a CubeTextureAssetTask to the list of active tasks
  63976. * @param taskName defines the name of the new task
  63977. * @param url defines the url of the file to load
  63978. * @param extensions defines the extension to use to load the cube map (can be null)
  63979. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  63980. * @param files defines the list of files to load (can be null)
  63981. * @returns a new CubeTextureAssetTask object
  63982. */
  63983. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  63984. /**
  63985. *
  63986. * Add a HDRCubeTextureAssetTask to the list of active tasks
  63987. * @param taskName defines the name of the new task
  63988. * @param url defines the url of the file to load
  63989. * @param size defines the size you want for the cubemap (can be null)
  63990. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  63991. * @param generateHarmonics defines if you want to automatically generate (true by default)
  63992. * @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)
  63993. * @param reserved Internal use only
  63994. * @returns a new HDRCubeTextureAssetTask object
  63995. */
  63996. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  63997. /**
  63998. *
  63999. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  64000. * @param taskName defines the name of the new task
  64001. * @param url defines the url of the file to load
  64002. * @param size defines the size you want for the cubemap (can be null)
  64003. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64004. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  64005. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  64006. * @returns a new EquiRectangularCubeTextureAssetTask object
  64007. */
  64008. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  64009. /**
  64010. * Remove a task from the assets manager.
  64011. * @param task the task to remove
  64012. */
  64013. removeTask(task: AbstractAssetTask): void;
  64014. private _decreaseWaitingTasksCount;
  64015. private _runTask;
  64016. /**
  64017. * Reset the AssetsManager and remove all tasks
  64018. * @return the current instance of the AssetsManager
  64019. */
  64020. reset(): AssetsManager;
  64021. /**
  64022. * Start the loading process
  64023. * @return the current instance of the AssetsManager
  64024. */
  64025. load(): AssetsManager;
  64026. /**
  64027. * Start the loading process as an async operation
  64028. * @return a promise returning the list of failed tasks
  64029. */
  64030. loadAsync(): Promise<void>;
  64031. }
  64032. }
  64033. declare module "babylonjs/Misc/deferred" {
  64034. /**
  64035. * Wrapper class for promise with external resolve and reject.
  64036. */
  64037. export class Deferred<T> {
  64038. /**
  64039. * The promise associated with this deferred object.
  64040. */
  64041. readonly promise: Promise<T>;
  64042. private _resolve;
  64043. private _reject;
  64044. /**
  64045. * The resolve method of the promise associated with this deferred object.
  64046. */
  64047. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  64048. /**
  64049. * The reject method of the promise associated with this deferred object.
  64050. */
  64051. readonly reject: (reason?: any) => void;
  64052. /**
  64053. * Constructor for this deferred object.
  64054. */
  64055. constructor();
  64056. }
  64057. }
  64058. declare module "babylonjs/Misc/meshExploder" {
  64059. import { Mesh } from "babylonjs/Meshes/mesh";
  64060. /**
  64061. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  64062. */
  64063. export class MeshExploder {
  64064. private _centerMesh;
  64065. private _meshes;
  64066. private _meshesOrigins;
  64067. private _toCenterVectors;
  64068. private _scaledDirection;
  64069. private _newPosition;
  64070. private _centerPosition;
  64071. /**
  64072. * Explodes meshes from a center mesh.
  64073. * @param meshes The meshes to explode.
  64074. * @param centerMesh The mesh to be center of explosion.
  64075. */
  64076. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  64077. private _setCenterMesh;
  64078. /**
  64079. * Get class name
  64080. * @returns "MeshExploder"
  64081. */
  64082. getClassName(): string;
  64083. /**
  64084. * "Exploded meshes"
  64085. * @returns Array of meshes with the centerMesh at index 0.
  64086. */
  64087. getMeshes(): Array<Mesh>;
  64088. /**
  64089. * Explodes meshes giving a specific direction
  64090. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  64091. */
  64092. explode(direction?: number): void;
  64093. }
  64094. }
  64095. declare module "babylonjs/Misc/filesInput" {
  64096. import { Engine } from "babylonjs/Engines/engine";
  64097. import { Scene } from "babylonjs/scene";
  64098. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  64099. /**
  64100. * Class used to help managing file picking and drag'n'drop
  64101. */
  64102. export class FilesInput {
  64103. /**
  64104. * List of files ready to be loaded
  64105. */
  64106. static readonly FilesToLoad: {
  64107. [key: string]: File;
  64108. };
  64109. /**
  64110. * Callback called when a file is processed
  64111. */
  64112. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  64113. private _engine;
  64114. private _currentScene;
  64115. private _sceneLoadedCallback;
  64116. private _progressCallback;
  64117. private _additionalRenderLoopLogicCallback;
  64118. private _textureLoadingCallback;
  64119. private _startingProcessingFilesCallback;
  64120. private _onReloadCallback;
  64121. private _errorCallback;
  64122. private _elementToMonitor;
  64123. private _sceneFileToLoad;
  64124. private _filesToLoad;
  64125. /**
  64126. * Creates a new FilesInput
  64127. * @param engine defines the rendering engine
  64128. * @param scene defines the hosting scene
  64129. * @param sceneLoadedCallback callback called when scene is loaded
  64130. * @param progressCallback callback called to track progress
  64131. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  64132. * @param textureLoadingCallback callback called when a texture is loading
  64133. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  64134. * @param onReloadCallback callback called when a reload is requested
  64135. * @param errorCallback callback call if an error occurs
  64136. */
  64137. 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);
  64138. private _dragEnterHandler;
  64139. private _dragOverHandler;
  64140. private _dropHandler;
  64141. /**
  64142. * Calls this function to listen to drag'n'drop events on a specific DOM element
  64143. * @param elementToMonitor defines the DOM element to track
  64144. */
  64145. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  64146. /**
  64147. * Release all associated resources
  64148. */
  64149. dispose(): void;
  64150. private renderFunction;
  64151. private drag;
  64152. private drop;
  64153. private _traverseFolder;
  64154. private _processFiles;
  64155. /**
  64156. * Load files from a drop event
  64157. * @param event defines the drop event to use as source
  64158. */
  64159. loadFiles(event: any): void;
  64160. private _processReload;
  64161. /**
  64162. * Reload the current scene from the loaded files
  64163. */
  64164. reload(): void;
  64165. }
  64166. }
  64167. declare module "babylonjs/Misc/HighDynamicRange/index" {
  64168. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  64169. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  64170. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  64171. }
  64172. declare module "babylonjs/Misc/sceneOptimizer" {
  64173. import { Scene, IDisposable } from "babylonjs/scene";
  64174. import { Observable } from "babylonjs/Misc/observable";
  64175. /**
  64176. * Defines the root class used to create scene optimization to use with SceneOptimizer
  64177. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64178. */
  64179. export class SceneOptimization {
  64180. /**
  64181. * Defines the priority of this optimization (0 by default which means first in the list)
  64182. */
  64183. priority: number;
  64184. /**
  64185. * Gets a string describing the action executed by the current optimization
  64186. * @returns description string
  64187. */
  64188. getDescription(): string;
  64189. /**
  64190. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64191. * @param scene defines the current scene where to apply this optimization
  64192. * @param optimizer defines the current optimizer
  64193. * @returns true if everything that can be done was applied
  64194. */
  64195. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64196. /**
  64197. * Creates the SceneOptimization object
  64198. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  64199. * @param desc defines the description associated with the optimization
  64200. */
  64201. constructor(
  64202. /**
  64203. * Defines the priority of this optimization (0 by default which means first in the list)
  64204. */
  64205. priority?: number);
  64206. }
  64207. /**
  64208. * Defines an optimization used to reduce the size of render target textures
  64209. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64210. */
  64211. export class TextureOptimization extends SceneOptimization {
  64212. /**
  64213. * Defines the priority of this optimization (0 by default which means first in the list)
  64214. */
  64215. priority: number;
  64216. /**
  64217. * 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
  64218. */
  64219. maximumSize: number;
  64220. /**
  64221. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  64222. */
  64223. step: number;
  64224. /**
  64225. * Gets a string describing the action executed by the current optimization
  64226. * @returns description string
  64227. */
  64228. getDescription(): string;
  64229. /**
  64230. * Creates the TextureOptimization object
  64231. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  64232. * @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
  64233. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  64234. */
  64235. constructor(
  64236. /**
  64237. * Defines the priority of this optimization (0 by default which means first in the list)
  64238. */
  64239. priority?: number,
  64240. /**
  64241. * 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
  64242. */
  64243. maximumSize?: number,
  64244. /**
  64245. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  64246. */
  64247. step?: number);
  64248. /**
  64249. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64250. * @param scene defines the current scene where to apply this optimization
  64251. * @param optimizer defines the current optimizer
  64252. * @returns true if everything that can be done was applied
  64253. */
  64254. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64255. }
  64256. /**
  64257. * Defines an optimization used to increase or decrease the rendering resolution
  64258. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64259. */
  64260. export class HardwareScalingOptimization extends SceneOptimization {
  64261. /**
  64262. * Defines the priority of this optimization (0 by default which means first in the list)
  64263. */
  64264. priority: number;
  64265. /**
  64266. * Defines the maximum scale to use (2 by default)
  64267. */
  64268. maximumScale: number;
  64269. /**
  64270. * Defines the step to use between two passes (0.5 by default)
  64271. */
  64272. step: number;
  64273. private _currentScale;
  64274. private _directionOffset;
  64275. /**
  64276. * Gets a string describing the action executed by the current optimization
  64277. * @return description string
  64278. */
  64279. getDescription(): string;
  64280. /**
  64281. * Creates the HardwareScalingOptimization object
  64282. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  64283. * @param maximumScale defines the maximum scale to use (2 by default)
  64284. * @param step defines the step to use between two passes (0.5 by default)
  64285. */
  64286. constructor(
  64287. /**
  64288. * Defines the priority of this optimization (0 by default which means first in the list)
  64289. */
  64290. priority?: number,
  64291. /**
  64292. * Defines the maximum scale to use (2 by default)
  64293. */
  64294. maximumScale?: number,
  64295. /**
  64296. * Defines the step to use between two passes (0.5 by default)
  64297. */
  64298. step?: number);
  64299. /**
  64300. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64301. * @param scene defines the current scene where to apply this optimization
  64302. * @param optimizer defines the current optimizer
  64303. * @returns true if everything that can be done was applied
  64304. */
  64305. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64306. }
  64307. /**
  64308. * Defines an optimization used to remove shadows
  64309. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64310. */
  64311. export class ShadowsOptimization extends SceneOptimization {
  64312. /**
  64313. * Gets a string describing the action executed by the current optimization
  64314. * @return description string
  64315. */
  64316. getDescription(): string;
  64317. /**
  64318. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64319. * @param scene defines the current scene where to apply this optimization
  64320. * @param optimizer defines the current optimizer
  64321. * @returns true if everything that can be done was applied
  64322. */
  64323. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64324. }
  64325. /**
  64326. * Defines an optimization used to turn post-processes off
  64327. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64328. */
  64329. export class PostProcessesOptimization extends SceneOptimization {
  64330. /**
  64331. * Gets a string describing the action executed by the current optimization
  64332. * @return description string
  64333. */
  64334. getDescription(): string;
  64335. /**
  64336. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64337. * @param scene defines the current scene where to apply this optimization
  64338. * @param optimizer defines the current optimizer
  64339. * @returns true if everything that can be done was applied
  64340. */
  64341. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64342. }
  64343. /**
  64344. * Defines an optimization used to turn lens flares off
  64345. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64346. */
  64347. export class LensFlaresOptimization extends SceneOptimization {
  64348. /**
  64349. * Gets a string describing the action executed by the current optimization
  64350. * @return description string
  64351. */
  64352. getDescription(): string;
  64353. /**
  64354. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64355. * @param scene defines the current scene where to apply this optimization
  64356. * @param optimizer defines the current optimizer
  64357. * @returns true if everything that can be done was applied
  64358. */
  64359. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64360. }
  64361. /**
  64362. * Defines an optimization based on user defined callback.
  64363. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64364. */
  64365. export class CustomOptimization extends SceneOptimization {
  64366. /**
  64367. * Callback called to apply the custom optimization.
  64368. */
  64369. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  64370. /**
  64371. * Callback called to get custom description
  64372. */
  64373. onGetDescription: () => string;
  64374. /**
  64375. * Gets a string describing the action executed by the current optimization
  64376. * @returns description string
  64377. */
  64378. getDescription(): string;
  64379. /**
  64380. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64381. * @param scene defines the current scene where to apply this optimization
  64382. * @param optimizer defines the current optimizer
  64383. * @returns true if everything that can be done was applied
  64384. */
  64385. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64386. }
  64387. /**
  64388. * Defines an optimization used to turn particles off
  64389. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64390. */
  64391. export class ParticlesOptimization extends SceneOptimization {
  64392. /**
  64393. * Gets a string describing the action executed by the current optimization
  64394. * @return description string
  64395. */
  64396. getDescription(): string;
  64397. /**
  64398. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64399. * @param scene defines the current scene where to apply this optimization
  64400. * @param optimizer defines the current optimizer
  64401. * @returns true if everything that can be done was applied
  64402. */
  64403. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64404. }
  64405. /**
  64406. * Defines an optimization used to turn render targets off
  64407. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64408. */
  64409. export class RenderTargetsOptimization extends SceneOptimization {
  64410. /**
  64411. * Gets a string describing the action executed by the current optimization
  64412. * @return description string
  64413. */
  64414. getDescription(): string;
  64415. /**
  64416. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64417. * @param scene defines the current scene where to apply this optimization
  64418. * @param optimizer defines the current optimizer
  64419. * @returns true if everything that can be done was applied
  64420. */
  64421. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64422. }
  64423. /**
  64424. * Defines an optimization used to merge meshes with compatible materials
  64425. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64426. */
  64427. export class MergeMeshesOptimization extends SceneOptimization {
  64428. private static _UpdateSelectionTree;
  64429. /**
  64430. * Gets or sets a boolean which defines if optimization octree has to be updated
  64431. */
  64432. /**
  64433. * Gets or sets a boolean which defines if optimization octree has to be updated
  64434. */
  64435. static UpdateSelectionTree: boolean;
  64436. /**
  64437. * Gets a string describing the action executed by the current optimization
  64438. * @return description string
  64439. */
  64440. getDescription(): string;
  64441. private _canBeMerged;
  64442. /**
  64443. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64444. * @param scene defines the current scene where to apply this optimization
  64445. * @param optimizer defines the current optimizer
  64446. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  64447. * @returns true if everything that can be done was applied
  64448. */
  64449. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  64450. }
  64451. /**
  64452. * Defines a list of options used by SceneOptimizer
  64453. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64454. */
  64455. export class SceneOptimizerOptions {
  64456. /**
  64457. * Defines the target frame rate to reach (60 by default)
  64458. */
  64459. targetFrameRate: number;
  64460. /**
  64461. * Defines the interval between two checkes (2000ms by default)
  64462. */
  64463. trackerDuration: number;
  64464. /**
  64465. * Gets the list of optimizations to apply
  64466. */
  64467. optimizations: SceneOptimization[];
  64468. /**
  64469. * Creates a new list of options used by SceneOptimizer
  64470. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  64471. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  64472. */
  64473. constructor(
  64474. /**
  64475. * Defines the target frame rate to reach (60 by default)
  64476. */
  64477. targetFrameRate?: number,
  64478. /**
  64479. * Defines the interval between two checkes (2000ms by default)
  64480. */
  64481. trackerDuration?: number);
  64482. /**
  64483. * Add a new optimization
  64484. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  64485. * @returns the current SceneOptimizerOptions
  64486. */
  64487. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  64488. /**
  64489. * Add a new custom optimization
  64490. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  64491. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  64492. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  64493. * @returns the current SceneOptimizerOptions
  64494. */
  64495. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  64496. /**
  64497. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  64498. * @param targetFrameRate defines the target frame rate (60 by default)
  64499. * @returns a SceneOptimizerOptions object
  64500. */
  64501. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  64502. /**
  64503. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  64504. * @param targetFrameRate defines the target frame rate (60 by default)
  64505. * @returns a SceneOptimizerOptions object
  64506. */
  64507. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  64508. /**
  64509. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  64510. * @param targetFrameRate defines the target frame rate (60 by default)
  64511. * @returns a SceneOptimizerOptions object
  64512. */
  64513. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  64514. }
  64515. /**
  64516. * Class used to run optimizations in order to reach a target frame rate
  64517. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64518. */
  64519. export class SceneOptimizer implements IDisposable {
  64520. private _isRunning;
  64521. private _options;
  64522. private _scene;
  64523. private _currentPriorityLevel;
  64524. private _targetFrameRate;
  64525. private _trackerDuration;
  64526. private _currentFrameRate;
  64527. private _sceneDisposeObserver;
  64528. private _improvementMode;
  64529. /**
  64530. * Defines an observable called when the optimizer reaches the target frame rate
  64531. */
  64532. onSuccessObservable: Observable<SceneOptimizer>;
  64533. /**
  64534. * Defines an observable called when the optimizer enables an optimization
  64535. */
  64536. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  64537. /**
  64538. * Defines an observable called when the optimizer is not able to reach the target frame rate
  64539. */
  64540. onFailureObservable: Observable<SceneOptimizer>;
  64541. /**
  64542. * Gets a boolean indicating if the optimizer is in improvement mode
  64543. */
  64544. readonly isInImprovementMode: boolean;
  64545. /**
  64546. * Gets the current priority level (0 at start)
  64547. */
  64548. readonly currentPriorityLevel: number;
  64549. /**
  64550. * Gets the current frame rate checked by the SceneOptimizer
  64551. */
  64552. readonly currentFrameRate: number;
  64553. /**
  64554. * Gets or sets the current target frame rate (60 by default)
  64555. */
  64556. /**
  64557. * Gets or sets the current target frame rate (60 by default)
  64558. */
  64559. targetFrameRate: number;
  64560. /**
  64561. * Gets or sets the current interval between two checks (every 2000ms by default)
  64562. */
  64563. /**
  64564. * Gets or sets the current interval between two checks (every 2000ms by default)
  64565. */
  64566. trackerDuration: number;
  64567. /**
  64568. * Gets the list of active optimizations
  64569. */
  64570. readonly optimizations: SceneOptimization[];
  64571. /**
  64572. * Creates a new SceneOptimizer
  64573. * @param scene defines the scene to work on
  64574. * @param options defines the options to use with the SceneOptimizer
  64575. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  64576. * @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)
  64577. */
  64578. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  64579. /**
  64580. * Stops the current optimizer
  64581. */
  64582. stop(): void;
  64583. /**
  64584. * Reset the optimizer to initial step (current priority level = 0)
  64585. */
  64586. reset(): void;
  64587. /**
  64588. * Start the optimizer. By default it will try to reach a specific framerate
  64589. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  64590. */
  64591. start(): void;
  64592. private _checkCurrentState;
  64593. /**
  64594. * Release all resources
  64595. */
  64596. dispose(): void;
  64597. /**
  64598. * Helper function to create a SceneOptimizer with one single line of code
  64599. * @param scene defines the scene to work on
  64600. * @param options defines the options to use with the SceneOptimizer
  64601. * @param onSuccess defines a callback to call on success
  64602. * @param onFailure defines a callback to call on failure
  64603. * @returns the new SceneOptimizer object
  64604. */
  64605. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  64606. }
  64607. }
  64608. declare module "babylonjs/Misc/sceneSerializer" {
  64609. import { Scene } from "babylonjs/scene";
  64610. /**
  64611. * Class used to serialize a scene into a string
  64612. */
  64613. export class SceneSerializer {
  64614. /**
  64615. * Clear cache used by a previous serialization
  64616. */
  64617. static ClearCache(): void;
  64618. /**
  64619. * Serialize a scene into a JSON compatible object
  64620. * @param scene defines the scene to serialize
  64621. * @returns a JSON compatible object
  64622. */
  64623. static Serialize(scene: Scene): any;
  64624. /**
  64625. * Serialize a mesh into a JSON compatible object
  64626. * @param toSerialize defines the mesh to serialize
  64627. * @param withParents defines if parents must be serialized as well
  64628. * @param withChildren defines if children must be serialized as well
  64629. * @returns a JSON compatible object
  64630. */
  64631. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  64632. }
  64633. }
  64634. declare module "babylonjs/Misc/textureTools" {
  64635. import { Texture } from "babylonjs/Materials/Textures/texture";
  64636. /**
  64637. * Class used to host texture specific utilities
  64638. */
  64639. export class TextureTools {
  64640. /**
  64641. * Uses the GPU to create a copy texture rescaled at a given size
  64642. * @param texture Texture to copy from
  64643. * @param width defines the desired width
  64644. * @param height defines the desired height
  64645. * @param useBilinearMode defines if bilinear mode has to be used
  64646. * @return the generated texture
  64647. */
  64648. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  64649. }
  64650. }
  64651. declare module "babylonjs/Misc/videoRecorder" {
  64652. import { Nullable } from "babylonjs/types";
  64653. import { Engine } from "babylonjs/Engines/engine";
  64654. /**
  64655. * This represents the different options available for the video capture.
  64656. */
  64657. export interface VideoRecorderOptions {
  64658. /** Defines the mime type of the video. */
  64659. mimeType: string;
  64660. /** Defines the FPS the video should be recorded at. */
  64661. fps: number;
  64662. /** Defines the chunk size for the recording data. */
  64663. recordChunckSize: number;
  64664. /** The audio tracks to attach to the recording. */
  64665. audioTracks?: MediaStreamTrack[];
  64666. }
  64667. /**
  64668. * This can help with recording videos from BabylonJS.
  64669. * This is based on the available WebRTC functionalities of the browser.
  64670. *
  64671. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  64672. */
  64673. export class VideoRecorder {
  64674. private static readonly _defaultOptions;
  64675. /**
  64676. * Returns whether or not the VideoRecorder is available in your browser.
  64677. * @param engine Defines the Babylon Engine.
  64678. * @returns true if supported otherwise false.
  64679. */
  64680. static IsSupported(engine: Engine): boolean;
  64681. private readonly _options;
  64682. private _canvas;
  64683. private _mediaRecorder;
  64684. private _recordedChunks;
  64685. private _fileName;
  64686. private _resolve;
  64687. private _reject;
  64688. /**
  64689. * True when a recording is already in progress.
  64690. */
  64691. readonly isRecording: boolean;
  64692. /**
  64693. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  64694. * @param engine Defines the BabylonJS Engine you wish to record.
  64695. * @param options Defines options that can be used to customize the capture.
  64696. */
  64697. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  64698. /**
  64699. * Stops the current recording before the default capture timeout passed in the startRecording function.
  64700. */
  64701. stopRecording(): void;
  64702. /**
  64703. * Starts recording the canvas for a max duration specified in parameters.
  64704. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  64705. * If null no automatic download will start and you can rely on the promise to get the data back.
  64706. * @param maxDuration Defines the maximum recording time in seconds.
  64707. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  64708. * @return A promise callback at the end of the recording with the video data in Blob.
  64709. */
  64710. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  64711. /**
  64712. * Releases internal resources used during the recording.
  64713. */
  64714. dispose(): void;
  64715. private _handleDataAvailable;
  64716. private _handleError;
  64717. private _handleStop;
  64718. }
  64719. }
  64720. declare module "babylonjs/Misc/screenshotTools" {
  64721. import { Camera } from "babylonjs/Cameras/camera";
  64722. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  64723. import { Engine } from "babylonjs/Engines/engine";
  64724. /**
  64725. * Class containing a set of static utilities functions for screenshots
  64726. */
  64727. export class ScreenshotTools {
  64728. /**
  64729. * Captures a screenshot of the current rendering
  64730. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  64731. * @param engine defines the rendering engine
  64732. * @param camera defines the source camera
  64733. * @param size This parameter can be set to a single number or to an object with the
  64734. * following (optional) properties: precision, width, height. If a single number is passed,
  64735. * it will be used for both width and height. If an object is passed, the screenshot size
  64736. * will be derived from the parameters. The precision property is a multiplier allowing
  64737. * rendering at a higher or lower resolution
  64738. * @param successCallback defines the callback receives a single parameter which contains the
  64739. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  64740. * src parameter of an <img> to display it
  64741. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  64742. * Check your browser for supported MIME types
  64743. */
  64744. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  64745. /**
  64746. * Captures a screenshot of the current rendering
  64747. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  64748. * @param engine defines the rendering engine
  64749. * @param camera defines the source camera
  64750. * @param size This parameter can be set to a single number or to an object with the
  64751. * following (optional) properties: precision, width, height. If a single number is passed,
  64752. * it will be used for both width and height. If an object is passed, the screenshot size
  64753. * will be derived from the parameters. The precision property is a multiplier allowing
  64754. * rendering at a higher or lower resolution
  64755. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  64756. * Check your browser for supported MIME types
  64757. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  64758. * to the src parameter of an <img> to display it
  64759. */
  64760. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  64761. /**
  64762. * Generates an image screenshot from the specified camera.
  64763. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  64764. * @param engine The engine to use for rendering
  64765. * @param camera The camera to use for rendering
  64766. * @param size This parameter can be set to a single number or to an object with the
  64767. * following (optional) properties: precision, width, height. If a single number is passed,
  64768. * it will be used for both width and height. If an object is passed, the screenshot size
  64769. * will be derived from the parameters. The precision property is a multiplier allowing
  64770. * rendering at a higher or lower resolution
  64771. * @param successCallback The callback receives a single parameter which contains the
  64772. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  64773. * src parameter of an <img> to display it
  64774. * @param mimeType The MIME type of the screenshot image (default: image/png).
  64775. * Check your browser for supported MIME types
  64776. * @param samples Texture samples (default: 1)
  64777. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  64778. * @param fileName A name for for the downloaded file.
  64779. */
  64780. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  64781. /**
  64782. * Generates an image screenshot from the specified camera.
  64783. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  64784. * @param engine The engine to use for rendering
  64785. * @param camera The camera to use for rendering
  64786. * @param size This parameter can be set to a single number or to an object with the
  64787. * following (optional) properties: precision, width, height. If a single number is passed,
  64788. * it will be used for both width and height. If an object is passed, the screenshot size
  64789. * will be derived from the parameters. The precision property is a multiplier allowing
  64790. * rendering at a higher or lower resolution
  64791. * @param mimeType The MIME type of the screenshot image (default: image/png).
  64792. * Check your browser for supported MIME types
  64793. * @param samples Texture samples (default: 1)
  64794. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  64795. * @param fileName A name for for the downloaded file.
  64796. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  64797. * to the src parameter of an <img> to display it
  64798. */
  64799. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  64800. /**
  64801. * Gets height and width for screenshot size
  64802. * @private
  64803. */
  64804. private static _getScreenshotSize;
  64805. }
  64806. }
  64807. declare module "babylonjs/Misc/index" {
  64808. export * from "babylonjs/Misc/andOrNotEvaluator";
  64809. export * from "babylonjs/Misc/assetsManager";
  64810. export * from "babylonjs/Misc/dds";
  64811. export * from "babylonjs/Misc/decorators";
  64812. export * from "babylonjs/Misc/deferred";
  64813. export * from "babylonjs/Misc/environmentTextureTools";
  64814. export * from "babylonjs/Misc/meshExploder";
  64815. export * from "babylonjs/Misc/filesInput";
  64816. export * from "babylonjs/Misc/HighDynamicRange/index";
  64817. export * from "babylonjs/Misc/khronosTextureContainer";
  64818. export * from "babylonjs/Misc/observable";
  64819. export * from "babylonjs/Misc/performanceMonitor";
  64820. export * from "babylonjs/Misc/promise";
  64821. export * from "babylonjs/Misc/sceneOptimizer";
  64822. export * from "babylonjs/Misc/sceneSerializer";
  64823. export * from "babylonjs/Misc/smartArray";
  64824. export * from "babylonjs/Misc/stringDictionary";
  64825. export * from "babylonjs/Misc/tags";
  64826. export * from "babylonjs/Misc/textureTools";
  64827. export * from "babylonjs/Misc/tga";
  64828. export * from "babylonjs/Misc/tools";
  64829. export * from "babylonjs/Misc/videoRecorder";
  64830. export * from "babylonjs/Misc/virtualJoystick";
  64831. export * from "babylonjs/Misc/workerPool";
  64832. export * from "babylonjs/Misc/logger";
  64833. export * from "babylonjs/Misc/typeStore";
  64834. export * from "babylonjs/Misc/filesInputStore";
  64835. export * from "babylonjs/Misc/deepCopier";
  64836. export * from "babylonjs/Misc/pivotTools";
  64837. export * from "babylonjs/Misc/precisionDate";
  64838. export * from "babylonjs/Misc/screenshotTools";
  64839. export * from "babylonjs/Misc/typeStore";
  64840. export * from "babylonjs/Misc/webRequest";
  64841. export * from "babylonjs/Misc/iInspectable";
  64842. export * from "babylonjs/Misc/brdfTextureTools";
  64843. export * from "babylonjs/Misc/gradients";
  64844. export * from "babylonjs/Misc/perfCounter";
  64845. export * from "babylonjs/Misc/fileRequest";
  64846. export * from "babylonjs/Misc/customAnimationFrameRequester";
  64847. export * from "babylonjs/Misc/retryStrategy";
  64848. export * from "babylonjs/Misc/loadFileError";
  64849. }
  64850. declare module "babylonjs/index" {
  64851. export * from "babylonjs/abstractScene";
  64852. export * from "babylonjs/Actions/index";
  64853. export * from "babylonjs/Animations/index";
  64854. export * from "babylonjs/assetContainer";
  64855. export * from "babylonjs/Audio/index";
  64856. export * from "babylonjs/Behaviors/index";
  64857. export * from "babylonjs/Bones/index";
  64858. export * from "babylonjs/Cameras/index";
  64859. export * from "babylonjs/Collisions/index";
  64860. export * from "babylonjs/Culling/index";
  64861. export * from "babylonjs/Debug/index";
  64862. export * from "babylonjs/Engines/index";
  64863. export * from "babylonjs/Events/index";
  64864. export * from "babylonjs/Gamepads/index";
  64865. export * from "babylonjs/Gizmos/index";
  64866. export * from "babylonjs/Helpers/index";
  64867. export * from "babylonjs/Instrumentation/index";
  64868. export * from "babylonjs/Layers/index";
  64869. export * from "babylonjs/LensFlares/index";
  64870. export * from "babylonjs/Lights/index";
  64871. export * from "babylonjs/Loading/index";
  64872. export * from "babylonjs/Materials/index";
  64873. export * from "babylonjs/Maths/index";
  64874. export * from "babylonjs/Meshes/index";
  64875. export * from "babylonjs/Morph/index";
  64876. export * from "babylonjs/Navigation/index";
  64877. export * from "babylonjs/node";
  64878. export * from "babylonjs/Offline/index";
  64879. export * from "babylonjs/Particles/index";
  64880. export * from "babylonjs/Physics/index";
  64881. export * from "babylonjs/PostProcesses/index";
  64882. export * from "babylonjs/Probes/index";
  64883. export * from "babylonjs/Rendering/index";
  64884. export * from "babylonjs/scene";
  64885. export * from "babylonjs/sceneComponent";
  64886. export * from "babylonjs/Sprites/index";
  64887. export * from "babylonjs/States/index";
  64888. export * from "babylonjs/Misc/index";
  64889. export * from "babylonjs/types";
  64890. }
  64891. declare module "babylonjs/Animations/pathCursor" {
  64892. import { Vector3 } from "babylonjs/Maths/math.vector";
  64893. import { Path2 } from "babylonjs/Maths/math.path";
  64894. /**
  64895. * A cursor which tracks a point on a path
  64896. */
  64897. export class PathCursor {
  64898. private path;
  64899. /**
  64900. * Stores path cursor callbacks for when an onchange event is triggered
  64901. */
  64902. private _onchange;
  64903. /**
  64904. * The value of the path cursor
  64905. */
  64906. value: number;
  64907. /**
  64908. * The animation array of the path cursor
  64909. */
  64910. animations: Animation[];
  64911. /**
  64912. * Initializes the path cursor
  64913. * @param path The path to track
  64914. */
  64915. constructor(path: Path2);
  64916. /**
  64917. * Gets the cursor point on the path
  64918. * @returns A point on the path cursor at the cursor location
  64919. */
  64920. getPoint(): Vector3;
  64921. /**
  64922. * Moves the cursor ahead by the step amount
  64923. * @param step The amount to move the cursor forward
  64924. * @returns This path cursor
  64925. */
  64926. moveAhead(step?: number): PathCursor;
  64927. /**
  64928. * Moves the cursor behind by the step amount
  64929. * @param step The amount to move the cursor back
  64930. * @returns This path cursor
  64931. */
  64932. moveBack(step?: number): PathCursor;
  64933. /**
  64934. * Moves the cursor by the step amount
  64935. * If the step amount is greater than one, an exception is thrown
  64936. * @param step The amount to move the cursor
  64937. * @returns This path cursor
  64938. */
  64939. move(step: number): PathCursor;
  64940. /**
  64941. * Ensures that the value is limited between zero and one
  64942. * @returns This path cursor
  64943. */
  64944. private ensureLimits;
  64945. /**
  64946. * Runs onchange callbacks on change (used by the animation engine)
  64947. * @returns This path cursor
  64948. */
  64949. private raiseOnChange;
  64950. /**
  64951. * Executes a function on change
  64952. * @param f A path cursor onchange callback
  64953. * @returns This path cursor
  64954. */
  64955. onchange(f: (cursor: PathCursor) => void): PathCursor;
  64956. }
  64957. }
  64958. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  64959. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  64960. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  64961. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  64962. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  64963. }
  64964. declare module "babylonjs/Engines/Processors/Expressions/index" {
  64965. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  64966. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  64967. }
  64968. declare module "babylonjs/Engines/Processors/index" {
  64969. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  64970. export * from "babylonjs/Engines/Processors/Expressions/index";
  64971. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  64972. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  64973. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  64974. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  64975. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  64976. export * from "babylonjs/Engines/Processors/shaderProcessor";
  64977. }
  64978. declare module "babylonjs/Legacy/legacy" {
  64979. import * as Babylon from "babylonjs/index";
  64980. export * from "babylonjs/index";
  64981. }
  64982. declare module "babylonjs/Shaders/blur.fragment" {
  64983. /** @hidden */
  64984. export var blurPixelShader: {
  64985. name: string;
  64986. shader: string;
  64987. };
  64988. }
  64989. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  64990. /** @hidden */
  64991. export var pointCloudVertexDeclaration: {
  64992. name: string;
  64993. shader: string;
  64994. };
  64995. }
  64996. declare module "babylonjs" {
  64997. export * from "babylonjs/Legacy/legacy";
  64998. }
  64999. declare module BABYLON {
  65000. /** Alias type for value that can be null */
  65001. export type Nullable<T> = T | null;
  65002. /**
  65003. * Alias type for number that are floats
  65004. * @ignorenaming
  65005. */
  65006. export type float = number;
  65007. /**
  65008. * Alias type for number that are doubles.
  65009. * @ignorenaming
  65010. */
  65011. export type double = number;
  65012. /**
  65013. * Alias type for number that are integer
  65014. * @ignorenaming
  65015. */
  65016. export type int = number;
  65017. /** Alias type for number array or Float32Array */
  65018. export type FloatArray = number[] | Float32Array;
  65019. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  65020. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  65021. /**
  65022. * Alias for types that can be used by a Buffer or VertexBuffer.
  65023. */
  65024. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  65025. /**
  65026. * Alias type for primitive types
  65027. * @ignorenaming
  65028. */
  65029. type Primitive = undefined | null | boolean | string | number | Function;
  65030. /**
  65031. * Type modifier to make all the properties of an object Readonly
  65032. */
  65033. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  65034. /**
  65035. * Type modifier to make all the properties of an object Readonly recursively
  65036. */
  65037. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  65038. /** @hidden */
  65039. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  65040. }
  65041. /** @hidden */
  65042. /** @hidden */
  65043. type DeepImmutableObject<T> = {
  65044. readonly [K in keyof T]: DeepImmutable<T[K]>;
  65045. };
  65046. }
  65047. declare module BABYLON {
  65048. /**
  65049. * A class serves as a medium between the observable and its observers
  65050. */
  65051. export class EventState {
  65052. /**
  65053. * Create a new EventState
  65054. * @param mask defines the mask associated with this state
  65055. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  65056. * @param target defines the original target of the state
  65057. * @param currentTarget defines the current target of the state
  65058. */
  65059. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  65060. /**
  65061. * Initialize the current event state
  65062. * @param mask defines the mask associated with this state
  65063. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  65064. * @param target defines the original target of the state
  65065. * @param currentTarget defines the current target of the state
  65066. * @returns the current event state
  65067. */
  65068. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  65069. /**
  65070. * An Observer can set this property to true to prevent subsequent observers of being notified
  65071. */
  65072. skipNextObservers: boolean;
  65073. /**
  65074. * Get the mask value that were used to trigger the event corresponding to this EventState object
  65075. */
  65076. mask: number;
  65077. /**
  65078. * The object that originally notified the event
  65079. */
  65080. target?: any;
  65081. /**
  65082. * The current object in the bubbling phase
  65083. */
  65084. currentTarget?: any;
  65085. /**
  65086. * This will be populated with the return value of the last function that was executed.
  65087. * If it is the first function in the callback chain it will be the event data.
  65088. */
  65089. lastReturnValue?: any;
  65090. }
  65091. /**
  65092. * Represent an Observer registered to a given Observable object.
  65093. */
  65094. export class Observer<T> {
  65095. /**
  65096. * Defines the callback to call when the observer is notified
  65097. */
  65098. callback: (eventData: T, eventState: EventState) => void;
  65099. /**
  65100. * Defines the mask of the observer (used to filter notifications)
  65101. */
  65102. mask: number;
  65103. /**
  65104. * Defines the current scope used to restore the JS context
  65105. */
  65106. scope: any;
  65107. /** @hidden */
  65108. _willBeUnregistered: boolean;
  65109. /**
  65110. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  65111. */
  65112. unregisterOnNextCall: boolean;
  65113. /**
  65114. * Creates a new observer
  65115. * @param callback defines the callback to call when the observer is notified
  65116. * @param mask defines the mask of the observer (used to filter notifications)
  65117. * @param scope defines the current scope used to restore the JS context
  65118. */
  65119. constructor(
  65120. /**
  65121. * Defines the callback to call when the observer is notified
  65122. */
  65123. callback: (eventData: T, eventState: EventState) => void,
  65124. /**
  65125. * Defines the mask of the observer (used to filter notifications)
  65126. */
  65127. mask: number,
  65128. /**
  65129. * Defines the current scope used to restore the JS context
  65130. */
  65131. scope?: any);
  65132. }
  65133. /**
  65134. * Represent a list of observers registered to multiple Observables object.
  65135. */
  65136. export class MultiObserver<T> {
  65137. private _observers;
  65138. private _observables;
  65139. /**
  65140. * Release associated resources
  65141. */
  65142. dispose(): void;
  65143. /**
  65144. * Raise a callback when one of the observable will notify
  65145. * @param observables defines a list of observables to watch
  65146. * @param callback defines the callback to call on notification
  65147. * @param mask defines the mask used to filter notifications
  65148. * @param scope defines the current scope used to restore the JS context
  65149. * @returns the new MultiObserver
  65150. */
  65151. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  65152. }
  65153. /**
  65154. * The Observable class is a simple implementation of the Observable pattern.
  65155. *
  65156. * 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.
  65157. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  65158. * 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).
  65159. * 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.
  65160. */
  65161. export class Observable<T> {
  65162. private _observers;
  65163. private _eventState;
  65164. private _onObserverAdded;
  65165. /**
  65166. * Gets the list of observers
  65167. */
  65168. readonly observers: Array<Observer<T>>;
  65169. /**
  65170. * Creates a new observable
  65171. * @param onObserverAdded defines a callback to call when a new observer is added
  65172. */
  65173. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  65174. /**
  65175. * Create a new Observer with the specified callback
  65176. * @param callback the callback that will be executed for that Observer
  65177. * @param mask the mask used to filter observers
  65178. * @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.
  65179. * @param scope optional scope for the callback to be called from
  65180. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  65181. * @returns the new observer created for the callback
  65182. */
  65183. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  65184. /**
  65185. * Create a new Observer with the specified callback and unregisters after the next notification
  65186. * @param callback the callback that will be executed for that Observer
  65187. * @returns the new observer created for the callback
  65188. */
  65189. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  65190. /**
  65191. * Remove an Observer from the Observable object
  65192. * @param observer the instance of the Observer to remove
  65193. * @returns false if it doesn't belong to this Observable
  65194. */
  65195. remove(observer: Nullable<Observer<T>>): boolean;
  65196. /**
  65197. * Remove a callback from the Observable object
  65198. * @param callback the callback to remove
  65199. * @param scope optional scope. If used only the callbacks with this scope will be removed
  65200. * @returns false if it doesn't belong to this Observable
  65201. */
  65202. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  65203. private _deferUnregister;
  65204. private _remove;
  65205. /**
  65206. * Moves the observable to the top of the observer list making it get called first when notified
  65207. * @param observer the observer to move
  65208. */
  65209. makeObserverTopPriority(observer: Observer<T>): void;
  65210. /**
  65211. * Moves the observable to the bottom of the observer list making it get called last when notified
  65212. * @param observer the observer to move
  65213. */
  65214. makeObserverBottomPriority(observer: Observer<T>): void;
  65215. /**
  65216. * Notify all Observers by calling their respective callback with the given data
  65217. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  65218. * @param eventData defines the data to send to all observers
  65219. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  65220. * @param target defines the original target of the state
  65221. * @param currentTarget defines the current target of the state
  65222. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  65223. */
  65224. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  65225. /**
  65226. * Calling this will execute each callback, expecting it to be a promise or return a value.
  65227. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  65228. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  65229. * and it is crucial that all callbacks will be executed.
  65230. * The order of the callbacks is kept, callbacks are not executed parallel.
  65231. *
  65232. * @param eventData The data to be sent to each callback
  65233. * @param mask is used to filter observers defaults to -1
  65234. * @param target defines the callback target (see EventState)
  65235. * @param currentTarget defines he current object in the bubbling phase
  65236. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  65237. */
  65238. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  65239. /**
  65240. * Notify a specific observer
  65241. * @param observer defines the observer to notify
  65242. * @param eventData defines the data to be sent to each callback
  65243. * @param mask is used to filter observers defaults to -1
  65244. */
  65245. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  65246. /**
  65247. * Gets a boolean indicating if the observable has at least one observer
  65248. * @returns true is the Observable has at least one Observer registered
  65249. */
  65250. hasObservers(): boolean;
  65251. /**
  65252. * Clear the list of observers
  65253. */
  65254. clear(): void;
  65255. /**
  65256. * Clone the current observable
  65257. * @returns a new observable
  65258. */
  65259. clone(): Observable<T>;
  65260. /**
  65261. * Does this observable handles observer registered with a given mask
  65262. * @param mask defines the mask to be tested
  65263. * @return whether or not one observer registered with the given mask is handeled
  65264. **/
  65265. hasSpecificMask(mask?: number): boolean;
  65266. }
  65267. }
  65268. declare module BABYLON {
  65269. /**
  65270. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  65271. * Babylon.js
  65272. */
  65273. export class DomManagement {
  65274. /**
  65275. * Checks if the window object exists
  65276. * @returns true if the window object exists
  65277. */
  65278. static IsWindowObjectExist(): boolean;
  65279. /**
  65280. * Extracts text content from a DOM element hierarchy
  65281. * @param element defines the root element
  65282. * @returns a string
  65283. */
  65284. static GetDOMTextContent(element: HTMLElement): string;
  65285. }
  65286. }
  65287. declare module BABYLON {
  65288. /**
  65289. * Logger used througouht the application to allow configuration of
  65290. * the log level required for the messages.
  65291. */
  65292. export class Logger {
  65293. /**
  65294. * No log
  65295. */
  65296. static readonly NoneLogLevel: number;
  65297. /**
  65298. * Only message logs
  65299. */
  65300. static readonly MessageLogLevel: number;
  65301. /**
  65302. * Only warning logs
  65303. */
  65304. static readonly WarningLogLevel: number;
  65305. /**
  65306. * Only error logs
  65307. */
  65308. static readonly ErrorLogLevel: number;
  65309. /**
  65310. * All logs
  65311. */
  65312. static readonly AllLogLevel: number;
  65313. private static _LogCache;
  65314. /**
  65315. * Gets a value indicating the number of loading errors
  65316. * @ignorenaming
  65317. */
  65318. static errorsCount: number;
  65319. /**
  65320. * Callback called when a new log is added
  65321. */
  65322. static OnNewCacheEntry: (entry: string) => void;
  65323. private static _AddLogEntry;
  65324. private static _FormatMessage;
  65325. private static _LogDisabled;
  65326. private static _LogEnabled;
  65327. private static _WarnDisabled;
  65328. private static _WarnEnabled;
  65329. private static _ErrorDisabled;
  65330. private static _ErrorEnabled;
  65331. /**
  65332. * Log a message to the console
  65333. */
  65334. static Log: (message: string) => void;
  65335. /**
  65336. * Write a warning message to the console
  65337. */
  65338. static Warn: (message: string) => void;
  65339. /**
  65340. * Write an error message to the console
  65341. */
  65342. static Error: (message: string) => void;
  65343. /**
  65344. * Gets current log cache (list of logs)
  65345. */
  65346. static readonly LogCache: string;
  65347. /**
  65348. * Clears the log cache
  65349. */
  65350. static ClearLogCache(): void;
  65351. /**
  65352. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  65353. */
  65354. static LogLevels: number;
  65355. }
  65356. }
  65357. declare module BABYLON {
  65358. /** @hidden */
  65359. export class _TypeStore {
  65360. /** @hidden */
  65361. static RegisteredTypes: {
  65362. [key: string]: Object;
  65363. };
  65364. /** @hidden */
  65365. static GetClass(fqdn: string): any;
  65366. }
  65367. }
  65368. declare module BABYLON {
  65369. /**
  65370. * Class containing a set of static utilities functions for deep copy.
  65371. */
  65372. export class DeepCopier {
  65373. /**
  65374. * Tries to copy an object by duplicating every property
  65375. * @param source defines the source object
  65376. * @param destination defines the target object
  65377. * @param doNotCopyList defines a list of properties to avoid
  65378. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  65379. */
  65380. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  65381. }
  65382. }
  65383. declare module BABYLON {
  65384. /**
  65385. * Class containing a set of static utilities functions for precision date
  65386. */
  65387. export class PrecisionDate {
  65388. /**
  65389. * Gets either window.performance.now() if supported or Date.now() else
  65390. */
  65391. static readonly Now: number;
  65392. }
  65393. }
  65394. declare module BABYLON {
  65395. /** @hidden */
  65396. export class _DevTools {
  65397. static WarnImport(name: string): string;
  65398. }
  65399. }
  65400. declare module BABYLON {
  65401. /**
  65402. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  65403. */
  65404. export class WebRequest {
  65405. private _xhr;
  65406. /**
  65407. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  65408. * i.e. when loading files, where the server/service expects an Authorization header
  65409. */
  65410. static CustomRequestHeaders: {
  65411. [key: string]: string;
  65412. };
  65413. /**
  65414. * Add callback functions in this array to update all the requests before they get sent to the network
  65415. */
  65416. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  65417. private _injectCustomRequestHeaders;
  65418. /**
  65419. * Gets or sets a function to be called when loading progress changes
  65420. */
  65421. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  65422. /**
  65423. * Returns client's state
  65424. */
  65425. readonly readyState: number;
  65426. /**
  65427. * Returns client's status
  65428. */
  65429. readonly status: number;
  65430. /**
  65431. * Returns client's status as a text
  65432. */
  65433. readonly statusText: string;
  65434. /**
  65435. * Returns client's response
  65436. */
  65437. readonly response: any;
  65438. /**
  65439. * Returns client's response url
  65440. */
  65441. readonly responseURL: string;
  65442. /**
  65443. * Returns client's response as text
  65444. */
  65445. readonly responseText: string;
  65446. /**
  65447. * Gets or sets the expected response type
  65448. */
  65449. responseType: XMLHttpRequestResponseType;
  65450. /** @hidden */
  65451. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  65452. /** @hidden */
  65453. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  65454. /**
  65455. * Cancels any network activity
  65456. */
  65457. abort(): void;
  65458. /**
  65459. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  65460. * @param body defines an optional request body
  65461. */
  65462. send(body?: Document | BodyInit | null): void;
  65463. /**
  65464. * Sets the request method, request URL
  65465. * @param method defines the method to use (GET, POST, etc..)
  65466. * @param url defines the url to connect with
  65467. */
  65468. open(method: string, url: string): void;
  65469. }
  65470. }
  65471. declare module BABYLON {
  65472. /**
  65473. * File request interface
  65474. */
  65475. export interface IFileRequest {
  65476. /**
  65477. * Raised when the request is complete (success or error).
  65478. */
  65479. onCompleteObservable: Observable<IFileRequest>;
  65480. /**
  65481. * Aborts the request for a file.
  65482. */
  65483. abort: () => void;
  65484. }
  65485. }
  65486. declare module BABYLON {
  65487. /**
  65488. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  65489. */
  65490. export class PerformanceMonitor {
  65491. private _enabled;
  65492. private _rollingFrameTime;
  65493. private _lastFrameTimeMs;
  65494. /**
  65495. * constructor
  65496. * @param frameSampleSize The number of samples required to saturate the sliding window
  65497. */
  65498. constructor(frameSampleSize?: number);
  65499. /**
  65500. * Samples current frame
  65501. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  65502. */
  65503. sampleFrame(timeMs?: number): void;
  65504. /**
  65505. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  65506. */
  65507. readonly averageFrameTime: number;
  65508. /**
  65509. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  65510. */
  65511. readonly averageFrameTimeVariance: number;
  65512. /**
  65513. * Returns the frame time of the most recent frame
  65514. */
  65515. readonly instantaneousFrameTime: number;
  65516. /**
  65517. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  65518. */
  65519. readonly averageFPS: number;
  65520. /**
  65521. * Returns the average framerate in frames per second using the most recent frame time
  65522. */
  65523. readonly instantaneousFPS: number;
  65524. /**
  65525. * Returns true if enough samples have been taken to completely fill the sliding window
  65526. */
  65527. readonly isSaturated: boolean;
  65528. /**
  65529. * Enables contributions to the sliding window sample set
  65530. */
  65531. enable(): void;
  65532. /**
  65533. * Disables contributions to the sliding window sample set
  65534. * Samples will not be interpolated over the disabled period
  65535. */
  65536. disable(): void;
  65537. /**
  65538. * Returns true if sampling is enabled
  65539. */
  65540. readonly isEnabled: boolean;
  65541. /**
  65542. * Resets performance monitor
  65543. */
  65544. reset(): void;
  65545. }
  65546. /**
  65547. * RollingAverage
  65548. *
  65549. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  65550. */
  65551. export class RollingAverage {
  65552. /**
  65553. * Current average
  65554. */
  65555. average: number;
  65556. /**
  65557. * Current variance
  65558. */
  65559. variance: number;
  65560. protected _samples: Array<number>;
  65561. protected _sampleCount: number;
  65562. protected _pos: number;
  65563. protected _m2: number;
  65564. /**
  65565. * constructor
  65566. * @param length The number of samples required to saturate the sliding window
  65567. */
  65568. constructor(length: number);
  65569. /**
  65570. * Adds a sample to the sample set
  65571. * @param v The sample value
  65572. */
  65573. add(v: number): void;
  65574. /**
  65575. * Returns previously added values or null if outside of history or outside the sliding window domain
  65576. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  65577. * @return Value previously recorded with add() or null if outside of range
  65578. */
  65579. history(i: number): number;
  65580. /**
  65581. * Returns true if enough samples have been taken to completely fill the sliding window
  65582. * @return true if sample-set saturated
  65583. */
  65584. isSaturated(): boolean;
  65585. /**
  65586. * Resets the rolling average (equivalent to 0 samples taken so far)
  65587. */
  65588. reset(): void;
  65589. /**
  65590. * Wraps a value around the sample range boundaries
  65591. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  65592. * @return Wrapped position in sample range
  65593. */
  65594. protected _wrapPosition(i: number): number;
  65595. }
  65596. }
  65597. declare module BABYLON {
  65598. /**
  65599. * This class implement a typical dictionary using a string as key and the generic type T as value.
  65600. * The underlying implementation relies on an associative array to ensure the best performances.
  65601. * The value can be anything including 'null' but except 'undefined'
  65602. */
  65603. export class StringDictionary<T> {
  65604. /**
  65605. * This will clear this dictionary and copy the content from the 'source' one.
  65606. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  65607. * @param source the dictionary to take the content from and copy to this dictionary
  65608. */
  65609. copyFrom(source: StringDictionary<T>): void;
  65610. /**
  65611. * Get a value based from its key
  65612. * @param key the given key to get the matching value from
  65613. * @return the value if found, otherwise undefined is returned
  65614. */
  65615. get(key: string): T | undefined;
  65616. /**
  65617. * Get a value from its key or add it if it doesn't exist.
  65618. * This method will ensure you that a given key/data will be present in the dictionary.
  65619. * @param key the given key to get the matching value from
  65620. * @param factory the factory that will create the value if the key is not present in the dictionary.
  65621. * The factory will only be invoked if there's no data for the given key.
  65622. * @return the value corresponding to the key.
  65623. */
  65624. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  65625. /**
  65626. * Get a value from its key if present in the dictionary otherwise add it
  65627. * @param key the key to get the value from
  65628. * @param val if there's no such key/value pair in the dictionary add it with this value
  65629. * @return the value corresponding to the key
  65630. */
  65631. getOrAdd(key: string, val: T): T;
  65632. /**
  65633. * Check if there's a given key in the dictionary
  65634. * @param key the key to check for
  65635. * @return true if the key is present, false otherwise
  65636. */
  65637. contains(key: string): boolean;
  65638. /**
  65639. * Add a new key and its corresponding value
  65640. * @param key the key to add
  65641. * @param value the value corresponding to the key
  65642. * @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
  65643. */
  65644. add(key: string, value: T): boolean;
  65645. /**
  65646. * Update a specific value associated to a key
  65647. * @param key defines the key to use
  65648. * @param value defines the value to store
  65649. * @returns true if the value was updated (or false if the key was not found)
  65650. */
  65651. set(key: string, value: T): boolean;
  65652. /**
  65653. * Get the element of the given key and remove it from the dictionary
  65654. * @param key defines the key to search
  65655. * @returns the value associated with the key or null if not found
  65656. */
  65657. getAndRemove(key: string): Nullable<T>;
  65658. /**
  65659. * Remove a key/value from the dictionary.
  65660. * @param key the key to remove
  65661. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  65662. */
  65663. remove(key: string): boolean;
  65664. /**
  65665. * Clear the whole content of the dictionary
  65666. */
  65667. clear(): void;
  65668. /**
  65669. * Gets the current count
  65670. */
  65671. readonly count: number;
  65672. /**
  65673. * Execute a callback on each key/val of the dictionary.
  65674. * Note that you can remove any element in this dictionary in the callback implementation
  65675. * @param callback the callback to execute on a given key/value pair
  65676. */
  65677. forEach(callback: (key: string, val: T) => void): void;
  65678. /**
  65679. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  65680. * If the callback returns null or undefined the method will iterate to the next key/value pair
  65681. * Note that you can remove any element in this dictionary in the callback implementation
  65682. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  65683. * @returns the first item
  65684. */
  65685. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  65686. private _count;
  65687. private _data;
  65688. }
  65689. }
  65690. declare module BABYLON {
  65691. /**
  65692. * Class used to store gfx data (like WebGLBuffer)
  65693. */
  65694. export class DataBuffer {
  65695. /**
  65696. * Gets or sets the number of objects referencing this buffer
  65697. */
  65698. references: number;
  65699. /** Gets or sets the size of the underlying buffer */
  65700. capacity: number;
  65701. /**
  65702. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  65703. */
  65704. is32Bits: boolean;
  65705. /**
  65706. * Gets the underlying buffer
  65707. */
  65708. readonly underlyingResource: any;
  65709. }
  65710. }
  65711. declare module BABYLON {
  65712. /**
  65713. * Class used to store data that will be store in GPU memory
  65714. */
  65715. export class Buffer {
  65716. private _engine;
  65717. private _buffer;
  65718. /** @hidden */
  65719. _data: Nullable<DataArray>;
  65720. private _updatable;
  65721. private _instanced;
  65722. /**
  65723. * Gets the byte stride.
  65724. */
  65725. readonly byteStride: number;
  65726. /**
  65727. * Constructor
  65728. * @param engine the engine
  65729. * @param data the data to use for this buffer
  65730. * @param updatable whether the data is updatable
  65731. * @param stride the stride (optional)
  65732. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  65733. * @param instanced whether the buffer is instanced (optional)
  65734. * @param useBytes set to true if the stride in in bytes (optional)
  65735. */
  65736. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  65737. /**
  65738. * Create a new VertexBuffer based on the current buffer
  65739. * @param kind defines the vertex buffer kind (position, normal, etc.)
  65740. * @param offset defines offset in the buffer (0 by default)
  65741. * @param size defines the size in floats of attributes (position is 3 for instance)
  65742. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  65743. * @param instanced defines if the vertex buffer contains indexed data
  65744. * @param useBytes defines if the offset and stride are in bytes
  65745. * @returns the new vertex buffer
  65746. */
  65747. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  65748. /**
  65749. * Gets a boolean indicating if the Buffer is updatable?
  65750. * @returns true if the buffer is updatable
  65751. */
  65752. isUpdatable(): boolean;
  65753. /**
  65754. * Gets current buffer's data
  65755. * @returns a DataArray or null
  65756. */
  65757. getData(): Nullable<DataArray>;
  65758. /**
  65759. * Gets underlying native buffer
  65760. * @returns underlying native buffer
  65761. */
  65762. getBuffer(): Nullable<DataBuffer>;
  65763. /**
  65764. * Gets the stride in float32 units (i.e. byte stride / 4).
  65765. * May not be an integer if the byte stride is not divisible by 4.
  65766. * DEPRECATED. Use byteStride instead.
  65767. * @returns the stride in float32 units
  65768. */
  65769. getStrideSize(): number;
  65770. /**
  65771. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  65772. * @param data defines the data to store
  65773. */
  65774. create(data?: Nullable<DataArray>): void;
  65775. /** @hidden */
  65776. _rebuild(): void;
  65777. /**
  65778. * Update current buffer data
  65779. * @param data defines the data to store
  65780. */
  65781. update(data: DataArray): void;
  65782. /**
  65783. * Updates the data directly.
  65784. * @param data the new data
  65785. * @param offset the new offset
  65786. * @param vertexCount the vertex count (optional)
  65787. * @param useBytes set to true if the offset is in bytes
  65788. */
  65789. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  65790. /**
  65791. * Release all resources
  65792. */
  65793. dispose(): void;
  65794. }
  65795. /**
  65796. * Specialized buffer used to store vertex data
  65797. */
  65798. export class VertexBuffer {
  65799. /** @hidden */
  65800. _buffer: Buffer;
  65801. private _kind;
  65802. private _size;
  65803. private _ownsBuffer;
  65804. private _instanced;
  65805. private _instanceDivisor;
  65806. /**
  65807. * The byte type.
  65808. */
  65809. static readonly BYTE: number;
  65810. /**
  65811. * The unsigned byte type.
  65812. */
  65813. static readonly UNSIGNED_BYTE: number;
  65814. /**
  65815. * The short type.
  65816. */
  65817. static readonly SHORT: number;
  65818. /**
  65819. * The unsigned short type.
  65820. */
  65821. static readonly UNSIGNED_SHORT: number;
  65822. /**
  65823. * The integer type.
  65824. */
  65825. static readonly INT: number;
  65826. /**
  65827. * The unsigned integer type.
  65828. */
  65829. static readonly UNSIGNED_INT: number;
  65830. /**
  65831. * The float type.
  65832. */
  65833. static readonly FLOAT: number;
  65834. /**
  65835. * Gets or sets the instance divisor when in instanced mode
  65836. */
  65837. instanceDivisor: number;
  65838. /**
  65839. * Gets the byte stride.
  65840. */
  65841. readonly byteStride: number;
  65842. /**
  65843. * Gets the byte offset.
  65844. */
  65845. readonly byteOffset: number;
  65846. /**
  65847. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  65848. */
  65849. readonly normalized: boolean;
  65850. /**
  65851. * Gets the data type of each component in the array.
  65852. */
  65853. readonly type: number;
  65854. /**
  65855. * Constructor
  65856. * @param engine the engine
  65857. * @param data the data to use for this vertex buffer
  65858. * @param kind the vertex buffer kind
  65859. * @param updatable whether the data is updatable
  65860. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  65861. * @param stride the stride (optional)
  65862. * @param instanced whether the buffer is instanced (optional)
  65863. * @param offset the offset of the data (optional)
  65864. * @param size the number of components (optional)
  65865. * @param type the type of the component (optional)
  65866. * @param normalized whether the data contains normalized data (optional)
  65867. * @param useBytes set to true if stride and offset are in bytes (optional)
  65868. */
  65869. 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);
  65870. /** @hidden */
  65871. _rebuild(): void;
  65872. /**
  65873. * Returns the kind of the VertexBuffer (string)
  65874. * @returns a string
  65875. */
  65876. getKind(): string;
  65877. /**
  65878. * Gets a boolean indicating if the VertexBuffer is updatable?
  65879. * @returns true if the buffer is updatable
  65880. */
  65881. isUpdatable(): boolean;
  65882. /**
  65883. * Gets current buffer's data
  65884. * @returns a DataArray or null
  65885. */
  65886. getData(): Nullable<DataArray>;
  65887. /**
  65888. * Gets underlying native buffer
  65889. * @returns underlying native buffer
  65890. */
  65891. getBuffer(): Nullable<DataBuffer>;
  65892. /**
  65893. * Gets the stride in float32 units (i.e. byte stride / 4).
  65894. * May not be an integer if the byte stride is not divisible by 4.
  65895. * DEPRECATED. Use byteStride instead.
  65896. * @returns the stride in float32 units
  65897. */
  65898. getStrideSize(): number;
  65899. /**
  65900. * Returns the offset as a multiple of the type byte length.
  65901. * DEPRECATED. Use byteOffset instead.
  65902. * @returns the offset in bytes
  65903. */
  65904. getOffset(): number;
  65905. /**
  65906. * Returns the number of components per vertex attribute (integer)
  65907. * @returns the size in float
  65908. */
  65909. getSize(): number;
  65910. /**
  65911. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  65912. * @returns true if this buffer is instanced
  65913. */
  65914. getIsInstanced(): boolean;
  65915. /**
  65916. * Returns the instancing divisor, zero for non-instanced (integer).
  65917. * @returns a number
  65918. */
  65919. getInstanceDivisor(): number;
  65920. /**
  65921. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  65922. * @param data defines the data to store
  65923. */
  65924. create(data?: DataArray): void;
  65925. /**
  65926. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  65927. * This function will create a new buffer if the current one is not updatable
  65928. * @param data defines the data to store
  65929. */
  65930. update(data: DataArray): void;
  65931. /**
  65932. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  65933. * Returns the directly updated WebGLBuffer.
  65934. * @param data the new data
  65935. * @param offset the new offset
  65936. * @param useBytes set to true if the offset is in bytes
  65937. */
  65938. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  65939. /**
  65940. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  65941. */
  65942. dispose(): void;
  65943. /**
  65944. * Enumerates each value of this vertex buffer as numbers.
  65945. * @param count the number of values to enumerate
  65946. * @param callback the callback function called for each value
  65947. */
  65948. forEach(count: number, callback: (value: number, index: number) => void): void;
  65949. /**
  65950. * Positions
  65951. */
  65952. static readonly PositionKind: string;
  65953. /**
  65954. * Normals
  65955. */
  65956. static readonly NormalKind: string;
  65957. /**
  65958. * Tangents
  65959. */
  65960. static readonly TangentKind: string;
  65961. /**
  65962. * Texture coordinates
  65963. */
  65964. static readonly UVKind: string;
  65965. /**
  65966. * Texture coordinates 2
  65967. */
  65968. static readonly UV2Kind: string;
  65969. /**
  65970. * Texture coordinates 3
  65971. */
  65972. static readonly UV3Kind: string;
  65973. /**
  65974. * Texture coordinates 4
  65975. */
  65976. static readonly UV4Kind: string;
  65977. /**
  65978. * Texture coordinates 5
  65979. */
  65980. static readonly UV5Kind: string;
  65981. /**
  65982. * Texture coordinates 6
  65983. */
  65984. static readonly UV6Kind: string;
  65985. /**
  65986. * Colors
  65987. */
  65988. static readonly ColorKind: string;
  65989. /**
  65990. * Matrix indices (for bones)
  65991. */
  65992. static readonly MatricesIndicesKind: string;
  65993. /**
  65994. * Matrix weights (for bones)
  65995. */
  65996. static readonly MatricesWeightsKind: string;
  65997. /**
  65998. * Additional matrix indices (for bones)
  65999. */
  66000. static readonly MatricesIndicesExtraKind: string;
  66001. /**
  66002. * Additional matrix weights (for bones)
  66003. */
  66004. static readonly MatricesWeightsExtraKind: string;
  66005. /**
  66006. * Deduces the stride given a kind.
  66007. * @param kind The kind string to deduce
  66008. * @returns The deduced stride
  66009. */
  66010. static DeduceStride(kind: string): number;
  66011. /**
  66012. * Gets the byte length of the given type.
  66013. * @param type the type
  66014. * @returns the number of bytes
  66015. */
  66016. static GetTypeByteLength(type: number): number;
  66017. /**
  66018. * Enumerates each value of the given parameters as numbers.
  66019. * @param data the data to enumerate
  66020. * @param byteOffset the byte offset of the data
  66021. * @param byteStride the byte stride of the data
  66022. * @param componentCount the number of components per element
  66023. * @param componentType the type of the component
  66024. * @param count the number of values to enumerate
  66025. * @param normalized whether the data is normalized
  66026. * @param callback the callback function called for each value
  66027. */
  66028. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  66029. private static _GetFloatValue;
  66030. }
  66031. }
  66032. declare module BABYLON {
  66033. /**
  66034. * Scalar computation library
  66035. */
  66036. export class Scalar {
  66037. /**
  66038. * Two pi constants convenient for computation.
  66039. */
  66040. static TwoPi: number;
  66041. /**
  66042. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  66043. * @param a number
  66044. * @param b number
  66045. * @param epsilon (default = 1.401298E-45)
  66046. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  66047. */
  66048. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  66049. /**
  66050. * Returns a string : the upper case translation of the number i to hexadecimal.
  66051. * @param i number
  66052. * @returns the upper case translation of the number i to hexadecimal.
  66053. */
  66054. static ToHex(i: number): string;
  66055. /**
  66056. * Returns -1 if value is negative and +1 is value is positive.
  66057. * @param value the value
  66058. * @returns the value itself if it's equal to zero.
  66059. */
  66060. static Sign(value: number): number;
  66061. /**
  66062. * Returns the value itself if it's between min and max.
  66063. * Returns min if the value is lower than min.
  66064. * Returns max if the value is greater than max.
  66065. * @param value the value to clmap
  66066. * @param min the min value to clamp to (default: 0)
  66067. * @param max the max value to clamp to (default: 1)
  66068. * @returns the clamped value
  66069. */
  66070. static Clamp(value: number, min?: number, max?: number): number;
  66071. /**
  66072. * the log2 of value.
  66073. * @param value the value to compute log2 of
  66074. * @returns the log2 of value.
  66075. */
  66076. static Log2(value: number): number;
  66077. /**
  66078. * Loops the value, so that it is never larger than length and never smaller than 0.
  66079. *
  66080. * This is similar to the modulo operator but it works with floating point numbers.
  66081. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  66082. * With t = 5 and length = 2.5, the result would be 0.0.
  66083. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  66084. * @param value the value
  66085. * @param length the length
  66086. * @returns the looped value
  66087. */
  66088. static Repeat(value: number, length: number): number;
  66089. /**
  66090. * Normalize the value between 0.0 and 1.0 using min and max values
  66091. * @param value value to normalize
  66092. * @param min max to normalize between
  66093. * @param max min to normalize between
  66094. * @returns the normalized value
  66095. */
  66096. static Normalize(value: number, min: number, max: number): number;
  66097. /**
  66098. * Denormalize the value from 0.0 and 1.0 using min and max values
  66099. * @param normalized value to denormalize
  66100. * @param min max to denormalize between
  66101. * @param max min to denormalize between
  66102. * @returns the denormalized value
  66103. */
  66104. static Denormalize(normalized: number, min: number, max: number): number;
  66105. /**
  66106. * Calculates the shortest difference between two given angles given in degrees.
  66107. * @param current current angle in degrees
  66108. * @param target target angle in degrees
  66109. * @returns the delta
  66110. */
  66111. static DeltaAngle(current: number, target: number): number;
  66112. /**
  66113. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  66114. * @param tx value
  66115. * @param length length
  66116. * @returns The returned value will move back and forth between 0 and length
  66117. */
  66118. static PingPong(tx: number, length: number): number;
  66119. /**
  66120. * Interpolates between min and max with smoothing at the limits.
  66121. *
  66122. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  66123. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  66124. * @param from from
  66125. * @param to to
  66126. * @param tx value
  66127. * @returns the smooth stepped value
  66128. */
  66129. static SmoothStep(from: number, to: number, tx: number): number;
  66130. /**
  66131. * Moves a value current towards target.
  66132. *
  66133. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  66134. * Negative values of maxDelta pushes the value away from target.
  66135. * @param current current value
  66136. * @param target target value
  66137. * @param maxDelta max distance to move
  66138. * @returns resulting value
  66139. */
  66140. static MoveTowards(current: number, target: number, maxDelta: number): number;
  66141. /**
  66142. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  66143. *
  66144. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  66145. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  66146. * @param current current value
  66147. * @param target target value
  66148. * @param maxDelta max distance to move
  66149. * @returns resulting angle
  66150. */
  66151. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  66152. /**
  66153. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  66154. * @param start start value
  66155. * @param end target value
  66156. * @param amount amount to lerp between
  66157. * @returns the lerped value
  66158. */
  66159. static Lerp(start: number, end: number, amount: number): number;
  66160. /**
  66161. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  66162. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  66163. * @param start start value
  66164. * @param end target value
  66165. * @param amount amount to lerp between
  66166. * @returns the lerped value
  66167. */
  66168. static LerpAngle(start: number, end: number, amount: number): number;
  66169. /**
  66170. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  66171. * @param a start value
  66172. * @param b target value
  66173. * @param value value between a and b
  66174. * @returns the inverseLerp value
  66175. */
  66176. static InverseLerp(a: number, b: number, value: number): number;
  66177. /**
  66178. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  66179. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  66180. * @param value1 spline value
  66181. * @param tangent1 spline value
  66182. * @param value2 spline value
  66183. * @param tangent2 spline value
  66184. * @param amount input value
  66185. * @returns hermite result
  66186. */
  66187. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  66188. /**
  66189. * Returns a random float number between and min and max values
  66190. * @param min min value of random
  66191. * @param max max value of random
  66192. * @returns random value
  66193. */
  66194. static RandomRange(min: number, max: number): number;
  66195. /**
  66196. * This function returns percentage of a number in a given range.
  66197. *
  66198. * RangeToPercent(40,20,60) will return 0.5 (50%)
  66199. * RangeToPercent(34,0,100) will return 0.34 (34%)
  66200. * @param number to convert to percentage
  66201. * @param min min range
  66202. * @param max max range
  66203. * @returns the percentage
  66204. */
  66205. static RangeToPercent(number: number, min: number, max: number): number;
  66206. /**
  66207. * This function returns number that corresponds to the percentage in a given range.
  66208. *
  66209. * PercentToRange(0.34,0,100) will return 34.
  66210. * @param percent to convert to number
  66211. * @param min min range
  66212. * @param max max range
  66213. * @returns the number
  66214. */
  66215. static PercentToRange(percent: number, min: number, max: number): number;
  66216. /**
  66217. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  66218. * @param angle The angle to normalize in radian.
  66219. * @return The converted angle.
  66220. */
  66221. static NormalizeRadians(angle: number): number;
  66222. }
  66223. }
  66224. declare module BABYLON {
  66225. /**
  66226. * Constant used to convert a value to gamma space
  66227. * @ignorenaming
  66228. */
  66229. export const ToGammaSpace: number;
  66230. /**
  66231. * Constant used to convert a value to linear space
  66232. * @ignorenaming
  66233. */
  66234. export const ToLinearSpace = 2.2;
  66235. /**
  66236. * Constant used to define the minimal number value in Babylon.js
  66237. * @ignorenaming
  66238. */
  66239. let Epsilon: number;
  66240. }
  66241. declare module BABYLON {
  66242. /**
  66243. * Class used to represent a viewport on screen
  66244. */
  66245. export class Viewport {
  66246. /** viewport left coordinate */
  66247. x: number;
  66248. /** viewport top coordinate */
  66249. y: number;
  66250. /**viewport width */
  66251. width: number;
  66252. /** viewport height */
  66253. height: number;
  66254. /**
  66255. * Creates a Viewport object located at (x, y) and sized (width, height)
  66256. * @param x defines viewport left coordinate
  66257. * @param y defines viewport top coordinate
  66258. * @param width defines the viewport width
  66259. * @param height defines the viewport height
  66260. */
  66261. constructor(
  66262. /** viewport left coordinate */
  66263. x: number,
  66264. /** viewport top coordinate */
  66265. y: number,
  66266. /**viewport width */
  66267. width: number,
  66268. /** viewport height */
  66269. height: number);
  66270. /**
  66271. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  66272. * @param renderWidth defines the rendering width
  66273. * @param renderHeight defines the rendering height
  66274. * @returns a new Viewport
  66275. */
  66276. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  66277. /**
  66278. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  66279. * @param renderWidth defines the rendering width
  66280. * @param renderHeight defines the rendering height
  66281. * @param ref defines the target viewport
  66282. * @returns the current viewport
  66283. */
  66284. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  66285. /**
  66286. * Returns a new Viewport copied from the current one
  66287. * @returns a new Viewport
  66288. */
  66289. clone(): Viewport;
  66290. }
  66291. }
  66292. declare module BABYLON {
  66293. /**
  66294. * Class containing a set of static utilities functions for arrays.
  66295. */
  66296. export class ArrayTools {
  66297. /**
  66298. * Returns an array of the given size filled with element built from the given constructor and the paramters
  66299. * @param size the number of element to construct and put in the array
  66300. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  66301. * @returns a new array filled with new objects
  66302. */
  66303. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  66304. }
  66305. }
  66306. declare module BABYLON {
  66307. /**
  66308. * @hidden
  66309. */
  66310. export interface IColor4Like {
  66311. r: float;
  66312. g: float;
  66313. b: float;
  66314. a: float;
  66315. }
  66316. /**
  66317. * @hidden
  66318. */
  66319. export interface IColor3Like {
  66320. r: float;
  66321. g: float;
  66322. b: float;
  66323. }
  66324. /**
  66325. * @hidden
  66326. */
  66327. export interface IVector4Like {
  66328. x: float;
  66329. y: float;
  66330. z: float;
  66331. w: float;
  66332. }
  66333. /**
  66334. * @hidden
  66335. */
  66336. export interface IVector3Like {
  66337. x: float;
  66338. y: float;
  66339. z: float;
  66340. }
  66341. /**
  66342. * @hidden
  66343. */
  66344. export interface IVector2Like {
  66345. x: float;
  66346. y: float;
  66347. }
  66348. /**
  66349. * @hidden
  66350. */
  66351. export interface IMatrixLike {
  66352. toArray(): DeepImmutable<Float32Array>;
  66353. updateFlag: int;
  66354. }
  66355. /**
  66356. * @hidden
  66357. */
  66358. export interface IViewportLike {
  66359. x: float;
  66360. y: float;
  66361. width: float;
  66362. height: float;
  66363. }
  66364. /**
  66365. * @hidden
  66366. */
  66367. export interface IPlaneLike {
  66368. normal: IVector3Like;
  66369. d: float;
  66370. normalize(): void;
  66371. }
  66372. }
  66373. declare module BABYLON {
  66374. /**
  66375. * Class representing a vector containing 2 coordinates
  66376. */
  66377. export class Vector2 {
  66378. /** defines the first coordinate */
  66379. x: number;
  66380. /** defines the second coordinate */
  66381. y: number;
  66382. /**
  66383. * Creates a new Vector2 from the given x and y coordinates
  66384. * @param x defines the first coordinate
  66385. * @param y defines the second coordinate
  66386. */
  66387. constructor(
  66388. /** defines the first coordinate */
  66389. x?: number,
  66390. /** defines the second coordinate */
  66391. y?: number);
  66392. /**
  66393. * Gets a string with the Vector2 coordinates
  66394. * @returns a string with the Vector2 coordinates
  66395. */
  66396. toString(): string;
  66397. /**
  66398. * Gets class name
  66399. * @returns the string "Vector2"
  66400. */
  66401. getClassName(): string;
  66402. /**
  66403. * Gets current vector hash code
  66404. * @returns the Vector2 hash code as a number
  66405. */
  66406. getHashCode(): number;
  66407. /**
  66408. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  66409. * @param array defines the source array
  66410. * @param index defines the offset in source array
  66411. * @returns the current Vector2
  66412. */
  66413. toArray(array: FloatArray, index?: number): Vector2;
  66414. /**
  66415. * Copy the current vector to an array
  66416. * @returns a new array with 2 elements: the Vector2 coordinates.
  66417. */
  66418. asArray(): number[];
  66419. /**
  66420. * Sets the Vector2 coordinates with the given Vector2 coordinates
  66421. * @param source defines the source Vector2
  66422. * @returns the current updated Vector2
  66423. */
  66424. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  66425. /**
  66426. * Sets the Vector2 coordinates with the given floats
  66427. * @param x defines the first coordinate
  66428. * @param y defines the second coordinate
  66429. * @returns the current updated Vector2
  66430. */
  66431. copyFromFloats(x: number, y: number): Vector2;
  66432. /**
  66433. * Sets the Vector2 coordinates with the given floats
  66434. * @param x defines the first coordinate
  66435. * @param y defines the second coordinate
  66436. * @returns the current updated Vector2
  66437. */
  66438. set(x: number, y: number): Vector2;
  66439. /**
  66440. * Add another vector with the current one
  66441. * @param otherVector defines the other vector
  66442. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  66443. */
  66444. add(otherVector: DeepImmutable<Vector2>): Vector2;
  66445. /**
  66446. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  66447. * @param otherVector defines the other vector
  66448. * @param result defines the target vector
  66449. * @returns the unmodified current Vector2
  66450. */
  66451. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  66452. /**
  66453. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  66454. * @param otherVector defines the other vector
  66455. * @returns the current updated Vector2
  66456. */
  66457. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  66458. /**
  66459. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  66460. * @param otherVector defines the other vector
  66461. * @returns a new Vector2
  66462. */
  66463. addVector3(otherVector: Vector3): Vector2;
  66464. /**
  66465. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  66466. * @param otherVector defines the other vector
  66467. * @returns a new Vector2
  66468. */
  66469. subtract(otherVector: Vector2): Vector2;
  66470. /**
  66471. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  66472. * @param otherVector defines the other vector
  66473. * @param result defines the target vector
  66474. * @returns the unmodified current Vector2
  66475. */
  66476. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  66477. /**
  66478. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  66479. * @param otherVector defines the other vector
  66480. * @returns the current updated Vector2
  66481. */
  66482. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  66483. /**
  66484. * Multiplies in place the current Vector2 coordinates by the given ones
  66485. * @param otherVector defines the other vector
  66486. * @returns the current updated Vector2
  66487. */
  66488. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  66489. /**
  66490. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  66491. * @param otherVector defines the other vector
  66492. * @returns a new Vector2
  66493. */
  66494. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  66495. /**
  66496. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  66497. * @param otherVector defines the other vector
  66498. * @param result defines the target vector
  66499. * @returns the unmodified current Vector2
  66500. */
  66501. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  66502. /**
  66503. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  66504. * @param x defines the first coordinate
  66505. * @param y defines the second coordinate
  66506. * @returns a new Vector2
  66507. */
  66508. multiplyByFloats(x: number, y: number): Vector2;
  66509. /**
  66510. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  66511. * @param otherVector defines the other vector
  66512. * @returns a new Vector2
  66513. */
  66514. divide(otherVector: Vector2): Vector2;
  66515. /**
  66516. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  66517. * @param otherVector defines the other vector
  66518. * @param result defines the target vector
  66519. * @returns the unmodified current Vector2
  66520. */
  66521. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  66522. /**
  66523. * Divides the current Vector2 coordinates by the given ones
  66524. * @param otherVector defines the other vector
  66525. * @returns the current updated Vector2
  66526. */
  66527. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  66528. /**
  66529. * Gets a new Vector2 with current Vector2 negated coordinates
  66530. * @returns a new Vector2
  66531. */
  66532. negate(): Vector2;
  66533. /**
  66534. * Multiply the Vector2 coordinates by scale
  66535. * @param scale defines the scaling factor
  66536. * @returns the current updated Vector2
  66537. */
  66538. scaleInPlace(scale: number): Vector2;
  66539. /**
  66540. * Returns a new Vector2 scaled by "scale" from the current Vector2
  66541. * @param scale defines the scaling factor
  66542. * @returns a new Vector2
  66543. */
  66544. scale(scale: number): Vector2;
  66545. /**
  66546. * Scale the current Vector2 values by a factor to a given Vector2
  66547. * @param scale defines the scale factor
  66548. * @param result defines the Vector2 object where to store the result
  66549. * @returns the unmodified current Vector2
  66550. */
  66551. scaleToRef(scale: number, result: Vector2): Vector2;
  66552. /**
  66553. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  66554. * @param scale defines the scale factor
  66555. * @param result defines the Vector2 object where to store the result
  66556. * @returns the unmodified current Vector2
  66557. */
  66558. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  66559. /**
  66560. * Gets a boolean if two vectors are equals
  66561. * @param otherVector defines the other vector
  66562. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  66563. */
  66564. equals(otherVector: DeepImmutable<Vector2>): boolean;
  66565. /**
  66566. * Gets a boolean if two vectors are equals (using an epsilon value)
  66567. * @param otherVector defines the other vector
  66568. * @param epsilon defines the minimal distance to consider equality
  66569. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  66570. */
  66571. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  66572. /**
  66573. * Gets a new Vector2 from current Vector2 floored values
  66574. * @returns a new Vector2
  66575. */
  66576. floor(): Vector2;
  66577. /**
  66578. * Gets a new Vector2 from current Vector2 floored values
  66579. * @returns a new Vector2
  66580. */
  66581. fract(): Vector2;
  66582. /**
  66583. * Gets the length of the vector
  66584. * @returns the vector length (float)
  66585. */
  66586. length(): number;
  66587. /**
  66588. * Gets the vector squared length
  66589. * @returns the vector squared length (float)
  66590. */
  66591. lengthSquared(): number;
  66592. /**
  66593. * Normalize the vector
  66594. * @returns the current updated Vector2
  66595. */
  66596. normalize(): Vector2;
  66597. /**
  66598. * Gets a new Vector2 copied from the Vector2
  66599. * @returns a new Vector2
  66600. */
  66601. clone(): Vector2;
  66602. /**
  66603. * Gets a new Vector2(0, 0)
  66604. * @returns a new Vector2
  66605. */
  66606. static Zero(): Vector2;
  66607. /**
  66608. * Gets a new Vector2(1, 1)
  66609. * @returns a new Vector2
  66610. */
  66611. static One(): Vector2;
  66612. /**
  66613. * Gets a new Vector2 set from the given index element of the given array
  66614. * @param array defines the data source
  66615. * @param offset defines the offset in the data source
  66616. * @returns a new Vector2
  66617. */
  66618. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  66619. /**
  66620. * Sets "result" from the given index element of the given array
  66621. * @param array defines the data source
  66622. * @param offset defines the offset in the data source
  66623. * @param result defines the target vector
  66624. */
  66625. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  66626. /**
  66627. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  66628. * @param value1 defines 1st point of control
  66629. * @param value2 defines 2nd point of control
  66630. * @param value3 defines 3rd point of control
  66631. * @param value4 defines 4th point of control
  66632. * @param amount defines the interpolation factor
  66633. * @returns a new Vector2
  66634. */
  66635. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  66636. /**
  66637. * 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".
  66638. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  66639. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  66640. * @param value defines the value to clamp
  66641. * @param min defines the lower limit
  66642. * @param max defines the upper limit
  66643. * @returns a new Vector2
  66644. */
  66645. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  66646. /**
  66647. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  66648. * @param value1 defines the 1st control point
  66649. * @param tangent1 defines the outgoing tangent
  66650. * @param value2 defines the 2nd control point
  66651. * @param tangent2 defines the incoming tangent
  66652. * @param amount defines the interpolation factor
  66653. * @returns a new Vector2
  66654. */
  66655. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  66656. /**
  66657. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  66658. * @param start defines the start vector
  66659. * @param end defines the end vector
  66660. * @param amount defines the interpolation factor
  66661. * @returns a new Vector2
  66662. */
  66663. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  66664. /**
  66665. * Gets the dot product of the vector "left" and the vector "right"
  66666. * @param left defines first vector
  66667. * @param right defines second vector
  66668. * @returns the dot product (float)
  66669. */
  66670. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  66671. /**
  66672. * Returns a new Vector2 equal to the normalized given vector
  66673. * @param vector defines the vector to normalize
  66674. * @returns a new Vector2
  66675. */
  66676. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  66677. /**
  66678. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  66679. * @param left defines 1st vector
  66680. * @param right defines 2nd vector
  66681. * @returns a new Vector2
  66682. */
  66683. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  66684. /**
  66685. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  66686. * @param left defines 1st vector
  66687. * @param right defines 2nd vector
  66688. * @returns a new Vector2
  66689. */
  66690. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  66691. /**
  66692. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  66693. * @param vector defines the vector to transform
  66694. * @param transformation defines the matrix to apply
  66695. * @returns a new Vector2
  66696. */
  66697. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  66698. /**
  66699. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  66700. * @param vector defines the vector to transform
  66701. * @param transformation defines the matrix to apply
  66702. * @param result defines the target vector
  66703. */
  66704. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  66705. /**
  66706. * Determines if a given vector is included in a triangle
  66707. * @param p defines the vector to test
  66708. * @param p0 defines 1st triangle point
  66709. * @param p1 defines 2nd triangle point
  66710. * @param p2 defines 3rd triangle point
  66711. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  66712. */
  66713. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  66714. /**
  66715. * Gets the distance between the vectors "value1" and "value2"
  66716. * @param value1 defines first vector
  66717. * @param value2 defines second vector
  66718. * @returns the distance between vectors
  66719. */
  66720. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  66721. /**
  66722. * Returns the squared distance between the vectors "value1" and "value2"
  66723. * @param value1 defines first vector
  66724. * @param value2 defines second vector
  66725. * @returns the squared distance between vectors
  66726. */
  66727. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  66728. /**
  66729. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  66730. * @param value1 defines first vector
  66731. * @param value2 defines second vector
  66732. * @returns a new Vector2
  66733. */
  66734. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  66735. /**
  66736. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  66737. * @param p defines the middle point
  66738. * @param segA defines one point of the segment
  66739. * @param segB defines the other point of the segment
  66740. * @returns the shortest distance
  66741. */
  66742. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  66743. }
  66744. /**
  66745. * Classed used to store (x,y,z) vector representation
  66746. * A Vector3 is the main object used in 3D geometry
  66747. * It can represent etiher the coordinates of a point the space, either a direction
  66748. * Reminder: js uses a left handed forward facing system
  66749. */
  66750. export class Vector3 {
  66751. /**
  66752. * Defines the first coordinates (on X axis)
  66753. */
  66754. x: number;
  66755. /**
  66756. * Defines the second coordinates (on Y axis)
  66757. */
  66758. y: number;
  66759. /**
  66760. * Defines the third coordinates (on Z axis)
  66761. */
  66762. z: number;
  66763. private static _UpReadOnly;
  66764. private static _ZeroReadOnly;
  66765. /**
  66766. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  66767. * @param x defines the first coordinates (on X axis)
  66768. * @param y defines the second coordinates (on Y axis)
  66769. * @param z defines the third coordinates (on Z axis)
  66770. */
  66771. constructor(
  66772. /**
  66773. * Defines the first coordinates (on X axis)
  66774. */
  66775. x?: number,
  66776. /**
  66777. * Defines the second coordinates (on Y axis)
  66778. */
  66779. y?: number,
  66780. /**
  66781. * Defines the third coordinates (on Z axis)
  66782. */
  66783. z?: number);
  66784. /**
  66785. * Creates a string representation of the Vector3
  66786. * @returns a string with the Vector3 coordinates.
  66787. */
  66788. toString(): string;
  66789. /**
  66790. * Gets the class name
  66791. * @returns the string "Vector3"
  66792. */
  66793. getClassName(): string;
  66794. /**
  66795. * Creates the Vector3 hash code
  66796. * @returns a number which tends to be unique between Vector3 instances
  66797. */
  66798. getHashCode(): number;
  66799. /**
  66800. * Creates an array containing three elements : the coordinates of the Vector3
  66801. * @returns a new array of numbers
  66802. */
  66803. asArray(): number[];
  66804. /**
  66805. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  66806. * @param array defines the destination array
  66807. * @param index defines the offset in the destination array
  66808. * @returns the current Vector3
  66809. */
  66810. toArray(array: FloatArray, index?: number): Vector3;
  66811. /**
  66812. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  66813. * @returns a new Quaternion object, computed from the Vector3 coordinates
  66814. */
  66815. toQuaternion(): Quaternion;
  66816. /**
  66817. * Adds the given vector to the current Vector3
  66818. * @param otherVector defines the second operand
  66819. * @returns the current updated Vector3
  66820. */
  66821. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  66822. /**
  66823. * Adds the given coordinates to the current Vector3
  66824. * @param x defines the x coordinate of the operand
  66825. * @param y defines the y coordinate of the operand
  66826. * @param z defines the z coordinate of the operand
  66827. * @returns the current updated Vector3
  66828. */
  66829. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  66830. /**
  66831. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  66832. * @param otherVector defines the second operand
  66833. * @returns the resulting Vector3
  66834. */
  66835. add(otherVector: DeepImmutable<Vector3>): Vector3;
  66836. /**
  66837. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  66838. * @param otherVector defines the second operand
  66839. * @param result defines the Vector3 object where to store the result
  66840. * @returns the current Vector3
  66841. */
  66842. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  66843. /**
  66844. * Subtract the given vector from the current Vector3
  66845. * @param otherVector defines the second operand
  66846. * @returns the current updated Vector3
  66847. */
  66848. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  66849. /**
  66850. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  66851. * @param otherVector defines the second operand
  66852. * @returns the resulting Vector3
  66853. */
  66854. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  66855. /**
  66856. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  66857. * @param otherVector defines the second operand
  66858. * @param result defines the Vector3 object where to store the result
  66859. * @returns the current Vector3
  66860. */
  66861. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  66862. /**
  66863. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  66864. * @param x defines the x coordinate of the operand
  66865. * @param y defines the y coordinate of the operand
  66866. * @param z defines the z coordinate of the operand
  66867. * @returns the resulting Vector3
  66868. */
  66869. subtractFromFloats(x: number, y: number, z: number): Vector3;
  66870. /**
  66871. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  66872. * @param x defines the x coordinate of the operand
  66873. * @param y defines the y coordinate of the operand
  66874. * @param z defines the z coordinate of the operand
  66875. * @param result defines the Vector3 object where to store the result
  66876. * @returns the current Vector3
  66877. */
  66878. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  66879. /**
  66880. * Gets a new Vector3 set with the current Vector3 negated coordinates
  66881. * @returns a new Vector3
  66882. */
  66883. negate(): Vector3;
  66884. /**
  66885. * Multiplies the Vector3 coordinates by the float "scale"
  66886. * @param scale defines the multiplier factor
  66887. * @returns the current updated Vector3
  66888. */
  66889. scaleInPlace(scale: number): Vector3;
  66890. /**
  66891. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  66892. * @param scale defines the multiplier factor
  66893. * @returns a new Vector3
  66894. */
  66895. scale(scale: number): Vector3;
  66896. /**
  66897. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  66898. * @param scale defines the multiplier factor
  66899. * @param result defines the Vector3 object where to store the result
  66900. * @returns the current Vector3
  66901. */
  66902. scaleToRef(scale: number, result: Vector3): Vector3;
  66903. /**
  66904. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  66905. * @param scale defines the scale factor
  66906. * @param result defines the Vector3 object where to store the result
  66907. * @returns the unmodified current Vector3
  66908. */
  66909. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  66910. /**
  66911. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  66912. * @param otherVector defines the second operand
  66913. * @returns true if both vectors are equals
  66914. */
  66915. equals(otherVector: DeepImmutable<Vector3>): boolean;
  66916. /**
  66917. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  66918. * @param otherVector defines the second operand
  66919. * @param epsilon defines the minimal distance to define values as equals
  66920. * @returns true if both vectors are distant less than epsilon
  66921. */
  66922. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  66923. /**
  66924. * Returns true if the current Vector3 coordinates equals the given floats
  66925. * @param x defines the x coordinate of the operand
  66926. * @param y defines the y coordinate of the operand
  66927. * @param z defines the z coordinate of the operand
  66928. * @returns true if both vectors are equals
  66929. */
  66930. equalsToFloats(x: number, y: number, z: number): boolean;
  66931. /**
  66932. * Multiplies the current Vector3 coordinates by the given ones
  66933. * @param otherVector defines the second operand
  66934. * @returns the current updated Vector3
  66935. */
  66936. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  66937. /**
  66938. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  66939. * @param otherVector defines the second operand
  66940. * @returns the new Vector3
  66941. */
  66942. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  66943. /**
  66944. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  66945. * @param otherVector defines the second operand
  66946. * @param result defines the Vector3 object where to store the result
  66947. * @returns the current Vector3
  66948. */
  66949. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  66950. /**
  66951. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  66952. * @param x defines the x coordinate of the operand
  66953. * @param y defines the y coordinate of the operand
  66954. * @param z defines the z coordinate of the operand
  66955. * @returns the new Vector3
  66956. */
  66957. multiplyByFloats(x: number, y: number, z: number): Vector3;
  66958. /**
  66959. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  66960. * @param otherVector defines the second operand
  66961. * @returns the new Vector3
  66962. */
  66963. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  66964. /**
  66965. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  66966. * @param otherVector defines the second operand
  66967. * @param result defines the Vector3 object where to store the result
  66968. * @returns the current Vector3
  66969. */
  66970. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  66971. /**
  66972. * Divides the current Vector3 coordinates by the given ones.
  66973. * @param otherVector defines the second operand
  66974. * @returns the current updated Vector3
  66975. */
  66976. divideInPlace(otherVector: Vector3): Vector3;
  66977. /**
  66978. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  66979. * @param other defines the second operand
  66980. * @returns the current updated Vector3
  66981. */
  66982. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  66983. /**
  66984. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  66985. * @param other defines the second operand
  66986. * @returns the current updated Vector3
  66987. */
  66988. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  66989. /**
  66990. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  66991. * @param x defines the x coordinate of the operand
  66992. * @param y defines the y coordinate of the operand
  66993. * @param z defines the z coordinate of the operand
  66994. * @returns the current updated Vector3
  66995. */
  66996. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  66997. /**
  66998. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  66999. * @param x defines the x coordinate of the operand
  67000. * @param y defines the y coordinate of the operand
  67001. * @param z defines the z coordinate of the operand
  67002. * @returns the current updated Vector3
  67003. */
  67004. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  67005. /**
  67006. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  67007. * Check if is non uniform within a certain amount of decimal places to account for this
  67008. * @param epsilon the amount the values can differ
  67009. * @returns if the the vector is non uniform to a certain number of decimal places
  67010. */
  67011. isNonUniformWithinEpsilon(epsilon: number): boolean;
  67012. /**
  67013. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  67014. */
  67015. readonly isNonUniform: boolean;
  67016. /**
  67017. * Gets a new Vector3 from current Vector3 floored values
  67018. * @returns a new Vector3
  67019. */
  67020. floor(): Vector3;
  67021. /**
  67022. * Gets a new Vector3 from current Vector3 floored values
  67023. * @returns a new Vector3
  67024. */
  67025. fract(): Vector3;
  67026. /**
  67027. * Gets the length of the Vector3
  67028. * @returns the length of the Vector3
  67029. */
  67030. length(): number;
  67031. /**
  67032. * Gets the squared length of the Vector3
  67033. * @returns squared length of the Vector3
  67034. */
  67035. lengthSquared(): number;
  67036. /**
  67037. * Normalize the current Vector3.
  67038. * Please note that this is an in place operation.
  67039. * @returns the current updated Vector3
  67040. */
  67041. normalize(): Vector3;
  67042. /**
  67043. * Reorders the x y z properties of the vector in place
  67044. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  67045. * @returns the current updated vector
  67046. */
  67047. reorderInPlace(order: string): this;
  67048. /**
  67049. * Rotates the vector around 0,0,0 by a quaternion
  67050. * @param quaternion the rotation quaternion
  67051. * @param result vector to store the result
  67052. * @returns the resulting vector
  67053. */
  67054. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  67055. /**
  67056. * Rotates a vector around a given point
  67057. * @param quaternion the rotation quaternion
  67058. * @param point the point to rotate around
  67059. * @param result vector to store the result
  67060. * @returns the resulting vector
  67061. */
  67062. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  67063. /**
  67064. * Normalize the current Vector3 with the given input length.
  67065. * Please note that this is an in place operation.
  67066. * @param len the length of the vector
  67067. * @returns the current updated Vector3
  67068. */
  67069. normalizeFromLength(len: number): Vector3;
  67070. /**
  67071. * Normalize the current Vector3 to a new vector
  67072. * @returns the new Vector3
  67073. */
  67074. normalizeToNew(): Vector3;
  67075. /**
  67076. * Normalize the current Vector3 to the reference
  67077. * @param reference define the Vector3 to update
  67078. * @returns the updated Vector3
  67079. */
  67080. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  67081. /**
  67082. * Creates a new Vector3 copied from the current Vector3
  67083. * @returns the new Vector3
  67084. */
  67085. clone(): Vector3;
  67086. /**
  67087. * Copies the given vector coordinates to the current Vector3 ones
  67088. * @param source defines the source Vector3
  67089. * @returns the current updated Vector3
  67090. */
  67091. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  67092. /**
  67093. * Copies the given floats to the current Vector3 coordinates
  67094. * @param x defines the x coordinate of the operand
  67095. * @param y defines the y coordinate of the operand
  67096. * @param z defines the z coordinate of the operand
  67097. * @returns the current updated Vector3
  67098. */
  67099. copyFromFloats(x: number, y: number, z: number): Vector3;
  67100. /**
  67101. * Copies the given floats to the current Vector3 coordinates
  67102. * @param x defines the x coordinate of the operand
  67103. * @param y defines the y coordinate of the operand
  67104. * @param z defines the z coordinate of the operand
  67105. * @returns the current updated Vector3
  67106. */
  67107. set(x: number, y: number, z: number): Vector3;
  67108. /**
  67109. * Copies the given float to the current Vector3 coordinates
  67110. * @param v defines the x, y and z coordinates of the operand
  67111. * @returns the current updated Vector3
  67112. */
  67113. setAll(v: number): Vector3;
  67114. /**
  67115. * Get the clip factor between two vectors
  67116. * @param vector0 defines the first operand
  67117. * @param vector1 defines the second operand
  67118. * @param axis defines the axis to use
  67119. * @param size defines the size along the axis
  67120. * @returns the clip factor
  67121. */
  67122. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  67123. /**
  67124. * Get angle between two vectors
  67125. * @param vector0 angle between vector0 and vector1
  67126. * @param vector1 angle between vector0 and vector1
  67127. * @param normal direction of the normal
  67128. * @return the angle between vector0 and vector1
  67129. */
  67130. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  67131. /**
  67132. * Returns a new Vector3 set from the index "offset" of the given array
  67133. * @param array defines the source array
  67134. * @param offset defines the offset in the source array
  67135. * @returns the new Vector3
  67136. */
  67137. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  67138. /**
  67139. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  67140. * This function is deprecated. Use FromArray instead
  67141. * @param array defines the source array
  67142. * @param offset defines the offset in the source array
  67143. * @returns the new Vector3
  67144. */
  67145. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  67146. /**
  67147. * Sets the given vector "result" with the element values from the index "offset" of the given array
  67148. * @param array defines the source array
  67149. * @param offset defines the offset in the source array
  67150. * @param result defines the Vector3 where to store the result
  67151. */
  67152. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  67153. /**
  67154. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  67155. * This function is deprecated. Use FromArrayToRef instead.
  67156. * @param array defines the source array
  67157. * @param offset defines the offset in the source array
  67158. * @param result defines the Vector3 where to store the result
  67159. */
  67160. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  67161. /**
  67162. * Sets the given vector "result" with the given floats.
  67163. * @param x defines the x coordinate of the source
  67164. * @param y defines the y coordinate of the source
  67165. * @param z defines the z coordinate of the source
  67166. * @param result defines the Vector3 where to store the result
  67167. */
  67168. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  67169. /**
  67170. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  67171. * @returns a new empty Vector3
  67172. */
  67173. static Zero(): Vector3;
  67174. /**
  67175. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  67176. * @returns a new unit Vector3
  67177. */
  67178. static One(): Vector3;
  67179. /**
  67180. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  67181. * @returns a new up Vector3
  67182. */
  67183. static Up(): Vector3;
  67184. /**
  67185. * Gets a up Vector3 that must not be updated
  67186. */
  67187. static readonly UpReadOnly: DeepImmutable<Vector3>;
  67188. /**
  67189. * Gets a zero Vector3 that must not be updated
  67190. */
  67191. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  67192. /**
  67193. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  67194. * @returns a new down Vector3
  67195. */
  67196. static Down(): Vector3;
  67197. /**
  67198. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  67199. * @returns a new forward Vector3
  67200. */
  67201. static Forward(): Vector3;
  67202. /**
  67203. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  67204. * @returns a new forward Vector3
  67205. */
  67206. static Backward(): Vector3;
  67207. /**
  67208. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  67209. * @returns a new right Vector3
  67210. */
  67211. static Right(): Vector3;
  67212. /**
  67213. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  67214. * @returns a new left Vector3
  67215. */
  67216. static Left(): Vector3;
  67217. /**
  67218. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  67219. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  67220. * @param vector defines the Vector3 to transform
  67221. * @param transformation defines the transformation matrix
  67222. * @returns the transformed Vector3
  67223. */
  67224. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  67225. /**
  67226. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  67227. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  67228. * @param vector defines the Vector3 to transform
  67229. * @param transformation defines the transformation matrix
  67230. * @param result defines the Vector3 where to store the result
  67231. */
  67232. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  67233. /**
  67234. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  67235. * This method computes tranformed coordinates only, not transformed direction vectors
  67236. * @param x define the x coordinate of the source vector
  67237. * @param y define the y coordinate of the source vector
  67238. * @param z define the z coordinate of the source vector
  67239. * @param transformation defines the transformation matrix
  67240. * @param result defines the Vector3 where to store the result
  67241. */
  67242. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  67243. /**
  67244. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  67245. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  67246. * @param vector defines the Vector3 to transform
  67247. * @param transformation defines the transformation matrix
  67248. * @returns the new Vector3
  67249. */
  67250. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  67251. /**
  67252. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  67253. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  67254. * @param vector defines the Vector3 to transform
  67255. * @param transformation defines the transformation matrix
  67256. * @param result defines the Vector3 where to store the result
  67257. */
  67258. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  67259. /**
  67260. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  67261. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  67262. * @param x define the x coordinate of the source vector
  67263. * @param y define the y coordinate of the source vector
  67264. * @param z define the z coordinate of the source vector
  67265. * @param transformation defines the transformation matrix
  67266. * @param result defines the Vector3 where to store the result
  67267. */
  67268. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  67269. /**
  67270. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  67271. * @param value1 defines the first control point
  67272. * @param value2 defines the second control point
  67273. * @param value3 defines the third control point
  67274. * @param value4 defines the fourth control point
  67275. * @param amount defines the amount on the spline to use
  67276. * @returns the new Vector3
  67277. */
  67278. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  67279. /**
  67280. * 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"
  67281. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  67282. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  67283. * @param value defines the current value
  67284. * @param min defines the lower range value
  67285. * @param max defines the upper range value
  67286. * @returns the new Vector3
  67287. */
  67288. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  67289. /**
  67290. * 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"
  67291. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  67292. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  67293. * @param value defines the current value
  67294. * @param min defines the lower range value
  67295. * @param max defines the upper range value
  67296. * @param result defines the Vector3 where to store the result
  67297. */
  67298. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  67299. /**
  67300. * Checks if a given vector is inside a specific range
  67301. * @param v defines the vector to test
  67302. * @param min defines the minimum range
  67303. * @param max defines the maximum range
  67304. */
  67305. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  67306. /**
  67307. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  67308. * @param value1 defines the first control point
  67309. * @param tangent1 defines the first tangent vector
  67310. * @param value2 defines the second control point
  67311. * @param tangent2 defines the second tangent vector
  67312. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  67313. * @returns the new Vector3
  67314. */
  67315. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  67316. /**
  67317. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  67318. * @param start defines the start value
  67319. * @param end defines the end value
  67320. * @param amount max defines amount between both (between 0 and 1)
  67321. * @returns the new Vector3
  67322. */
  67323. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  67324. /**
  67325. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  67326. * @param start defines the start value
  67327. * @param end defines the end value
  67328. * @param amount max defines amount between both (between 0 and 1)
  67329. * @param result defines the Vector3 where to store the result
  67330. */
  67331. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  67332. /**
  67333. * Returns the dot product (float) between the vectors "left" and "right"
  67334. * @param left defines the left operand
  67335. * @param right defines the right operand
  67336. * @returns the dot product
  67337. */
  67338. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  67339. /**
  67340. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  67341. * The cross product is then orthogonal to both "left" and "right"
  67342. * @param left defines the left operand
  67343. * @param right defines the right operand
  67344. * @returns the cross product
  67345. */
  67346. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  67347. /**
  67348. * Sets the given vector "result" with the cross product of "left" and "right"
  67349. * The cross product is then orthogonal to both "left" and "right"
  67350. * @param left defines the left operand
  67351. * @param right defines the right operand
  67352. * @param result defines the Vector3 where to store the result
  67353. */
  67354. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  67355. /**
  67356. * Returns a new Vector3 as the normalization of the given vector
  67357. * @param vector defines the Vector3 to normalize
  67358. * @returns the new Vector3
  67359. */
  67360. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  67361. /**
  67362. * Sets the given vector "result" with the normalization of the given first vector
  67363. * @param vector defines the Vector3 to normalize
  67364. * @param result defines the Vector3 where to store the result
  67365. */
  67366. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  67367. /**
  67368. * Project a Vector3 onto screen space
  67369. * @param vector defines the Vector3 to project
  67370. * @param world defines the world matrix to use
  67371. * @param transform defines the transform (view x projection) matrix to use
  67372. * @param viewport defines the screen viewport to use
  67373. * @returns the new Vector3
  67374. */
  67375. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  67376. /** @hidden */
  67377. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  67378. /**
  67379. * Unproject from screen space to object space
  67380. * @param source defines the screen space Vector3 to use
  67381. * @param viewportWidth defines the current width of the viewport
  67382. * @param viewportHeight defines the current height of the viewport
  67383. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  67384. * @param transform defines the transform (view x projection) matrix to use
  67385. * @returns the new Vector3
  67386. */
  67387. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  67388. /**
  67389. * Unproject from screen space to object space
  67390. * @param source defines the screen space Vector3 to use
  67391. * @param viewportWidth defines the current width of the viewport
  67392. * @param viewportHeight defines the current height of the viewport
  67393. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  67394. * @param view defines the view matrix to use
  67395. * @param projection defines the projection matrix to use
  67396. * @returns the new Vector3
  67397. */
  67398. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  67399. /**
  67400. * Unproject from screen space to object space
  67401. * @param source defines the screen space Vector3 to use
  67402. * @param viewportWidth defines the current width of the viewport
  67403. * @param viewportHeight defines the current height of the viewport
  67404. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  67405. * @param view defines the view matrix to use
  67406. * @param projection defines the projection matrix to use
  67407. * @param result defines the Vector3 where to store the result
  67408. */
  67409. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  67410. /**
  67411. * Unproject from screen space to object space
  67412. * @param sourceX defines the screen space x coordinate to use
  67413. * @param sourceY defines the screen space y coordinate to use
  67414. * @param sourceZ defines the screen space z coordinate to use
  67415. * @param viewportWidth defines the current width of the viewport
  67416. * @param viewportHeight defines the current height of the viewport
  67417. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  67418. * @param view defines the view matrix to use
  67419. * @param projection defines the projection matrix to use
  67420. * @param result defines the Vector3 where to store the result
  67421. */
  67422. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  67423. /**
  67424. * Gets the minimal coordinate values between two Vector3
  67425. * @param left defines the first operand
  67426. * @param right defines the second operand
  67427. * @returns the new Vector3
  67428. */
  67429. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  67430. /**
  67431. * Gets the maximal coordinate values between two Vector3
  67432. * @param left defines the first operand
  67433. * @param right defines the second operand
  67434. * @returns the new Vector3
  67435. */
  67436. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  67437. /**
  67438. * Returns the distance between the vectors "value1" and "value2"
  67439. * @param value1 defines the first operand
  67440. * @param value2 defines the second operand
  67441. * @returns the distance
  67442. */
  67443. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  67444. /**
  67445. * Returns the squared distance between the vectors "value1" and "value2"
  67446. * @param value1 defines the first operand
  67447. * @param value2 defines the second operand
  67448. * @returns the squared distance
  67449. */
  67450. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  67451. /**
  67452. * Returns a new Vector3 located at the center between "value1" and "value2"
  67453. * @param value1 defines the first operand
  67454. * @param value2 defines the second operand
  67455. * @returns the new Vector3
  67456. */
  67457. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  67458. /**
  67459. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  67460. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  67461. * to something in order to rotate it from its local system to the given target system
  67462. * Note: axis1, axis2 and axis3 are normalized during this operation
  67463. * @param axis1 defines the first axis
  67464. * @param axis2 defines the second axis
  67465. * @param axis3 defines the third axis
  67466. * @returns a new Vector3
  67467. */
  67468. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  67469. /**
  67470. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  67471. * @param axis1 defines the first axis
  67472. * @param axis2 defines the second axis
  67473. * @param axis3 defines the third axis
  67474. * @param ref defines the Vector3 where to store the result
  67475. */
  67476. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  67477. }
  67478. /**
  67479. * Vector4 class created for EulerAngle class conversion to Quaternion
  67480. */
  67481. export class Vector4 {
  67482. /** x value of the vector */
  67483. x: number;
  67484. /** y value of the vector */
  67485. y: number;
  67486. /** z value of the vector */
  67487. z: number;
  67488. /** w value of the vector */
  67489. w: number;
  67490. /**
  67491. * Creates a Vector4 object from the given floats.
  67492. * @param x x value of the vector
  67493. * @param y y value of the vector
  67494. * @param z z value of the vector
  67495. * @param w w value of the vector
  67496. */
  67497. constructor(
  67498. /** x value of the vector */
  67499. x: number,
  67500. /** y value of the vector */
  67501. y: number,
  67502. /** z value of the vector */
  67503. z: number,
  67504. /** w value of the vector */
  67505. w: number);
  67506. /**
  67507. * Returns the string with the Vector4 coordinates.
  67508. * @returns a string containing all the vector values
  67509. */
  67510. toString(): string;
  67511. /**
  67512. * Returns the string "Vector4".
  67513. * @returns "Vector4"
  67514. */
  67515. getClassName(): string;
  67516. /**
  67517. * Returns the Vector4 hash code.
  67518. * @returns a unique hash code
  67519. */
  67520. getHashCode(): number;
  67521. /**
  67522. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  67523. * @returns the resulting array
  67524. */
  67525. asArray(): number[];
  67526. /**
  67527. * Populates the given array from the given index with the Vector4 coordinates.
  67528. * @param array array to populate
  67529. * @param index index of the array to start at (default: 0)
  67530. * @returns the Vector4.
  67531. */
  67532. toArray(array: FloatArray, index?: number): Vector4;
  67533. /**
  67534. * Adds the given vector to the current Vector4.
  67535. * @param otherVector the vector to add
  67536. * @returns the updated Vector4.
  67537. */
  67538. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  67539. /**
  67540. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  67541. * @param otherVector the vector to add
  67542. * @returns the resulting vector
  67543. */
  67544. add(otherVector: DeepImmutable<Vector4>): Vector4;
  67545. /**
  67546. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  67547. * @param otherVector the vector to add
  67548. * @param result the vector to store the result
  67549. * @returns the current Vector4.
  67550. */
  67551. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  67552. /**
  67553. * Subtract in place the given vector from the current Vector4.
  67554. * @param otherVector the vector to subtract
  67555. * @returns the updated Vector4.
  67556. */
  67557. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  67558. /**
  67559. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  67560. * @param otherVector the vector to add
  67561. * @returns the new vector with the result
  67562. */
  67563. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  67564. /**
  67565. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  67566. * @param otherVector the vector to subtract
  67567. * @param result the vector to store the result
  67568. * @returns the current Vector4.
  67569. */
  67570. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  67571. /**
  67572. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  67573. */
  67574. /**
  67575. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  67576. * @param x value to subtract
  67577. * @param y value to subtract
  67578. * @param z value to subtract
  67579. * @param w value to subtract
  67580. * @returns new vector containing the result
  67581. */
  67582. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  67583. /**
  67584. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  67585. * @param x value to subtract
  67586. * @param y value to subtract
  67587. * @param z value to subtract
  67588. * @param w value to subtract
  67589. * @param result the vector to store the result in
  67590. * @returns the current Vector4.
  67591. */
  67592. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  67593. /**
  67594. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  67595. * @returns a new vector with the negated values
  67596. */
  67597. negate(): Vector4;
  67598. /**
  67599. * Multiplies the current Vector4 coordinates by scale (float).
  67600. * @param scale the number to scale with
  67601. * @returns the updated Vector4.
  67602. */
  67603. scaleInPlace(scale: number): Vector4;
  67604. /**
  67605. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  67606. * @param scale the number to scale with
  67607. * @returns a new vector with the result
  67608. */
  67609. scale(scale: number): Vector4;
  67610. /**
  67611. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  67612. * @param scale the number to scale with
  67613. * @param result a vector to store the result in
  67614. * @returns the current Vector4.
  67615. */
  67616. scaleToRef(scale: number, result: Vector4): Vector4;
  67617. /**
  67618. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  67619. * @param scale defines the scale factor
  67620. * @param result defines the Vector4 object where to store the result
  67621. * @returns the unmodified current Vector4
  67622. */
  67623. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  67624. /**
  67625. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  67626. * @param otherVector the vector to compare against
  67627. * @returns true if they are equal
  67628. */
  67629. equals(otherVector: DeepImmutable<Vector4>): boolean;
  67630. /**
  67631. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  67632. * @param otherVector vector to compare against
  67633. * @param epsilon (Default: very small number)
  67634. * @returns true if they are equal
  67635. */
  67636. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  67637. /**
  67638. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  67639. * @param x x value to compare against
  67640. * @param y y value to compare against
  67641. * @param z z value to compare against
  67642. * @param w w value to compare against
  67643. * @returns true if equal
  67644. */
  67645. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  67646. /**
  67647. * Multiplies in place the current Vector4 by the given one.
  67648. * @param otherVector vector to multiple with
  67649. * @returns the updated Vector4.
  67650. */
  67651. multiplyInPlace(otherVector: Vector4): Vector4;
  67652. /**
  67653. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  67654. * @param otherVector vector to multiple with
  67655. * @returns resulting new vector
  67656. */
  67657. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  67658. /**
  67659. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  67660. * @param otherVector vector to multiple with
  67661. * @param result vector to store the result
  67662. * @returns the current Vector4.
  67663. */
  67664. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  67665. /**
  67666. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  67667. * @param x x value multiply with
  67668. * @param y y value multiply with
  67669. * @param z z value multiply with
  67670. * @param w w value multiply with
  67671. * @returns resulting new vector
  67672. */
  67673. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  67674. /**
  67675. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  67676. * @param otherVector vector to devide with
  67677. * @returns resulting new vector
  67678. */
  67679. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  67680. /**
  67681. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  67682. * @param otherVector vector to devide with
  67683. * @param result vector to store the result
  67684. * @returns the current Vector4.
  67685. */
  67686. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  67687. /**
  67688. * Divides the current Vector3 coordinates by the given ones.
  67689. * @param otherVector vector to devide with
  67690. * @returns the updated Vector3.
  67691. */
  67692. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  67693. /**
  67694. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  67695. * @param other defines the second operand
  67696. * @returns the current updated Vector4
  67697. */
  67698. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  67699. /**
  67700. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  67701. * @param other defines the second operand
  67702. * @returns the current updated Vector4
  67703. */
  67704. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  67705. /**
  67706. * Gets a new Vector4 from current Vector4 floored values
  67707. * @returns a new Vector4
  67708. */
  67709. floor(): Vector4;
  67710. /**
  67711. * Gets a new Vector4 from current Vector3 floored values
  67712. * @returns a new Vector4
  67713. */
  67714. fract(): Vector4;
  67715. /**
  67716. * Returns the Vector4 length (float).
  67717. * @returns the length
  67718. */
  67719. length(): number;
  67720. /**
  67721. * Returns the Vector4 squared length (float).
  67722. * @returns the length squared
  67723. */
  67724. lengthSquared(): number;
  67725. /**
  67726. * Normalizes in place the Vector4.
  67727. * @returns the updated Vector4.
  67728. */
  67729. normalize(): Vector4;
  67730. /**
  67731. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  67732. * @returns this converted to a new vector3
  67733. */
  67734. toVector3(): Vector3;
  67735. /**
  67736. * Returns a new Vector4 copied from the current one.
  67737. * @returns the new cloned vector
  67738. */
  67739. clone(): Vector4;
  67740. /**
  67741. * Updates the current Vector4 with the given one coordinates.
  67742. * @param source the source vector to copy from
  67743. * @returns the updated Vector4.
  67744. */
  67745. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  67746. /**
  67747. * Updates the current Vector4 coordinates with the given floats.
  67748. * @param x float to copy from
  67749. * @param y float to copy from
  67750. * @param z float to copy from
  67751. * @param w float to copy from
  67752. * @returns the updated Vector4.
  67753. */
  67754. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  67755. /**
  67756. * Updates the current Vector4 coordinates with the given floats.
  67757. * @param x float to set from
  67758. * @param y float to set from
  67759. * @param z float to set from
  67760. * @param w float to set from
  67761. * @returns the updated Vector4.
  67762. */
  67763. set(x: number, y: number, z: number, w: number): Vector4;
  67764. /**
  67765. * Copies the given float to the current Vector3 coordinates
  67766. * @param v defines the x, y, z and w coordinates of the operand
  67767. * @returns the current updated Vector3
  67768. */
  67769. setAll(v: number): Vector4;
  67770. /**
  67771. * Returns a new Vector4 set from the starting index of the given array.
  67772. * @param array the array to pull values from
  67773. * @param offset the offset into the array to start at
  67774. * @returns the new vector
  67775. */
  67776. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  67777. /**
  67778. * Updates the given vector "result" from the starting index of the given array.
  67779. * @param array the array to pull values from
  67780. * @param offset the offset into the array to start at
  67781. * @param result the vector to store the result in
  67782. */
  67783. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  67784. /**
  67785. * Updates the given vector "result" from the starting index of the given Float32Array.
  67786. * @param array the array to pull values from
  67787. * @param offset the offset into the array to start at
  67788. * @param result the vector to store the result in
  67789. */
  67790. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  67791. /**
  67792. * Updates the given vector "result" coordinates from the given floats.
  67793. * @param x float to set from
  67794. * @param y float to set from
  67795. * @param z float to set from
  67796. * @param w float to set from
  67797. * @param result the vector to the floats in
  67798. */
  67799. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  67800. /**
  67801. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  67802. * @returns the new vector
  67803. */
  67804. static Zero(): Vector4;
  67805. /**
  67806. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  67807. * @returns the new vector
  67808. */
  67809. static One(): Vector4;
  67810. /**
  67811. * Returns a new normalized Vector4 from the given one.
  67812. * @param vector the vector to normalize
  67813. * @returns the vector
  67814. */
  67815. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  67816. /**
  67817. * Updates the given vector "result" from the normalization of the given one.
  67818. * @param vector the vector to normalize
  67819. * @param result the vector to store the result in
  67820. */
  67821. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  67822. /**
  67823. * Returns a vector with the minimum values from the left and right vectors
  67824. * @param left left vector to minimize
  67825. * @param right right vector to minimize
  67826. * @returns a new vector with the minimum of the left and right vector values
  67827. */
  67828. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  67829. /**
  67830. * Returns a vector with the maximum values from the left and right vectors
  67831. * @param left left vector to maximize
  67832. * @param right right vector to maximize
  67833. * @returns a new vector with the maximum of the left and right vector values
  67834. */
  67835. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  67836. /**
  67837. * Returns the distance (float) between the vectors "value1" and "value2".
  67838. * @param value1 value to calulate the distance between
  67839. * @param value2 value to calulate the distance between
  67840. * @return the distance between the two vectors
  67841. */
  67842. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  67843. /**
  67844. * Returns the squared distance (float) between the vectors "value1" and "value2".
  67845. * @param value1 value to calulate the distance between
  67846. * @param value2 value to calulate the distance between
  67847. * @return the distance between the two vectors squared
  67848. */
  67849. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  67850. /**
  67851. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  67852. * @param value1 value to calulate the center between
  67853. * @param value2 value to calulate the center between
  67854. * @return the center between the two vectors
  67855. */
  67856. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  67857. /**
  67858. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  67859. * This methods computes transformed normalized direction vectors only.
  67860. * @param vector the vector to transform
  67861. * @param transformation the transformation matrix to apply
  67862. * @returns the new vector
  67863. */
  67864. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  67865. /**
  67866. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  67867. * This methods computes transformed normalized direction vectors only.
  67868. * @param vector the vector to transform
  67869. * @param transformation the transformation matrix to apply
  67870. * @param result the vector to store the result in
  67871. */
  67872. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  67873. /**
  67874. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  67875. * This methods computes transformed normalized direction vectors only.
  67876. * @param x value to transform
  67877. * @param y value to transform
  67878. * @param z value to transform
  67879. * @param w value to transform
  67880. * @param transformation the transformation matrix to apply
  67881. * @param result the vector to store the results in
  67882. */
  67883. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  67884. /**
  67885. * Creates a new Vector4 from a Vector3
  67886. * @param source defines the source data
  67887. * @param w defines the 4th component (default is 0)
  67888. * @returns a new Vector4
  67889. */
  67890. static FromVector3(source: Vector3, w?: number): Vector4;
  67891. }
  67892. /**
  67893. * Class used to store quaternion data
  67894. * @see https://en.wikipedia.org/wiki/Quaternion
  67895. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  67896. */
  67897. export class Quaternion {
  67898. /** defines the first component (0 by default) */
  67899. x: number;
  67900. /** defines the second component (0 by default) */
  67901. y: number;
  67902. /** defines the third component (0 by default) */
  67903. z: number;
  67904. /** defines the fourth component (1.0 by default) */
  67905. w: number;
  67906. /**
  67907. * Creates a new Quaternion from the given floats
  67908. * @param x defines the first component (0 by default)
  67909. * @param y defines the second component (0 by default)
  67910. * @param z defines the third component (0 by default)
  67911. * @param w defines the fourth component (1.0 by default)
  67912. */
  67913. constructor(
  67914. /** defines the first component (0 by default) */
  67915. x?: number,
  67916. /** defines the second component (0 by default) */
  67917. y?: number,
  67918. /** defines the third component (0 by default) */
  67919. z?: number,
  67920. /** defines the fourth component (1.0 by default) */
  67921. w?: number);
  67922. /**
  67923. * Gets a string representation for the current quaternion
  67924. * @returns a string with the Quaternion coordinates
  67925. */
  67926. toString(): string;
  67927. /**
  67928. * Gets the class name of the quaternion
  67929. * @returns the string "Quaternion"
  67930. */
  67931. getClassName(): string;
  67932. /**
  67933. * Gets a hash code for this quaternion
  67934. * @returns the quaternion hash code
  67935. */
  67936. getHashCode(): number;
  67937. /**
  67938. * Copy the quaternion to an array
  67939. * @returns a new array populated with 4 elements from the quaternion coordinates
  67940. */
  67941. asArray(): number[];
  67942. /**
  67943. * Check if two quaternions are equals
  67944. * @param otherQuaternion defines the second operand
  67945. * @return true if the current quaternion and the given one coordinates are strictly equals
  67946. */
  67947. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  67948. /**
  67949. * Clone the current quaternion
  67950. * @returns a new quaternion copied from the current one
  67951. */
  67952. clone(): Quaternion;
  67953. /**
  67954. * Copy a quaternion to the current one
  67955. * @param other defines the other quaternion
  67956. * @returns the updated current quaternion
  67957. */
  67958. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  67959. /**
  67960. * Updates the current quaternion with the given float coordinates
  67961. * @param x defines the x coordinate
  67962. * @param y defines the y coordinate
  67963. * @param z defines the z coordinate
  67964. * @param w defines the w coordinate
  67965. * @returns the updated current quaternion
  67966. */
  67967. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  67968. /**
  67969. * Updates the current quaternion from the given float coordinates
  67970. * @param x defines the x coordinate
  67971. * @param y defines the y coordinate
  67972. * @param z defines the z coordinate
  67973. * @param w defines the w coordinate
  67974. * @returns the updated current quaternion
  67975. */
  67976. set(x: number, y: number, z: number, w: number): Quaternion;
  67977. /**
  67978. * Adds two quaternions
  67979. * @param other defines the second operand
  67980. * @returns a new quaternion as the addition result of the given one and the current quaternion
  67981. */
  67982. add(other: DeepImmutable<Quaternion>): Quaternion;
  67983. /**
  67984. * Add a quaternion to the current one
  67985. * @param other defines the quaternion to add
  67986. * @returns the current quaternion
  67987. */
  67988. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  67989. /**
  67990. * Subtract two quaternions
  67991. * @param other defines the second operand
  67992. * @returns a new quaternion as the subtraction result of the given one from the current one
  67993. */
  67994. subtract(other: Quaternion): Quaternion;
  67995. /**
  67996. * Multiplies the current quaternion by a scale factor
  67997. * @param value defines the scale factor
  67998. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  67999. */
  68000. scale(value: number): Quaternion;
  68001. /**
  68002. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  68003. * @param scale defines the scale factor
  68004. * @param result defines the Quaternion object where to store the result
  68005. * @returns the unmodified current quaternion
  68006. */
  68007. scaleToRef(scale: number, result: Quaternion): Quaternion;
  68008. /**
  68009. * Multiplies in place the current quaternion by a scale factor
  68010. * @param value defines the scale factor
  68011. * @returns the current modified quaternion
  68012. */
  68013. scaleInPlace(value: number): Quaternion;
  68014. /**
  68015. * Scale the current quaternion values by a factor and add the result to a given quaternion
  68016. * @param scale defines the scale factor
  68017. * @param result defines the Quaternion object where to store the result
  68018. * @returns the unmodified current quaternion
  68019. */
  68020. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  68021. /**
  68022. * Multiplies two quaternions
  68023. * @param q1 defines the second operand
  68024. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  68025. */
  68026. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  68027. /**
  68028. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  68029. * @param q1 defines the second operand
  68030. * @param result defines the target quaternion
  68031. * @returns the current quaternion
  68032. */
  68033. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  68034. /**
  68035. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  68036. * @param q1 defines the second operand
  68037. * @returns the currentupdated quaternion
  68038. */
  68039. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  68040. /**
  68041. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  68042. * @param ref defines the target quaternion
  68043. * @returns the current quaternion
  68044. */
  68045. conjugateToRef(ref: Quaternion): Quaternion;
  68046. /**
  68047. * Conjugates in place (1-q) the current quaternion
  68048. * @returns the current updated quaternion
  68049. */
  68050. conjugateInPlace(): Quaternion;
  68051. /**
  68052. * Conjugates in place (1-q) the current quaternion
  68053. * @returns a new quaternion
  68054. */
  68055. conjugate(): Quaternion;
  68056. /**
  68057. * Gets length of current quaternion
  68058. * @returns the quaternion length (float)
  68059. */
  68060. length(): number;
  68061. /**
  68062. * Normalize in place the current quaternion
  68063. * @returns the current updated quaternion
  68064. */
  68065. normalize(): Quaternion;
  68066. /**
  68067. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  68068. * @param order is a reserved parameter and is ignore for now
  68069. * @returns a new Vector3 containing the Euler angles
  68070. */
  68071. toEulerAngles(order?: string): Vector3;
  68072. /**
  68073. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  68074. * @param result defines the vector which will be filled with the Euler angles
  68075. * @param order is a reserved parameter and is ignore for now
  68076. * @returns the current unchanged quaternion
  68077. */
  68078. toEulerAnglesToRef(result: Vector3): Quaternion;
  68079. /**
  68080. * Updates the given rotation matrix with the current quaternion values
  68081. * @param result defines the target matrix
  68082. * @returns the current unchanged quaternion
  68083. */
  68084. toRotationMatrix(result: Matrix): Quaternion;
  68085. /**
  68086. * Updates the current quaternion from the given rotation matrix values
  68087. * @param matrix defines the source matrix
  68088. * @returns the current updated quaternion
  68089. */
  68090. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  68091. /**
  68092. * Creates a new quaternion from a rotation matrix
  68093. * @param matrix defines the source matrix
  68094. * @returns a new quaternion created from the given rotation matrix values
  68095. */
  68096. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  68097. /**
  68098. * Updates the given quaternion with the given rotation matrix values
  68099. * @param matrix defines the source matrix
  68100. * @param result defines the target quaternion
  68101. */
  68102. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  68103. /**
  68104. * Returns the dot product (float) between the quaternions "left" and "right"
  68105. * @param left defines the left operand
  68106. * @param right defines the right operand
  68107. * @returns the dot product
  68108. */
  68109. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  68110. /**
  68111. * Checks if the two quaternions are close to each other
  68112. * @param quat0 defines the first quaternion to check
  68113. * @param quat1 defines the second quaternion to check
  68114. * @returns true if the two quaternions are close to each other
  68115. */
  68116. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  68117. /**
  68118. * Creates an empty quaternion
  68119. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  68120. */
  68121. static Zero(): Quaternion;
  68122. /**
  68123. * Inverse a given quaternion
  68124. * @param q defines the source quaternion
  68125. * @returns a new quaternion as the inverted current quaternion
  68126. */
  68127. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  68128. /**
  68129. * Inverse a given quaternion
  68130. * @param q defines the source quaternion
  68131. * @param result the quaternion the result will be stored in
  68132. * @returns the result quaternion
  68133. */
  68134. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  68135. /**
  68136. * Creates an identity quaternion
  68137. * @returns the identity quaternion
  68138. */
  68139. static Identity(): Quaternion;
  68140. /**
  68141. * Gets a boolean indicating if the given quaternion is identity
  68142. * @param quaternion defines the quaternion to check
  68143. * @returns true if the quaternion is identity
  68144. */
  68145. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  68146. /**
  68147. * Creates a quaternion from a rotation around an axis
  68148. * @param axis defines the axis to use
  68149. * @param angle defines the angle to use
  68150. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  68151. */
  68152. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  68153. /**
  68154. * Creates a rotation around an axis and stores it into the given quaternion
  68155. * @param axis defines the axis to use
  68156. * @param angle defines the angle to use
  68157. * @param result defines the target quaternion
  68158. * @returns the target quaternion
  68159. */
  68160. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  68161. /**
  68162. * Creates a new quaternion from data stored into an array
  68163. * @param array defines the data source
  68164. * @param offset defines the offset in the source array where the data starts
  68165. * @returns a new quaternion
  68166. */
  68167. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  68168. /**
  68169. * Create a quaternion from Euler rotation angles
  68170. * @param x Pitch
  68171. * @param y Yaw
  68172. * @param z Roll
  68173. * @returns the new Quaternion
  68174. */
  68175. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  68176. /**
  68177. * Updates a quaternion from Euler rotation angles
  68178. * @param x Pitch
  68179. * @param y Yaw
  68180. * @param z Roll
  68181. * @param result the quaternion to store the result
  68182. * @returns the updated quaternion
  68183. */
  68184. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  68185. /**
  68186. * Create a quaternion from Euler rotation vector
  68187. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  68188. * @returns the new Quaternion
  68189. */
  68190. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  68191. /**
  68192. * Updates a quaternion from Euler rotation vector
  68193. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  68194. * @param result the quaternion to store the result
  68195. * @returns the updated quaternion
  68196. */
  68197. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  68198. /**
  68199. * Creates a new quaternion from the given Euler float angles (y, x, z)
  68200. * @param yaw defines the rotation around Y axis
  68201. * @param pitch defines the rotation around X axis
  68202. * @param roll defines the rotation around Z axis
  68203. * @returns the new quaternion
  68204. */
  68205. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  68206. /**
  68207. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  68208. * @param yaw defines the rotation around Y axis
  68209. * @param pitch defines the rotation around X axis
  68210. * @param roll defines the rotation around Z axis
  68211. * @param result defines the target quaternion
  68212. */
  68213. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  68214. /**
  68215. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  68216. * @param alpha defines the rotation around first axis
  68217. * @param beta defines the rotation around second axis
  68218. * @param gamma defines the rotation around third axis
  68219. * @returns the new quaternion
  68220. */
  68221. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  68222. /**
  68223. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  68224. * @param alpha defines the rotation around first axis
  68225. * @param beta defines the rotation around second axis
  68226. * @param gamma defines the rotation around third axis
  68227. * @param result defines the target quaternion
  68228. */
  68229. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  68230. /**
  68231. * 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)
  68232. * @param axis1 defines the first axis
  68233. * @param axis2 defines the second axis
  68234. * @param axis3 defines the third axis
  68235. * @returns the new quaternion
  68236. */
  68237. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  68238. /**
  68239. * 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
  68240. * @param axis1 defines the first axis
  68241. * @param axis2 defines the second axis
  68242. * @param axis3 defines the third axis
  68243. * @param ref defines the target quaternion
  68244. */
  68245. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  68246. /**
  68247. * Interpolates between two quaternions
  68248. * @param left defines first quaternion
  68249. * @param right defines second quaternion
  68250. * @param amount defines the gradient to use
  68251. * @returns the new interpolated quaternion
  68252. */
  68253. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  68254. /**
  68255. * Interpolates between two quaternions and stores it into a target quaternion
  68256. * @param left defines first quaternion
  68257. * @param right defines second quaternion
  68258. * @param amount defines the gradient to use
  68259. * @param result defines the target quaternion
  68260. */
  68261. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  68262. /**
  68263. * Interpolate between two quaternions using Hermite interpolation
  68264. * @param value1 defines first quaternion
  68265. * @param tangent1 defines the incoming tangent
  68266. * @param value2 defines second quaternion
  68267. * @param tangent2 defines the outgoing tangent
  68268. * @param amount defines the target quaternion
  68269. * @returns the new interpolated quaternion
  68270. */
  68271. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  68272. }
  68273. /**
  68274. * Class used to store matrix data (4x4)
  68275. */
  68276. export class Matrix {
  68277. private static _updateFlagSeed;
  68278. private static _identityReadOnly;
  68279. private _isIdentity;
  68280. private _isIdentityDirty;
  68281. private _isIdentity3x2;
  68282. private _isIdentity3x2Dirty;
  68283. /**
  68284. * Gets the update flag of the matrix which is an unique number for the matrix.
  68285. * It will be incremented every time the matrix data change.
  68286. * You can use it to speed the comparison between two versions of the same matrix.
  68287. */
  68288. updateFlag: number;
  68289. private readonly _m;
  68290. /**
  68291. * Gets the internal data of the matrix
  68292. */
  68293. readonly m: DeepImmutable<Float32Array>;
  68294. /** @hidden */
  68295. _markAsUpdated(): void;
  68296. /** @hidden */
  68297. private _updateIdentityStatus;
  68298. /**
  68299. * Creates an empty matrix (filled with zeros)
  68300. */
  68301. constructor();
  68302. /**
  68303. * Check if the current matrix is identity
  68304. * @returns true is the matrix is the identity matrix
  68305. */
  68306. isIdentity(): boolean;
  68307. /**
  68308. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  68309. * @returns true is the matrix is the identity matrix
  68310. */
  68311. isIdentityAs3x2(): boolean;
  68312. /**
  68313. * Gets the determinant of the matrix
  68314. * @returns the matrix determinant
  68315. */
  68316. determinant(): number;
  68317. /**
  68318. * Returns the matrix as a Float32Array
  68319. * @returns the matrix underlying array
  68320. */
  68321. toArray(): DeepImmutable<Float32Array>;
  68322. /**
  68323. * Returns the matrix as a Float32Array
  68324. * @returns the matrix underlying array.
  68325. */
  68326. asArray(): DeepImmutable<Float32Array>;
  68327. /**
  68328. * Inverts the current matrix in place
  68329. * @returns the current inverted matrix
  68330. */
  68331. invert(): Matrix;
  68332. /**
  68333. * Sets all the matrix elements to zero
  68334. * @returns the current matrix
  68335. */
  68336. reset(): Matrix;
  68337. /**
  68338. * Adds the current matrix with a second one
  68339. * @param other defines the matrix to add
  68340. * @returns a new matrix as the addition of the current matrix and the given one
  68341. */
  68342. add(other: DeepImmutable<Matrix>): Matrix;
  68343. /**
  68344. * Sets the given matrix "result" to the addition of the current matrix and the given one
  68345. * @param other defines the matrix to add
  68346. * @param result defines the target matrix
  68347. * @returns the current matrix
  68348. */
  68349. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  68350. /**
  68351. * Adds in place the given matrix to the current matrix
  68352. * @param other defines the second operand
  68353. * @returns the current updated matrix
  68354. */
  68355. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  68356. /**
  68357. * Sets the given matrix to the current inverted Matrix
  68358. * @param other defines the target matrix
  68359. * @returns the unmodified current matrix
  68360. */
  68361. invertToRef(other: Matrix): Matrix;
  68362. /**
  68363. * add a value at the specified position in the current Matrix
  68364. * @param index the index of the value within the matrix. between 0 and 15.
  68365. * @param value the value to be added
  68366. * @returns the current updated matrix
  68367. */
  68368. addAtIndex(index: number, value: number): Matrix;
  68369. /**
  68370. * mutiply the specified position in the current Matrix by a value
  68371. * @param index the index of the value within the matrix. between 0 and 15.
  68372. * @param value the value to be added
  68373. * @returns the current updated matrix
  68374. */
  68375. multiplyAtIndex(index: number, value: number): Matrix;
  68376. /**
  68377. * Inserts the translation vector (using 3 floats) in the current matrix
  68378. * @param x defines the 1st component of the translation
  68379. * @param y defines the 2nd component of the translation
  68380. * @param z defines the 3rd component of the translation
  68381. * @returns the current updated matrix
  68382. */
  68383. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  68384. /**
  68385. * Adds the translation vector (using 3 floats) in the current matrix
  68386. * @param x defines the 1st component of the translation
  68387. * @param y defines the 2nd component of the translation
  68388. * @param z defines the 3rd component of the translation
  68389. * @returns the current updated matrix
  68390. */
  68391. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  68392. /**
  68393. * Inserts the translation vector in the current matrix
  68394. * @param vector3 defines the translation to insert
  68395. * @returns the current updated matrix
  68396. */
  68397. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  68398. /**
  68399. * Gets the translation value of the current matrix
  68400. * @returns a new Vector3 as the extracted translation from the matrix
  68401. */
  68402. getTranslation(): Vector3;
  68403. /**
  68404. * Fill a Vector3 with the extracted translation from the matrix
  68405. * @param result defines the Vector3 where to store the translation
  68406. * @returns the current matrix
  68407. */
  68408. getTranslationToRef(result: Vector3): Matrix;
  68409. /**
  68410. * Remove rotation and scaling part from the matrix
  68411. * @returns the updated matrix
  68412. */
  68413. removeRotationAndScaling(): Matrix;
  68414. /**
  68415. * Multiply two matrices
  68416. * @param other defines the second operand
  68417. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  68418. */
  68419. multiply(other: DeepImmutable<Matrix>): Matrix;
  68420. /**
  68421. * Copy the current matrix from the given one
  68422. * @param other defines the source matrix
  68423. * @returns the current updated matrix
  68424. */
  68425. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  68426. /**
  68427. * Populates the given array from the starting index with the current matrix values
  68428. * @param array defines the target array
  68429. * @param offset defines the offset in the target array where to start storing values
  68430. * @returns the current matrix
  68431. */
  68432. copyToArray(array: Float32Array, offset?: number): Matrix;
  68433. /**
  68434. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  68435. * @param other defines the second operand
  68436. * @param result defines the matrix where to store the multiplication
  68437. * @returns the current matrix
  68438. */
  68439. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  68440. /**
  68441. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  68442. * @param other defines the second operand
  68443. * @param result defines the array where to store the multiplication
  68444. * @param offset defines the offset in the target array where to start storing values
  68445. * @returns the current matrix
  68446. */
  68447. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  68448. /**
  68449. * Check equality between this matrix and a second one
  68450. * @param value defines the second matrix to compare
  68451. * @returns true is the current matrix and the given one values are strictly equal
  68452. */
  68453. equals(value: DeepImmutable<Matrix>): boolean;
  68454. /**
  68455. * Clone the current matrix
  68456. * @returns a new matrix from the current matrix
  68457. */
  68458. clone(): Matrix;
  68459. /**
  68460. * Returns the name of the current matrix class
  68461. * @returns the string "Matrix"
  68462. */
  68463. getClassName(): string;
  68464. /**
  68465. * Gets the hash code of the current matrix
  68466. * @returns the hash code
  68467. */
  68468. getHashCode(): number;
  68469. /**
  68470. * Decomposes the current Matrix into a translation, rotation and scaling components
  68471. * @param scale defines the scale vector3 given as a reference to update
  68472. * @param rotation defines the rotation quaternion given as a reference to update
  68473. * @param translation defines the translation vector3 given as a reference to update
  68474. * @returns true if operation was successful
  68475. */
  68476. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  68477. /**
  68478. * Gets specific row of the matrix
  68479. * @param index defines the number of the row to get
  68480. * @returns the index-th row of the current matrix as a new Vector4
  68481. */
  68482. getRow(index: number): Nullable<Vector4>;
  68483. /**
  68484. * Sets the index-th row of the current matrix to the vector4 values
  68485. * @param index defines the number of the row to set
  68486. * @param row defines the target vector4
  68487. * @returns the updated current matrix
  68488. */
  68489. setRow(index: number, row: Vector4): Matrix;
  68490. /**
  68491. * Compute the transpose of the matrix
  68492. * @returns the new transposed matrix
  68493. */
  68494. transpose(): Matrix;
  68495. /**
  68496. * Compute the transpose of the matrix and store it in a given matrix
  68497. * @param result defines the target matrix
  68498. * @returns the current matrix
  68499. */
  68500. transposeToRef(result: Matrix): Matrix;
  68501. /**
  68502. * Sets the index-th row of the current matrix with the given 4 x float values
  68503. * @param index defines the row index
  68504. * @param x defines the x component to set
  68505. * @param y defines the y component to set
  68506. * @param z defines the z component to set
  68507. * @param w defines the w component to set
  68508. * @returns the updated current matrix
  68509. */
  68510. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  68511. /**
  68512. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  68513. * @param scale defines the scale factor
  68514. * @returns a new matrix
  68515. */
  68516. scale(scale: number): Matrix;
  68517. /**
  68518. * Scale the current matrix values by a factor to a given result matrix
  68519. * @param scale defines the scale factor
  68520. * @param result defines the matrix to store the result
  68521. * @returns the current matrix
  68522. */
  68523. scaleToRef(scale: number, result: Matrix): Matrix;
  68524. /**
  68525. * Scale the current matrix values by a factor and add the result to a given matrix
  68526. * @param scale defines the scale factor
  68527. * @param result defines the Matrix to store the result
  68528. * @returns the current matrix
  68529. */
  68530. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  68531. /**
  68532. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  68533. * @param ref matrix to store the result
  68534. */
  68535. toNormalMatrix(ref: Matrix): void;
  68536. /**
  68537. * Gets only rotation part of the current matrix
  68538. * @returns a new matrix sets to the extracted rotation matrix from the current one
  68539. */
  68540. getRotationMatrix(): Matrix;
  68541. /**
  68542. * Extracts the rotation matrix from the current one and sets it as the given "result"
  68543. * @param result defines the target matrix to store data to
  68544. * @returns the current matrix
  68545. */
  68546. getRotationMatrixToRef(result: Matrix): Matrix;
  68547. /**
  68548. * Toggles model matrix from being right handed to left handed in place and vice versa
  68549. */
  68550. toggleModelMatrixHandInPlace(): void;
  68551. /**
  68552. * Toggles projection matrix from being right handed to left handed in place and vice versa
  68553. */
  68554. toggleProjectionMatrixHandInPlace(): void;
  68555. /**
  68556. * Creates a matrix from an array
  68557. * @param array defines the source array
  68558. * @param offset defines an offset in the source array
  68559. * @returns a new Matrix set from the starting index of the given array
  68560. */
  68561. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  68562. /**
  68563. * Copy the content of an array into a given matrix
  68564. * @param array defines the source array
  68565. * @param offset defines an offset in the source array
  68566. * @param result defines the target matrix
  68567. */
  68568. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  68569. /**
  68570. * Stores an array into a matrix after having multiplied each component by a given factor
  68571. * @param array defines the source array
  68572. * @param offset defines the offset in the source array
  68573. * @param scale defines the scaling factor
  68574. * @param result defines the target matrix
  68575. */
  68576. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  68577. /**
  68578. * Gets an identity matrix that must not be updated
  68579. */
  68580. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  68581. /**
  68582. * Stores a list of values (16) inside a given matrix
  68583. * @param initialM11 defines 1st value of 1st row
  68584. * @param initialM12 defines 2nd value of 1st row
  68585. * @param initialM13 defines 3rd value of 1st row
  68586. * @param initialM14 defines 4th value of 1st row
  68587. * @param initialM21 defines 1st value of 2nd row
  68588. * @param initialM22 defines 2nd value of 2nd row
  68589. * @param initialM23 defines 3rd value of 2nd row
  68590. * @param initialM24 defines 4th value of 2nd row
  68591. * @param initialM31 defines 1st value of 3rd row
  68592. * @param initialM32 defines 2nd value of 3rd row
  68593. * @param initialM33 defines 3rd value of 3rd row
  68594. * @param initialM34 defines 4th value of 3rd row
  68595. * @param initialM41 defines 1st value of 4th row
  68596. * @param initialM42 defines 2nd value of 4th row
  68597. * @param initialM43 defines 3rd value of 4th row
  68598. * @param initialM44 defines 4th value of 4th row
  68599. * @param result defines the target matrix
  68600. */
  68601. 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;
  68602. /**
  68603. * Creates new matrix from a list of values (16)
  68604. * @param initialM11 defines 1st value of 1st row
  68605. * @param initialM12 defines 2nd value of 1st row
  68606. * @param initialM13 defines 3rd value of 1st row
  68607. * @param initialM14 defines 4th value of 1st row
  68608. * @param initialM21 defines 1st value of 2nd row
  68609. * @param initialM22 defines 2nd value of 2nd row
  68610. * @param initialM23 defines 3rd value of 2nd row
  68611. * @param initialM24 defines 4th value of 2nd row
  68612. * @param initialM31 defines 1st value of 3rd row
  68613. * @param initialM32 defines 2nd value of 3rd row
  68614. * @param initialM33 defines 3rd value of 3rd row
  68615. * @param initialM34 defines 4th value of 3rd row
  68616. * @param initialM41 defines 1st value of 4th row
  68617. * @param initialM42 defines 2nd value of 4th row
  68618. * @param initialM43 defines 3rd value of 4th row
  68619. * @param initialM44 defines 4th value of 4th row
  68620. * @returns the new matrix
  68621. */
  68622. 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;
  68623. /**
  68624. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  68625. * @param scale defines the scale vector3
  68626. * @param rotation defines the rotation quaternion
  68627. * @param translation defines the translation vector3
  68628. * @returns a new matrix
  68629. */
  68630. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  68631. /**
  68632. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  68633. * @param scale defines the scale vector3
  68634. * @param rotation defines the rotation quaternion
  68635. * @param translation defines the translation vector3
  68636. * @param result defines the target matrix
  68637. */
  68638. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  68639. /**
  68640. * Creates a new identity matrix
  68641. * @returns a new identity matrix
  68642. */
  68643. static Identity(): Matrix;
  68644. /**
  68645. * Creates a new identity matrix and stores the result in a given matrix
  68646. * @param result defines the target matrix
  68647. */
  68648. static IdentityToRef(result: Matrix): void;
  68649. /**
  68650. * Creates a new zero matrix
  68651. * @returns a new zero matrix
  68652. */
  68653. static Zero(): Matrix;
  68654. /**
  68655. * Creates a new rotation matrix for "angle" radians around the X axis
  68656. * @param angle defines the angle (in radians) to use
  68657. * @return the new matrix
  68658. */
  68659. static RotationX(angle: number): Matrix;
  68660. /**
  68661. * Creates a new matrix as the invert of a given matrix
  68662. * @param source defines the source matrix
  68663. * @returns the new matrix
  68664. */
  68665. static Invert(source: DeepImmutable<Matrix>): Matrix;
  68666. /**
  68667. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  68668. * @param angle defines the angle (in radians) to use
  68669. * @param result defines the target matrix
  68670. */
  68671. static RotationXToRef(angle: number, result: Matrix): void;
  68672. /**
  68673. * Creates a new rotation matrix for "angle" radians around the Y axis
  68674. * @param angle defines the angle (in radians) to use
  68675. * @return the new matrix
  68676. */
  68677. static RotationY(angle: number): Matrix;
  68678. /**
  68679. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  68680. * @param angle defines the angle (in radians) to use
  68681. * @param result defines the target matrix
  68682. */
  68683. static RotationYToRef(angle: number, result: Matrix): void;
  68684. /**
  68685. * Creates a new rotation matrix for "angle" radians around the Z axis
  68686. * @param angle defines the angle (in radians) to use
  68687. * @return the new matrix
  68688. */
  68689. static RotationZ(angle: number): Matrix;
  68690. /**
  68691. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  68692. * @param angle defines the angle (in radians) to use
  68693. * @param result defines the target matrix
  68694. */
  68695. static RotationZToRef(angle: number, result: Matrix): void;
  68696. /**
  68697. * Creates a new rotation matrix for "angle" radians around the given axis
  68698. * @param axis defines the axis to use
  68699. * @param angle defines the angle (in radians) to use
  68700. * @return the new matrix
  68701. */
  68702. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  68703. /**
  68704. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  68705. * @param axis defines the axis to use
  68706. * @param angle defines the angle (in radians) to use
  68707. * @param result defines the target matrix
  68708. */
  68709. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  68710. /**
  68711. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  68712. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  68713. * @param from defines the vector to align
  68714. * @param to defines the vector to align to
  68715. * @param result defines the target matrix
  68716. */
  68717. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  68718. /**
  68719. * Creates a rotation matrix
  68720. * @param yaw defines the yaw angle in radians (Y axis)
  68721. * @param pitch defines the pitch angle in radians (X axis)
  68722. * @param roll defines the roll angle in radians (X axis)
  68723. * @returns the new rotation matrix
  68724. */
  68725. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  68726. /**
  68727. * Creates a rotation matrix and stores it in a given matrix
  68728. * @param yaw defines the yaw angle in radians (Y axis)
  68729. * @param pitch defines the pitch angle in radians (X axis)
  68730. * @param roll defines the roll angle in radians (X axis)
  68731. * @param result defines the target matrix
  68732. */
  68733. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  68734. /**
  68735. * Creates a scaling matrix
  68736. * @param x defines the scale factor on X axis
  68737. * @param y defines the scale factor on Y axis
  68738. * @param z defines the scale factor on Z axis
  68739. * @returns the new matrix
  68740. */
  68741. static Scaling(x: number, y: number, z: number): Matrix;
  68742. /**
  68743. * Creates a scaling matrix and stores it in a given matrix
  68744. * @param x defines the scale factor on X axis
  68745. * @param y defines the scale factor on Y axis
  68746. * @param z defines the scale factor on Z axis
  68747. * @param result defines the target matrix
  68748. */
  68749. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  68750. /**
  68751. * Creates a translation matrix
  68752. * @param x defines the translation on X axis
  68753. * @param y defines the translation on Y axis
  68754. * @param z defines the translationon Z axis
  68755. * @returns the new matrix
  68756. */
  68757. static Translation(x: number, y: number, z: number): Matrix;
  68758. /**
  68759. * Creates a translation matrix and stores it in a given matrix
  68760. * @param x defines the translation on X axis
  68761. * @param y defines the translation on Y axis
  68762. * @param z defines the translationon Z axis
  68763. * @param result defines the target matrix
  68764. */
  68765. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  68766. /**
  68767. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  68768. * @param startValue defines the start value
  68769. * @param endValue defines the end value
  68770. * @param gradient defines the gradient factor
  68771. * @returns the new matrix
  68772. */
  68773. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  68774. /**
  68775. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  68776. * @param startValue defines the start value
  68777. * @param endValue defines the end value
  68778. * @param gradient defines the gradient factor
  68779. * @param result defines the Matrix object where to store data
  68780. */
  68781. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  68782. /**
  68783. * Builds a new matrix whose values are computed by:
  68784. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  68785. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  68786. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  68787. * @param startValue defines the first matrix
  68788. * @param endValue defines the second matrix
  68789. * @param gradient defines the gradient between the two matrices
  68790. * @returns the new matrix
  68791. */
  68792. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  68793. /**
  68794. * Update a matrix to values which are computed by:
  68795. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  68796. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  68797. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  68798. * @param startValue defines the first matrix
  68799. * @param endValue defines the second matrix
  68800. * @param gradient defines the gradient between the two matrices
  68801. * @param result defines the target matrix
  68802. */
  68803. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  68804. /**
  68805. * 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"
  68806. * This function works in left handed mode
  68807. * @param eye defines the final position of the entity
  68808. * @param target defines where the entity should look at
  68809. * @param up defines the up vector for the entity
  68810. * @returns the new matrix
  68811. */
  68812. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  68813. /**
  68814. * 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".
  68815. * This function works in left handed mode
  68816. * @param eye defines the final position of the entity
  68817. * @param target defines where the entity should look at
  68818. * @param up defines the up vector for the entity
  68819. * @param result defines the target matrix
  68820. */
  68821. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  68822. /**
  68823. * 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"
  68824. * This function works in right handed mode
  68825. * @param eye defines the final position of the entity
  68826. * @param target defines where the entity should look at
  68827. * @param up defines the up vector for the entity
  68828. * @returns the new matrix
  68829. */
  68830. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  68831. /**
  68832. * 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".
  68833. * This function works in right handed mode
  68834. * @param eye defines the final position of the entity
  68835. * @param target defines where the entity should look at
  68836. * @param up defines the up vector for the entity
  68837. * @param result defines the target matrix
  68838. */
  68839. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  68840. /**
  68841. * Create a left-handed orthographic projection matrix
  68842. * @param width defines the viewport width
  68843. * @param height defines the viewport height
  68844. * @param znear defines the near clip plane
  68845. * @param zfar defines the far clip plane
  68846. * @returns a new matrix as a left-handed orthographic projection matrix
  68847. */
  68848. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  68849. /**
  68850. * Store a left-handed orthographic projection to a given matrix
  68851. * @param width defines the viewport width
  68852. * @param height defines the viewport height
  68853. * @param znear defines the near clip plane
  68854. * @param zfar defines the far clip plane
  68855. * @param result defines the target matrix
  68856. */
  68857. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  68858. /**
  68859. * Create a left-handed orthographic projection matrix
  68860. * @param left defines the viewport left coordinate
  68861. * @param right defines the viewport right coordinate
  68862. * @param bottom defines the viewport bottom coordinate
  68863. * @param top defines the viewport top coordinate
  68864. * @param znear defines the near clip plane
  68865. * @param zfar defines the far clip plane
  68866. * @returns a new matrix as a left-handed orthographic projection matrix
  68867. */
  68868. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  68869. /**
  68870. * Stores a left-handed orthographic projection into a given matrix
  68871. * @param left defines the viewport left coordinate
  68872. * @param right defines the viewport right coordinate
  68873. * @param bottom defines the viewport bottom coordinate
  68874. * @param top defines the viewport top coordinate
  68875. * @param znear defines the near clip plane
  68876. * @param zfar defines the far clip plane
  68877. * @param result defines the target matrix
  68878. */
  68879. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  68880. /**
  68881. * Creates a right-handed orthographic projection matrix
  68882. * @param left defines the viewport left coordinate
  68883. * @param right defines the viewport right coordinate
  68884. * @param bottom defines the viewport bottom coordinate
  68885. * @param top defines the viewport top coordinate
  68886. * @param znear defines the near clip plane
  68887. * @param zfar defines the far clip plane
  68888. * @returns a new matrix as a right-handed orthographic projection matrix
  68889. */
  68890. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  68891. /**
  68892. * Stores a right-handed orthographic projection into a given matrix
  68893. * @param left defines the viewport left coordinate
  68894. * @param right defines the viewport right coordinate
  68895. * @param bottom defines the viewport bottom coordinate
  68896. * @param top defines the viewport top coordinate
  68897. * @param znear defines the near clip plane
  68898. * @param zfar defines the far clip plane
  68899. * @param result defines the target matrix
  68900. */
  68901. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  68902. /**
  68903. * Creates a left-handed perspective projection matrix
  68904. * @param width defines the viewport width
  68905. * @param height defines the viewport height
  68906. * @param znear defines the near clip plane
  68907. * @param zfar defines the far clip plane
  68908. * @returns a new matrix as a left-handed perspective projection matrix
  68909. */
  68910. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  68911. /**
  68912. * Creates a left-handed perspective projection matrix
  68913. * @param fov defines the horizontal field of view
  68914. * @param aspect defines the aspect ratio
  68915. * @param znear defines the near clip plane
  68916. * @param zfar defines the far clip plane
  68917. * @returns a new matrix as a left-handed perspective projection matrix
  68918. */
  68919. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  68920. /**
  68921. * Stores a left-handed perspective projection into a given matrix
  68922. * @param fov defines the horizontal field of view
  68923. * @param aspect defines the aspect ratio
  68924. * @param znear defines the near clip plane
  68925. * @param zfar defines the far clip plane
  68926. * @param result defines the target matrix
  68927. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  68928. */
  68929. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  68930. /**
  68931. * Creates a right-handed perspective projection matrix
  68932. * @param fov defines the horizontal field of view
  68933. * @param aspect defines the aspect ratio
  68934. * @param znear defines the near clip plane
  68935. * @param zfar defines the far clip plane
  68936. * @returns a new matrix as a right-handed perspective projection matrix
  68937. */
  68938. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  68939. /**
  68940. * Stores a right-handed perspective projection into a given matrix
  68941. * @param fov defines the horizontal field of view
  68942. * @param aspect defines the aspect ratio
  68943. * @param znear defines the near clip plane
  68944. * @param zfar defines the far clip plane
  68945. * @param result defines the target matrix
  68946. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  68947. */
  68948. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  68949. /**
  68950. * Stores a perspective projection for WebVR info a given matrix
  68951. * @param fov defines the field of view
  68952. * @param znear defines the near clip plane
  68953. * @param zfar defines the far clip plane
  68954. * @param result defines the target matrix
  68955. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  68956. */
  68957. static PerspectiveFovWebVRToRef(fov: {
  68958. upDegrees: number;
  68959. downDegrees: number;
  68960. leftDegrees: number;
  68961. rightDegrees: number;
  68962. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  68963. /**
  68964. * Computes a complete transformation matrix
  68965. * @param viewport defines the viewport to use
  68966. * @param world defines the world matrix
  68967. * @param view defines the view matrix
  68968. * @param projection defines the projection matrix
  68969. * @param zmin defines the near clip plane
  68970. * @param zmax defines the far clip plane
  68971. * @returns the transformation matrix
  68972. */
  68973. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  68974. /**
  68975. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  68976. * @param matrix defines the matrix to use
  68977. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  68978. */
  68979. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  68980. /**
  68981. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  68982. * @param matrix defines the matrix to use
  68983. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  68984. */
  68985. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  68986. /**
  68987. * Compute the transpose of a given matrix
  68988. * @param matrix defines the matrix to transpose
  68989. * @returns the new matrix
  68990. */
  68991. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  68992. /**
  68993. * Compute the transpose of a matrix and store it in a target matrix
  68994. * @param matrix defines the matrix to transpose
  68995. * @param result defines the target matrix
  68996. */
  68997. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  68998. /**
  68999. * Computes a reflection matrix from a plane
  69000. * @param plane defines the reflection plane
  69001. * @returns a new matrix
  69002. */
  69003. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  69004. /**
  69005. * Computes a reflection matrix from a plane
  69006. * @param plane defines the reflection plane
  69007. * @param result defines the target matrix
  69008. */
  69009. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  69010. /**
  69011. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  69012. * @param xaxis defines the value of the 1st axis
  69013. * @param yaxis defines the value of the 2nd axis
  69014. * @param zaxis defines the value of the 3rd axis
  69015. * @param result defines the target matrix
  69016. */
  69017. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  69018. /**
  69019. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  69020. * @param quat defines the quaternion to use
  69021. * @param result defines the target matrix
  69022. */
  69023. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  69024. }
  69025. /**
  69026. * @hidden
  69027. */
  69028. export class TmpVectors {
  69029. static Vector2: Vector2[];
  69030. static Vector3: Vector3[];
  69031. static Vector4: Vector4[];
  69032. static Quaternion: Quaternion[];
  69033. static Matrix: Matrix[];
  69034. }
  69035. }
  69036. declare module BABYLON {
  69037. /** Defines the cross module used constants to avoid circular dependncies */
  69038. export class Constants {
  69039. /** Defines that alpha blending is disabled */
  69040. static readonly ALPHA_DISABLE: number;
  69041. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  69042. static readonly ALPHA_ADD: number;
  69043. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  69044. static readonly ALPHA_COMBINE: number;
  69045. /** Defines that alpha blending to DEST - SRC * DEST */
  69046. static readonly ALPHA_SUBTRACT: number;
  69047. /** Defines that alpha blending to SRC * DEST */
  69048. static readonly ALPHA_MULTIPLY: number;
  69049. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  69050. static readonly ALPHA_MAXIMIZED: number;
  69051. /** Defines that alpha blending to SRC + DEST */
  69052. static readonly ALPHA_ONEONE: number;
  69053. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  69054. static readonly ALPHA_PREMULTIPLIED: number;
  69055. /**
  69056. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  69057. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  69058. */
  69059. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  69060. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  69061. static readonly ALPHA_INTERPOLATE: number;
  69062. /**
  69063. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  69064. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  69065. */
  69066. static readonly ALPHA_SCREENMODE: number;
  69067. /** Defines that the ressource is not delayed*/
  69068. static readonly DELAYLOADSTATE_NONE: number;
  69069. /** Defines that the ressource was successfully delay loaded */
  69070. static readonly DELAYLOADSTATE_LOADED: number;
  69071. /** Defines that the ressource is currently delay loading */
  69072. static readonly DELAYLOADSTATE_LOADING: number;
  69073. /** Defines that the ressource is delayed and has not started loading */
  69074. static readonly DELAYLOADSTATE_NOTLOADED: number;
  69075. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  69076. static readonly NEVER: number;
  69077. /** 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 */
  69078. static readonly ALWAYS: number;
  69079. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  69080. static readonly LESS: number;
  69081. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  69082. static readonly EQUAL: number;
  69083. /** 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 */
  69084. static readonly LEQUAL: number;
  69085. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  69086. static readonly GREATER: number;
  69087. /** 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 */
  69088. static readonly GEQUAL: number;
  69089. /** 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 */
  69090. static readonly NOTEQUAL: number;
  69091. /** Passed to stencilOperation to specify that stencil value must be kept */
  69092. static readonly KEEP: number;
  69093. /** Passed to stencilOperation to specify that stencil value must be replaced */
  69094. static readonly REPLACE: number;
  69095. /** Passed to stencilOperation to specify that stencil value must be incremented */
  69096. static readonly INCR: number;
  69097. /** Passed to stencilOperation to specify that stencil value must be decremented */
  69098. static readonly DECR: number;
  69099. /** Passed to stencilOperation to specify that stencil value must be inverted */
  69100. static readonly INVERT: number;
  69101. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  69102. static readonly INCR_WRAP: number;
  69103. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  69104. static readonly DECR_WRAP: number;
  69105. /** Texture is not repeating outside of 0..1 UVs */
  69106. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  69107. /** Texture is repeating outside of 0..1 UVs */
  69108. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  69109. /** Texture is repeating and mirrored */
  69110. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  69111. /** ALPHA */
  69112. static readonly TEXTUREFORMAT_ALPHA: number;
  69113. /** LUMINANCE */
  69114. static readonly TEXTUREFORMAT_LUMINANCE: number;
  69115. /** LUMINANCE_ALPHA */
  69116. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  69117. /** RGB */
  69118. static readonly TEXTUREFORMAT_RGB: number;
  69119. /** RGBA */
  69120. static readonly TEXTUREFORMAT_RGBA: number;
  69121. /** RED */
  69122. static readonly TEXTUREFORMAT_RED: number;
  69123. /** RED (2nd reference) */
  69124. static readonly TEXTUREFORMAT_R: number;
  69125. /** RG */
  69126. static readonly TEXTUREFORMAT_RG: number;
  69127. /** RED_INTEGER */
  69128. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  69129. /** RED_INTEGER (2nd reference) */
  69130. static readonly TEXTUREFORMAT_R_INTEGER: number;
  69131. /** RG_INTEGER */
  69132. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  69133. /** RGB_INTEGER */
  69134. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  69135. /** RGBA_INTEGER */
  69136. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  69137. /** UNSIGNED_BYTE */
  69138. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  69139. /** UNSIGNED_BYTE (2nd reference) */
  69140. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  69141. /** FLOAT */
  69142. static readonly TEXTURETYPE_FLOAT: number;
  69143. /** HALF_FLOAT */
  69144. static readonly TEXTURETYPE_HALF_FLOAT: number;
  69145. /** BYTE */
  69146. static readonly TEXTURETYPE_BYTE: number;
  69147. /** SHORT */
  69148. static readonly TEXTURETYPE_SHORT: number;
  69149. /** UNSIGNED_SHORT */
  69150. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  69151. /** INT */
  69152. static readonly TEXTURETYPE_INT: number;
  69153. /** UNSIGNED_INT */
  69154. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  69155. /** UNSIGNED_SHORT_4_4_4_4 */
  69156. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  69157. /** UNSIGNED_SHORT_5_5_5_1 */
  69158. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  69159. /** UNSIGNED_SHORT_5_6_5 */
  69160. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  69161. /** UNSIGNED_INT_2_10_10_10_REV */
  69162. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  69163. /** UNSIGNED_INT_24_8 */
  69164. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  69165. /** UNSIGNED_INT_10F_11F_11F_REV */
  69166. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  69167. /** UNSIGNED_INT_5_9_9_9_REV */
  69168. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  69169. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  69170. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  69171. /** nearest is mag = nearest and min = nearest and mip = linear */
  69172. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  69173. /** Bilinear is mag = linear and min = linear and mip = nearest */
  69174. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  69175. /** Trilinear is mag = linear and min = linear and mip = linear */
  69176. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  69177. /** nearest is mag = nearest and min = nearest and mip = linear */
  69178. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  69179. /** Bilinear is mag = linear and min = linear and mip = nearest */
  69180. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  69181. /** Trilinear is mag = linear and min = linear and mip = linear */
  69182. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  69183. /** mag = nearest and min = nearest and mip = nearest */
  69184. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  69185. /** mag = nearest and min = linear and mip = nearest */
  69186. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  69187. /** mag = nearest and min = linear and mip = linear */
  69188. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  69189. /** mag = nearest and min = linear and mip = none */
  69190. static readonly TEXTURE_NEAREST_LINEAR: number;
  69191. /** mag = nearest and min = nearest and mip = none */
  69192. static readonly TEXTURE_NEAREST_NEAREST: number;
  69193. /** mag = linear and min = nearest and mip = nearest */
  69194. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  69195. /** mag = linear and min = nearest and mip = linear */
  69196. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  69197. /** mag = linear and min = linear and mip = none */
  69198. static readonly TEXTURE_LINEAR_LINEAR: number;
  69199. /** mag = linear and min = nearest and mip = none */
  69200. static readonly TEXTURE_LINEAR_NEAREST: number;
  69201. /** Explicit coordinates mode */
  69202. static readonly TEXTURE_EXPLICIT_MODE: number;
  69203. /** Spherical coordinates mode */
  69204. static readonly TEXTURE_SPHERICAL_MODE: number;
  69205. /** Planar coordinates mode */
  69206. static readonly TEXTURE_PLANAR_MODE: number;
  69207. /** Cubic coordinates mode */
  69208. static readonly TEXTURE_CUBIC_MODE: number;
  69209. /** Projection coordinates mode */
  69210. static readonly TEXTURE_PROJECTION_MODE: number;
  69211. /** Skybox coordinates mode */
  69212. static readonly TEXTURE_SKYBOX_MODE: number;
  69213. /** Inverse Cubic coordinates mode */
  69214. static readonly TEXTURE_INVCUBIC_MODE: number;
  69215. /** Equirectangular coordinates mode */
  69216. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  69217. /** Equirectangular Fixed coordinates mode */
  69218. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  69219. /** Equirectangular Fixed Mirrored coordinates mode */
  69220. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  69221. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  69222. static readonly SCALEMODE_FLOOR: number;
  69223. /** Defines that texture rescaling will look for the nearest power of 2 size */
  69224. static readonly SCALEMODE_NEAREST: number;
  69225. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  69226. static readonly SCALEMODE_CEILING: number;
  69227. /**
  69228. * The dirty texture flag value
  69229. */
  69230. static readonly MATERIAL_TextureDirtyFlag: number;
  69231. /**
  69232. * The dirty light flag value
  69233. */
  69234. static readonly MATERIAL_LightDirtyFlag: number;
  69235. /**
  69236. * The dirty fresnel flag value
  69237. */
  69238. static readonly MATERIAL_FresnelDirtyFlag: number;
  69239. /**
  69240. * The dirty attribute flag value
  69241. */
  69242. static readonly MATERIAL_AttributesDirtyFlag: number;
  69243. /**
  69244. * The dirty misc flag value
  69245. */
  69246. static readonly MATERIAL_MiscDirtyFlag: number;
  69247. /**
  69248. * The all dirty flag value
  69249. */
  69250. static readonly MATERIAL_AllDirtyFlag: number;
  69251. /**
  69252. * Returns the triangle fill mode
  69253. */
  69254. static readonly MATERIAL_TriangleFillMode: number;
  69255. /**
  69256. * Returns the wireframe mode
  69257. */
  69258. static readonly MATERIAL_WireFrameFillMode: number;
  69259. /**
  69260. * Returns the point fill mode
  69261. */
  69262. static readonly MATERIAL_PointFillMode: number;
  69263. /**
  69264. * Returns the point list draw mode
  69265. */
  69266. static readonly MATERIAL_PointListDrawMode: number;
  69267. /**
  69268. * Returns the line list draw mode
  69269. */
  69270. static readonly MATERIAL_LineListDrawMode: number;
  69271. /**
  69272. * Returns the line loop draw mode
  69273. */
  69274. static readonly MATERIAL_LineLoopDrawMode: number;
  69275. /**
  69276. * Returns the line strip draw mode
  69277. */
  69278. static readonly MATERIAL_LineStripDrawMode: number;
  69279. /**
  69280. * Returns the triangle strip draw mode
  69281. */
  69282. static readonly MATERIAL_TriangleStripDrawMode: number;
  69283. /**
  69284. * Returns the triangle fan draw mode
  69285. */
  69286. static readonly MATERIAL_TriangleFanDrawMode: number;
  69287. /**
  69288. * Stores the clock-wise side orientation
  69289. */
  69290. static readonly MATERIAL_ClockWiseSideOrientation: number;
  69291. /**
  69292. * Stores the counter clock-wise side orientation
  69293. */
  69294. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  69295. /**
  69296. * Nothing
  69297. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69298. */
  69299. static readonly ACTION_NothingTrigger: number;
  69300. /**
  69301. * On pick
  69302. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69303. */
  69304. static readonly ACTION_OnPickTrigger: number;
  69305. /**
  69306. * On left pick
  69307. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69308. */
  69309. static readonly ACTION_OnLeftPickTrigger: number;
  69310. /**
  69311. * On right pick
  69312. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69313. */
  69314. static readonly ACTION_OnRightPickTrigger: number;
  69315. /**
  69316. * On center pick
  69317. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69318. */
  69319. static readonly ACTION_OnCenterPickTrigger: number;
  69320. /**
  69321. * On pick down
  69322. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69323. */
  69324. static readonly ACTION_OnPickDownTrigger: number;
  69325. /**
  69326. * On double pick
  69327. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69328. */
  69329. static readonly ACTION_OnDoublePickTrigger: number;
  69330. /**
  69331. * On pick up
  69332. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69333. */
  69334. static readonly ACTION_OnPickUpTrigger: number;
  69335. /**
  69336. * On pick out.
  69337. * This trigger will only be raised if you also declared a OnPickDown
  69338. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69339. */
  69340. static readonly ACTION_OnPickOutTrigger: number;
  69341. /**
  69342. * On long press
  69343. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69344. */
  69345. static readonly ACTION_OnLongPressTrigger: number;
  69346. /**
  69347. * On pointer over
  69348. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69349. */
  69350. static readonly ACTION_OnPointerOverTrigger: number;
  69351. /**
  69352. * On pointer out
  69353. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69354. */
  69355. static readonly ACTION_OnPointerOutTrigger: number;
  69356. /**
  69357. * On every frame
  69358. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69359. */
  69360. static readonly ACTION_OnEveryFrameTrigger: number;
  69361. /**
  69362. * On intersection enter
  69363. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69364. */
  69365. static readonly ACTION_OnIntersectionEnterTrigger: number;
  69366. /**
  69367. * On intersection exit
  69368. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69369. */
  69370. static readonly ACTION_OnIntersectionExitTrigger: number;
  69371. /**
  69372. * On key down
  69373. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69374. */
  69375. static readonly ACTION_OnKeyDownTrigger: number;
  69376. /**
  69377. * On key up
  69378. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69379. */
  69380. static readonly ACTION_OnKeyUpTrigger: number;
  69381. /**
  69382. * Billboard mode will only apply to Y axis
  69383. */
  69384. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  69385. /**
  69386. * Billboard mode will apply to all axes
  69387. */
  69388. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  69389. /**
  69390. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  69391. */
  69392. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  69393. /**
  69394. * Gets or sets base Assets URL
  69395. */
  69396. static PARTICLES_BaseAssetsUrl: string;
  69397. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  69398. * Test order :
  69399. * Is the bounding sphere outside the frustum ?
  69400. * If not, are the bounding box vertices outside the frustum ?
  69401. * It not, then the cullable object is in the frustum.
  69402. */
  69403. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  69404. /** Culling strategy : Bounding Sphere Only.
  69405. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  69406. * It's also less accurate than the standard because some not visible objects can still be selected.
  69407. * Test : is the bounding sphere outside the frustum ?
  69408. * If not, then the cullable object is in the frustum.
  69409. */
  69410. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  69411. /** Culling strategy : Optimistic Inclusion.
  69412. * This in an inclusion test first, then the standard exclusion test.
  69413. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  69414. * 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.
  69415. * Anyway, it's as accurate as the standard strategy.
  69416. * Test :
  69417. * Is the cullable object bounding sphere center in the frustum ?
  69418. * If not, apply the default culling strategy.
  69419. */
  69420. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  69421. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  69422. * This in an inclusion test first, then the bounding sphere only exclusion test.
  69423. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  69424. * 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.
  69425. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  69426. * Test :
  69427. * Is the cullable object bounding sphere center in the frustum ?
  69428. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  69429. */
  69430. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  69431. /**
  69432. * No logging while loading
  69433. */
  69434. static readonly SCENELOADER_NO_LOGGING: number;
  69435. /**
  69436. * Minimal logging while loading
  69437. */
  69438. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  69439. /**
  69440. * Summary logging while loading
  69441. */
  69442. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  69443. /**
  69444. * Detailled logging while loading
  69445. */
  69446. static readonly SCENELOADER_DETAILED_LOGGING: number;
  69447. }
  69448. }
  69449. declare module BABYLON {
  69450. /**
  69451. * Class used to store and describe the pipeline context associated with an effect
  69452. */
  69453. export interface IPipelineContext {
  69454. /**
  69455. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  69456. */
  69457. isAsync: boolean;
  69458. /**
  69459. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  69460. */
  69461. isReady: boolean;
  69462. /** @hidden */
  69463. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  69464. }
  69465. }
  69466. declare module BABYLON {
  69467. /** @hidden */
  69468. export interface IShaderProcessor {
  69469. attributeProcessor?: (attribute: string) => string;
  69470. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  69471. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  69472. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  69473. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  69474. lineProcessor?: (line: string, isFragment: boolean) => string;
  69475. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  69476. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  69477. }
  69478. }
  69479. declare module BABYLON {
  69480. /** @hidden */
  69481. export interface ProcessingOptions {
  69482. defines: string[];
  69483. indexParameters: any;
  69484. isFragment: boolean;
  69485. shouldUseHighPrecisionShader: boolean;
  69486. supportsUniformBuffers: boolean;
  69487. shadersRepository: string;
  69488. includesShadersStore: {
  69489. [key: string]: string;
  69490. };
  69491. processor?: IShaderProcessor;
  69492. version: string;
  69493. platformName: string;
  69494. lookForClosingBracketForUniformBuffer?: boolean;
  69495. }
  69496. }
  69497. declare module BABYLON {
  69498. /**
  69499. * Helper to manipulate strings
  69500. */
  69501. export class StringTools {
  69502. /**
  69503. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  69504. * @param str Source string
  69505. * @param suffix Suffix to search for in the source string
  69506. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  69507. */
  69508. static EndsWith(str: string, suffix: string): boolean;
  69509. /**
  69510. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  69511. * @param str Source string
  69512. * @param suffix Suffix to search for in the source string
  69513. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  69514. */
  69515. static StartsWith(str: string, suffix: string): boolean;
  69516. }
  69517. }
  69518. declare module BABYLON {
  69519. /** @hidden */
  69520. export class ShaderCodeNode {
  69521. line: string;
  69522. children: ShaderCodeNode[];
  69523. additionalDefineKey?: string;
  69524. additionalDefineValue?: string;
  69525. isValid(preprocessors: {
  69526. [key: string]: string;
  69527. }): boolean;
  69528. process(preprocessors: {
  69529. [key: string]: string;
  69530. }, options: ProcessingOptions): string;
  69531. }
  69532. }
  69533. declare module BABYLON {
  69534. /** @hidden */
  69535. export class ShaderCodeCursor {
  69536. private _lines;
  69537. lineIndex: number;
  69538. readonly currentLine: string;
  69539. readonly canRead: boolean;
  69540. lines: string[];
  69541. }
  69542. }
  69543. declare module BABYLON {
  69544. /** @hidden */
  69545. export class ShaderCodeConditionNode extends ShaderCodeNode {
  69546. process(preprocessors: {
  69547. [key: string]: string;
  69548. }, options: ProcessingOptions): string;
  69549. }
  69550. }
  69551. declare module BABYLON {
  69552. /** @hidden */
  69553. export class ShaderDefineExpression {
  69554. isTrue(preprocessors: {
  69555. [key: string]: string;
  69556. }): boolean;
  69557. }
  69558. }
  69559. declare module BABYLON {
  69560. /** @hidden */
  69561. export class ShaderCodeTestNode extends ShaderCodeNode {
  69562. testExpression: ShaderDefineExpression;
  69563. isValid(preprocessors: {
  69564. [key: string]: string;
  69565. }): boolean;
  69566. }
  69567. }
  69568. declare module BABYLON {
  69569. /** @hidden */
  69570. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  69571. define: string;
  69572. not: boolean;
  69573. constructor(define: string, not?: boolean);
  69574. isTrue(preprocessors: {
  69575. [key: string]: string;
  69576. }): boolean;
  69577. }
  69578. }
  69579. declare module BABYLON {
  69580. /** @hidden */
  69581. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  69582. leftOperand: ShaderDefineExpression;
  69583. rightOperand: ShaderDefineExpression;
  69584. isTrue(preprocessors: {
  69585. [key: string]: string;
  69586. }): boolean;
  69587. }
  69588. }
  69589. declare module BABYLON {
  69590. /** @hidden */
  69591. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  69592. leftOperand: ShaderDefineExpression;
  69593. rightOperand: ShaderDefineExpression;
  69594. isTrue(preprocessors: {
  69595. [key: string]: string;
  69596. }): boolean;
  69597. }
  69598. }
  69599. declare module BABYLON {
  69600. /** @hidden */
  69601. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  69602. define: string;
  69603. operand: string;
  69604. testValue: string;
  69605. constructor(define: string, operand: string, testValue: string);
  69606. isTrue(preprocessors: {
  69607. [key: string]: string;
  69608. }): boolean;
  69609. }
  69610. }
  69611. declare module BABYLON {
  69612. /**
  69613. * @ignore
  69614. * Application error to support additional information when loading a file
  69615. */
  69616. export class LoadFileError extends Error {
  69617. /** defines the optional web request */
  69618. request?: WebRequest | undefined;
  69619. private static _setPrototypeOf;
  69620. /**
  69621. * Creates a new LoadFileError
  69622. * @param message defines the message of the error
  69623. * @param request defines the optional web request
  69624. */
  69625. constructor(message: string,
  69626. /** defines the optional web request */
  69627. request?: WebRequest | undefined);
  69628. }
  69629. }
  69630. declare module BABYLON {
  69631. /**
  69632. * Class used to enable access to offline support
  69633. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  69634. */
  69635. export interface IOfflineProvider {
  69636. /**
  69637. * Gets a boolean indicating if scene must be saved in the database
  69638. */
  69639. enableSceneOffline: boolean;
  69640. /**
  69641. * Gets a boolean indicating if textures must be saved in the database
  69642. */
  69643. enableTexturesOffline: boolean;
  69644. /**
  69645. * Open the offline support and make it available
  69646. * @param successCallback defines the callback to call on success
  69647. * @param errorCallback defines the callback to call on error
  69648. */
  69649. open(successCallback: () => void, errorCallback: () => void): void;
  69650. /**
  69651. * Loads an image from the offline support
  69652. * @param url defines the url to load from
  69653. * @param image defines the target DOM image
  69654. */
  69655. loadImage(url: string, image: HTMLImageElement): void;
  69656. /**
  69657. * Loads a file from offline support
  69658. * @param url defines the URL to load from
  69659. * @param sceneLoaded defines a callback to call on success
  69660. * @param progressCallBack defines a callback to call when progress changed
  69661. * @param errorCallback defines a callback to call on error
  69662. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  69663. */
  69664. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  69665. }
  69666. }
  69667. declare module BABYLON {
  69668. /**
  69669. * Class used to help managing file picking and drag'n'drop
  69670. * File Storage
  69671. */
  69672. export class FilesInputStore {
  69673. /**
  69674. * List of files ready to be loaded
  69675. */
  69676. static FilesToLoad: {
  69677. [key: string]: File;
  69678. };
  69679. }
  69680. }
  69681. declare module BABYLON {
  69682. /**
  69683. * Class used to define a retry strategy when error happens while loading assets
  69684. */
  69685. export class RetryStrategy {
  69686. /**
  69687. * Function used to defines an exponential back off strategy
  69688. * @param maxRetries defines the maximum number of retries (3 by default)
  69689. * @param baseInterval defines the interval between retries
  69690. * @returns the strategy function to use
  69691. */
  69692. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  69693. }
  69694. }
  69695. declare module BABYLON {
  69696. /**
  69697. * @hidden
  69698. */
  69699. export class FileTools {
  69700. /**
  69701. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  69702. */
  69703. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  69704. /**
  69705. * Gets or sets the base URL to use to load assets
  69706. */
  69707. static BaseUrl: string;
  69708. /**
  69709. * Default behaviour for cors in the application.
  69710. * It can be a string if the expected behavior is identical in the entire app.
  69711. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  69712. */
  69713. static CorsBehavior: string | ((url: string | string[]) => string);
  69714. /**
  69715. * Gets or sets a function used to pre-process url before using them to load assets
  69716. */
  69717. static PreprocessUrl: (url: string) => string;
  69718. /**
  69719. * Removes unwanted characters from an url
  69720. * @param url defines the url to clean
  69721. * @returns the cleaned url
  69722. */
  69723. private static _CleanUrl;
  69724. /**
  69725. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  69726. * @param url define the url we are trying
  69727. * @param element define the dom element where to configure the cors policy
  69728. */
  69729. static SetCorsBehavior(url: string | string[], element: {
  69730. crossOrigin: string | null;
  69731. }): void;
  69732. /**
  69733. * Loads an image as an HTMLImageElement.
  69734. * @param input url string, ArrayBuffer, or Blob to load
  69735. * @param onLoad callback called when the image successfully loads
  69736. * @param onError callback called when the image fails to load
  69737. * @param offlineProvider offline provider for caching
  69738. * @returns the HTMLImageElement of the loaded image
  69739. */
  69740. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  69741. /**
  69742. * Loads a file
  69743. * @param fileToLoad defines the file to load
  69744. * @param callback defines the callback to call when data is loaded
  69745. * @param progressCallBack defines the callback to call during loading process
  69746. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  69747. * @returns a file request object
  69748. */
  69749. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  69750. /**
  69751. * Loads a file
  69752. * @param url url string, ArrayBuffer, or Blob to load
  69753. * @param onSuccess callback called when the file successfully loads
  69754. * @param onProgress callback called while file is loading (if the server supports this mode)
  69755. * @param offlineProvider defines the offline provider for caching
  69756. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  69757. * @param onError callback called when the file fails to load
  69758. * @returns a file request object
  69759. */
  69760. 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;
  69761. /**
  69762. * Checks if the loaded document was accessed via `file:`-Protocol.
  69763. * @returns boolean
  69764. */
  69765. static IsFileURL(): boolean;
  69766. }
  69767. }
  69768. declare module BABYLON {
  69769. /** @hidden */
  69770. export class ShaderProcessor {
  69771. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  69772. private static _ProcessPrecision;
  69773. private static _ExtractOperation;
  69774. private static _BuildSubExpression;
  69775. private static _BuildExpression;
  69776. private static _MoveCursorWithinIf;
  69777. private static _MoveCursor;
  69778. private static _EvaluatePreProcessors;
  69779. private static _PreparePreProcessors;
  69780. private static _ProcessShaderConversion;
  69781. private static _ProcessIncludes;
  69782. }
  69783. }
  69784. declare module BABYLON {
  69785. /**
  69786. * Class used to hold a RBG color
  69787. */
  69788. export class Color3 {
  69789. /**
  69790. * Defines the red component (between 0 and 1, default is 0)
  69791. */
  69792. r: number;
  69793. /**
  69794. * Defines the green component (between 0 and 1, default is 0)
  69795. */
  69796. g: number;
  69797. /**
  69798. * Defines the blue component (between 0 and 1, default is 0)
  69799. */
  69800. b: number;
  69801. /**
  69802. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  69803. * @param r defines the red component (between 0 and 1, default is 0)
  69804. * @param g defines the green component (between 0 and 1, default is 0)
  69805. * @param b defines the blue component (between 0 and 1, default is 0)
  69806. */
  69807. constructor(
  69808. /**
  69809. * Defines the red component (between 0 and 1, default is 0)
  69810. */
  69811. r?: number,
  69812. /**
  69813. * Defines the green component (between 0 and 1, default is 0)
  69814. */
  69815. g?: number,
  69816. /**
  69817. * Defines the blue component (between 0 and 1, default is 0)
  69818. */
  69819. b?: number);
  69820. /**
  69821. * Creates a string with the Color3 current values
  69822. * @returns the string representation of the Color3 object
  69823. */
  69824. toString(): string;
  69825. /**
  69826. * Returns the string "Color3"
  69827. * @returns "Color3"
  69828. */
  69829. getClassName(): string;
  69830. /**
  69831. * Compute the Color3 hash code
  69832. * @returns an unique number that can be used to hash Color3 objects
  69833. */
  69834. getHashCode(): number;
  69835. /**
  69836. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  69837. * @param array defines the array where to store the r,g,b components
  69838. * @param index defines an optional index in the target array to define where to start storing values
  69839. * @returns the current Color3 object
  69840. */
  69841. toArray(array: FloatArray, index?: number): Color3;
  69842. /**
  69843. * Returns a new Color4 object from the current Color3 and the given alpha
  69844. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  69845. * @returns a new Color4 object
  69846. */
  69847. toColor4(alpha?: number): Color4;
  69848. /**
  69849. * Returns a new array populated with 3 numeric elements : red, green and blue values
  69850. * @returns the new array
  69851. */
  69852. asArray(): number[];
  69853. /**
  69854. * Returns the luminance value
  69855. * @returns a float value
  69856. */
  69857. toLuminance(): number;
  69858. /**
  69859. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  69860. * @param otherColor defines the second operand
  69861. * @returns the new Color3 object
  69862. */
  69863. multiply(otherColor: DeepImmutable<Color3>): Color3;
  69864. /**
  69865. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  69866. * @param otherColor defines the second operand
  69867. * @param result defines the Color3 object where to store the result
  69868. * @returns the current Color3
  69869. */
  69870. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  69871. /**
  69872. * Determines equality between Color3 objects
  69873. * @param otherColor defines the second operand
  69874. * @returns true if the rgb values are equal to the given ones
  69875. */
  69876. equals(otherColor: DeepImmutable<Color3>): boolean;
  69877. /**
  69878. * Determines equality between the current Color3 object and a set of r,b,g values
  69879. * @param r defines the red component to check
  69880. * @param g defines the green component to check
  69881. * @param b defines the blue component to check
  69882. * @returns true if the rgb values are equal to the given ones
  69883. */
  69884. equalsFloats(r: number, g: number, b: number): boolean;
  69885. /**
  69886. * Multiplies in place each rgb value by scale
  69887. * @param scale defines the scaling factor
  69888. * @returns the updated Color3
  69889. */
  69890. scale(scale: number): Color3;
  69891. /**
  69892. * Multiplies the rgb values by scale and stores the result into "result"
  69893. * @param scale defines the scaling factor
  69894. * @param result defines the Color3 object where to store the result
  69895. * @returns the unmodified current Color3
  69896. */
  69897. scaleToRef(scale: number, result: Color3): Color3;
  69898. /**
  69899. * Scale the current Color3 values by a factor and add the result to a given Color3
  69900. * @param scale defines the scale factor
  69901. * @param result defines color to store the result into
  69902. * @returns the unmodified current Color3
  69903. */
  69904. scaleAndAddToRef(scale: number, result: Color3): Color3;
  69905. /**
  69906. * Clamps the rgb values by the min and max values and stores the result into "result"
  69907. * @param min defines minimum clamping value (default is 0)
  69908. * @param max defines maximum clamping value (default is 1)
  69909. * @param result defines color to store the result into
  69910. * @returns the original Color3
  69911. */
  69912. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  69913. /**
  69914. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  69915. * @param otherColor defines the second operand
  69916. * @returns the new Color3
  69917. */
  69918. add(otherColor: DeepImmutable<Color3>): Color3;
  69919. /**
  69920. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  69921. * @param otherColor defines the second operand
  69922. * @param result defines Color3 object to store the result into
  69923. * @returns the unmodified current Color3
  69924. */
  69925. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  69926. /**
  69927. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  69928. * @param otherColor defines the second operand
  69929. * @returns the new Color3
  69930. */
  69931. subtract(otherColor: DeepImmutable<Color3>): Color3;
  69932. /**
  69933. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  69934. * @param otherColor defines the second operand
  69935. * @param result defines Color3 object to store the result into
  69936. * @returns the unmodified current Color3
  69937. */
  69938. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  69939. /**
  69940. * Copy the current object
  69941. * @returns a new Color3 copied the current one
  69942. */
  69943. clone(): Color3;
  69944. /**
  69945. * Copies the rgb values from the source in the current Color3
  69946. * @param source defines the source Color3 object
  69947. * @returns the updated Color3 object
  69948. */
  69949. copyFrom(source: DeepImmutable<Color3>): Color3;
  69950. /**
  69951. * Updates the Color3 rgb values from the given floats
  69952. * @param r defines the red component to read from
  69953. * @param g defines the green component to read from
  69954. * @param b defines the blue component to read from
  69955. * @returns the current Color3 object
  69956. */
  69957. copyFromFloats(r: number, g: number, b: number): Color3;
  69958. /**
  69959. * Updates the Color3 rgb values from the given floats
  69960. * @param r defines the red component to read from
  69961. * @param g defines the green component to read from
  69962. * @param b defines the blue component to read from
  69963. * @returns the current Color3 object
  69964. */
  69965. set(r: number, g: number, b: number): Color3;
  69966. /**
  69967. * Compute the Color3 hexadecimal code as a string
  69968. * @returns a string containing the hexadecimal representation of the Color3 object
  69969. */
  69970. toHexString(): string;
  69971. /**
  69972. * Computes a new Color3 converted from the current one to linear space
  69973. * @returns a new Color3 object
  69974. */
  69975. toLinearSpace(): Color3;
  69976. /**
  69977. * Converts current color in rgb space to HSV values
  69978. * @returns a new color3 representing the HSV values
  69979. */
  69980. toHSV(): Color3;
  69981. /**
  69982. * Converts current color in rgb space to HSV values
  69983. * @param result defines the Color3 where to store the HSV values
  69984. */
  69985. toHSVToRef(result: Color3): void;
  69986. /**
  69987. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  69988. * @param convertedColor defines the Color3 object where to store the linear space version
  69989. * @returns the unmodified Color3
  69990. */
  69991. toLinearSpaceToRef(convertedColor: Color3): Color3;
  69992. /**
  69993. * Computes a new Color3 converted from the current one to gamma space
  69994. * @returns a new Color3 object
  69995. */
  69996. toGammaSpace(): Color3;
  69997. /**
  69998. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  69999. * @param convertedColor defines the Color3 object where to store the gamma space version
  70000. * @returns the unmodified Color3
  70001. */
  70002. toGammaSpaceToRef(convertedColor: Color3): Color3;
  70003. private static _BlackReadOnly;
  70004. /**
  70005. * Convert Hue, saturation and value to a Color3 (RGB)
  70006. * @param hue defines the hue
  70007. * @param saturation defines the saturation
  70008. * @param value defines the value
  70009. * @param result defines the Color3 where to store the RGB values
  70010. */
  70011. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  70012. /**
  70013. * Creates a new Color3 from the string containing valid hexadecimal values
  70014. * @param hex defines a string containing valid hexadecimal values
  70015. * @returns a new Color3 object
  70016. */
  70017. static FromHexString(hex: string): Color3;
  70018. /**
  70019. * Creates a new Color3 from the starting index of the given array
  70020. * @param array defines the source array
  70021. * @param offset defines an offset in the source array
  70022. * @returns a new Color3 object
  70023. */
  70024. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  70025. /**
  70026. * Creates a new Color3 from integer values (< 256)
  70027. * @param r defines the red component to read from (value between 0 and 255)
  70028. * @param g defines the green component to read from (value between 0 and 255)
  70029. * @param b defines the blue component to read from (value between 0 and 255)
  70030. * @returns a new Color3 object
  70031. */
  70032. static FromInts(r: number, g: number, b: number): Color3;
  70033. /**
  70034. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  70035. * @param start defines the start Color3 value
  70036. * @param end defines the end Color3 value
  70037. * @param amount defines the gradient value between start and end
  70038. * @returns a new Color3 object
  70039. */
  70040. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  70041. /**
  70042. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  70043. * @param left defines the start value
  70044. * @param right defines the end value
  70045. * @param amount defines the gradient factor
  70046. * @param result defines the Color3 object where to store the result
  70047. */
  70048. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  70049. /**
  70050. * Returns a Color3 value containing a red color
  70051. * @returns a new Color3 object
  70052. */
  70053. static Red(): Color3;
  70054. /**
  70055. * Returns a Color3 value containing a green color
  70056. * @returns a new Color3 object
  70057. */
  70058. static Green(): Color3;
  70059. /**
  70060. * Returns a Color3 value containing a blue color
  70061. * @returns a new Color3 object
  70062. */
  70063. static Blue(): Color3;
  70064. /**
  70065. * Returns a Color3 value containing a black color
  70066. * @returns a new Color3 object
  70067. */
  70068. static Black(): Color3;
  70069. /**
  70070. * Gets a Color3 value containing a black color that must not be updated
  70071. */
  70072. static readonly BlackReadOnly: DeepImmutable<Color3>;
  70073. /**
  70074. * Returns a Color3 value containing a white color
  70075. * @returns a new Color3 object
  70076. */
  70077. static White(): Color3;
  70078. /**
  70079. * Returns a Color3 value containing a purple color
  70080. * @returns a new Color3 object
  70081. */
  70082. static Purple(): Color3;
  70083. /**
  70084. * Returns a Color3 value containing a magenta color
  70085. * @returns a new Color3 object
  70086. */
  70087. static Magenta(): Color3;
  70088. /**
  70089. * Returns a Color3 value containing a yellow color
  70090. * @returns a new Color3 object
  70091. */
  70092. static Yellow(): Color3;
  70093. /**
  70094. * Returns a Color3 value containing a gray color
  70095. * @returns a new Color3 object
  70096. */
  70097. static Gray(): Color3;
  70098. /**
  70099. * Returns a Color3 value containing a teal color
  70100. * @returns a new Color3 object
  70101. */
  70102. static Teal(): Color3;
  70103. /**
  70104. * Returns a Color3 value containing a random color
  70105. * @returns a new Color3 object
  70106. */
  70107. static Random(): Color3;
  70108. }
  70109. /**
  70110. * Class used to hold a RBGA color
  70111. */
  70112. export class Color4 {
  70113. /**
  70114. * Defines the red component (between 0 and 1, default is 0)
  70115. */
  70116. r: number;
  70117. /**
  70118. * Defines the green component (between 0 and 1, default is 0)
  70119. */
  70120. g: number;
  70121. /**
  70122. * Defines the blue component (between 0 and 1, default is 0)
  70123. */
  70124. b: number;
  70125. /**
  70126. * Defines the alpha component (between 0 and 1, default is 1)
  70127. */
  70128. a: number;
  70129. /**
  70130. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  70131. * @param r defines the red component (between 0 and 1, default is 0)
  70132. * @param g defines the green component (between 0 and 1, default is 0)
  70133. * @param b defines the blue component (between 0 and 1, default is 0)
  70134. * @param a defines the alpha component (between 0 and 1, default is 1)
  70135. */
  70136. constructor(
  70137. /**
  70138. * Defines the red component (between 0 and 1, default is 0)
  70139. */
  70140. r?: number,
  70141. /**
  70142. * Defines the green component (between 0 and 1, default is 0)
  70143. */
  70144. g?: number,
  70145. /**
  70146. * Defines the blue component (between 0 and 1, default is 0)
  70147. */
  70148. b?: number,
  70149. /**
  70150. * Defines the alpha component (between 0 and 1, default is 1)
  70151. */
  70152. a?: number);
  70153. /**
  70154. * Adds in place the given Color4 values to the current Color4 object
  70155. * @param right defines the second operand
  70156. * @returns the current updated Color4 object
  70157. */
  70158. addInPlace(right: DeepImmutable<Color4>): Color4;
  70159. /**
  70160. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  70161. * @returns the new array
  70162. */
  70163. asArray(): number[];
  70164. /**
  70165. * Stores from the starting index in the given array the Color4 successive values
  70166. * @param array defines the array where to store the r,g,b components
  70167. * @param index defines an optional index in the target array to define where to start storing values
  70168. * @returns the current Color4 object
  70169. */
  70170. toArray(array: number[], index?: number): Color4;
  70171. /**
  70172. * Determines equality between Color4 objects
  70173. * @param otherColor defines the second operand
  70174. * @returns true if the rgba values are equal to the given ones
  70175. */
  70176. equals(otherColor: DeepImmutable<Color4>): boolean;
  70177. /**
  70178. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  70179. * @param right defines the second operand
  70180. * @returns a new Color4 object
  70181. */
  70182. add(right: DeepImmutable<Color4>): Color4;
  70183. /**
  70184. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  70185. * @param right defines the second operand
  70186. * @returns a new Color4 object
  70187. */
  70188. subtract(right: DeepImmutable<Color4>): Color4;
  70189. /**
  70190. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  70191. * @param right defines the second operand
  70192. * @param result defines the Color4 object where to store the result
  70193. * @returns the current Color4 object
  70194. */
  70195. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  70196. /**
  70197. * Creates a new Color4 with the current Color4 values multiplied by scale
  70198. * @param scale defines the scaling factor to apply
  70199. * @returns a new Color4 object
  70200. */
  70201. scale(scale: number): Color4;
  70202. /**
  70203. * Multiplies the current Color4 values by scale and stores the result in "result"
  70204. * @param scale defines the scaling factor to apply
  70205. * @param result defines the Color4 object where to store the result
  70206. * @returns the current unmodified Color4
  70207. */
  70208. scaleToRef(scale: number, result: Color4): Color4;
  70209. /**
  70210. * Scale the current Color4 values by a factor and add the result to a given Color4
  70211. * @param scale defines the scale factor
  70212. * @param result defines the Color4 object where to store the result
  70213. * @returns the unmodified current Color4
  70214. */
  70215. scaleAndAddToRef(scale: number, result: Color4): Color4;
  70216. /**
  70217. * Clamps the rgb values by the min and max values and stores the result into "result"
  70218. * @param min defines minimum clamping value (default is 0)
  70219. * @param max defines maximum clamping value (default is 1)
  70220. * @param result defines color to store the result into.
  70221. * @returns the cuurent Color4
  70222. */
  70223. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  70224. /**
  70225. * Multipy an Color4 value by another and return a new Color4 object
  70226. * @param color defines the Color4 value to multiply by
  70227. * @returns a new Color4 object
  70228. */
  70229. multiply(color: Color4): Color4;
  70230. /**
  70231. * Multipy a Color4 value by another and push the result in a reference value
  70232. * @param color defines the Color4 value to multiply by
  70233. * @param result defines the Color4 to fill the result in
  70234. * @returns the result Color4
  70235. */
  70236. multiplyToRef(color: Color4, result: Color4): Color4;
  70237. /**
  70238. * Creates a string with the Color4 current values
  70239. * @returns the string representation of the Color4 object
  70240. */
  70241. toString(): string;
  70242. /**
  70243. * Returns the string "Color4"
  70244. * @returns "Color4"
  70245. */
  70246. getClassName(): string;
  70247. /**
  70248. * Compute the Color4 hash code
  70249. * @returns an unique number that can be used to hash Color4 objects
  70250. */
  70251. getHashCode(): number;
  70252. /**
  70253. * Creates a new Color4 copied from the current one
  70254. * @returns a new Color4 object
  70255. */
  70256. clone(): Color4;
  70257. /**
  70258. * Copies the given Color4 values into the current one
  70259. * @param source defines the source Color4 object
  70260. * @returns the current updated Color4 object
  70261. */
  70262. copyFrom(source: Color4): Color4;
  70263. /**
  70264. * Copies the given float values into the current one
  70265. * @param r defines the red component to read from
  70266. * @param g defines the green component to read from
  70267. * @param b defines the blue component to read from
  70268. * @param a defines the alpha component to read from
  70269. * @returns the current updated Color4 object
  70270. */
  70271. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  70272. /**
  70273. * Copies the given float values into the current one
  70274. * @param r defines the red component to read from
  70275. * @param g defines the green component to read from
  70276. * @param b defines the blue component to read from
  70277. * @param a defines the alpha component to read from
  70278. * @returns the current updated Color4 object
  70279. */
  70280. set(r: number, g: number, b: number, a: number): Color4;
  70281. /**
  70282. * Compute the Color4 hexadecimal code as a string
  70283. * @returns a string containing the hexadecimal representation of the Color4 object
  70284. */
  70285. toHexString(): string;
  70286. /**
  70287. * Computes a new Color4 converted from the current one to linear space
  70288. * @returns a new Color4 object
  70289. */
  70290. toLinearSpace(): Color4;
  70291. /**
  70292. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  70293. * @param convertedColor defines the Color4 object where to store the linear space version
  70294. * @returns the unmodified Color4
  70295. */
  70296. toLinearSpaceToRef(convertedColor: Color4): Color4;
  70297. /**
  70298. * Computes a new Color4 converted from the current one to gamma space
  70299. * @returns a new Color4 object
  70300. */
  70301. toGammaSpace(): Color4;
  70302. /**
  70303. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  70304. * @param convertedColor defines the Color4 object where to store the gamma space version
  70305. * @returns the unmodified Color4
  70306. */
  70307. toGammaSpaceToRef(convertedColor: Color4): Color4;
  70308. /**
  70309. * Creates a new Color4 from the string containing valid hexadecimal values
  70310. * @param hex defines a string containing valid hexadecimal values
  70311. * @returns a new Color4 object
  70312. */
  70313. static FromHexString(hex: string): Color4;
  70314. /**
  70315. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  70316. * @param left defines the start value
  70317. * @param right defines the end value
  70318. * @param amount defines the gradient factor
  70319. * @returns a new Color4 object
  70320. */
  70321. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  70322. /**
  70323. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  70324. * @param left defines the start value
  70325. * @param right defines the end value
  70326. * @param amount defines the gradient factor
  70327. * @param result defines the Color4 object where to store data
  70328. */
  70329. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  70330. /**
  70331. * Creates a new Color4 from a Color3 and an alpha value
  70332. * @param color3 defines the source Color3 to read from
  70333. * @param alpha defines the alpha component (1.0 by default)
  70334. * @returns a new Color4 object
  70335. */
  70336. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  70337. /**
  70338. * Creates a new Color4 from the starting index element of the given array
  70339. * @param array defines the source array to read from
  70340. * @param offset defines the offset in the source array
  70341. * @returns a new Color4 object
  70342. */
  70343. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  70344. /**
  70345. * Creates a new Color3 from integer values (< 256)
  70346. * @param r defines the red component to read from (value between 0 and 255)
  70347. * @param g defines the green component to read from (value between 0 and 255)
  70348. * @param b defines the blue component to read from (value between 0 and 255)
  70349. * @param a defines the alpha component to read from (value between 0 and 255)
  70350. * @returns a new Color3 object
  70351. */
  70352. static FromInts(r: number, g: number, b: number, a: number): Color4;
  70353. /**
  70354. * Check the content of a given array and convert it to an array containing RGBA data
  70355. * If the original array was already containing count * 4 values then it is returned directly
  70356. * @param colors defines the array to check
  70357. * @param count defines the number of RGBA data to expect
  70358. * @returns an array containing count * 4 values (RGBA)
  70359. */
  70360. static CheckColors4(colors: number[], count: number): number[];
  70361. }
  70362. /**
  70363. * @hidden
  70364. */
  70365. export class TmpColors {
  70366. static Color3: Color3[];
  70367. static Color4: Color4[];
  70368. }
  70369. }
  70370. declare module BABYLON {
  70371. /**
  70372. * Class representing spherical harmonics coefficients to the 3rd degree
  70373. */
  70374. export class SphericalHarmonics {
  70375. /**
  70376. * Defines whether or not the harmonics have been prescaled for rendering.
  70377. */
  70378. preScaled: boolean;
  70379. /**
  70380. * The l0,0 coefficients of the spherical harmonics
  70381. */
  70382. l00: Vector3;
  70383. /**
  70384. * The l1,-1 coefficients of the spherical harmonics
  70385. */
  70386. l1_1: Vector3;
  70387. /**
  70388. * The l1,0 coefficients of the spherical harmonics
  70389. */
  70390. l10: Vector3;
  70391. /**
  70392. * The l1,1 coefficients of the spherical harmonics
  70393. */
  70394. l11: Vector3;
  70395. /**
  70396. * The l2,-2 coefficients of the spherical harmonics
  70397. */
  70398. l2_2: Vector3;
  70399. /**
  70400. * The l2,-1 coefficients of the spherical harmonics
  70401. */
  70402. l2_1: Vector3;
  70403. /**
  70404. * The l2,0 coefficients of the spherical harmonics
  70405. */
  70406. l20: Vector3;
  70407. /**
  70408. * The l2,1 coefficients of the spherical harmonics
  70409. */
  70410. l21: Vector3;
  70411. /**
  70412. * The l2,2 coefficients of the spherical harmonics
  70413. */
  70414. l22: Vector3;
  70415. /**
  70416. * Adds a light to the spherical harmonics
  70417. * @param direction the direction of the light
  70418. * @param color the color of the light
  70419. * @param deltaSolidAngle the delta solid angle of the light
  70420. */
  70421. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  70422. /**
  70423. * Scales the spherical harmonics by the given amount
  70424. * @param scale the amount to scale
  70425. */
  70426. scaleInPlace(scale: number): void;
  70427. /**
  70428. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  70429. *
  70430. * ```
  70431. * E_lm = A_l * L_lm
  70432. * ```
  70433. *
  70434. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  70435. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  70436. * the scaling factors are given in equation 9.
  70437. */
  70438. convertIncidentRadianceToIrradiance(): void;
  70439. /**
  70440. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  70441. *
  70442. * ```
  70443. * L = (1/pi) * E * rho
  70444. * ```
  70445. *
  70446. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  70447. */
  70448. convertIrradianceToLambertianRadiance(): void;
  70449. /**
  70450. * Integrates the reconstruction coefficients directly in to the SH preventing further
  70451. * required operations at run time.
  70452. *
  70453. * This is simply done by scaling back the SH with Ylm constants parameter.
  70454. * The trigonometric part being applied by the shader at run time.
  70455. */
  70456. preScaleForRendering(): void;
  70457. /**
  70458. * Constructs a spherical harmonics from an array.
  70459. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  70460. * @returns the spherical harmonics
  70461. */
  70462. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  70463. /**
  70464. * Gets the spherical harmonics from polynomial
  70465. * @param polynomial the spherical polynomial
  70466. * @returns the spherical harmonics
  70467. */
  70468. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  70469. }
  70470. /**
  70471. * Class representing spherical polynomial coefficients to the 3rd degree
  70472. */
  70473. export class SphericalPolynomial {
  70474. private _harmonics;
  70475. /**
  70476. * The spherical harmonics used to create the polynomials.
  70477. */
  70478. readonly preScaledHarmonics: SphericalHarmonics;
  70479. /**
  70480. * The x coefficients of the spherical polynomial
  70481. */
  70482. x: Vector3;
  70483. /**
  70484. * The y coefficients of the spherical polynomial
  70485. */
  70486. y: Vector3;
  70487. /**
  70488. * The z coefficients of the spherical polynomial
  70489. */
  70490. z: Vector3;
  70491. /**
  70492. * The xx coefficients of the spherical polynomial
  70493. */
  70494. xx: Vector3;
  70495. /**
  70496. * The yy coefficients of the spherical polynomial
  70497. */
  70498. yy: Vector3;
  70499. /**
  70500. * The zz coefficients of the spherical polynomial
  70501. */
  70502. zz: Vector3;
  70503. /**
  70504. * The xy coefficients of the spherical polynomial
  70505. */
  70506. xy: Vector3;
  70507. /**
  70508. * The yz coefficients of the spherical polynomial
  70509. */
  70510. yz: Vector3;
  70511. /**
  70512. * The zx coefficients of the spherical polynomial
  70513. */
  70514. zx: Vector3;
  70515. /**
  70516. * Adds an ambient color to the spherical polynomial
  70517. * @param color the color to add
  70518. */
  70519. addAmbient(color: Color3): void;
  70520. /**
  70521. * Scales the spherical polynomial by the given amount
  70522. * @param scale the amount to scale
  70523. */
  70524. scaleInPlace(scale: number): void;
  70525. /**
  70526. * Gets the spherical polynomial from harmonics
  70527. * @param harmonics the spherical harmonics
  70528. * @returns the spherical polynomial
  70529. */
  70530. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  70531. /**
  70532. * Constructs a spherical polynomial from an array.
  70533. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  70534. * @returns the spherical polynomial
  70535. */
  70536. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  70537. }
  70538. }
  70539. declare module BABYLON {
  70540. /**
  70541. * Define options used to create a render target texture
  70542. */
  70543. export class RenderTargetCreationOptions {
  70544. /**
  70545. * Specifies is mipmaps must be generated
  70546. */
  70547. generateMipMaps?: boolean;
  70548. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  70549. generateDepthBuffer?: boolean;
  70550. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  70551. generateStencilBuffer?: boolean;
  70552. /** Defines texture type (int by default) */
  70553. type?: number;
  70554. /** Defines sampling mode (trilinear by default) */
  70555. samplingMode?: number;
  70556. /** Defines format (RGBA by default) */
  70557. format?: number;
  70558. }
  70559. }
  70560. declare module BABYLON {
  70561. /**
  70562. * @hidden
  70563. **/
  70564. export class _AlphaState {
  70565. private _isAlphaBlendDirty;
  70566. private _isBlendFunctionParametersDirty;
  70567. private _isBlendEquationParametersDirty;
  70568. private _isBlendConstantsDirty;
  70569. private _alphaBlend;
  70570. private _blendFunctionParameters;
  70571. private _blendEquationParameters;
  70572. private _blendConstants;
  70573. /**
  70574. * Initializes the state.
  70575. */
  70576. constructor();
  70577. readonly isDirty: boolean;
  70578. alphaBlend: boolean;
  70579. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  70580. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  70581. setAlphaEquationParameters(rgb: number, alpha: number): void;
  70582. reset(): void;
  70583. apply(gl: WebGLRenderingContext): void;
  70584. }
  70585. }
  70586. declare module BABYLON {
  70587. /**
  70588. * @hidden
  70589. **/
  70590. export class _DepthCullingState {
  70591. private _isDepthTestDirty;
  70592. private _isDepthMaskDirty;
  70593. private _isDepthFuncDirty;
  70594. private _isCullFaceDirty;
  70595. private _isCullDirty;
  70596. private _isZOffsetDirty;
  70597. private _isFrontFaceDirty;
  70598. private _depthTest;
  70599. private _depthMask;
  70600. private _depthFunc;
  70601. private _cull;
  70602. private _cullFace;
  70603. private _zOffset;
  70604. private _frontFace;
  70605. /**
  70606. * Initializes the state.
  70607. */
  70608. constructor();
  70609. readonly isDirty: boolean;
  70610. zOffset: number;
  70611. cullFace: Nullable<number>;
  70612. cull: Nullable<boolean>;
  70613. depthFunc: Nullable<number>;
  70614. depthMask: boolean;
  70615. depthTest: boolean;
  70616. frontFace: Nullable<number>;
  70617. reset(): void;
  70618. apply(gl: WebGLRenderingContext): void;
  70619. }
  70620. }
  70621. declare module BABYLON {
  70622. /**
  70623. * @hidden
  70624. **/
  70625. export class _StencilState {
  70626. /** 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 */
  70627. static readonly ALWAYS: number;
  70628. /** Passed to stencilOperation to specify that stencil value must be kept */
  70629. static readonly KEEP: number;
  70630. /** Passed to stencilOperation to specify that stencil value must be replaced */
  70631. static readonly REPLACE: number;
  70632. private _isStencilTestDirty;
  70633. private _isStencilMaskDirty;
  70634. private _isStencilFuncDirty;
  70635. private _isStencilOpDirty;
  70636. private _stencilTest;
  70637. private _stencilMask;
  70638. private _stencilFunc;
  70639. private _stencilFuncRef;
  70640. private _stencilFuncMask;
  70641. private _stencilOpStencilFail;
  70642. private _stencilOpDepthFail;
  70643. private _stencilOpStencilDepthPass;
  70644. readonly isDirty: boolean;
  70645. stencilFunc: number;
  70646. stencilFuncRef: number;
  70647. stencilFuncMask: number;
  70648. stencilOpStencilFail: number;
  70649. stencilOpDepthFail: number;
  70650. stencilOpStencilDepthPass: number;
  70651. stencilMask: number;
  70652. stencilTest: boolean;
  70653. constructor();
  70654. reset(): void;
  70655. apply(gl: WebGLRenderingContext): void;
  70656. }
  70657. }
  70658. declare module BABYLON {
  70659. /**
  70660. * @hidden
  70661. **/
  70662. export class _TimeToken {
  70663. _startTimeQuery: Nullable<WebGLQuery>;
  70664. _endTimeQuery: Nullable<WebGLQuery>;
  70665. _timeElapsedQuery: Nullable<WebGLQuery>;
  70666. _timeElapsedQueryEnded: boolean;
  70667. }
  70668. }
  70669. declare module BABYLON {
  70670. /**
  70671. * Class used to evalaute queries containing `and` and `or` operators
  70672. */
  70673. export class AndOrNotEvaluator {
  70674. /**
  70675. * Evaluate a query
  70676. * @param query defines the query to evaluate
  70677. * @param evaluateCallback defines the callback used to filter result
  70678. * @returns true if the query matches
  70679. */
  70680. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  70681. private static _HandleParenthesisContent;
  70682. private static _SimplifyNegation;
  70683. }
  70684. }
  70685. declare module BABYLON {
  70686. /**
  70687. * Class used to store custom tags
  70688. */
  70689. export class Tags {
  70690. /**
  70691. * Adds support for tags on the given object
  70692. * @param obj defines the object to use
  70693. */
  70694. static EnableFor(obj: any): void;
  70695. /**
  70696. * Removes tags support
  70697. * @param obj defines the object to use
  70698. */
  70699. static DisableFor(obj: any): void;
  70700. /**
  70701. * Gets a boolean indicating if the given object has tags
  70702. * @param obj defines the object to use
  70703. * @returns a boolean
  70704. */
  70705. static HasTags(obj: any): boolean;
  70706. /**
  70707. * Gets the tags available on a given object
  70708. * @param obj defines the object to use
  70709. * @param asString defines if the tags must be returned as a string instead of an array of strings
  70710. * @returns the tags
  70711. */
  70712. static GetTags(obj: any, asString?: boolean): any;
  70713. /**
  70714. * Adds tags to an object
  70715. * @param obj defines the object to use
  70716. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  70717. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  70718. */
  70719. static AddTagsTo(obj: any, tagsString: string): void;
  70720. /**
  70721. * @hidden
  70722. */
  70723. static _AddTagTo(obj: any, tag: string): void;
  70724. /**
  70725. * Removes specific tags from a specific object
  70726. * @param obj defines the object to use
  70727. * @param tagsString defines the tags to remove
  70728. */
  70729. static RemoveTagsFrom(obj: any, tagsString: string): void;
  70730. /**
  70731. * @hidden
  70732. */
  70733. static _RemoveTagFrom(obj: any, tag: string): void;
  70734. /**
  70735. * Defines if tags hosted on an object match a given query
  70736. * @param obj defines the object to use
  70737. * @param tagsQuery defines the tag query
  70738. * @returns a boolean
  70739. */
  70740. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  70741. }
  70742. }
  70743. declare module BABYLON {
  70744. /**
  70745. * Defines potential orientation for back face culling
  70746. */
  70747. export enum Orientation {
  70748. /**
  70749. * Clockwise
  70750. */
  70751. CW = 0,
  70752. /** Counter clockwise */
  70753. CCW = 1
  70754. }
  70755. /** Class used to represent a Bezier curve */
  70756. export class BezierCurve {
  70757. /**
  70758. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  70759. * @param t defines the time
  70760. * @param x1 defines the left coordinate on X axis
  70761. * @param y1 defines the left coordinate on Y axis
  70762. * @param x2 defines the right coordinate on X axis
  70763. * @param y2 defines the right coordinate on Y axis
  70764. * @returns the interpolated value
  70765. */
  70766. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  70767. }
  70768. /**
  70769. * Defines angle representation
  70770. */
  70771. export class Angle {
  70772. private _radians;
  70773. /**
  70774. * Creates an Angle object of "radians" radians (float).
  70775. * @param radians the angle in radians
  70776. */
  70777. constructor(radians: number);
  70778. /**
  70779. * Get value in degrees
  70780. * @returns the Angle value in degrees (float)
  70781. */
  70782. degrees(): number;
  70783. /**
  70784. * Get value in radians
  70785. * @returns the Angle value in radians (float)
  70786. */
  70787. radians(): number;
  70788. /**
  70789. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  70790. * @param a defines first vector
  70791. * @param b defines second vector
  70792. * @returns a new Angle
  70793. */
  70794. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  70795. /**
  70796. * Gets a new Angle object from the given float in radians
  70797. * @param radians defines the angle value in radians
  70798. * @returns a new Angle
  70799. */
  70800. static FromRadians(radians: number): Angle;
  70801. /**
  70802. * Gets a new Angle object from the given float in degrees
  70803. * @param degrees defines the angle value in degrees
  70804. * @returns a new Angle
  70805. */
  70806. static FromDegrees(degrees: number): Angle;
  70807. }
  70808. /**
  70809. * This represents an arc in a 2d space.
  70810. */
  70811. export class Arc2 {
  70812. /** Defines the start point of the arc */
  70813. startPoint: Vector2;
  70814. /** Defines the mid point of the arc */
  70815. midPoint: Vector2;
  70816. /** Defines the end point of the arc */
  70817. endPoint: Vector2;
  70818. /**
  70819. * Defines the center point of the arc.
  70820. */
  70821. centerPoint: Vector2;
  70822. /**
  70823. * Defines the radius of the arc.
  70824. */
  70825. radius: number;
  70826. /**
  70827. * Defines the angle of the arc (from mid point to end point).
  70828. */
  70829. angle: Angle;
  70830. /**
  70831. * Defines the start angle of the arc (from start point to middle point).
  70832. */
  70833. startAngle: Angle;
  70834. /**
  70835. * Defines the orientation of the arc (clock wise/counter clock wise).
  70836. */
  70837. orientation: Orientation;
  70838. /**
  70839. * Creates an Arc object from the three given points : start, middle and end.
  70840. * @param startPoint Defines the start point of the arc
  70841. * @param midPoint Defines the midlle point of the arc
  70842. * @param endPoint Defines the end point of the arc
  70843. */
  70844. constructor(
  70845. /** Defines the start point of the arc */
  70846. startPoint: Vector2,
  70847. /** Defines the mid point of the arc */
  70848. midPoint: Vector2,
  70849. /** Defines the end point of the arc */
  70850. endPoint: Vector2);
  70851. }
  70852. /**
  70853. * Represents a 2D path made up of multiple 2D points
  70854. */
  70855. export class Path2 {
  70856. private _points;
  70857. private _length;
  70858. /**
  70859. * If the path start and end point are the same
  70860. */
  70861. closed: boolean;
  70862. /**
  70863. * Creates a Path2 object from the starting 2D coordinates x and y.
  70864. * @param x the starting points x value
  70865. * @param y the starting points y value
  70866. */
  70867. constructor(x: number, y: number);
  70868. /**
  70869. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  70870. * @param x the added points x value
  70871. * @param y the added points y value
  70872. * @returns the updated Path2.
  70873. */
  70874. addLineTo(x: number, y: number): Path2;
  70875. /**
  70876. * 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.
  70877. * @param midX middle point x value
  70878. * @param midY middle point y value
  70879. * @param endX end point x value
  70880. * @param endY end point y value
  70881. * @param numberOfSegments (default: 36)
  70882. * @returns the updated Path2.
  70883. */
  70884. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  70885. /**
  70886. * Closes the Path2.
  70887. * @returns the Path2.
  70888. */
  70889. close(): Path2;
  70890. /**
  70891. * Gets the sum of the distance between each sequential point in the path
  70892. * @returns the Path2 total length (float).
  70893. */
  70894. length(): number;
  70895. /**
  70896. * Gets the points which construct the path
  70897. * @returns the Path2 internal array of points.
  70898. */
  70899. getPoints(): Vector2[];
  70900. /**
  70901. * Retreives the point at the distance aways from the starting point
  70902. * @param normalizedLengthPosition the length along the path to retreive the point from
  70903. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  70904. */
  70905. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  70906. /**
  70907. * Creates a new path starting from an x and y position
  70908. * @param x starting x value
  70909. * @param y starting y value
  70910. * @returns a new Path2 starting at the coordinates (x, y).
  70911. */
  70912. static StartingAt(x: number, y: number): Path2;
  70913. }
  70914. /**
  70915. * Represents a 3D path made up of multiple 3D points
  70916. */
  70917. export class Path3D {
  70918. /**
  70919. * an array of Vector3, the curve axis of the Path3D
  70920. */
  70921. path: Vector3[];
  70922. private _curve;
  70923. private _distances;
  70924. private _tangents;
  70925. private _normals;
  70926. private _binormals;
  70927. private _raw;
  70928. /**
  70929. * new Path3D(path, normal, raw)
  70930. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  70931. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  70932. * @param path an array of Vector3, the curve axis of the Path3D
  70933. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  70934. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  70935. */
  70936. constructor(
  70937. /**
  70938. * an array of Vector3, the curve axis of the Path3D
  70939. */
  70940. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  70941. /**
  70942. * Returns the Path3D array of successive Vector3 designing its curve.
  70943. * @returns the Path3D array of successive Vector3 designing its curve.
  70944. */
  70945. getCurve(): Vector3[];
  70946. /**
  70947. * Returns an array populated with tangent vectors on each Path3D curve point.
  70948. * @returns an array populated with tangent vectors on each Path3D curve point.
  70949. */
  70950. getTangents(): Vector3[];
  70951. /**
  70952. * Returns an array populated with normal vectors on each Path3D curve point.
  70953. * @returns an array populated with normal vectors on each Path3D curve point.
  70954. */
  70955. getNormals(): Vector3[];
  70956. /**
  70957. * Returns an array populated with binormal vectors on each Path3D curve point.
  70958. * @returns an array populated with binormal vectors on each Path3D curve point.
  70959. */
  70960. getBinormals(): Vector3[];
  70961. /**
  70962. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  70963. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  70964. */
  70965. getDistances(): number[];
  70966. /**
  70967. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  70968. * @param path path which all values are copied into the curves points
  70969. * @param firstNormal which should be projected onto the curve
  70970. * @returns the same object updated.
  70971. */
  70972. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  70973. private _compute;
  70974. private _getFirstNonNullVector;
  70975. private _getLastNonNullVector;
  70976. private _normalVector;
  70977. }
  70978. /**
  70979. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  70980. * A Curve3 is designed from a series of successive Vector3.
  70981. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  70982. */
  70983. export class Curve3 {
  70984. private _points;
  70985. private _length;
  70986. /**
  70987. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  70988. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  70989. * @param v1 (Vector3) the control point
  70990. * @param v2 (Vector3) the end point of the Quadratic Bezier
  70991. * @param nbPoints (integer) the wanted number of points in the curve
  70992. * @returns the created Curve3
  70993. */
  70994. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  70995. /**
  70996. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  70997. * @param v0 (Vector3) the origin point of the Cubic Bezier
  70998. * @param v1 (Vector3) the first control point
  70999. * @param v2 (Vector3) the second control point
  71000. * @param v3 (Vector3) the end point of the Cubic Bezier
  71001. * @param nbPoints (integer) the wanted number of points in the curve
  71002. * @returns the created Curve3
  71003. */
  71004. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71005. /**
  71006. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  71007. * @param p1 (Vector3) the origin point of the Hermite Spline
  71008. * @param t1 (Vector3) the tangent vector at the origin point
  71009. * @param p2 (Vector3) the end point of the Hermite Spline
  71010. * @param t2 (Vector3) the tangent vector at the end point
  71011. * @param nbPoints (integer) the wanted number of points in the curve
  71012. * @returns the created Curve3
  71013. */
  71014. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71015. /**
  71016. * Returns a Curve3 object along a CatmullRom Spline curve :
  71017. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  71018. * @param nbPoints (integer) the wanted number of points between each curve control points
  71019. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  71020. * @returns the created Curve3
  71021. */
  71022. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  71023. /**
  71024. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  71025. * A Curve3 is designed from a series of successive Vector3.
  71026. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  71027. * @param points points which make up the curve
  71028. */
  71029. constructor(points: Vector3[]);
  71030. /**
  71031. * @returns the Curve3 stored array of successive Vector3
  71032. */
  71033. getPoints(): Vector3[];
  71034. /**
  71035. * @returns the computed length (float) of the curve.
  71036. */
  71037. length(): number;
  71038. /**
  71039. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  71040. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  71041. * curveA and curveB keep unchanged.
  71042. * @param curve the curve to continue from this curve
  71043. * @returns the newly constructed curve
  71044. */
  71045. continue(curve: DeepImmutable<Curve3>): Curve3;
  71046. private _computeLength;
  71047. }
  71048. }
  71049. declare module BABYLON {
  71050. /**
  71051. * This represents the main contract an easing function should follow.
  71052. * Easing functions are used throughout the animation system.
  71053. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71054. */
  71055. export interface IEasingFunction {
  71056. /**
  71057. * Given an input gradient between 0 and 1, this returns the corrseponding value
  71058. * of the easing function.
  71059. * The link below provides some of the most common examples of easing functions.
  71060. * @see https://easings.net/
  71061. * @param gradient Defines the value between 0 and 1 we want the easing value for
  71062. * @returns the corresponding value on the curve defined by the easing function
  71063. */
  71064. ease(gradient: number): number;
  71065. }
  71066. /**
  71067. * Base class used for every default easing function.
  71068. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71069. */
  71070. export class EasingFunction implements IEasingFunction {
  71071. /**
  71072. * Interpolation follows the mathematical formula associated with the easing function.
  71073. */
  71074. static readonly EASINGMODE_EASEIN: number;
  71075. /**
  71076. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  71077. */
  71078. static readonly EASINGMODE_EASEOUT: number;
  71079. /**
  71080. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  71081. */
  71082. static readonly EASINGMODE_EASEINOUT: number;
  71083. private _easingMode;
  71084. /**
  71085. * Sets the easing mode of the current function.
  71086. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  71087. */
  71088. setEasingMode(easingMode: number): void;
  71089. /**
  71090. * Gets the current easing mode.
  71091. * @returns the easing mode
  71092. */
  71093. getEasingMode(): number;
  71094. /**
  71095. * @hidden
  71096. */
  71097. easeInCore(gradient: number): number;
  71098. /**
  71099. * Given an input gradient between 0 and 1, this returns the corresponding value
  71100. * of the easing function.
  71101. * @param gradient Defines the value between 0 and 1 we want the easing value for
  71102. * @returns the corresponding value on the curve defined by the easing function
  71103. */
  71104. ease(gradient: number): number;
  71105. }
  71106. /**
  71107. * Easing function with a circle shape (see link below).
  71108. * @see https://easings.net/#easeInCirc
  71109. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71110. */
  71111. export class CircleEase extends EasingFunction implements IEasingFunction {
  71112. /** @hidden */
  71113. easeInCore(gradient: number): number;
  71114. }
  71115. /**
  71116. * Easing function with a ease back shape (see link below).
  71117. * @see https://easings.net/#easeInBack
  71118. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71119. */
  71120. export class BackEase extends EasingFunction implements IEasingFunction {
  71121. /** Defines the amplitude of the function */
  71122. amplitude: number;
  71123. /**
  71124. * Instantiates a back ease easing
  71125. * @see https://easings.net/#easeInBack
  71126. * @param amplitude Defines the amplitude of the function
  71127. */
  71128. constructor(
  71129. /** Defines the amplitude of the function */
  71130. amplitude?: number);
  71131. /** @hidden */
  71132. easeInCore(gradient: number): number;
  71133. }
  71134. /**
  71135. * Easing function with a bouncing shape (see link below).
  71136. * @see https://easings.net/#easeInBounce
  71137. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71138. */
  71139. export class BounceEase extends EasingFunction implements IEasingFunction {
  71140. /** Defines the number of bounces */
  71141. bounces: number;
  71142. /** Defines the amplitude of the bounce */
  71143. bounciness: number;
  71144. /**
  71145. * Instantiates a bounce easing
  71146. * @see https://easings.net/#easeInBounce
  71147. * @param bounces Defines the number of bounces
  71148. * @param bounciness Defines the amplitude of the bounce
  71149. */
  71150. constructor(
  71151. /** Defines the number of bounces */
  71152. bounces?: number,
  71153. /** Defines the amplitude of the bounce */
  71154. bounciness?: number);
  71155. /** @hidden */
  71156. easeInCore(gradient: number): number;
  71157. }
  71158. /**
  71159. * Easing function with a power of 3 shape (see link below).
  71160. * @see https://easings.net/#easeInCubic
  71161. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71162. */
  71163. export class CubicEase extends EasingFunction implements IEasingFunction {
  71164. /** @hidden */
  71165. easeInCore(gradient: number): number;
  71166. }
  71167. /**
  71168. * Easing function with an elastic shape (see link below).
  71169. * @see https://easings.net/#easeInElastic
  71170. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71171. */
  71172. export class ElasticEase extends EasingFunction implements IEasingFunction {
  71173. /** Defines the number of oscillations*/
  71174. oscillations: number;
  71175. /** Defines the amplitude of the oscillations*/
  71176. springiness: number;
  71177. /**
  71178. * Instantiates an elastic easing function
  71179. * @see https://easings.net/#easeInElastic
  71180. * @param oscillations Defines the number of oscillations
  71181. * @param springiness Defines the amplitude of the oscillations
  71182. */
  71183. constructor(
  71184. /** Defines the number of oscillations*/
  71185. oscillations?: number,
  71186. /** Defines the amplitude of the oscillations*/
  71187. springiness?: number);
  71188. /** @hidden */
  71189. easeInCore(gradient: number): number;
  71190. }
  71191. /**
  71192. * Easing function with an exponential shape (see link below).
  71193. * @see https://easings.net/#easeInExpo
  71194. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71195. */
  71196. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  71197. /** Defines the exponent of the function */
  71198. exponent: number;
  71199. /**
  71200. * Instantiates an exponential easing function
  71201. * @see https://easings.net/#easeInExpo
  71202. * @param exponent Defines the exponent of the function
  71203. */
  71204. constructor(
  71205. /** Defines the exponent of the function */
  71206. exponent?: number);
  71207. /** @hidden */
  71208. easeInCore(gradient: number): number;
  71209. }
  71210. /**
  71211. * Easing function with a power shape (see link below).
  71212. * @see https://easings.net/#easeInQuad
  71213. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71214. */
  71215. export class PowerEase extends EasingFunction implements IEasingFunction {
  71216. /** Defines the power of the function */
  71217. power: number;
  71218. /**
  71219. * Instantiates an power base easing function
  71220. * @see https://easings.net/#easeInQuad
  71221. * @param power Defines the power of the function
  71222. */
  71223. constructor(
  71224. /** Defines the power of the function */
  71225. power?: number);
  71226. /** @hidden */
  71227. easeInCore(gradient: number): number;
  71228. }
  71229. /**
  71230. * Easing function with a power of 2 shape (see link below).
  71231. * @see https://easings.net/#easeInQuad
  71232. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71233. */
  71234. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  71235. /** @hidden */
  71236. easeInCore(gradient: number): number;
  71237. }
  71238. /**
  71239. * Easing function with a power of 4 shape (see link below).
  71240. * @see https://easings.net/#easeInQuart
  71241. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71242. */
  71243. export class QuarticEase extends EasingFunction implements IEasingFunction {
  71244. /** @hidden */
  71245. easeInCore(gradient: number): number;
  71246. }
  71247. /**
  71248. * Easing function with a power of 5 shape (see link below).
  71249. * @see https://easings.net/#easeInQuint
  71250. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71251. */
  71252. export class QuinticEase extends EasingFunction implements IEasingFunction {
  71253. /** @hidden */
  71254. easeInCore(gradient: number): number;
  71255. }
  71256. /**
  71257. * Easing function with a sin shape (see link below).
  71258. * @see https://easings.net/#easeInSine
  71259. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71260. */
  71261. export class SineEase extends EasingFunction implements IEasingFunction {
  71262. /** @hidden */
  71263. easeInCore(gradient: number): number;
  71264. }
  71265. /**
  71266. * Easing function with a bezier shape (see link below).
  71267. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  71268. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71269. */
  71270. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  71271. /** Defines the x component of the start tangent in the bezier curve */
  71272. x1: number;
  71273. /** Defines the y component of the start tangent in the bezier curve */
  71274. y1: number;
  71275. /** Defines the x component of the end tangent in the bezier curve */
  71276. x2: number;
  71277. /** Defines the y component of the end tangent in the bezier curve */
  71278. y2: number;
  71279. /**
  71280. * Instantiates a bezier function
  71281. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  71282. * @param x1 Defines the x component of the start tangent in the bezier curve
  71283. * @param y1 Defines the y component of the start tangent in the bezier curve
  71284. * @param x2 Defines the x component of the end tangent in the bezier curve
  71285. * @param y2 Defines the y component of the end tangent in the bezier curve
  71286. */
  71287. constructor(
  71288. /** Defines the x component of the start tangent in the bezier curve */
  71289. x1?: number,
  71290. /** Defines the y component of the start tangent in the bezier curve */
  71291. y1?: number,
  71292. /** Defines the x component of the end tangent in the bezier curve */
  71293. x2?: number,
  71294. /** Defines the y component of the end tangent in the bezier curve */
  71295. y2?: number);
  71296. /** @hidden */
  71297. easeInCore(gradient: number): number;
  71298. }
  71299. }
  71300. declare module BABYLON {
  71301. /**
  71302. * Defines an interface which represents an animation key frame
  71303. */
  71304. export interface IAnimationKey {
  71305. /**
  71306. * Frame of the key frame
  71307. */
  71308. frame: number;
  71309. /**
  71310. * Value at the specifies key frame
  71311. */
  71312. value: any;
  71313. /**
  71314. * The input tangent for the cubic hermite spline
  71315. */
  71316. inTangent?: any;
  71317. /**
  71318. * The output tangent for the cubic hermite spline
  71319. */
  71320. outTangent?: any;
  71321. /**
  71322. * The animation interpolation type
  71323. */
  71324. interpolation?: AnimationKeyInterpolation;
  71325. }
  71326. /**
  71327. * Enum for the animation key frame interpolation type
  71328. */
  71329. export enum AnimationKeyInterpolation {
  71330. /**
  71331. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  71332. */
  71333. STEP = 1
  71334. }
  71335. }
  71336. declare module BABYLON {
  71337. /**
  71338. * Represents the range of an animation
  71339. */
  71340. export class AnimationRange {
  71341. /**The name of the animation range**/
  71342. name: string;
  71343. /**The starting frame of the animation */
  71344. from: number;
  71345. /**The ending frame of the animation*/
  71346. to: number;
  71347. /**
  71348. * Initializes the range of an animation
  71349. * @param name The name of the animation range
  71350. * @param from The starting frame of the animation
  71351. * @param to The ending frame of the animation
  71352. */
  71353. constructor(
  71354. /**The name of the animation range**/
  71355. name: string,
  71356. /**The starting frame of the animation */
  71357. from: number,
  71358. /**The ending frame of the animation*/
  71359. to: number);
  71360. /**
  71361. * Makes a copy of the animation range
  71362. * @returns A copy of the animation range
  71363. */
  71364. clone(): AnimationRange;
  71365. }
  71366. }
  71367. declare module BABYLON {
  71368. /**
  71369. * Composed of a frame, and an action function
  71370. */
  71371. export class AnimationEvent {
  71372. /** The frame for which the event is triggered **/
  71373. frame: number;
  71374. /** The event to perform when triggered **/
  71375. action: (currentFrame: number) => void;
  71376. /** Specifies if the event should be triggered only once**/
  71377. onlyOnce?: boolean | undefined;
  71378. /**
  71379. * Specifies if the animation event is done
  71380. */
  71381. isDone: boolean;
  71382. /**
  71383. * Initializes the animation event
  71384. * @param frame The frame for which the event is triggered
  71385. * @param action The event to perform when triggered
  71386. * @param onlyOnce Specifies if the event should be triggered only once
  71387. */
  71388. constructor(
  71389. /** The frame for which the event is triggered **/
  71390. frame: number,
  71391. /** The event to perform when triggered **/
  71392. action: (currentFrame: number) => void,
  71393. /** Specifies if the event should be triggered only once**/
  71394. onlyOnce?: boolean | undefined);
  71395. /** @hidden */
  71396. _clone(): AnimationEvent;
  71397. }
  71398. }
  71399. declare module BABYLON {
  71400. /**
  71401. * Interface used to define a behavior
  71402. */
  71403. export interface Behavior<T> {
  71404. /** gets or sets behavior's name */
  71405. name: string;
  71406. /**
  71407. * Function called when the behavior needs to be initialized (after attaching it to a target)
  71408. */
  71409. init(): void;
  71410. /**
  71411. * Called when the behavior is attached to a target
  71412. * @param target defines the target where the behavior is attached to
  71413. */
  71414. attach(target: T): void;
  71415. /**
  71416. * Called when the behavior is detached from its target
  71417. */
  71418. detach(): void;
  71419. }
  71420. /**
  71421. * Interface implemented by classes supporting behaviors
  71422. */
  71423. export interface IBehaviorAware<T> {
  71424. /**
  71425. * Attach a behavior
  71426. * @param behavior defines the behavior to attach
  71427. * @returns the current host
  71428. */
  71429. addBehavior(behavior: Behavior<T>): T;
  71430. /**
  71431. * Remove a behavior from the current object
  71432. * @param behavior defines the behavior to detach
  71433. * @returns the current host
  71434. */
  71435. removeBehavior(behavior: Behavior<T>): T;
  71436. /**
  71437. * Gets a behavior using its name to search
  71438. * @param name defines the name to search
  71439. * @returns the behavior or null if not found
  71440. */
  71441. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  71442. }
  71443. }
  71444. declare module BABYLON {
  71445. /**
  71446. * Defines an array and its length.
  71447. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  71448. */
  71449. export interface ISmartArrayLike<T> {
  71450. /**
  71451. * The data of the array.
  71452. */
  71453. data: Array<T>;
  71454. /**
  71455. * The active length of the array.
  71456. */
  71457. length: number;
  71458. }
  71459. /**
  71460. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  71461. */
  71462. export class SmartArray<T> implements ISmartArrayLike<T> {
  71463. /**
  71464. * The full set of data from the array.
  71465. */
  71466. data: Array<T>;
  71467. /**
  71468. * The active length of the array.
  71469. */
  71470. length: number;
  71471. protected _id: number;
  71472. /**
  71473. * Instantiates a Smart Array.
  71474. * @param capacity defines the default capacity of the array.
  71475. */
  71476. constructor(capacity: number);
  71477. /**
  71478. * Pushes a value at the end of the active data.
  71479. * @param value defines the object to push in the array.
  71480. */
  71481. push(value: T): void;
  71482. /**
  71483. * Iterates over the active data and apply the lambda to them.
  71484. * @param func defines the action to apply on each value.
  71485. */
  71486. forEach(func: (content: T) => void): void;
  71487. /**
  71488. * Sorts the full sets of data.
  71489. * @param compareFn defines the comparison function to apply.
  71490. */
  71491. sort(compareFn: (a: T, b: T) => number): void;
  71492. /**
  71493. * Resets the active data to an empty array.
  71494. */
  71495. reset(): void;
  71496. /**
  71497. * Releases all the data from the array as well as the array.
  71498. */
  71499. dispose(): void;
  71500. /**
  71501. * Concats the active data with a given array.
  71502. * @param array defines the data to concatenate with.
  71503. */
  71504. concat(array: any): void;
  71505. /**
  71506. * Returns the position of a value in the active data.
  71507. * @param value defines the value to find the index for
  71508. * @returns the index if found in the active data otherwise -1
  71509. */
  71510. indexOf(value: T): number;
  71511. /**
  71512. * Returns whether an element is part of the active data.
  71513. * @param value defines the value to look for
  71514. * @returns true if found in the active data otherwise false
  71515. */
  71516. contains(value: T): boolean;
  71517. private static _GlobalId;
  71518. }
  71519. /**
  71520. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  71521. * The data in this array can only be present once
  71522. */
  71523. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  71524. private _duplicateId;
  71525. /**
  71526. * Pushes a value at the end of the active data.
  71527. * THIS DOES NOT PREVENT DUPPLICATE DATA
  71528. * @param value defines the object to push in the array.
  71529. */
  71530. push(value: T): void;
  71531. /**
  71532. * Pushes a value at the end of the active data.
  71533. * If the data is already present, it won t be added again
  71534. * @param value defines the object to push in the array.
  71535. * @returns true if added false if it was already present
  71536. */
  71537. pushNoDuplicate(value: T): boolean;
  71538. /**
  71539. * Resets the active data to an empty array.
  71540. */
  71541. reset(): void;
  71542. /**
  71543. * Concats the active data with a given array.
  71544. * This ensures no dupplicate will be present in the result.
  71545. * @param array defines the data to concatenate with.
  71546. */
  71547. concatWithNoDuplicate(array: any): void;
  71548. }
  71549. }
  71550. declare module BABYLON {
  71551. /**
  71552. * @ignore
  71553. * This is a list of all the different input types that are available in the application.
  71554. * Fo instance: ArcRotateCameraGamepadInput...
  71555. */
  71556. export var CameraInputTypes: {};
  71557. /**
  71558. * This is the contract to implement in order to create a new input class.
  71559. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  71560. */
  71561. export interface ICameraInput<TCamera extends Camera> {
  71562. /**
  71563. * Defines the camera the input is attached to.
  71564. */
  71565. camera: Nullable<TCamera>;
  71566. /**
  71567. * Gets the class name of the current intput.
  71568. * @returns the class name
  71569. */
  71570. getClassName(): string;
  71571. /**
  71572. * Get the friendly name associated with the input class.
  71573. * @returns the input friendly name
  71574. */
  71575. getSimpleName(): string;
  71576. /**
  71577. * Attach the input controls to a specific dom element to get the input from.
  71578. * @param element Defines the element the controls should be listened from
  71579. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71580. */
  71581. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71582. /**
  71583. * Detach the current controls from the specified dom element.
  71584. * @param element Defines the element to stop listening the inputs from
  71585. */
  71586. detachControl(element: Nullable<HTMLElement>): void;
  71587. /**
  71588. * Update the current camera state depending on the inputs that have been used this frame.
  71589. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  71590. */
  71591. checkInputs?: () => void;
  71592. }
  71593. /**
  71594. * Represents a map of input types to input instance or input index to input instance.
  71595. */
  71596. export interface CameraInputsMap<TCamera extends Camera> {
  71597. /**
  71598. * Accessor to the input by input type.
  71599. */
  71600. [name: string]: ICameraInput<TCamera>;
  71601. /**
  71602. * Accessor to the input by input index.
  71603. */
  71604. [idx: number]: ICameraInput<TCamera>;
  71605. }
  71606. /**
  71607. * This represents the input manager used within a camera.
  71608. * It helps dealing with all the different kind of input attached to a camera.
  71609. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71610. */
  71611. export class CameraInputsManager<TCamera extends Camera> {
  71612. /**
  71613. * Defines the list of inputs attahed to the camera.
  71614. */
  71615. attached: CameraInputsMap<TCamera>;
  71616. /**
  71617. * Defines the dom element the camera is collecting inputs from.
  71618. * This is null if the controls have not been attached.
  71619. */
  71620. attachedElement: Nullable<HTMLElement>;
  71621. /**
  71622. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71623. */
  71624. noPreventDefault: boolean;
  71625. /**
  71626. * Defined the camera the input manager belongs to.
  71627. */
  71628. camera: TCamera;
  71629. /**
  71630. * Update the current camera state depending on the inputs that have been used this frame.
  71631. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  71632. */
  71633. checkInputs: () => void;
  71634. /**
  71635. * Instantiate a new Camera Input Manager.
  71636. * @param camera Defines the camera the input manager blongs to
  71637. */
  71638. constructor(camera: TCamera);
  71639. /**
  71640. * Add an input method to a camera
  71641. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71642. * @param input camera input method
  71643. */
  71644. add(input: ICameraInput<TCamera>): void;
  71645. /**
  71646. * Remove a specific input method from a camera
  71647. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  71648. * @param inputToRemove camera input method
  71649. */
  71650. remove(inputToRemove: ICameraInput<TCamera>): void;
  71651. /**
  71652. * Remove a specific input type from a camera
  71653. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  71654. * @param inputType the type of the input to remove
  71655. */
  71656. removeByType(inputType: string): void;
  71657. private _addCheckInputs;
  71658. /**
  71659. * Attach the input controls to the currently attached dom element to listen the events from.
  71660. * @param input Defines the input to attach
  71661. */
  71662. attachInput(input: ICameraInput<TCamera>): void;
  71663. /**
  71664. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  71665. * @param element Defines the dom element to collect the events from
  71666. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71667. */
  71668. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  71669. /**
  71670. * Detach the current manager inputs controls from a specific dom element.
  71671. * @param element Defines the dom element to collect the events from
  71672. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  71673. */
  71674. detachElement(element: HTMLElement, disconnect?: boolean): void;
  71675. /**
  71676. * Rebuild the dynamic inputCheck function from the current list of
  71677. * defined inputs in the manager.
  71678. */
  71679. rebuildInputCheck(): void;
  71680. /**
  71681. * Remove all attached input methods from a camera
  71682. */
  71683. clear(): void;
  71684. /**
  71685. * Serialize the current input manager attached to a camera.
  71686. * This ensures than once parsed,
  71687. * the input associated to the camera will be identical to the current ones
  71688. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  71689. */
  71690. serialize(serializedCamera: any): void;
  71691. /**
  71692. * Parses an input manager serialized JSON to restore the previous list of inputs
  71693. * and states associated to a camera.
  71694. * @param parsedCamera Defines the JSON to parse
  71695. */
  71696. parse(parsedCamera: any): void;
  71697. }
  71698. }
  71699. declare module BABYLON {
  71700. /**
  71701. * @hidden
  71702. */
  71703. export class IntersectionInfo {
  71704. bu: Nullable<number>;
  71705. bv: Nullable<number>;
  71706. distance: number;
  71707. faceId: number;
  71708. subMeshId: number;
  71709. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  71710. }
  71711. }
  71712. declare module BABYLON {
  71713. /**
  71714. * Represens a plane by the equation ax + by + cz + d = 0
  71715. */
  71716. export class Plane {
  71717. private static _TmpMatrix;
  71718. /**
  71719. * Normal of the plane (a,b,c)
  71720. */
  71721. normal: Vector3;
  71722. /**
  71723. * d component of the plane
  71724. */
  71725. d: number;
  71726. /**
  71727. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  71728. * @param a a component of the plane
  71729. * @param b b component of the plane
  71730. * @param c c component of the plane
  71731. * @param d d component of the plane
  71732. */
  71733. constructor(a: number, b: number, c: number, d: number);
  71734. /**
  71735. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  71736. */
  71737. asArray(): number[];
  71738. /**
  71739. * @returns a new plane copied from the current Plane.
  71740. */
  71741. clone(): Plane;
  71742. /**
  71743. * @returns the string "Plane".
  71744. */
  71745. getClassName(): string;
  71746. /**
  71747. * @returns the Plane hash code.
  71748. */
  71749. getHashCode(): number;
  71750. /**
  71751. * Normalize the current Plane in place.
  71752. * @returns the updated Plane.
  71753. */
  71754. normalize(): Plane;
  71755. /**
  71756. * Applies a transformation the plane and returns the result
  71757. * @param transformation the transformation matrix to be applied to the plane
  71758. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  71759. */
  71760. transform(transformation: DeepImmutable<Matrix>): Plane;
  71761. /**
  71762. * Calcualtte the dot product between the point and the plane normal
  71763. * @param point point to calculate the dot product with
  71764. * @returns the dot product (float) of the point coordinates and the plane normal.
  71765. */
  71766. dotCoordinate(point: DeepImmutable<Vector3>): number;
  71767. /**
  71768. * Updates the current Plane from the plane defined by the three given points.
  71769. * @param point1 one of the points used to contruct the plane
  71770. * @param point2 one of the points used to contruct the plane
  71771. * @param point3 one of the points used to contruct the plane
  71772. * @returns the updated Plane.
  71773. */
  71774. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  71775. /**
  71776. * Checks if the plane is facing a given direction
  71777. * @param direction the direction to check if the plane is facing
  71778. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  71779. * @returns True is the vector "direction" is the same side than the plane normal.
  71780. */
  71781. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  71782. /**
  71783. * Calculates the distance to a point
  71784. * @param point point to calculate distance to
  71785. * @returns the signed distance (float) from the given point to the Plane.
  71786. */
  71787. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  71788. /**
  71789. * Creates a plane from an array
  71790. * @param array the array to create a plane from
  71791. * @returns a new Plane from the given array.
  71792. */
  71793. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  71794. /**
  71795. * Creates a plane from three points
  71796. * @param point1 point used to create the plane
  71797. * @param point2 point used to create the plane
  71798. * @param point3 point used to create the plane
  71799. * @returns a new Plane defined by the three given points.
  71800. */
  71801. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  71802. /**
  71803. * Creates a plane from an origin point and a normal
  71804. * @param origin origin of the plane to be constructed
  71805. * @param normal normal of the plane to be constructed
  71806. * @returns a new Plane the normal vector to this plane at the given origin point.
  71807. * Note : the vector "normal" is updated because normalized.
  71808. */
  71809. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  71810. /**
  71811. * Calculates the distance from a plane and a point
  71812. * @param origin origin of the plane to be constructed
  71813. * @param normal normal of the plane to be constructed
  71814. * @param point point to calculate distance to
  71815. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  71816. */
  71817. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  71818. }
  71819. }
  71820. declare module BABYLON {
  71821. /**
  71822. * Class used to store bounding sphere information
  71823. */
  71824. export class BoundingSphere {
  71825. /**
  71826. * Gets the center of the bounding sphere in local space
  71827. */
  71828. readonly center: Vector3;
  71829. /**
  71830. * Radius of the bounding sphere in local space
  71831. */
  71832. radius: number;
  71833. /**
  71834. * Gets the center of the bounding sphere in world space
  71835. */
  71836. readonly centerWorld: Vector3;
  71837. /**
  71838. * Radius of the bounding sphere in world space
  71839. */
  71840. radiusWorld: number;
  71841. /**
  71842. * Gets the minimum vector in local space
  71843. */
  71844. readonly minimum: Vector3;
  71845. /**
  71846. * Gets the maximum vector in local space
  71847. */
  71848. readonly maximum: Vector3;
  71849. private _worldMatrix;
  71850. private static readonly TmpVector3;
  71851. /**
  71852. * Creates a new bounding sphere
  71853. * @param min defines the minimum vector (in local space)
  71854. * @param max defines the maximum vector (in local space)
  71855. * @param worldMatrix defines the new world matrix
  71856. */
  71857. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  71858. /**
  71859. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  71860. * @param min defines the new minimum vector (in local space)
  71861. * @param max defines the new maximum vector (in local space)
  71862. * @param worldMatrix defines the new world matrix
  71863. */
  71864. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  71865. /**
  71866. * Scale the current bounding sphere by applying a scale factor
  71867. * @param factor defines the scale factor to apply
  71868. * @returns the current bounding box
  71869. */
  71870. scale(factor: number): BoundingSphere;
  71871. /**
  71872. * Gets the world matrix of the bounding box
  71873. * @returns a matrix
  71874. */
  71875. getWorldMatrix(): DeepImmutable<Matrix>;
  71876. /** @hidden */
  71877. _update(worldMatrix: DeepImmutable<Matrix>): void;
  71878. /**
  71879. * Tests if the bounding sphere is intersecting the frustum planes
  71880. * @param frustumPlanes defines the frustum planes to test
  71881. * @returns true if there is an intersection
  71882. */
  71883. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  71884. /**
  71885. * Tests if the bounding sphere center is in between the frustum planes.
  71886. * Used for optimistic fast inclusion.
  71887. * @param frustumPlanes defines the frustum planes to test
  71888. * @returns true if the sphere center is in between the frustum planes
  71889. */
  71890. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  71891. /**
  71892. * Tests if a point is inside the bounding sphere
  71893. * @param point defines the point to test
  71894. * @returns true if the point is inside the bounding sphere
  71895. */
  71896. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  71897. /**
  71898. * Checks if two sphere intersct
  71899. * @param sphere0 sphere 0
  71900. * @param sphere1 sphere 1
  71901. * @returns true if the speres intersect
  71902. */
  71903. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  71904. }
  71905. }
  71906. declare module BABYLON {
  71907. /**
  71908. * Class used to store bounding box information
  71909. */
  71910. export class BoundingBox implements ICullable {
  71911. /**
  71912. * Gets the 8 vectors representing the bounding box in local space
  71913. */
  71914. readonly vectors: Vector3[];
  71915. /**
  71916. * Gets the center of the bounding box in local space
  71917. */
  71918. readonly center: Vector3;
  71919. /**
  71920. * Gets the center of the bounding box in world space
  71921. */
  71922. readonly centerWorld: Vector3;
  71923. /**
  71924. * Gets the extend size in local space
  71925. */
  71926. readonly extendSize: Vector3;
  71927. /**
  71928. * Gets the extend size in world space
  71929. */
  71930. readonly extendSizeWorld: Vector3;
  71931. /**
  71932. * Gets the OBB (object bounding box) directions
  71933. */
  71934. readonly directions: Vector3[];
  71935. /**
  71936. * Gets the 8 vectors representing the bounding box in world space
  71937. */
  71938. readonly vectorsWorld: Vector3[];
  71939. /**
  71940. * Gets the minimum vector in world space
  71941. */
  71942. readonly minimumWorld: Vector3;
  71943. /**
  71944. * Gets the maximum vector in world space
  71945. */
  71946. readonly maximumWorld: Vector3;
  71947. /**
  71948. * Gets the minimum vector in local space
  71949. */
  71950. readonly minimum: Vector3;
  71951. /**
  71952. * Gets the maximum vector in local space
  71953. */
  71954. readonly maximum: Vector3;
  71955. private _worldMatrix;
  71956. private static readonly TmpVector3;
  71957. /**
  71958. * @hidden
  71959. */
  71960. _tag: number;
  71961. /**
  71962. * Creates a new bounding box
  71963. * @param min defines the minimum vector (in local space)
  71964. * @param max defines the maximum vector (in local space)
  71965. * @param worldMatrix defines the new world matrix
  71966. */
  71967. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  71968. /**
  71969. * Recreates the entire bounding box from scratch as if we call the constructor in place
  71970. * @param min defines the new minimum vector (in local space)
  71971. * @param max defines the new maximum vector (in local space)
  71972. * @param worldMatrix defines the new world matrix
  71973. */
  71974. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  71975. /**
  71976. * Scale the current bounding box by applying a scale factor
  71977. * @param factor defines the scale factor to apply
  71978. * @returns the current bounding box
  71979. */
  71980. scale(factor: number): BoundingBox;
  71981. /**
  71982. * Gets the world matrix of the bounding box
  71983. * @returns a matrix
  71984. */
  71985. getWorldMatrix(): DeepImmutable<Matrix>;
  71986. /** @hidden */
  71987. _update(world: DeepImmutable<Matrix>): void;
  71988. /**
  71989. * Tests if the bounding box is intersecting the frustum planes
  71990. * @param frustumPlanes defines the frustum planes to test
  71991. * @returns true if there is an intersection
  71992. */
  71993. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  71994. /**
  71995. * Tests if the bounding box is entirely inside the frustum planes
  71996. * @param frustumPlanes defines the frustum planes to test
  71997. * @returns true if there is an inclusion
  71998. */
  71999. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72000. /**
  72001. * Tests if a point is inside the bounding box
  72002. * @param point defines the point to test
  72003. * @returns true if the point is inside the bounding box
  72004. */
  72005. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  72006. /**
  72007. * Tests if the bounding box intersects with a bounding sphere
  72008. * @param sphere defines the sphere to test
  72009. * @returns true if there is an intersection
  72010. */
  72011. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  72012. /**
  72013. * Tests if the bounding box intersects with a box defined by a min and max vectors
  72014. * @param min defines the min vector to use
  72015. * @param max defines the max vector to use
  72016. * @returns true if there is an intersection
  72017. */
  72018. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  72019. /**
  72020. * Tests if two bounding boxes are intersections
  72021. * @param box0 defines the first box to test
  72022. * @param box1 defines the second box to test
  72023. * @returns true if there is an intersection
  72024. */
  72025. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  72026. /**
  72027. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  72028. * @param minPoint defines the minimum vector of the bounding box
  72029. * @param maxPoint defines the maximum vector of the bounding box
  72030. * @param sphereCenter defines the sphere center
  72031. * @param sphereRadius defines the sphere radius
  72032. * @returns true if there is an intersection
  72033. */
  72034. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  72035. /**
  72036. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  72037. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  72038. * @param frustumPlanes defines the frustum planes to test
  72039. * @return true if there is an inclusion
  72040. */
  72041. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72042. /**
  72043. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  72044. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  72045. * @param frustumPlanes defines the frustum planes to test
  72046. * @return true if there is an intersection
  72047. */
  72048. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72049. }
  72050. }
  72051. declare module BABYLON {
  72052. /** @hidden */
  72053. export class Collider {
  72054. /** Define if a collision was found */
  72055. collisionFound: boolean;
  72056. /**
  72057. * Define last intersection point in local space
  72058. */
  72059. intersectionPoint: Vector3;
  72060. /**
  72061. * Define last collided mesh
  72062. */
  72063. collidedMesh: Nullable<AbstractMesh>;
  72064. private _collisionPoint;
  72065. private _planeIntersectionPoint;
  72066. private _tempVector;
  72067. private _tempVector2;
  72068. private _tempVector3;
  72069. private _tempVector4;
  72070. private _edge;
  72071. private _baseToVertex;
  72072. private _destinationPoint;
  72073. private _slidePlaneNormal;
  72074. private _displacementVector;
  72075. /** @hidden */
  72076. _radius: Vector3;
  72077. /** @hidden */
  72078. _retry: number;
  72079. private _velocity;
  72080. private _basePoint;
  72081. private _epsilon;
  72082. /** @hidden */
  72083. _velocityWorldLength: number;
  72084. /** @hidden */
  72085. _basePointWorld: Vector3;
  72086. private _velocityWorld;
  72087. private _normalizedVelocity;
  72088. /** @hidden */
  72089. _initialVelocity: Vector3;
  72090. /** @hidden */
  72091. _initialPosition: Vector3;
  72092. private _nearestDistance;
  72093. private _collisionMask;
  72094. collisionMask: number;
  72095. /**
  72096. * Gets the plane normal used to compute the sliding response (in local space)
  72097. */
  72098. readonly slidePlaneNormal: Vector3;
  72099. /** @hidden */
  72100. _initialize(source: Vector3, dir: Vector3, e: number): void;
  72101. /** @hidden */
  72102. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  72103. /** @hidden */
  72104. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  72105. /** @hidden */
  72106. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  72107. /** @hidden */
  72108. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  72109. /** @hidden */
  72110. _getResponse(pos: Vector3, vel: Vector3): void;
  72111. }
  72112. }
  72113. declare module BABYLON {
  72114. /**
  72115. * Interface for cullable objects
  72116. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  72117. */
  72118. export interface ICullable {
  72119. /**
  72120. * Checks if the object or part of the object is in the frustum
  72121. * @param frustumPlanes Camera near/planes
  72122. * @returns true if the object is in frustum otherwise false
  72123. */
  72124. isInFrustum(frustumPlanes: Plane[]): boolean;
  72125. /**
  72126. * Checks if a cullable object (mesh...) is in the camera frustum
  72127. * Unlike isInFrustum this cheks the full bounding box
  72128. * @param frustumPlanes Camera near/planes
  72129. * @returns true if the object is in frustum otherwise false
  72130. */
  72131. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  72132. }
  72133. /**
  72134. * Info for a bounding data of a mesh
  72135. */
  72136. export class BoundingInfo implements ICullable {
  72137. /**
  72138. * Bounding box for the mesh
  72139. */
  72140. readonly boundingBox: BoundingBox;
  72141. /**
  72142. * Bounding sphere for the mesh
  72143. */
  72144. readonly boundingSphere: BoundingSphere;
  72145. private _isLocked;
  72146. private static readonly TmpVector3;
  72147. /**
  72148. * Constructs bounding info
  72149. * @param minimum min vector of the bounding box/sphere
  72150. * @param maximum max vector of the bounding box/sphere
  72151. * @param worldMatrix defines the new world matrix
  72152. */
  72153. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  72154. /**
  72155. * Recreates the entire bounding info from scratch as if we call the constructor in place
  72156. * @param min defines the new minimum vector (in local space)
  72157. * @param max defines the new maximum vector (in local space)
  72158. * @param worldMatrix defines the new world matrix
  72159. */
  72160. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  72161. /**
  72162. * min vector of the bounding box/sphere
  72163. */
  72164. readonly minimum: Vector3;
  72165. /**
  72166. * max vector of the bounding box/sphere
  72167. */
  72168. readonly maximum: Vector3;
  72169. /**
  72170. * If the info is locked and won't be updated to avoid perf overhead
  72171. */
  72172. isLocked: boolean;
  72173. /**
  72174. * Updates the bounding sphere and box
  72175. * @param world world matrix to be used to update
  72176. */
  72177. update(world: DeepImmutable<Matrix>): void;
  72178. /**
  72179. * Recreate the bounding info to be centered around a specific point given a specific extend.
  72180. * @param center New center of the bounding info
  72181. * @param extend New extend of the bounding info
  72182. * @returns the current bounding info
  72183. */
  72184. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  72185. /**
  72186. * Scale the current bounding info by applying a scale factor
  72187. * @param factor defines the scale factor to apply
  72188. * @returns the current bounding info
  72189. */
  72190. scale(factor: number): BoundingInfo;
  72191. /**
  72192. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  72193. * @param frustumPlanes defines the frustum to test
  72194. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  72195. * @returns true if the bounding info is in the frustum planes
  72196. */
  72197. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  72198. /**
  72199. * Gets the world distance between the min and max points of the bounding box
  72200. */
  72201. readonly diagonalLength: number;
  72202. /**
  72203. * Checks if a cullable object (mesh...) is in the camera frustum
  72204. * Unlike isInFrustum this cheks the full bounding box
  72205. * @param frustumPlanes Camera near/planes
  72206. * @returns true if the object is in frustum otherwise false
  72207. */
  72208. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72209. /** @hidden */
  72210. _checkCollision(collider: Collider): boolean;
  72211. /**
  72212. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  72213. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  72214. * @param point the point to check intersection with
  72215. * @returns if the point intersects
  72216. */
  72217. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  72218. /**
  72219. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  72220. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  72221. * @param boundingInfo the bounding info to check intersection with
  72222. * @param precise if the intersection should be done using OBB
  72223. * @returns if the bounding info intersects
  72224. */
  72225. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  72226. }
  72227. }
  72228. declare module BABYLON {
  72229. /**
  72230. * Extracts minimum and maximum values from a list of indexed positions
  72231. * @param positions defines the positions to use
  72232. * @param indices defines the indices to the positions
  72233. * @param indexStart defines the start index
  72234. * @param indexCount defines the end index
  72235. * @param bias defines bias value to add to the result
  72236. * @return minimum and maximum values
  72237. */
  72238. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  72239. minimum: Vector3;
  72240. maximum: Vector3;
  72241. };
  72242. /**
  72243. * Extracts minimum and maximum values from a list of positions
  72244. * @param positions defines the positions to use
  72245. * @param start defines the start index in the positions array
  72246. * @param count defines the number of positions to handle
  72247. * @param bias defines bias value to add to the result
  72248. * @param stride defines the stride size to use (distance between two positions in the positions array)
  72249. * @return minimum and maximum values
  72250. */
  72251. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  72252. minimum: Vector3;
  72253. maximum: Vector3;
  72254. };
  72255. }
  72256. declare module BABYLON {
  72257. /**
  72258. * Enum that determines the text-wrapping mode to use.
  72259. */
  72260. export enum InspectableType {
  72261. /**
  72262. * Checkbox for booleans
  72263. */
  72264. Checkbox = 0,
  72265. /**
  72266. * Sliders for numbers
  72267. */
  72268. Slider = 1,
  72269. /**
  72270. * Vector3
  72271. */
  72272. Vector3 = 2,
  72273. /**
  72274. * Quaternions
  72275. */
  72276. Quaternion = 3,
  72277. /**
  72278. * Color3
  72279. */
  72280. Color3 = 4,
  72281. /**
  72282. * String
  72283. */
  72284. String = 5
  72285. }
  72286. /**
  72287. * Interface used to define custom inspectable properties.
  72288. * This interface is used by the inspector to display custom property grids
  72289. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  72290. */
  72291. export interface IInspectable {
  72292. /**
  72293. * Gets the label to display
  72294. */
  72295. label: string;
  72296. /**
  72297. * Gets the name of the property to edit
  72298. */
  72299. propertyName: string;
  72300. /**
  72301. * Gets the type of the editor to use
  72302. */
  72303. type: InspectableType;
  72304. /**
  72305. * Gets the minimum value of the property when using in "slider" mode
  72306. */
  72307. min?: number;
  72308. /**
  72309. * Gets the maximum value of the property when using in "slider" mode
  72310. */
  72311. max?: number;
  72312. /**
  72313. * Gets the setp to use when using in "slider" mode
  72314. */
  72315. step?: number;
  72316. }
  72317. }
  72318. declare module BABYLON {
  72319. /**
  72320. * Class used to provide helper for timing
  72321. */
  72322. export class TimingTools {
  72323. /**
  72324. * Polyfill for setImmediate
  72325. * @param action defines the action to execute after the current execution block
  72326. */
  72327. static SetImmediate(action: () => void): void;
  72328. }
  72329. }
  72330. declare module BABYLON {
  72331. /**
  72332. * Class used to enable instatition of objects by class name
  72333. */
  72334. export class InstantiationTools {
  72335. /**
  72336. * Use this object to register external classes like custom textures or material
  72337. * to allow the laoders to instantiate them
  72338. */
  72339. static RegisteredExternalClasses: {
  72340. [key: string]: Object;
  72341. };
  72342. /**
  72343. * Tries to instantiate a new object from a given class name
  72344. * @param className defines the class name to instantiate
  72345. * @returns the new object or null if the system was not able to do the instantiation
  72346. */
  72347. static Instantiate(className: string): any;
  72348. }
  72349. }
  72350. declare module BABYLON {
  72351. /**
  72352. * This represents the required contract to create a new type of texture loader.
  72353. */
  72354. export interface IInternalTextureLoader {
  72355. /**
  72356. * Defines wether the loader supports cascade loading the different faces.
  72357. */
  72358. supportCascades: boolean;
  72359. /**
  72360. * This returns if the loader support the current file information.
  72361. * @param extension defines the file extension of the file being loaded
  72362. * @param textureFormatInUse defines the current compressed format in use iun the engine
  72363. * @param fallback defines the fallback internal texture if any
  72364. * @param isBase64 defines whether the texture is encoded as a base64
  72365. * @param isBuffer defines whether the texture data are stored as a buffer
  72366. * @returns true if the loader can load the specified file
  72367. */
  72368. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  72369. /**
  72370. * Transform the url before loading if required.
  72371. * @param rootUrl the url of the texture
  72372. * @param textureFormatInUse defines the current compressed format in use iun the engine
  72373. * @returns the transformed texture
  72374. */
  72375. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  72376. /**
  72377. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  72378. * @param rootUrl the url of the texture
  72379. * @param textureFormatInUse defines the current compressed format in use iun the engine
  72380. * @returns the fallback texture
  72381. */
  72382. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  72383. /**
  72384. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  72385. * @param data contains the texture data
  72386. * @param texture defines the BabylonJS internal texture
  72387. * @param createPolynomials will be true if polynomials have been requested
  72388. * @param onLoad defines the callback to trigger once the texture is ready
  72389. * @param onError defines the callback to trigger in case of error
  72390. */
  72391. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  72392. /**
  72393. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  72394. * @param data contains the texture data
  72395. * @param texture defines the BabylonJS internal texture
  72396. * @param callback defines the method to call once ready to upload
  72397. */
  72398. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  72399. }
  72400. }
  72401. declare module BABYLON {
  72402. interface Engine {
  72403. /**
  72404. * Creates a depth stencil cube texture.
  72405. * This is only available in WebGL 2.
  72406. * @param size The size of face edge in the cube texture.
  72407. * @param options The options defining the cube texture.
  72408. * @returns The cube texture
  72409. */
  72410. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  72411. /**
  72412. * Creates a cube texture
  72413. * @param rootUrl defines the url where the files to load is located
  72414. * @param scene defines the current scene
  72415. * @param files defines the list of files to load (1 per face)
  72416. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  72417. * @param onLoad defines an optional callback raised when the texture is loaded
  72418. * @param onError defines an optional callback raised if there is an issue to load the texture
  72419. * @param format defines the format of the data
  72420. * @param forcedExtension defines the extension to use to pick the right loader
  72421. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  72422. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  72423. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  72424. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  72425. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  72426. * @returns the cube texture as an InternalTexture
  72427. */
  72428. 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;
  72429. /**
  72430. * Creates a cube texture
  72431. * @param rootUrl defines the url where the files to load is located
  72432. * @param scene defines the current scene
  72433. * @param files defines the list of files to load (1 per face)
  72434. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  72435. * @param onLoad defines an optional callback raised when the texture is loaded
  72436. * @param onError defines an optional callback raised if there is an issue to load the texture
  72437. * @param format defines the format of the data
  72438. * @param forcedExtension defines the extension to use to pick the right loader
  72439. * @returns the cube texture as an InternalTexture
  72440. */
  72441. 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;
  72442. /**
  72443. * Creates a cube texture
  72444. * @param rootUrl defines the url where the files to load is located
  72445. * @param scene defines the current scene
  72446. * @param files defines the list of files to load (1 per face)
  72447. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  72448. * @param onLoad defines an optional callback raised when the texture is loaded
  72449. * @param onError defines an optional callback raised if there is an issue to load the texture
  72450. * @param format defines the format of the data
  72451. * @param forcedExtension defines the extension to use to pick the right loader
  72452. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  72453. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  72454. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  72455. * @returns the cube texture as an InternalTexture
  72456. */
  72457. 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;
  72458. /** @hidden */
  72459. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  72460. /** @hidden */
  72461. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  72462. /** @hidden */
  72463. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  72464. /** @hidden */
  72465. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  72466. }
  72467. }
  72468. declare module BABYLON {
  72469. /**
  72470. * Class for creating a cube texture
  72471. */
  72472. export class CubeTexture extends BaseTexture {
  72473. private _delayedOnLoad;
  72474. /**
  72475. * The url of the texture
  72476. */
  72477. url: string;
  72478. /**
  72479. * Gets or sets the center of the bounding box associated with the cube texture.
  72480. * It must define where the camera used to render the texture was set
  72481. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  72482. */
  72483. boundingBoxPosition: Vector3;
  72484. private _boundingBoxSize;
  72485. /**
  72486. * Gets or sets the size of the bounding box associated with the cube texture
  72487. * When defined, the cubemap will switch to local mode
  72488. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  72489. * @example https://www.babylonjs-playground.com/#RNASML
  72490. */
  72491. /**
  72492. * Returns the bounding box size
  72493. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  72494. */
  72495. boundingBoxSize: Vector3;
  72496. protected _rotationY: number;
  72497. /**
  72498. * Sets texture matrix rotation angle around Y axis in radians.
  72499. */
  72500. /**
  72501. * Gets texture matrix rotation angle around Y axis radians.
  72502. */
  72503. rotationY: number;
  72504. /**
  72505. * Are mip maps generated for this texture or not.
  72506. */
  72507. readonly noMipmap: boolean;
  72508. private _noMipmap;
  72509. private _files;
  72510. private _extensions;
  72511. private _textureMatrix;
  72512. private _format;
  72513. private _createPolynomials;
  72514. /** @hidden */
  72515. _prefiltered: boolean;
  72516. /**
  72517. * Creates a cube texture from an array of image urls
  72518. * @param files defines an array of image urls
  72519. * @param scene defines the hosting scene
  72520. * @param noMipmap specifies if mip maps are not used
  72521. * @returns a cube texture
  72522. */
  72523. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  72524. /**
  72525. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  72526. * @param url defines the url of the prefiltered texture
  72527. * @param scene defines the scene the texture is attached to
  72528. * @param forcedExtension defines the extension of the file if different from the url
  72529. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  72530. * @return the prefiltered texture
  72531. */
  72532. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  72533. /**
  72534. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  72535. * as prefiltered data.
  72536. * @param rootUrl defines the url of the texture or the root name of the six images
  72537. * @param scene defines the scene the texture is attached to
  72538. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  72539. * @param noMipmap defines if mipmaps should be created or not
  72540. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  72541. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  72542. * @param onError defines a callback triggered in case of error during load
  72543. * @param format defines the internal format to use for the texture once loaded
  72544. * @param prefiltered defines whether or not the texture is created from prefiltered data
  72545. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  72546. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  72547. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  72548. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  72549. * @return the cube texture
  72550. */
  72551. 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);
  72552. /**
  72553. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  72554. */
  72555. readonly isPrefiltered: boolean;
  72556. /**
  72557. * Get the current class name of the texture useful for serialization or dynamic coding.
  72558. * @returns "CubeTexture"
  72559. */
  72560. getClassName(): string;
  72561. /**
  72562. * Update the url (and optional buffer) of this texture if url was null during construction.
  72563. * @param url the url of the texture
  72564. * @param forcedExtension defines the extension to use
  72565. * @param onLoad callback called when the texture is loaded (defaults to null)
  72566. */
  72567. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  72568. /**
  72569. * Delays loading of the cube texture
  72570. * @param forcedExtension defines the extension to use
  72571. */
  72572. delayLoad(forcedExtension?: string): void;
  72573. /**
  72574. * Returns the reflection texture matrix
  72575. * @returns the reflection texture matrix
  72576. */
  72577. getReflectionTextureMatrix(): Matrix;
  72578. /**
  72579. * Sets the reflection texture matrix
  72580. * @param value Reflection texture matrix
  72581. */
  72582. setReflectionTextureMatrix(value: Matrix): void;
  72583. /**
  72584. * Parses text to create a cube texture
  72585. * @param parsedTexture define the serialized text to read from
  72586. * @param scene defines the hosting scene
  72587. * @param rootUrl defines the root url of the cube texture
  72588. * @returns a cube texture
  72589. */
  72590. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  72591. /**
  72592. * Makes a clone, or deep copy, of the cube texture
  72593. * @returns a new cube texture
  72594. */
  72595. clone(): CubeTexture;
  72596. }
  72597. }
  72598. declare module BABYLON {
  72599. /**
  72600. * Manages the defines for the Material
  72601. */
  72602. export class MaterialDefines {
  72603. /** @hidden */
  72604. protected _keys: string[];
  72605. private _isDirty;
  72606. /** @hidden */
  72607. _renderId: number;
  72608. /** @hidden */
  72609. _areLightsDirty: boolean;
  72610. /** @hidden */
  72611. _areLightsDisposed: boolean;
  72612. /** @hidden */
  72613. _areAttributesDirty: boolean;
  72614. /** @hidden */
  72615. _areTexturesDirty: boolean;
  72616. /** @hidden */
  72617. _areFresnelDirty: boolean;
  72618. /** @hidden */
  72619. _areMiscDirty: boolean;
  72620. /** @hidden */
  72621. _areImageProcessingDirty: boolean;
  72622. /** @hidden */
  72623. _normals: boolean;
  72624. /** @hidden */
  72625. _uvs: boolean;
  72626. /** @hidden */
  72627. _needNormals: boolean;
  72628. /** @hidden */
  72629. _needUVs: boolean;
  72630. [id: string]: any;
  72631. /**
  72632. * Specifies if the material needs to be re-calculated
  72633. */
  72634. readonly isDirty: boolean;
  72635. /**
  72636. * Marks the material to indicate that it has been re-calculated
  72637. */
  72638. markAsProcessed(): void;
  72639. /**
  72640. * Marks the material to indicate that it needs to be re-calculated
  72641. */
  72642. markAsUnprocessed(): void;
  72643. /**
  72644. * Marks the material to indicate all of its defines need to be re-calculated
  72645. */
  72646. markAllAsDirty(): void;
  72647. /**
  72648. * Marks the material to indicate that image processing needs to be re-calculated
  72649. */
  72650. markAsImageProcessingDirty(): void;
  72651. /**
  72652. * Marks the material to indicate the lights need to be re-calculated
  72653. * @param disposed Defines whether the light is dirty due to dispose or not
  72654. */
  72655. markAsLightDirty(disposed?: boolean): void;
  72656. /**
  72657. * Marks the attribute state as changed
  72658. */
  72659. markAsAttributesDirty(): void;
  72660. /**
  72661. * Marks the texture state as changed
  72662. */
  72663. markAsTexturesDirty(): void;
  72664. /**
  72665. * Marks the fresnel state as changed
  72666. */
  72667. markAsFresnelDirty(): void;
  72668. /**
  72669. * Marks the misc state as changed
  72670. */
  72671. markAsMiscDirty(): void;
  72672. /**
  72673. * Rebuilds the material defines
  72674. */
  72675. rebuild(): void;
  72676. /**
  72677. * Specifies if two material defines are equal
  72678. * @param other - A material define instance to compare to
  72679. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  72680. */
  72681. isEqual(other: MaterialDefines): boolean;
  72682. /**
  72683. * Clones this instance's defines to another instance
  72684. * @param other - material defines to clone values to
  72685. */
  72686. cloneTo(other: MaterialDefines): void;
  72687. /**
  72688. * Resets the material define values
  72689. */
  72690. reset(): void;
  72691. /**
  72692. * Converts the material define values to a string
  72693. * @returns - String of material define information
  72694. */
  72695. toString(): string;
  72696. }
  72697. }
  72698. declare module BABYLON {
  72699. /**
  72700. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  72701. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  72702. * 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;
  72703. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  72704. */
  72705. export class ColorCurves {
  72706. private _dirty;
  72707. private _tempColor;
  72708. private _globalCurve;
  72709. private _highlightsCurve;
  72710. private _midtonesCurve;
  72711. private _shadowsCurve;
  72712. private _positiveCurve;
  72713. private _negativeCurve;
  72714. private _globalHue;
  72715. private _globalDensity;
  72716. private _globalSaturation;
  72717. private _globalExposure;
  72718. /**
  72719. * Gets the global Hue value.
  72720. * 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).
  72721. */
  72722. /**
  72723. * Sets the global Hue value.
  72724. * 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).
  72725. */
  72726. globalHue: number;
  72727. /**
  72728. * Gets the global Density value.
  72729. * 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.
  72730. * Values less than zero provide a filter of opposite hue.
  72731. */
  72732. /**
  72733. * Sets the global Density value.
  72734. * 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.
  72735. * Values less than zero provide a filter of opposite hue.
  72736. */
  72737. globalDensity: number;
  72738. /**
  72739. * Gets the global Saturation value.
  72740. * 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.
  72741. */
  72742. /**
  72743. * Sets the global Saturation value.
  72744. * 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.
  72745. */
  72746. globalSaturation: number;
  72747. /**
  72748. * Gets the global Exposure value.
  72749. * 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.
  72750. */
  72751. /**
  72752. * Sets the global Exposure value.
  72753. * 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.
  72754. */
  72755. globalExposure: number;
  72756. private _highlightsHue;
  72757. private _highlightsDensity;
  72758. private _highlightsSaturation;
  72759. private _highlightsExposure;
  72760. /**
  72761. * Gets the highlights Hue value.
  72762. * 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).
  72763. */
  72764. /**
  72765. * Sets the highlights Hue value.
  72766. * 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).
  72767. */
  72768. highlightsHue: number;
  72769. /**
  72770. * Gets the highlights Density value.
  72771. * 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.
  72772. * Values less than zero provide a filter of opposite hue.
  72773. */
  72774. /**
  72775. * Sets the highlights Density value.
  72776. * 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.
  72777. * Values less than zero provide a filter of opposite hue.
  72778. */
  72779. highlightsDensity: number;
  72780. /**
  72781. * Gets the highlights Saturation value.
  72782. * 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.
  72783. */
  72784. /**
  72785. * Sets the highlights Saturation value.
  72786. * 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.
  72787. */
  72788. highlightsSaturation: number;
  72789. /**
  72790. * Gets the highlights Exposure value.
  72791. * 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.
  72792. */
  72793. /**
  72794. * Sets the highlights Exposure value.
  72795. * 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.
  72796. */
  72797. highlightsExposure: number;
  72798. private _midtonesHue;
  72799. private _midtonesDensity;
  72800. private _midtonesSaturation;
  72801. private _midtonesExposure;
  72802. /**
  72803. * Gets the midtones Hue value.
  72804. * 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).
  72805. */
  72806. /**
  72807. * Sets the midtones Hue value.
  72808. * 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).
  72809. */
  72810. midtonesHue: number;
  72811. /**
  72812. * Gets the midtones Density value.
  72813. * 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.
  72814. * Values less than zero provide a filter of opposite hue.
  72815. */
  72816. /**
  72817. * Sets the midtones Density value.
  72818. * 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.
  72819. * Values less than zero provide a filter of opposite hue.
  72820. */
  72821. midtonesDensity: number;
  72822. /**
  72823. * Gets the midtones Saturation value.
  72824. * 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.
  72825. */
  72826. /**
  72827. * Sets the midtones Saturation value.
  72828. * 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.
  72829. */
  72830. midtonesSaturation: number;
  72831. /**
  72832. * Gets the midtones Exposure value.
  72833. * 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.
  72834. */
  72835. /**
  72836. * Sets the midtones Exposure value.
  72837. * 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.
  72838. */
  72839. midtonesExposure: number;
  72840. private _shadowsHue;
  72841. private _shadowsDensity;
  72842. private _shadowsSaturation;
  72843. private _shadowsExposure;
  72844. /**
  72845. * Gets the shadows Hue value.
  72846. * 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).
  72847. */
  72848. /**
  72849. * Sets the shadows Hue value.
  72850. * 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).
  72851. */
  72852. shadowsHue: number;
  72853. /**
  72854. * Gets the shadows Density value.
  72855. * 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.
  72856. * Values less than zero provide a filter of opposite hue.
  72857. */
  72858. /**
  72859. * Sets the shadows Density value.
  72860. * 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.
  72861. * Values less than zero provide a filter of opposite hue.
  72862. */
  72863. shadowsDensity: number;
  72864. /**
  72865. * Gets the shadows Saturation value.
  72866. * 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.
  72867. */
  72868. /**
  72869. * Sets the shadows Saturation value.
  72870. * 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.
  72871. */
  72872. shadowsSaturation: number;
  72873. /**
  72874. * Gets the shadows Exposure value.
  72875. * 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.
  72876. */
  72877. /**
  72878. * Sets the shadows Exposure value.
  72879. * 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.
  72880. */
  72881. shadowsExposure: number;
  72882. /**
  72883. * Returns the class name
  72884. * @returns The class name
  72885. */
  72886. getClassName(): string;
  72887. /**
  72888. * Binds the color curves to the shader.
  72889. * @param colorCurves The color curve to bind
  72890. * @param effect The effect to bind to
  72891. * @param positiveUniform The positive uniform shader parameter
  72892. * @param neutralUniform The neutral uniform shader parameter
  72893. * @param negativeUniform The negative uniform shader parameter
  72894. */
  72895. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  72896. /**
  72897. * Prepare the list of uniforms associated with the ColorCurves effects.
  72898. * @param uniformsList The list of uniforms used in the effect
  72899. */
  72900. static PrepareUniforms(uniformsList: string[]): void;
  72901. /**
  72902. * Returns color grading data based on a hue, density, saturation and exposure value.
  72903. * @param filterHue The hue of the color filter.
  72904. * @param filterDensity The density of the color filter.
  72905. * @param saturation The saturation.
  72906. * @param exposure The exposure.
  72907. * @param result The result data container.
  72908. */
  72909. private getColorGradingDataToRef;
  72910. /**
  72911. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  72912. * @param value The input slider value in range [-100,100].
  72913. * @returns Adjusted value.
  72914. */
  72915. private static applyColorGradingSliderNonlinear;
  72916. /**
  72917. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  72918. * @param hue The hue (H) input.
  72919. * @param saturation The saturation (S) input.
  72920. * @param brightness The brightness (B) input.
  72921. * @result An RGBA color represented as Vector4.
  72922. */
  72923. private static fromHSBToRef;
  72924. /**
  72925. * Returns a value clamped between min and max
  72926. * @param value The value to clamp
  72927. * @param min The minimum of value
  72928. * @param max The maximum of value
  72929. * @returns The clamped value.
  72930. */
  72931. private static clamp;
  72932. /**
  72933. * Clones the current color curve instance.
  72934. * @return The cloned curves
  72935. */
  72936. clone(): ColorCurves;
  72937. /**
  72938. * Serializes the current color curve instance to a json representation.
  72939. * @return a JSON representation
  72940. */
  72941. serialize(): any;
  72942. /**
  72943. * Parses the color curve from a json representation.
  72944. * @param source the JSON source to parse
  72945. * @return The parsed curves
  72946. */
  72947. static Parse(source: any): ColorCurves;
  72948. }
  72949. }
  72950. declare module BABYLON {
  72951. /**
  72952. * Interface to follow in your material defines to integrate easily the
  72953. * Image proccessing functions.
  72954. * @hidden
  72955. */
  72956. export interface IImageProcessingConfigurationDefines {
  72957. IMAGEPROCESSING: boolean;
  72958. VIGNETTE: boolean;
  72959. VIGNETTEBLENDMODEMULTIPLY: boolean;
  72960. VIGNETTEBLENDMODEOPAQUE: boolean;
  72961. TONEMAPPING: boolean;
  72962. TONEMAPPING_ACES: boolean;
  72963. CONTRAST: boolean;
  72964. EXPOSURE: boolean;
  72965. COLORCURVES: boolean;
  72966. COLORGRADING: boolean;
  72967. COLORGRADING3D: boolean;
  72968. SAMPLER3DGREENDEPTH: boolean;
  72969. SAMPLER3DBGRMAP: boolean;
  72970. IMAGEPROCESSINGPOSTPROCESS: boolean;
  72971. }
  72972. /**
  72973. * @hidden
  72974. */
  72975. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  72976. IMAGEPROCESSING: boolean;
  72977. VIGNETTE: boolean;
  72978. VIGNETTEBLENDMODEMULTIPLY: boolean;
  72979. VIGNETTEBLENDMODEOPAQUE: boolean;
  72980. TONEMAPPING: boolean;
  72981. TONEMAPPING_ACES: boolean;
  72982. CONTRAST: boolean;
  72983. COLORCURVES: boolean;
  72984. COLORGRADING: boolean;
  72985. COLORGRADING3D: boolean;
  72986. SAMPLER3DGREENDEPTH: boolean;
  72987. SAMPLER3DBGRMAP: boolean;
  72988. IMAGEPROCESSINGPOSTPROCESS: boolean;
  72989. EXPOSURE: boolean;
  72990. constructor();
  72991. }
  72992. /**
  72993. * This groups together the common properties used for image processing either in direct forward pass
  72994. * or through post processing effect depending on the use of the image processing pipeline in your scene
  72995. * or not.
  72996. */
  72997. export class ImageProcessingConfiguration {
  72998. /**
  72999. * Default tone mapping applied in BabylonJS.
  73000. */
  73001. static readonly TONEMAPPING_STANDARD: number;
  73002. /**
  73003. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  73004. * to other engines rendering to increase portability.
  73005. */
  73006. static readonly TONEMAPPING_ACES: number;
  73007. /**
  73008. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  73009. */
  73010. colorCurves: Nullable<ColorCurves>;
  73011. private _colorCurvesEnabled;
  73012. /**
  73013. * Gets wether the color curves effect is enabled.
  73014. */
  73015. /**
  73016. * Sets wether the color curves effect is enabled.
  73017. */
  73018. colorCurvesEnabled: boolean;
  73019. private _colorGradingTexture;
  73020. /**
  73021. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  73022. */
  73023. /**
  73024. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  73025. */
  73026. colorGradingTexture: Nullable<BaseTexture>;
  73027. private _colorGradingEnabled;
  73028. /**
  73029. * Gets wether the color grading effect is enabled.
  73030. */
  73031. /**
  73032. * Sets wether the color grading effect is enabled.
  73033. */
  73034. colorGradingEnabled: boolean;
  73035. private _colorGradingWithGreenDepth;
  73036. /**
  73037. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  73038. */
  73039. /**
  73040. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  73041. */
  73042. colorGradingWithGreenDepth: boolean;
  73043. private _colorGradingBGR;
  73044. /**
  73045. * Gets wether the color grading texture contains BGR values.
  73046. */
  73047. /**
  73048. * Sets wether the color grading texture contains BGR values.
  73049. */
  73050. colorGradingBGR: boolean;
  73051. /** @hidden */
  73052. _exposure: number;
  73053. /**
  73054. * Gets the Exposure used in the effect.
  73055. */
  73056. /**
  73057. * Sets the Exposure used in the effect.
  73058. */
  73059. exposure: number;
  73060. private _toneMappingEnabled;
  73061. /**
  73062. * Gets wether the tone mapping effect is enabled.
  73063. */
  73064. /**
  73065. * Sets wether the tone mapping effect is enabled.
  73066. */
  73067. toneMappingEnabled: boolean;
  73068. private _toneMappingType;
  73069. /**
  73070. * Gets the type of tone mapping effect.
  73071. */
  73072. /**
  73073. * Sets the type of tone mapping effect used in BabylonJS.
  73074. */
  73075. toneMappingType: number;
  73076. protected _contrast: number;
  73077. /**
  73078. * Gets the contrast used in the effect.
  73079. */
  73080. /**
  73081. * Sets the contrast used in the effect.
  73082. */
  73083. contrast: number;
  73084. /**
  73085. * Vignette stretch size.
  73086. */
  73087. vignetteStretch: number;
  73088. /**
  73089. * Vignette centre X Offset.
  73090. */
  73091. vignetteCentreX: number;
  73092. /**
  73093. * Vignette centre Y Offset.
  73094. */
  73095. vignetteCentreY: number;
  73096. /**
  73097. * Vignette weight or intensity of the vignette effect.
  73098. */
  73099. vignetteWeight: number;
  73100. /**
  73101. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  73102. * if vignetteEnabled is set to true.
  73103. */
  73104. vignetteColor: Color4;
  73105. /**
  73106. * Camera field of view used by the Vignette effect.
  73107. */
  73108. vignetteCameraFov: number;
  73109. private _vignetteBlendMode;
  73110. /**
  73111. * Gets the vignette blend mode allowing different kind of effect.
  73112. */
  73113. /**
  73114. * Sets the vignette blend mode allowing different kind of effect.
  73115. */
  73116. vignetteBlendMode: number;
  73117. private _vignetteEnabled;
  73118. /**
  73119. * Gets wether the vignette effect is enabled.
  73120. */
  73121. /**
  73122. * Sets wether the vignette effect is enabled.
  73123. */
  73124. vignetteEnabled: boolean;
  73125. private _applyByPostProcess;
  73126. /**
  73127. * Gets wether the image processing is applied through a post process or not.
  73128. */
  73129. /**
  73130. * Sets wether the image processing is applied through a post process or not.
  73131. */
  73132. applyByPostProcess: boolean;
  73133. private _isEnabled;
  73134. /**
  73135. * Gets wether the image processing is enabled or not.
  73136. */
  73137. /**
  73138. * Sets wether the image processing is enabled or not.
  73139. */
  73140. isEnabled: boolean;
  73141. /**
  73142. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  73143. */
  73144. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  73145. /**
  73146. * Method called each time the image processing information changes requires to recompile the effect.
  73147. */
  73148. protected _updateParameters(): void;
  73149. /**
  73150. * Gets the current class name.
  73151. * @return "ImageProcessingConfiguration"
  73152. */
  73153. getClassName(): string;
  73154. /**
  73155. * Prepare the list of uniforms associated with the Image Processing effects.
  73156. * @param uniforms The list of uniforms used in the effect
  73157. * @param defines the list of defines currently in use
  73158. */
  73159. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  73160. /**
  73161. * Prepare the list of samplers associated with the Image Processing effects.
  73162. * @param samplersList The list of uniforms used in the effect
  73163. * @param defines the list of defines currently in use
  73164. */
  73165. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  73166. /**
  73167. * Prepare the list of defines associated to the shader.
  73168. * @param defines the list of defines to complete
  73169. * @param forPostProcess Define if we are currently in post process mode or not
  73170. */
  73171. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  73172. /**
  73173. * Returns true if all the image processing information are ready.
  73174. * @returns True if ready, otherwise, false
  73175. */
  73176. isReady(): boolean;
  73177. /**
  73178. * Binds the image processing to the shader.
  73179. * @param effect The effect to bind to
  73180. * @param aspectRatio Define the current aspect ratio of the effect
  73181. */
  73182. bind(effect: Effect, aspectRatio?: number): void;
  73183. /**
  73184. * Clones the current image processing instance.
  73185. * @return The cloned image processing
  73186. */
  73187. clone(): ImageProcessingConfiguration;
  73188. /**
  73189. * Serializes the current image processing instance to a json representation.
  73190. * @return a JSON representation
  73191. */
  73192. serialize(): any;
  73193. /**
  73194. * Parses the image processing from a json representation.
  73195. * @param source the JSON source to parse
  73196. * @return The parsed image processing
  73197. */
  73198. static Parse(source: any): ImageProcessingConfiguration;
  73199. private static _VIGNETTEMODE_MULTIPLY;
  73200. private static _VIGNETTEMODE_OPAQUE;
  73201. /**
  73202. * Used to apply the vignette as a mix with the pixel color.
  73203. */
  73204. static readonly VIGNETTEMODE_MULTIPLY: number;
  73205. /**
  73206. * Used to apply the vignette as a replacement of the pixel color.
  73207. */
  73208. static readonly VIGNETTEMODE_OPAQUE: number;
  73209. }
  73210. }
  73211. declare module BABYLON {
  73212. /** @hidden */
  73213. export var postprocessVertexShader: {
  73214. name: string;
  73215. shader: string;
  73216. };
  73217. }
  73218. declare module BABYLON {
  73219. /** Defines supported spaces */
  73220. export enum Space {
  73221. /** Local (object) space */
  73222. LOCAL = 0,
  73223. /** World space */
  73224. WORLD = 1,
  73225. /** Bone space */
  73226. BONE = 2
  73227. }
  73228. /** Defines the 3 main axes */
  73229. export class Axis {
  73230. /** X axis */
  73231. static X: Vector3;
  73232. /** Y axis */
  73233. static Y: Vector3;
  73234. /** Z axis */
  73235. static Z: Vector3;
  73236. }
  73237. }
  73238. declare module BABYLON {
  73239. /**
  73240. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  73241. * This is the base of the follow, arc rotate cameras and Free camera
  73242. * @see http://doc.babylonjs.com/features/cameras
  73243. */
  73244. export class TargetCamera extends Camera {
  73245. private static _RigCamTransformMatrix;
  73246. private static _TargetTransformMatrix;
  73247. private static _TargetFocalPoint;
  73248. /**
  73249. * Define the current direction the camera is moving to
  73250. */
  73251. cameraDirection: Vector3;
  73252. /**
  73253. * Define the current rotation the camera is rotating to
  73254. */
  73255. cameraRotation: Vector2;
  73256. /**
  73257. * When set, the up vector of the camera will be updated by the rotation of the camera
  73258. */
  73259. updateUpVectorFromRotation: boolean;
  73260. private _tmpQuaternion;
  73261. /**
  73262. * Define the current rotation of the camera
  73263. */
  73264. rotation: Vector3;
  73265. /**
  73266. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  73267. */
  73268. rotationQuaternion: Quaternion;
  73269. /**
  73270. * Define the current speed of the camera
  73271. */
  73272. speed: number;
  73273. /**
  73274. * Add cconstraint to the camera to prevent it to move freely in all directions and
  73275. * around all axis.
  73276. */
  73277. noRotationConstraint: boolean;
  73278. /**
  73279. * Define the current target of the camera as an object or a position.
  73280. */
  73281. lockedTarget: any;
  73282. /** @hidden */
  73283. _currentTarget: Vector3;
  73284. /** @hidden */
  73285. _initialFocalDistance: number;
  73286. /** @hidden */
  73287. _viewMatrix: Matrix;
  73288. /** @hidden */
  73289. _camMatrix: Matrix;
  73290. /** @hidden */
  73291. _cameraTransformMatrix: Matrix;
  73292. /** @hidden */
  73293. _cameraRotationMatrix: Matrix;
  73294. /** @hidden */
  73295. _referencePoint: Vector3;
  73296. /** @hidden */
  73297. _transformedReferencePoint: Vector3;
  73298. protected _globalCurrentTarget: Vector3;
  73299. protected _globalCurrentUpVector: Vector3;
  73300. /** @hidden */
  73301. _reset: () => void;
  73302. private _defaultUp;
  73303. /**
  73304. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  73305. * This is the base of the follow, arc rotate cameras and Free camera
  73306. * @see http://doc.babylonjs.com/features/cameras
  73307. * @param name Defines the name of the camera in the scene
  73308. * @param position Defines the start position of the camera in the scene
  73309. * @param scene Defines the scene the camera belongs to
  73310. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  73311. */
  73312. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  73313. /**
  73314. * Gets the position in front of the camera at a given distance.
  73315. * @param distance The distance from the camera we want the position to be
  73316. * @returns the position
  73317. */
  73318. getFrontPosition(distance: number): Vector3;
  73319. /** @hidden */
  73320. _getLockedTargetPosition(): Nullable<Vector3>;
  73321. private _storedPosition;
  73322. private _storedRotation;
  73323. private _storedRotationQuaternion;
  73324. /**
  73325. * Store current camera state of the camera (fov, position, rotation, etc..)
  73326. * @returns the camera
  73327. */
  73328. storeState(): Camera;
  73329. /**
  73330. * Restored camera state. You must call storeState() first
  73331. * @returns whether it was successful or not
  73332. * @hidden
  73333. */
  73334. _restoreStateValues(): boolean;
  73335. /** @hidden */
  73336. _initCache(): void;
  73337. /** @hidden */
  73338. _updateCache(ignoreParentClass?: boolean): void;
  73339. /** @hidden */
  73340. _isSynchronizedViewMatrix(): boolean;
  73341. /** @hidden */
  73342. _computeLocalCameraSpeed(): number;
  73343. /**
  73344. * Defines the target the camera should look at.
  73345. * @param target Defines the new target as a Vector or a mesh
  73346. */
  73347. setTarget(target: Vector3): void;
  73348. /**
  73349. * Return the current target position of the camera. This value is expressed in local space.
  73350. * @returns the target position
  73351. */
  73352. getTarget(): Vector3;
  73353. /** @hidden */
  73354. _decideIfNeedsToMove(): boolean;
  73355. /** @hidden */
  73356. _updatePosition(): void;
  73357. /** @hidden */
  73358. _checkInputs(): void;
  73359. protected _updateCameraRotationMatrix(): void;
  73360. /**
  73361. * 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)
  73362. * @returns the current camera
  73363. */
  73364. private _rotateUpVectorWithCameraRotationMatrix;
  73365. private _cachedRotationZ;
  73366. private _cachedQuaternionRotationZ;
  73367. /** @hidden */
  73368. _getViewMatrix(): Matrix;
  73369. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  73370. /**
  73371. * @hidden
  73372. */
  73373. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  73374. /**
  73375. * @hidden
  73376. */
  73377. _updateRigCameras(): void;
  73378. private _getRigCamPositionAndTarget;
  73379. /**
  73380. * Gets the current object class name.
  73381. * @return the class name
  73382. */
  73383. getClassName(): string;
  73384. }
  73385. }
  73386. declare module BABYLON {
  73387. /**
  73388. * Gather the list of keyboard event types as constants.
  73389. */
  73390. export class KeyboardEventTypes {
  73391. /**
  73392. * The keydown event is fired when a key becomes active (pressed).
  73393. */
  73394. static readonly KEYDOWN: number;
  73395. /**
  73396. * The keyup event is fired when a key has been released.
  73397. */
  73398. static readonly KEYUP: number;
  73399. }
  73400. /**
  73401. * This class is used to store keyboard related info for the onKeyboardObservable event.
  73402. */
  73403. export class KeyboardInfo {
  73404. /**
  73405. * Defines the type of event (KeyboardEventTypes)
  73406. */
  73407. type: number;
  73408. /**
  73409. * Defines the related dom event
  73410. */
  73411. event: KeyboardEvent;
  73412. /**
  73413. * Instantiates a new keyboard info.
  73414. * This class is used to store keyboard related info for the onKeyboardObservable event.
  73415. * @param type Defines the type of event (KeyboardEventTypes)
  73416. * @param event Defines the related dom event
  73417. */
  73418. constructor(
  73419. /**
  73420. * Defines the type of event (KeyboardEventTypes)
  73421. */
  73422. type: number,
  73423. /**
  73424. * Defines the related dom event
  73425. */
  73426. event: KeyboardEvent);
  73427. }
  73428. /**
  73429. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  73430. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  73431. */
  73432. export class KeyboardInfoPre extends KeyboardInfo {
  73433. /**
  73434. * Defines the type of event (KeyboardEventTypes)
  73435. */
  73436. type: number;
  73437. /**
  73438. * Defines the related dom event
  73439. */
  73440. event: KeyboardEvent;
  73441. /**
  73442. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  73443. */
  73444. skipOnPointerObservable: boolean;
  73445. /**
  73446. * Instantiates a new keyboard pre info.
  73447. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  73448. * @param type Defines the type of event (KeyboardEventTypes)
  73449. * @param event Defines the related dom event
  73450. */
  73451. constructor(
  73452. /**
  73453. * Defines the type of event (KeyboardEventTypes)
  73454. */
  73455. type: number,
  73456. /**
  73457. * Defines the related dom event
  73458. */
  73459. event: KeyboardEvent);
  73460. }
  73461. }
  73462. declare module BABYLON {
  73463. /**
  73464. * Manage the keyboard inputs to control the movement of a free camera.
  73465. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  73466. */
  73467. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  73468. /**
  73469. * Defines the camera the input is attached to.
  73470. */
  73471. camera: FreeCamera;
  73472. /**
  73473. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  73474. */
  73475. keysUp: number[];
  73476. /**
  73477. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  73478. */
  73479. keysDown: number[];
  73480. /**
  73481. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  73482. */
  73483. keysLeft: number[];
  73484. /**
  73485. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  73486. */
  73487. keysRight: number[];
  73488. private _keys;
  73489. private _onCanvasBlurObserver;
  73490. private _onKeyboardObserver;
  73491. private _engine;
  73492. private _scene;
  73493. /**
  73494. * Attach the input controls to a specific dom element to get the input from.
  73495. * @param element Defines the element the controls should be listened from
  73496. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  73497. */
  73498. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  73499. /**
  73500. * Detach the current controls from the specified dom element.
  73501. * @param element Defines the element to stop listening the inputs from
  73502. */
  73503. detachControl(element: Nullable<HTMLElement>): void;
  73504. /**
  73505. * Update the current camera state depending on the inputs that have been used this frame.
  73506. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  73507. */
  73508. checkInputs(): void;
  73509. /**
  73510. * Gets the class name of the current intput.
  73511. * @returns the class name
  73512. */
  73513. getClassName(): string;
  73514. /** @hidden */
  73515. _onLostFocus(): void;
  73516. /**
  73517. * Get the friendly name associated with the input class.
  73518. * @returns the input friendly name
  73519. */
  73520. getSimpleName(): string;
  73521. }
  73522. }
  73523. declare module BABYLON {
  73524. /**
  73525. * Interface describing all the common properties and methods a shadow light needs to implement.
  73526. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  73527. * as well as binding the different shadow properties to the effects.
  73528. */
  73529. export interface IShadowLight extends Light {
  73530. /**
  73531. * The light id in the scene (used in scene.findLighById for instance)
  73532. */
  73533. id: string;
  73534. /**
  73535. * The position the shdow will be casted from.
  73536. */
  73537. position: Vector3;
  73538. /**
  73539. * In 2d mode (needCube being false), the direction used to cast the shadow.
  73540. */
  73541. direction: Vector3;
  73542. /**
  73543. * The transformed position. Position of the light in world space taking parenting in account.
  73544. */
  73545. transformedPosition: Vector3;
  73546. /**
  73547. * The transformed direction. Direction of the light in world space taking parenting in account.
  73548. */
  73549. transformedDirection: Vector3;
  73550. /**
  73551. * The friendly name of the light in the scene.
  73552. */
  73553. name: string;
  73554. /**
  73555. * Defines the shadow projection clipping minimum z value.
  73556. */
  73557. shadowMinZ: number;
  73558. /**
  73559. * Defines the shadow projection clipping maximum z value.
  73560. */
  73561. shadowMaxZ: number;
  73562. /**
  73563. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  73564. * @returns true if the information has been computed, false if it does not need to (no parenting)
  73565. */
  73566. computeTransformedInformation(): boolean;
  73567. /**
  73568. * Gets the scene the light belongs to.
  73569. * @returns The scene
  73570. */
  73571. getScene(): Scene;
  73572. /**
  73573. * Callback defining a custom Projection Matrix Builder.
  73574. * This can be used to override the default projection matrix computation.
  73575. */
  73576. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  73577. /**
  73578. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  73579. * @param matrix The materix to updated with the projection information
  73580. * @param viewMatrix The transform matrix of the light
  73581. * @param renderList The list of mesh to render in the map
  73582. * @returns The current light
  73583. */
  73584. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  73585. /**
  73586. * Gets the current depth scale used in ESM.
  73587. * @returns The scale
  73588. */
  73589. getDepthScale(): number;
  73590. /**
  73591. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  73592. * @returns true if a cube texture needs to be use
  73593. */
  73594. needCube(): boolean;
  73595. /**
  73596. * Detects if the projection matrix requires to be recomputed this frame.
  73597. * @returns true if it requires to be recomputed otherwise, false.
  73598. */
  73599. needProjectionMatrixCompute(): boolean;
  73600. /**
  73601. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  73602. */
  73603. forceProjectionMatrixCompute(): void;
  73604. /**
  73605. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  73606. * @param faceIndex The index of the face we are computed the direction to generate shadow
  73607. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  73608. */
  73609. getShadowDirection(faceIndex?: number): Vector3;
  73610. /**
  73611. * Gets the minZ used for shadow according to both the scene and the light.
  73612. * @param activeCamera The camera we are returning the min for
  73613. * @returns the depth min z
  73614. */
  73615. getDepthMinZ(activeCamera: Camera): number;
  73616. /**
  73617. * Gets the maxZ used for shadow according to both the scene and the light.
  73618. * @param activeCamera The camera we are returning the max for
  73619. * @returns the depth max z
  73620. */
  73621. getDepthMaxZ(activeCamera: Camera): number;
  73622. }
  73623. /**
  73624. * Base implementation IShadowLight
  73625. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  73626. */
  73627. export abstract class ShadowLight extends Light implements IShadowLight {
  73628. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  73629. protected _position: Vector3;
  73630. protected _setPosition(value: Vector3): void;
  73631. /**
  73632. * Sets the position the shadow will be casted from. Also use as the light position for both
  73633. * point and spot lights.
  73634. */
  73635. /**
  73636. * Sets the position the shadow will be casted from. Also use as the light position for both
  73637. * point and spot lights.
  73638. */
  73639. position: Vector3;
  73640. protected _direction: Vector3;
  73641. protected _setDirection(value: Vector3): void;
  73642. /**
  73643. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  73644. * Also use as the light direction on spot and directional lights.
  73645. */
  73646. /**
  73647. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  73648. * Also use as the light direction on spot and directional lights.
  73649. */
  73650. direction: Vector3;
  73651. private _shadowMinZ;
  73652. /**
  73653. * Gets the shadow projection clipping minimum z value.
  73654. */
  73655. /**
  73656. * Sets the shadow projection clipping minimum z value.
  73657. */
  73658. shadowMinZ: number;
  73659. private _shadowMaxZ;
  73660. /**
  73661. * Sets the shadow projection clipping maximum z value.
  73662. */
  73663. /**
  73664. * Gets the shadow projection clipping maximum z value.
  73665. */
  73666. shadowMaxZ: number;
  73667. /**
  73668. * Callback defining a custom Projection Matrix Builder.
  73669. * This can be used to override the default projection matrix computation.
  73670. */
  73671. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  73672. /**
  73673. * The transformed position. Position of the light in world space taking parenting in account.
  73674. */
  73675. transformedPosition: Vector3;
  73676. /**
  73677. * The transformed direction. Direction of the light in world space taking parenting in account.
  73678. */
  73679. transformedDirection: Vector3;
  73680. private _needProjectionMatrixCompute;
  73681. /**
  73682. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  73683. * @returns true if the information has been computed, false if it does not need to (no parenting)
  73684. */
  73685. computeTransformedInformation(): boolean;
  73686. /**
  73687. * Return the depth scale used for the shadow map.
  73688. * @returns the depth scale.
  73689. */
  73690. getDepthScale(): number;
  73691. /**
  73692. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  73693. * @param faceIndex The index of the face we are computed the direction to generate shadow
  73694. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  73695. */
  73696. getShadowDirection(faceIndex?: number): Vector3;
  73697. /**
  73698. * Returns the ShadowLight absolute position in the World.
  73699. * @returns the position vector in world space
  73700. */
  73701. getAbsolutePosition(): Vector3;
  73702. /**
  73703. * Sets the ShadowLight direction toward the passed target.
  73704. * @param target The point to target in local space
  73705. * @returns the updated ShadowLight direction
  73706. */
  73707. setDirectionToTarget(target: Vector3): Vector3;
  73708. /**
  73709. * Returns the light rotation in euler definition.
  73710. * @returns the x y z rotation in local space.
  73711. */
  73712. getRotation(): Vector3;
  73713. /**
  73714. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  73715. * @returns true if a cube texture needs to be use
  73716. */
  73717. needCube(): boolean;
  73718. /**
  73719. * Detects if the projection matrix requires to be recomputed this frame.
  73720. * @returns true if it requires to be recomputed otherwise, false.
  73721. */
  73722. needProjectionMatrixCompute(): boolean;
  73723. /**
  73724. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  73725. */
  73726. forceProjectionMatrixCompute(): void;
  73727. /** @hidden */
  73728. _initCache(): void;
  73729. /** @hidden */
  73730. _isSynchronized(): boolean;
  73731. /**
  73732. * Computes the world matrix of the node
  73733. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  73734. * @returns the world matrix
  73735. */
  73736. computeWorldMatrix(force?: boolean): Matrix;
  73737. /**
  73738. * Gets the minZ used for shadow according to both the scene and the light.
  73739. * @param activeCamera The camera we are returning the min for
  73740. * @returns the depth min z
  73741. */
  73742. getDepthMinZ(activeCamera: Camera): number;
  73743. /**
  73744. * Gets the maxZ used for shadow according to both the scene and the light.
  73745. * @param activeCamera The camera we are returning the max for
  73746. * @returns the depth max z
  73747. */
  73748. getDepthMaxZ(activeCamera: Camera): number;
  73749. /**
  73750. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  73751. * @param matrix The materix to updated with the projection information
  73752. * @param viewMatrix The transform matrix of the light
  73753. * @param renderList The list of mesh to render in the map
  73754. * @returns The current light
  73755. */
  73756. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  73757. }
  73758. }
  73759. declare module BABYLON {
  73760. /**
  73761. * "Static Class" containing the most commonly used helper while dealing with material for
  73762. * rendering purpose.
  73763. *
  73764. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  73765. *
  73766. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  73767. */
  73768. export class MaterialHelper {
  73769. /**
  73770. * Bind the current view position to an effect.
  73771. * @param effect The effect to be bound
  73772. * @param scene The scene the eyes position is used from
  73773. */
  73774. static BindEyePosition(effect: Effect, scene: Scene): void;
  73775. /**
  73776. * Helps preparing the defines values about the UVs in used in the effect.
  73777. * UVs are shared as much as we can accross channels in the shaders.
  73778. * @param texture The texture we are preparing the UVs for
  73779. * @param defines The defines to update
  73780. * @param key The channel key "diffuse", "specular"... used in the shader
  73781. */
  73782. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  73783. /**
  73784. * Binds a texture matrix value to its corrsponding uniform
  73785. * @param texture The texture to bind the matrix for
  73786. * @param uniformBuffer The uniform buffer receivin the data
  73787. * @param key The channel key "diffuse", "specular"... used in the shader
  73788. */
  73789. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  73790. /**
  73791. * Gets the current status of the fog (should it be enabled?)
  73792. * @param mesh defines the mesh to evaluate for fog support
  73793. * @param scene defines the hosting scene
  73794. * @returns true if fog must be enabled
  73795. */
  73796. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  73797. /**
  73798. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  73799. * @param mesh defines the current mesh
  73800. * @param scene defines the current scene
  73801. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  73802. * @param pointsCloud defines if point cloud rendering has to be turned on
  73803. * @param fogEnabled defines if fog has to be turned on
  73804. * @param alphaTest defines if alpha testing has to be turned on
  73805. * @param defines defines the current list of defines
  73806. */
  73807. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  73808. /**
  73809. * Helper used to prepare the list of defines associated with frame values for shader compilation
  73810. * @param scene defines the current scene
  73811. * @param engine defines the current engine
  73812. * @param defines specifies the list of active defines
  73813. * @param useInstances defines if instances have to be turned on
  73814. * @param useClipPlane defines if clip plane have to be turned on
  73815. */
  73816. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  73817. /**
  73818. * Prepares the defines for bones
  73819. * @param mesh The mesh containing the geometry data we will draw
  73820. * @param defines The defines to update
  73821. */
  73822. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  73823. /**
  73824. * Prepares the defines for morph targets
  73825. * @param mesh The mesh containing the geometry data we will draw
  73826. * @param defines The defines to update
  73827. */
  73828. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  73829. /**
  73830. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  73831. * @param mesh The mesh containing the geometry data we will draw
  73832. * @param defines The defines to update
  73833. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  73834. * @param useBones Precise whether bones should be used or not (override mesh info)
  73835. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  73836. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  73837. * @returns false if defines are considered not dirty and have not been checked
  73838. */
  73839. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  73840. /**
  73841. * Prepares the defines related to multiview
  73842. * @param scene The scene we are intending to draw
  73843. * @param defines The defines to update
  73844. */
  73845. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  73846. /**
  73847. * Prepares the defines related to the light information passed in parameter
  73848. * @param scene The scene we are intending to draw
  73849. * @param mesh The mesh the effect is compiling for
  73850. * @param light The light the effect is compiling for
  73851. * @param lightIndex The index of the light
  73852. * @param defines The defines to update
  73853. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  73854. * @param state Defines the current state regarding what is needed (normals, etc...)
  73855. */
  73856. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  73857. needNormals: boolean;
  73858. needRebuild: boolean;
  73859. shadowEnabled: boolean;
  73860. specularEnabled: boolean;
  73861. lightmapMode: boolean;
  73862. }): void;
  73863. /**
  73864. * Prepares the defines related to the light information passed in parameter
  73865. * @param scene The scene we are intending to draw
  73866. * @param mesh The mesh the effect is compiling for
  73867. * @param defines The defines to update
  73868. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  73869. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  73870. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  73871. * @returns true if normals will be required for the rest of the effect
  73872. */
  73873. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  73874. /**
  73875. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  73876. * @param lightIndex defines the light index
  73877. * @param uniformsList The uniform list
  73878. * @param samplersList The sampler list
  73879. * @param projectedLightTexture defines if projected texture must be used
  73880. * @param uniformBuffersList defines an optional list of uniform buffers
  73881. */
  73882. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  73883. /**
  73884. * Prepares the uniforms and samplers list to be used in the effect
  73885. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  73886. * @param samplersList The sampler list
  73887. * @param defines The defines helping in the list generation
  73888. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  73889. */
  73890. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  73891. /**
  73892. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  73893. * @param defines The defines to update while falling back
  73894. * @param fallbacks The authorized effect fallbacks
  73895. * @param maxSimultaneousLights The maximum number of lights allowed
  73896. * @param rank the current rank of the Effect
  73897. * @returns The newly affected rank
  73898. */
  73899. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  73900. private static _TmpMorphInfluencers;
  73901. /**
  73902. * Prepares the list of attributes required for morph targets according to the effect defines.
  73903. * @param attribs The current list of supported attribs
  73904. * @param mesh The mesh to prepare the morph targets attributes for
  73905. * @param influencers The number of influencers
  73906. */
  73907. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  73908. /**
  73909. * Prepares the list of attributes required for morph targets according to the effect defines.
  73910. * @param attribs The current list of supported attribs
  73911. * @param mesh The mesh to prepare the morph targets attributes for
  73912. * @param defines The current Defines of the effect
  73913. */
  73914. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  73915. /**
  73916. * Prepares the list of attributes required for bones according to the effect defines.
  73917. * @param attribs The current list of supported attribs
  73918. * @param mesh The mesh to prepare the bones attributes for
  73919. * @param defines The current Defines of the effect
  73920. * @param fallbacks The current efffect fallback strategy
  73921. */
  73922. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  73923. /**
  73924. * Check and prepare the list of attributes required for instances according to the effect defines.
  73925. * @param attribs The current list of supported attribs
  73926. * @param defines The current MaterialDefines of the effect
  73927. */
  73928. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  73929. /**
  73930. * Add the list of attributes required for instances to the attribs array.
  73931. * @param attribs The current list of supported attribs
  73932. */
  73933. static PushAttributesForInstances(attribs: string[]): void;
  73934. /**
  73935. * Binds the light shadow information to the effect for the given mesh.
  73936. * @param light The light containing the generator
  73937. * @param scene The scene the lights belongs to
  73938. * @param mesh The mesh we are binding the information to render
  73939. * @param lightIndex The light index in the effect used to render the mesh
  73940. * @param effect The effect we are binding the data to
  73941. */
  73942. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  73943. /**
  73944. * Binds the light information to the effect.
  73945. * @param light The light containing the generator
  73946. * @param effect The effect we are binding the data to
  73947. * @param lightIndex The light index in the effect used to render
  73948. */
  73949. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  73950. /**
  73951. * Binds the lights information from the scene to the effect for the given mesh.
  73952. * @param light Light to bind
  73953. * @param lightIndex Light index
  73954. * @param scene The scene where the light belongs to
  73955. * @param mesh The mesh we are binding the information to render
  73956. * @param effect The effect we are binding the data to
  73957. * @param useSpecular Defines if specular is supported
  73958. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  73959. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  73960. */
  73961. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  73962. /**
  73963. * Binds the lights information from the scene to the effect for the given mesh.
  73964. * @param scene The scene the lights belongs to
  73965. * @param mesh The mesh we are binding the information to render
  73966. * @param effect The effect we are binding the data to
  73967. * @param defines The generated defines for the effect
  73968. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  73969. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  73970. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  73971. */
  73972. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  73973. private static _tempFogColor;
  73974. /**
  73975. * Binds the fog information from the scene to the effect for the given mesh.
  73976. * @param scene The scene the lights belongs to
  73977. * @param mesh The mesh we are binding the information to render
  73978. * @param effect The effect we are binding the data to
  73979. * @param linearSpace Defines if the fog effect is applied in linear space
  73980. */
  73981. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  73982. /**
  73983. * Binds the bones information from the mesh to the effect.
  73984. * @param mesh The mesh we are binding the information to render
  73985. * @param effect The effect we are binding the data to
  73986. */
  73987. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  73988. /**
  73989. * Binds the morph targets information from the mesh to the effect.
  73990. * @param abstractMesh The mesh we are binding the information to render
  73991. * @param effect The effect we are binding the data to
  73992. */
  73993. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  73994. /**
  73995. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  73996. * @param defines The generated defines used in the effect
  73997. * @param effect The effect we are binding the data to
  73998. * @param scene The scene we are willing to render with logarithmic scale for
  73999. */
  74000. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  74001. /**
  74002. * Binds the clip plane information from the scene to the effect.
  74003. * @param scene The scene the clip plane information are extracted from
  74004. * @param effect The effect we are binding the data to
  74005. */
  74006. static BindClipPlane(effect: Effect, scene: Scene): void;
  74007. }
  74008. }
  74009. declare module BABYLON {
  74010. /** @hidden */
  74011. export var packingFunctions: {
  74012. name: string;
  74013. shader: string;
  74014. };
  74015. }
  74016. declare module BABYLON {
  74017. /** @hidden */
  74018. export var shadowMapPixelShader: {
  74019. name: string;
  74020. shader: string;
  74021. };
  74022. }
  74023. declare module BABYLON {
  74024. /** @hidden */
  74025. export var bonesDeclaration: {
  74026. name: string;
  74027. shader: string;
  74028. };
  74029. }
  74030. declare module BABYLON {
  74031. /** @hidden */
  74032. export var morphTargetsVertexGlobalDeclaration: {
  74033. name: string;
  74034. shader: string;
  74035. };
  74036. }
  74037. declare module BABYLON {
  74038. /** @hidden */
  74039. export var morphTargetsVertexDeclaration: {
  74040. name: string;
  74041. shader: string;
  74042. };
  74043. }
  74044. declare module BABYLON {
  74045. /** @hidden */
  74046. export var instancesDeclaration: {
  74047. name: string;
  74048. shader: string;
  74049. };
  74050. }
  74051. declare module BABYLON {
  74052. /** @hidden */
  74053. export var helperFunctions: {
  74054. name: string;
  74055. shader: string;
  74056. };
  74057. }
  74058. declare module BABYLON {
  74059. /** @hidden */
  74060. export var morphTargetsVertex: {
  74061. name: string;
  74062. shader: string;
  74063. };
  74064. }
  74065. declare module BABYLON {
  74066. /** @hidden */
  74067. export var instancesVertex: {
  74068. name: string;
  74069. shader: string;
  74070. };
  74071. }
  74072. declare module BABYLON {
  74073. /** @hidden */
  74074. export var bonesVertex: {
  74075. name: string;
  74076. shader: string;
  74077. };
  74078. }
  74079. declare module BABYLON {
  74080. /** @hidden */
  74081. export var shadowMapVertexShader: {
  74082. name: string;
  74083. shader: string;
  74084. };
  74085. }
  74086. declare module BABYLON {
  74087. /** @hidden */
  74088. export var depthBoxBlurPixelShader: {
  74089. name: string;
  74090. shader: string;
  74091. };
  74092. }
  74093. declare module BABYLON {
  74094. /**
  74095. * Defines the options associated with the creation of a custom shader for a shadow generator.
  74096. */
  74097. export interface ICustomShaderOptions {
  74098. /**
  74099. * Gets or sets the custom shader name to use
  74100. */
  74101. shaderName: string;
  74102. /**
  74103. * The list of attribute names used in the shader
  74104. */
  74105. attributes?: string[];
  74106. /**
  74107. * The list of unifrom names used in the shader
  74108. */
  74109. uniforms?: string[];
  74110. /**
  74111. * The list of sampler names used in the shader
  74112. */
  74113. samplers?: string[];
  74114. /**
  74115. * The list of defines used in the shader
  74116. */
  74117. defines?: string[];
  74118. }
  74119. /**
  74120. * Interface to implement to create a shadow generator compatible with BJS.
  74121. */
  74122. export interface IShadowGenerator {
  74123. /**
  74124. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  74125. * @returns The render target texture if present otherwise, null
  74126. */
  74127. getShadowMap(): Nullable<RenderTargetTexture>;
  74128. /**
  74129. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  74130. * @returns The render target texture if the shadow map is present otherwise, null
  74131. */
  74132. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  74133. /**
  74134. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  74135. * @param subMesh The submesh we want to render in the shadow map
  74136. * @param useInstances Defines wether will draw in the map using instances
  74137. * @returns true if ready otherwise, false
  74138. */
  74139. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  74140. /**
  74141. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  74142. * @param defines Defines of the material we want to update
  74143. * @param lightIndex Index of the light in the enabled light list of the material
  74144. */
  74145. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  74146. /**
  74147. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  74148. * defined in the generator but impacting the effect).
  74149. * It implies the unifroms available on the materials are the standard BJS ones.
  74150. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  74151. * @param effect The effect we are binfing the information for
  74152. */
  74153. bindShadowLight(lightIndex: string, effect: Effect): void;
  74154. /**
  74155. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  74156. * (eq to shadow prjection matrix * light transform matrix)
  74157. * @returns The transform matrix used to create the shadow map
  74158. */
  74159. getTransformMatrix(): Matrix;
  74160. /**
  74161. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  74162. * Cube and 2D textures for instance.
  74163. */
  74164. recreateShadowMap(): void;
  74165. /**
  74166. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74167. * @param onCompiled Callback triggered at the and of the effects compilation
  74168. * @param options Sets of optional options forcing the compilation with different modes
  74169. */
  74170. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  74171. useInstances: boolean;
  74172. }>): void;
  74173. /**
  74174. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74175. * @param options Sets of optional options forcing the compilation with different modes
  74176. * @returns A promise that resolves when the compilation completes
  74177. */
  74178. forceCompilationAsync(options?: Partial<{
  74179. useInstances: boolean;
  74180. }>): Promise<void>;
  74181. /**
  74182. * Serializes the shadow generator setup to a json object.
  74183. * @returns The serialized JSON object
  74184. */
  74185. serialize(): any;
  74186. /**
  74187. * Disposes the Shadow map and related Textures and effects.
  74188. */
  74189. dispose(): void;
  74190. }
  74191. /**
  74192. * Default implementation IShadowGenerator.
  74193. * This is the main object responsible of generating shadows in the framework.
  74194. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  74195. */
  74196. export class ShadowGenerator implements IShadowGenerator {
  74197. /**
  74198. * Shadow generator mode None: no filtering applied.
  74199. */
  74200. static readonly FILTER_NONE: number;
  74201. /**
  74202. * Shadow generator mode ESM: Exponential Shadow Mapping.
  74203. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  74204. */
  74205. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  74206. /**
  74207. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  74208. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  74209. */
  74210. static readonly FILTER_POISSONSAMPLING: number;
  74211. /**
  74212. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  74213. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  74214. */
  74215. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  74216. /**
  74217. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  74218. * edge artifacts on steep falloff.
  74219. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  74220. */
  74221. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  74222. /**
  74223. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  74224. * edge artifacts on steep falloff.
  74225. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  74226. */
  74227. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  74228. /**
  74229. * Shadow generator mode PCF: Percentage Closer Filtering
  74230. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  74231. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  74232. */
  74233. static readonly FILTER_PCF: number;
  74234. /**
  74235. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  74236. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  74237. * Contact Hardening
  74238. */
  74239. static readonly FILTER_PCSS: number;
  74240. /**
  74241. * Reserved for PCF and PCSS
  74242. * Highest Quality.
  74243. *
  74244. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  74245. *
  74246. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  74247. */
  74248. static readonly QUALITY_HIGH: number;
  74249. /**
  74250. * Reserved for PCF and PCSS
  74251. * Good tradeoff for quality/perf cross devices
  74252. *
  74253. * Execute PCF on a 3*3 kernel.
  74254. *
  74255. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  74256. */
  74257. static readonly QUALITY_MEDIUM: number;
  74258. /**
  74259. * Reserved for PCF and PCSS
  74260. * The lowest quality but the fastest.
  74261. *
  74262. * Execute PCF on a 1*1 kernel.
  74263. *
  74264. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  74265. */
  74266. static readonly QUALITY_LOW: number;
  74267. /** Gets or sets the custom shader name to use */
  74268. customShaderOptions: ICustomShaderOptions;
  74269. /**
  74270. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  74271. */
  74272. onBeforeShadowMapRenderObservable: Observable<Effect>;
  74273. /**
  74274. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  74275. */
  74276. onAfterShadowMapRenderObservable: Observable<Effect>;
  74277. /**
  74278. * Observable triggered before a mesh is rendered in the shadow map.
  74279. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  74280. */
  74281. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  74282. /**
  74283. * Observable triggered after a mesh is rendered in the shadow map.
  74284. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  74285. */
  74286. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  74287. private _bias;
  74288. /**
  74289. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  74290. */
  74291. /**
  74292. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  74293. */
  74294. bias: number;
  74295. private _normalBias;
  74296. /**
  74297. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  74298. */
  74299. /**
  74300. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  74301. */
  74302. normalBias: number;
  74303. private _blurBoxOffset;
  74304. /**
  74305. * Gets the blur box offset: offset applied during the blur pass.
  74306. * Only useful if useKernelBlur = false
  74307. */
  74308. /**
  74309. * Sets the blur box offset: offset applied during the blur pass.
  74310. * Only useful if useKernelBlur = false
  74311. */
  74312. blurBoxOffset: number;
  74313. private _blurScale;
  74314. /**
  74315. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  74316. * 2 means half of the size.
  74317. */
  74318. /**
  74319. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  74320. * 2 means half of the size.
  74321. */
  74322. blurScale: number;
  74323. private _blurKernel;
  74324. /**
  74325. * Gets the blur kernel: kernel size of the blur pass.
  74326. * Only useful if useKernelBlur = true
  74327. */
  74328. /**
  74329. * Sets the blur kernel: kernel size of the blur pass.
  74330. * Only useful if useKernelBlur = true
  74331. */
  74332. blurKernel: number;
  74333. private _useKernelBlur;
  74334. /**
  74335. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  74336. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  74337. */
  74338. /**
  74339. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  74340. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  74341. */
  74342. useKernelBlur: boolean;
  74343. private _depthScale;
  74344. /**
  74345. * Gets the depth scale used in ESM mode.
  74346. */
  74347. /**
  74348. * Sets the depth scale used in ESM mode.
  74349. * This can override the scale stored on the light.
  74350. */
  74351. depthScale: number;
  74352. private _filter;
  74353. /**
  74354. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  74355. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  74356. */
  74357. /**
  74358. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  74359. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  74360. */
  74361. filter: number;
  74362. /**
  74363. * Gets if the current filter is set to Poisson Sampling.
  74364. */
  74365. /**
  74366. * Sets the current filter to Poisson Sampling.
  74367. */
  74368. usePoissonSampling: boolean;
  74369. /**
  74370. * Gets if the current filter is set to ESM.
  74371. */
  74372. /**
  74373. * Sets the current filter is to ESM.
  74374. */
  74375. useExponentialShadowMap: boolean;
  74376. /**
  74377. * Gets if the current filter is set to filtered ESM.
  74378. */
  74379. /**
  74380. * Gets if the current filter is set to filtered ESM.
  74381. */
  74382. useBlurExponentialShadowMap: boolean;
  74383. /**
  74384. * Gets if the current filter is set to "close ESM" (using the inverse of the
  74385. * exponential to prevent steep falloff artifacts).
  74386. */
  74387. /**
  74388. * Sets the current filter to "close ESM" (using the inverse of the
  74389. * exponential to prevent steep falloff artifacts).
  74390. */
  74391. useCloseExponentialShadowMap: boolean;
  74392. /**
  74393. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  74394. * exponential to prevent steep falloff artifacts).
  74395. */
  74396. /**
  74397. * Sets the current filter to filtered "close ESM" (using the inverse of the
  74398. * exponential to prevent steep falloff artifacts).
  74399. */
  74400. useBlurCloseExponentialShadowMap: boolean;
  74401. /**
  74402. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  74403. */
  74404. /**
  74405. * Sets the current filter to "PCF" (percentage closer filtering).
  74406. */
  74407. usePercentageCloserFiltering: boolean;
  74408. private _filteringQuality;
  74409. /**
  74410. * Gets the PCF or PCSS Quality.
  74411. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  74412. */
  74413. /**
  74414. * Sets the PCF or PCSS Quality.
  74415. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  74416. */
  74417. filteringQuality: number;
  74418. /**
  74419. * Gets if the current filter is set to "PCSS" (contact hardening).
  74420. */
  74421. /**
  74422. * Sets the current filter to "PCSS" (contact hardening).
  74423. */
  74424. useContactHardeningShadow: boolean;
  74425. private _contactHardeningLightSizeUVRatio;
  74426. /**
  74427. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  74428. * Using a ratio helps keeping shape stability independently of the map size.
  74429. *
  74430. * It does not account for the light projection as it was having too much
  74431. * instability during the light setup or during light position changes.
  74432. *
  74433. * Only valid if useContactHardeningShadow is true.
  74434. */
  74435. /**
  74436. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  74437. * Using a ratio helps keeping shape stability independently of the map size.
  74438. *
  74439. * It does not account for the light projection as it was having too much
  74440. * instability during the light setup or during light position changes.
  74441. *
  74442. * Only valid if useContactHardeningShadow is true.
  74443. */
  74444. contactHardeningLightSizeUVRatio: number;
  74445. private _darkness;
  74446. /** Gets or sets the actual darkness of a shadow */
  74447. darkness: number;
  74448. /**
  74449. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  74450. * 0 means strongest and 1 would means no shadow.
  74451. * @returns the darkness.
  74452. */
  74453. getDarkness(): number;
  74454. /**
  74455. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  74456. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  74457. * @returns the shadow generator allowing fluent coding.
  74458. */
  74459. setDarkness(darkness: number): ShadowGenerator;
  74460. private _transparencyShadow;
  74461. /** Gets or sets the ability to have transparent shadow */
  74462. transparencyShadow: boolean;
  74463. /**
  74464. * Sets the ability to have transparent shadow (boolean).
  74465. * @param transparent True if transparent else False
  74466. * @returns the shadow generator allowing fluent coding
  74467. */
  74468. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  74469. private _shadowMap;
  74470. private _shadowMap2;
  74471. /**
  74472. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  74473. * @returns The render target texture if present otherwise, null
  74474. */
  74475. getShadowMap(): Nullable<RenderTargetTexture>;
  74476. /**
  74477. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  74478. * @returns The render target texture if the shadow map is present otherwise, null
  74479. */
  74480. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  74481. /**
  74482. * Gets the class name of that object
  74483. * @returns "ShadowGenerator"
  74484. */
  74485. getClassName(): string;
  74486. /**
  74487. * Helper function to add a mesh and its descendants to the list of shadow casters.
  74488. * @param mesh Mesh to add
  74489. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  74490. * @returns the Shadow Generator itself
  74491. */
  74492. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  74493. /**
  74494. * Helper function to remove a mesh and its descendants from the list of shadow casters
  74495. * @param mesh Mesh to remove
  74496. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  74497. * @returns the Shadow Generator itself
  74498. */
  74499. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  74500. /**
  74501. * Controls the extent to which the shadows fade out at the edge of the frustum
  74502. * Used only by directionals and spots
  74503. */
  74504. frustumEdgeFalloff: number;
  74505. private _light;
  74506. /**
  74507. * Returns the associated light object.
  74508. * @returns the light generating the shadow
  74509. */
  74510. getLight(): IShadowLight;
  74511. /**
  74512. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  74513. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  74514. * It might on the other hand introduce peter panning.
  74515. */
  74516. forceBackFacesOnly: boolean;
  74517. private _scene;
  74518. private _lightDirection;
  74519. private _effect;
  74520. private _viewMatrix;
  74521. private _projectionMatrix;
  74522. private _transformMatrix;
  74523. private _cachedPosition;
  74524. private _cachedDirection;
  74525. private _cachedDefines;
  74526. private _currentRenderID;
  74527. private _boxBlurPostprocess;
  74528. private _kernelBlurXPostprocess;
  74529. private _kernelBlurYPostprocess;
  74530. private _blurPostProcesses;
  74531. private _mapSize;
  74532. private _currentFaceIndex;
  74533. private _currentFaceIndexCache;
  74534. private _textureType;
  74535. private _defaultTextureMatrix;
  74536. /** @hidden */
  74537. static _SceneComponentInitialization: (scene: Scene) => void;
  74538. /**
  74539. * Creates a ShadowGenerator object.
  74540. * A ShadowGenerator is the required tool to use the shadows.
  74541. * Each light casting shadows needs to use its own ShadowGenerator.
  74542. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  74543. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  74544. * @param light The light object generating the shadows.
  74545. * @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.
  74546. */
  74547. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  74548. private _initializeGenerator;
  74549. private _initializeShadowMap;
  74550. private _initializeBlurRTTAndPostProcesses;
  74551. private _renderForShadowMap;
  74552. private _renderSubMeshForShadowMap;
  74553. private _applyFilterValues;
  74554. /**
  74555. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74556. * @param onCompiled Callback triggered at the and of the effects compilation
  74557. * @param options Sets of optional options forcing the compilation with different modes
  74558. */
  74559. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  74560. useInstances: boolean;
  74561. }>): void;
  74562. /**
  74563. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74564. * @param options Sets of optional options forcing the compilation with different modes
  74565. * @returns A promise that resolves when the compilation completes
  74566. */
  74567. forceCompilationAsync(options?: Partial<{
  74568. useInstances: boolean;
  74569. }>): Promise<void>;
  74570. /**
  74571. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  74572. * @param subMesh The submesh we want to render in the shadow map
  74573. * @param useInstances Defines wether will draw in the map using instances
  74574. * @returns true if ready otherwise, false
  74575. */
  74576. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  74577. /**
  74578. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  74579. * @param defines Defines of the material we want to update
  74580. * @param lightIndex Index of the light in the enabled light list of the material
  74581. */
  74582. prepareDefines(defines: any, lightIndex: number): void;
  74583. /**
  74584. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  74585. * defined in the generator but impacting the effect).
  74586. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  74587. * @param effect The effect we are binfing the information for
  74588. */
  74589. bindShadowLight(lightIndex: string, effect: Effect): void;
  74590. /**
  74591. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  74592. * (eq to shadow prjection matrix * light transform matrix)
  74593. * @returns The transform matrix used to create the shadow map
  74594. */
  74595. getTransformMatrix(): Matrix;
  74596. /**
  74597. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  74598. * Cube and 2D textures for instance.
  74599. */
  74600. recreateShadowMap(): void;
  74601. private _disposeBlurPostProcesses;
  74602. private _disposeRTTandPostProcesses;
  74603. /**
  74604. * Disposes the ShadowGenerator.
  74605. * Returns nothing.
  74606. */
  74607. dispose(): void;
  74608. /**
  74609. * Serializes the shadow generator setup to a json object.
  74610. * @returns The serialized JSON object
  74611. */
  74612. serialize(): any;
  74613. /**
  74614. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  74615. * @param parsedShadowGenerator The JSON object to parse
  74616. * @param scene The scene to create the shadow map for
  74617. * @returns The parsed shadow generator
  74618. */
  74619. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  74620. }
  74621. }
  74622. declare module BABYLON {
  74623. /**
  74624. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  74625. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  74626. * 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.
  74627. */
  74628. export abstract class Light extends Node {
  74629. /**
  74630. * Falloff Default: light is falling off following the material specification:
  74631. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  74632. */
  74633. static readonly FALLOFF_DEFAULT: number;
  74634. /**
  74635. * Falloff Physical: light is falling off following the inverse squared distance law.
  74636. */
  74637. static readonly FALLOFF_PHYSICAL: number;
  74638. /**
  74639. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  74640. * to enhance interoperability with other engines.
  74641. */
  74642. static readonly FALLOFF_GLTF: number;
  74643. /**
  74644. * Falloff Standard: light is falling off like in the standard material
  74645. * to enhance interoperability with other materials.
  74646. */
  74647. static readonly FALLOFF_STANDARD: number;
  74648. /**
  74649. * If every light affecting the material is in this lightmapMode,
  74650. * material.lightmapTexture adds or multiplies
  74651. * (depends on material.useLightmapAsShadowmap)
  74652. * after every other light calculations.
  74653. */
  74654. static readonly LIGHTMAP_DEFAULT: number;
  74655. /**
  74656. * material.lightmapTexture as only diffuse lighting from this light
  74657. * adds only specular lighting from this light
  74658. * adds dynamic shadows
  74659. */
  74660. static readonly LIGHTMAP_SPECULAR: number;
  74661. /**
  74662. * material.lightmapTexture as only lighting
  74663. * no light calculation from this light
  74664. * only adds dynamic shadows from this light
  74665. */
  74666. static readonly LIGHTMAP_SHADOWSONLY: number;
  74667. /**
  74668. * Each light type uses the default quantity according to its type:
  74669. * point/spot lights use luminous intensity
  74670. * directional lights use illuminance
  74671. */
  74672. static readonly INTENSITYMODE_AUTOMATIC: number;
  74673. /**
  74674. * lumen (lm)
  74675. */
  74676. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  74677. /**
  74678. * candela (lm/sr)
  74679. */
  74680. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  74681. /**
  74682. * lux (lm/m^2)
  74683. */
  74684. static readonly INTENSITYMODE_ILLUMINANCE: number;
  74685. /**
  74686. * nit (cd/m^2)
  74687. */
  74688. static readonly INTENSITYMODE_LUMINANCE: number;
  74689. /**
  74690. * Light type const id of the point light.
  74691. */
  74692. static readonly LIGHTTYPEID_POINTLIGHT: number;
  74693. /**
  74694. * Light type const id of the directional light.
  74695. */
  74696. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  74697. /**
  74698. * Light type const id of the spot light.
  74699. */
  74700. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  74701. /**
  74702. * Light type const id of the hemispheric light.
  74703. */
  74704. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  74705. /**
  74706. * Diffuse gives the basic color to an object.
  74707. */
  74708. diffuse: Color3;
  74709. /**
  74710. * Specular produces a highlight color on an object.
  74711. * Note: This is note affecting PBR materials.
  74712. */
  74713. specular: Color3;
  74714. /**
  74715. * Defines the falloff type for this light. This lets overrriding how punctual light are
  74716. * falling off base on range or angle.
  74717. * This can be set to any values in Light.FALLOFF_x.
  74718. *
  74719. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  74720. * other types of materials.
  74721. */
  74722. falloffType: number;
  74723. /**
  74724. * Strength of the light.
  74725. * Note: By default it is define in the framework own unit.
  74726. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  74727. */
  74728. intensity: number;
  74729. private _range;
  74730. protected _inverseSquaredRange: number;
  74731. /**
  74732. * Defines how far from the source the light is impacting in scene units.
  74733. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  74734. */
  74735. /**
  74736. * Defines how far from the source the light is impacting in scene units.
  74737. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  74738. */
  74739. range: number;
  74740. /**
  74741. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  74742. * of light.
  74743. */
  74744. private _photometricScale;
  74745. private _intensityMode;
  74746. /**
  74747. * Gets the photometric scale used to interpret the intensity.
  74748. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  74749. */
  74750. /**
  74751. * Sets the photometric scale used to interpret the intensity.
  74752. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  74753. */
  74754. intensityMode: number;
  74755. private _radius;
  74756. /**
  74757. * Gets the light radius used by PBR Materials to simulate soft area lights.
  74758. */
  74759. /**
  74760. * sets the light radius used by PBR Materials to simulate soft area lights.
  74761. */
  74762. radius: number;
  74763. private _renderPriority;
  74764. /**
  74765. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  74766. * exceeding the number allowed of the materials.
  74767. */
  74768. renderPriority: number;
  74769. private _shadowEnabled;
  74770. /**
  74771. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  74772. * the current shadow generator.
  74773. */
  74774. /**
  74775. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  74776. * the current shadow generator.
  74777. */
  74778. shadowEnabled: boolean;
  74779. private _includedOnlyMeshes;
  74780. /**
  74781. * Gets the only meshes impacted by this light.
  74782. */
  74783. /**
  74784. * Sets the only meshes impacted by this light.
  74785. */
  74786. includedOnlyMeshes: AbstractMesh[];
  74787. private _excludedMeshes;
  74788. /**
  74789. * Gets the meshes not impacted by this light.
  74790. */
  74791. /**
  74792. * Sets the meshes not impacted by this light.
  74793. */
  74794. excludedMeshes: AbstractMesh[];
  74795. private _excludeWithLayerMask;
  74796. /**
  74797. * Gets the layer id use to find what meshes are not impacted by the light.
  74798. * Inactive if 0
  74799. */
  74800. /**
  74801. * Sets the layer id use to find what meshes are not impacted by the light.
  74802. * Inactive if 0
  74803. */
  74804. excludeWithLayerMask: number;
  74805. private _includeOnlyWithLayerMask;
  74806. /**
  74807. * Gets the layer id use to find what meshes are impacted by the light.
  74808. * Inactive if 0
  74809. */
  74810. /**
  74811. * Sets the layer id use to find what meshes are impacted by the light.
  74812. * Inactive if 0
  74813. */
  74814. includeOnlyWithLayerMask: number;
  74815. private _lightmapMode;
  74816. /**
  74817. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  74818. */
  74819. /**
  74820. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  74821. */
  74822. lightmapMode: number;
  74823. /**
  74824. * Shadow generator associted to the light.
  74825. * @hidden Internal use only.
  74826. */
  74827. _shadowGenerator: Nullable<IShadowGenerator>;
  74828. /**
  74829. * @hidden Internal use only.
  74830. */
  74831. _excludedMeshesIds: string[];
  74832. /**
  74833. * @hidden Internal use only.
  74834. */
  74835. _includedOnlyMeshesIds: string[];
  74836. /**
  74837. * The current light unifom buffer.
  74838. * @hidden Internal use only.
  74839. */
  74840. _uniformBuffer: UniformBuffer;
  74841. /**
  74842. * Creates a Light object in the scene.
  74843. * Documentation : https://doc.babylonjs.com/babylon101/lights
  74844. * @param name The firendly name of the light
  74845. * @param scene The scene the light belongs too
  74846. */
  74847. constructor(name: string, scene: Scene);
  74848. protected abstract _buildUniformLayout(): void;
  74849. /**
  74850. * Sets the passed Effect "effect" with the Light information.
  74851. * @param effect The effect to update
  74852. * @param lightIndex The index of the light in the effect to update
  74853. * @returns The light
  74854. */
  74855. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  74856. /**
  74857. * Returns the string "Light".
  74858. * @returns the class name
  74859. */
  74860. getClassName(): string;
  74861. /** @hidden */
  74862. readonly _isLight: boolean;
  74863. /**
  74864. * Converts the light information to a readable string for debug purpose.
  74865. * @param fullDetails Supports for multiple levels of logging within scene loading
  74866. * @returns the human readable light info
  74867. */
  74868. toString(fullDetails?: boolean): string;
  74869. /** @hidden */
  74870. protected _syncParentEnabledState(): void;
  74871. /**
  74872. * Set the enabled state of this node.
  74873. * @param value - the new enabled state
  74874. */
  74875. setEnabled(value: boolean): void;
  74876. /**
  74877. * Returns the Light associated shadow generator if any.
  74878. * @return the associated shadow generator.
  74879. */
  74880. getShadowGenerator(): Nullable<IShadowGenerator>;
  74881. /**
  74882. * Returns a Vector3, the absolute light position in the World.
  74883. * @returns the world space position of the light
  74884. */
  74885. getAbsolutePosition(): Vector3;
  74886. /**
  74887. * Specifies if the light will affect the passed mesh.
  74888. * @param mesh The mesh to test against the light
  74889. * @return true the mesh is affected otherwise, false.
  74890. */
  74891. canAffectMesh(mesh: AbstractMesh): boolean;
  74892. /**
  74893. * Sort function to order lights for rendering.
  74894. * @param a First Light object to compare to second.
  74895. * @param b Second Light object to compare first.
  74896. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  74897. */
  74898. static CompareLightsPriority(a: Light, b: Light): number;
  74899. /**
  74900. * Releases resources associated with this node.
  74901. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  74902. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  74903. */
  74904. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  74905. /**
  74906. * Returns the light type ID (integer).
  74907. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  74908. */
  74909. getTypeID(): number;
  74910. /**
  74911. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  74912. * @returns the scaled intensity in intensity mode unit
  74913. */
  74914. getScaledIntensity(): number;
  74915. /**
  74916. * Returns a new Light object, named "name", from the current one.
  74917. * @param name The name of the cloned light
  74918. * @returns the new created light
  74919. */
  74920. clone(name: string): Nullable<Light>;
  74921. /**
  74922. * Serializes the current light into a Serialization object.
  74923. * @returns the serialized object.
  74924. */
  74925. serialize(): any;
  74926. /**
  74927. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  74928. * This new light is named "name" and added to the passed scene.
  74929. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  74930. * @param name The friendly name of the light
  74931. * @param scene The scene the new light will belong to
  74932. * @returns the constructor function
  74933. */
  74934. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  74935. /**
  74936. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  74937. * @param parsedLight The JSON representation of the light
  74938. * @param scene The scene to create the parsed light in
  74939. * @returns the created light after parsing
  74940. */
  74941. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  74942. private _hookArrayForExcluded;
  74943. private _hookArrayForIncludedOnly;
  74944. private _resyncMeshes;
  74945. /**
  74946. * Forces the meshes to update their light related information in their rendering used effects
  74947. * @hidden Internal Use Only
  74948. */
  74949. _markMeshesAsLightDirty(): void;
  74950. /**
  74951. * Recomputes the cached photometric scale if needed.
  74952. */
  74953. private _computePhotometricScale;
  74954. /**
  74955. * Returns the Photometric Scale according to the light type and intensity mode.
  74956. */
  74957. private _getPhotometricScale;
  74958. /**
  74959. * Reorder the light in the scene according to their defined priority.
  74960. * @hidden Internal Use Only
  74961. */
  74962. _reorderLightsInScene(): void;
  74963. /**
  74964. * Prepares the list of defines specific to the light type.
  74965. * @param defines the list of defines
  74966. * @param lightIndex defines the index of the light for the effect
  74967. */
  74968. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  74969. }
  74970. }
  74971. declare module BABYLON {
  74972. /**
  74973. * Interface used to define Action
  74974. */
  74975. export interface IAction {
  74976. /**
  74977. * Trigger for the action
  74978. */
  74979. trigger: number;
  74980. /** Options of the trigger */
  74981. triggerOptions: any;
  74982. /**
  74983. * Gets the trigger parameters
  74984. * @returns the trigger parameters
  74985. */
  74986. getTriggerParameter(): any;
  74987. /**
  74988. * Internal only - executes current action event
  74989. * @hidden
  74990. */
  74991. _executeCurrent(evt?: ActionEvent): void;
  74992. /**
  74993. * Serialize placeholder for child classes
  74994. * @param parent of child
  74995. * @returns the serialized object
  74996. */
  74997. serialize(parent: any): any;
  74998. /**
  74999. * Internal only
  75000. * @hidden
  75001. */
  75002. _prepare(): void;
  75003. /**
  75004. * Internal only - manager for action
  75005. * @hidden
  75006. */
  75007. _actionManager: AbstractActionManager;
  75008. /**
  75009. * Adds action to chain of actions, may be a DoNothingAction
  75010. * @param action defines the next action to execute
  75011. * @returns The action passed in
  75012. * @see https://www.babylonjs-playground.com/#1T30HR#0
  75013. */
  75014. then(action: IAction): IAction;
  75015. }
  75016. /**
  75017. * The action to be carried out following a trigger
  75018. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  75019. */
  75020. export class Action implements IAction {
  75021. /** the trigger, with or without parameters, for the action */
  75022. triggerOptions: any;
  75023. /**
  75024. * Trigger for the action
  75025. */
  75026. trigger: number;
  75027. /**
  75028. * Internal only - manager for action
  75029. * @hidden
  75030. */
  75031. _actionManager: ActionManager;
  75032. private _nextActiveAction;
  75033. private _child;
  75034. private _condition?;
  75035. private _triggerParameter;
  75036. /**
  75037. * An event triggered prior to action being executed.
  75038. */
  75039. onBeforeExecuteObservable: Observable<Action>;
  75040. /**
  75041. * Creates a new Action
  75042. * @param triggerOptions the trigger, with or without parameters, for the action
  75043. * @param condition an optional determinant of action
  75044. */
  75045. constructor(
  75046. /** the trigger, with or without parameters, for the action */
  75047. triggerOptions: any, condition?: Condition);
  75048. /**
  75049. * Internal only
  75050. * @hidden
  75051. */
  75052. _prepare(): void;
  75053. /**
  75054. * Gets the trigger parameters
  75055. * @returns the trigger parameters
  75056. */
  75057. getTriggerParameter(): any;
  75058. /**
  75059. * Internal only - executes current action event
  75060. * @hidden
  75061. */
  75062. _executeCurrent(evt?: ActionEvent): void;
  75063. /**
  75064. * Execute placeholder for child classes
  75065. * @param evt optional action event
  75066. */
  75067. execute(evt?: ActionEvent): void;
  75068. /**
  75069. * Skips to next active action
  75070. */
  75071. skipToNextActiveAction(): void;
  75072. /**
  75073. * Adds action to chain of actions, may be a DoNothingAction
  75074. * @param action defines the next action to execute
  75075. * @returns The action passed in
  75076. * @see https://www.babylonjs-playground.com/#1T30HR#0
  75077. */
  75078. then(action: Action): Action;
  75079. /**
  75080. * Internal only
  75081. * @hidden
  75082. */
  75083. _getProperty(propertyPath: string): string;
  75084. /**
  75085. * Internal only
  75086. * @hidden
  75087. */
  75088. _getEffectiveTarget(target: any, propertyPath: string): any;
  75089. /**
  75090. * Serialize placeholder for child classes
  75091. * @param parent of child
  75092. * @returns the serialized object
  75093. */
  75094. serialize(parent: any): any;
  75095. /**
  75096. * Internal only called by serialize
  75097. * @hidden
  75098. */
  75099. protected _serialize(serializedAction: any, parent?: any): any;
  75100. /**
  75101. * Internal only
  75102. * @hidden
  75103. */
  75104. static _SerializeValueAsString: (value: any) => string;
  75105. /**
  75106. * Internal only
  75107. * @hidden
  75108. */
  75109. static _GetTargetProperty: (target: Node | Scene) => {
  75110. name: string;
  75111. targetType: string;
  75112. value: string;
  75113. };
  75114. }
  75115. }
  75116. declare module BABYLON {
  75117. /**
  75118. * A Condition applied to an Action
  75119. */
  75120. export class Condition {
  75121. /**
  75122. * Internal only - manager for action
  75123. * @hidden
  75124. */
  75125. _actionManager: ActionManager;
  75126. /**
  75127. * Internal only
  75128. * @hidden
  75129. */
  75130. _evaluationId: number;
  75131. /**
  75132. * Internal only
  75133. * @hidden
  75134. */
  75135. _currentResult: boolean;
  75136. /**
  75137. * Creates a new Condition
  75138. * @param actionManager the manager of the action the condition is applied to
  75139. */
  75140. constructor(actionManager: ActionManager);
  75141. /**
  75142. * Check if the current condition is valid
  75143. * @returns a boolean
  75144. */
  75145. isValid(): boolean;
  75146. /**
  75147. * Internal only
  75148. * @hidden
  75149. */
  75150. _getProperty(propertyPath: string): string;
  75151. /**
  75152. * Internal only
  75153. * @hidden
  75154. */
  75155. _getEffectiveTarget(target: any, propertyPath: string): any;
  75156. /**
  75157. * Serialize placeholder for child classes
  75158. * @returns the serialized object
  75159. */
  75160. serialize(): any;
  75161. /**
  75162. * Internal only
  75163. * @hidden
  75164. */
  75165. protected _serialize(serializedCondition: any): any;
  75166. }
  75167. /**
  75168. * Defines specific conditional operators as extensions of Condition
  75169. */
  75170. export class ValueCondition extends Condition {
  75171. /** path to specify the property of the target the conditional operator uses */
  75172. propertyPath: string;
  75173. /** the value compared by the conditional operator against the current value of the property */
  75174. value: any;
  75175. /** the conditional operator, default ValueCondition.IsEqual */
  75176. operator: number;
  75177. /**
  75178. * Internal only
  75179. * @hidden
  75180. */
  75181. private static _IsEqual;
  75182. /**
  75183. * Internal only
  75184. * @hidden
  75185. */
  75186. private static _IsDifferent;
  75187. /**
  75188. * Internal only
  75189. * @hidden
  75190. */
  75191. private static _IsGreater;
  75192. /**
  75193. * Internal only
  75194. * @hidden
  75195. */
  75196. private static _IsLesser;
  75197. /**
  75198. * returns the number for IsEqual
  75199. */
  75200. static readonly IsEqual: number;
  75201. /**
  75202. * Returns the number for IsDifferent
  75203. */
  75204. static readonly IsDifferent: number;
  75205. /**
  75206. * Returns the number for IsGreater
  75207. */
  75208. static readonly IsGreater: number;
  75209. /**
  75210. * Returns the number for IsLesser
  75211. */
  75212. static readonly IsLesser: number;
  75213. /**
  75214. * Internal only The action manager for the condition
  75215. * @hidden
  75216. */
  75217. _actionManager: ActionManager;
  75218. /**
  75219. * Internal only
  75220. * @hidden
  75221. */
  75222. private _target;
  75223. /**
  75224. * Internal only
  75225. * @hidden
  75226. */
  75227. private _effectiveTarget;
  75228. /**
  75229. * Internal only
  75230. * @hidden
  75231. */
  75232. private _property;
  75233. /**
  75234. * Creates a new ValueCondition
  75235. * @param actionManager manager for the action the condition applies to
  75236. * @param target for the action
  75237. * @param propertyPath path to specify the property of the target the conditional operator uses
  75238. * @param value the value compared by the conditional operator against the current value of the property
  75239. * @param operator the conditional operator, default ValueCondition.IsEqual
  75240. */
  75241. constructor(actionManager: ActionManager, target: any,
  75242. /** path to specify the property of the target the conditional operator uses */
  75243. propertyPath: string,
  75244. /** the value compared by the conditional operator against the current value of the property */
  75245. value: any,
  75246. /** the conditional operator, default ValueCondition.IsEqual */
  75247. operator?: number);
  75248. /**
  75249. * Compares the given value with the property value for the specified conditional operator
  75250. * @returns the result of the comparison
  75251. */
  75252. isValid(): boolean;
  75253. /**
  75254. * Serialize the ValueCondition into a JSON compatible object
  75255. * @returns serialization object
  75256. */
  75257. serialize(): any;
  75258. /**
  75259. * Gets the name of the conditional operator for the ValueCondition
  75260. * @param operator the conditional operator
  75261. * @returns the name
  75262. */
  75263. static GetOperatorName(operator: number): string;
  75264. }
  75265. /**
  75266. * Defines a predicate condition as an extension of Condition
  75267. */
  75268. export class PredicateCondition extends Condition {
  75269. /** defines the predicate function used to validate the condition */
  75270. predicate: () => boolean;
  75271. /**
  75272. * Internal only - manager for action
  75273. * @hidden
  75274. */
  75275. _actionManager: ActionManager;
  75276. /**
  75277. * Creates a new PredicateCondition
  75278. * @param actionManager manager for the action the condition applies to
  75279. * @param predicate defines the predicate function used to validate the condition
  75280. */
  75281. constructor(actionManager: ActionManager,
  75282. /** defines the predicate function used to validate the condition */
  75283. predicate: () => boolean);
  75284. /**
  75285. * @returns the validity of the predicate condition
  75286. */
  75287. isValid(): boolean;
  75288. }
  75289. /**
  75290. * Defines a state condition as an extension of Condition
  75291. */
  75292. export class StateCondition extends Condition {
  75293. /** Value to compare with target state */
  75294. value: string;
  75295. /**
  75296. * Internal only - manager for action
  75297. * @hidden
  75298. */
  75299. _actionManager: ActionManager;
  75300. /**
  75301. * Internal only
  75302. * @hidden
  75303. */
  75304. private _target;
  75305. /**
  75306. * Creates a new StateCondition
  75307. * @param actionManager manager for the action the condition applies to
  75308. * @param target of the condition
  75309. * @param value to compare with target state
  75310. */
  75311. constructor(actionManager: ActionManager, target: any,
  75312. /** Value to compare with target state */
  75313. value: string);
  75314. /**
  75315. * Gets a boolean indicating if the current condition is met
  75316. * @returns the validity of the state
  75317. */
  75318. isValid(): boolean;
  75319. /**
  75320. * Serialize the StateCondition into a JSON compatible object
  75321. * @returns serialization object
  75322. */
  75323. serialize(): any;
  75324. }
  75325. }
  75326. declare module BABYLON {
  75327. /**
  75328. * This defines an action responsible to toggle a boolean once triggered.
  75329. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75330. */
  75331. export class SwitchBooleanAction extends Action {
  75332. /**
  75333. * The path to the boolean property in the target object
  75334. */
  75335. propertyPath: string;
  75336. private _target;
  75337. private _effectiveTarget;
  75338. private _property;
  75339. /**
  75340. * Instantiate the action
  75341. * @param triggerOptions defines the trigger options
  75342. * @param target defines the object containing the boolean
  75343. * @param propertyPath defines the path to the boolean property in the target object
  75344. * @param condition defines the trigger related conditions
  75345. */
  75346. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  75347. /** @hidden */
  75348. _prepare(): void;
  75349. /**
  75350. * Execute the action toggle the boolean value.
  75351. */
  75352. execute(): void;
  75353. /**
  75354. * Serializes the actions and its related information.
  75355. * @param parent defines the object to serialize in
  75356. * @returns the serialized object
  75357. */
  75358. serialize(parent: any): any;
  75359. }
  75360. /**
  75361. * This defines an action responsible to set a the state field of the target
  75362. * to a desired value once triggered.
  75363. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75364. */
  75365. export class SetStateAction extends Action {
  75366. /**
  75367. * The value to store in the state field.
  75368. */
  75369. value: string;
  75370. private _target;
  75371. /**
  75372. * Instantiate the action
  75373. * @param triggerOptions defines the trigger options
  75374. * @param target defines the object containing the state property
  75375. * @param value defines the value to store in the state field
  75376. * @param condition defines the trigger related conditions
  75377. */
  75378. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  75379. /**
  75380. * Execute the action and store the value on the target state property.
  75381. */
  75382. execute(): void;
  75383. /**
  75384. * Serializes the actions and its related information.
  75385. * @param parent defines the object to serialize in
  75386. * @returns the serialized object
  75387. */
  75388. serialize(parent: any): any;
  75389. }
  75390. /**
  75391. * This defines an action responsible to set a property of the target
  75392. * to a desired value once triggered.
  75393. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75394. */
  75395. export class SetValueAction extends Action {
  75396. /**
  75397. * The path of the property to set in the target.
  75398. */
  75399. propertyPath: string;
  75400. /**
  75401. * The value to set in the property
  75402. */
  75403. value: any;
  75404. private _target;
  75405. private _effectiveTarget;
  75406. private _property;
  75407. /**
  75408. * Instantiate the action
  75409. * @param triggerOptions defines the trigger options
  75410. * @param target defines the object containing the property
  75411. * @param propertyPath defines the path of the property to set in the target
  75412. * @param value defines the value to set in the property
  75413. * @param condition defines the trigger related conditions
  75414. */
  75415. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  75416. /** @hidden */
  75417. _prepare(): void;
  75418. /**
  75419. * Execute the action and set the targetted property to the desired value.
  75420. */
  75421. execute(): void;
  75422. /**
  75423. * Serializes the actions and its related information.
  75424. * @param parent defines the object to serialize in
  75425. * @returns the serialized object
  75426. */
  75427. serialize(parent: any): any;
  75428. }
  75429. /**
  75430. * This defines an action responsible to increment the target value
  75431. * to a desired value once triggered.
  75432. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75433. */
  75434. export class IncrementValueAction extends Action {
  75435. /**
  75436. * The path of the property to increment in the target.
  75437. */
  75438. propertyPath: string;
  75439. /**
  75440. * The value we should increment the property by.
  75441. */
  75442. value: any;
  75443. private _target;
  75444. private _effectiveTarget;
  75445. private _property;
  75446. /**
  75447. * Instantiate the action
  75448. * @param triggerOptions defines the trigger options
  75449. * @param target defines the object containing the property
  75450. * @param propertyPath defines the path of the property to increment in the target
  75451. * @param value defines the value value we should increment the property by
  75452. * @param condition defines the trigger related conditions
  75453. */
  75454. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  75455. /** @hidden */
  75456. _prepare(): void;
  75457. /**
  75458. * Execute the action and increment the target of the value amount.
  75459. */
  75460. execute(): void;
  75461. /**
  75462. * Serializes the actions and its related information.
  75463. * @param parent defines the object to serialize in
  75464. * @returns the serialized object
  75465. */
  75466. serialize(parent: any): any;
  75467. }
  75468. /**
  75469. * This defines an action responsible to start an animation once triggered.
  75470. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75471. */
  75472. export class PlayAnimationAction extends Action {
  75473. /**
  75474. * Where the animation should start (animation frame)
  75475. */
  75476. from: number;
  75477. /**
  75478. * Where the animation should stop (animation frame)
  75479. */
  75480. to: number;
  75481. /**
  75482. * Define if the animation should loop or stop after the first play.
  75483. */
  75484. loop?: boolean;
  75485. private _target;
  75486. /**
  75487. * Instantiate the action
  75488. * @param triggerOptions defines the trigger options
  75489. * @param target defines the target animation or animation name
  75490. * @param from defines from where the animation should start (animation frame)
  75491. * @param end defines where the animation should stop (animation frame)
  75492. * @param loop defines if the animation should loop or stop after the first play
  75493. * @param condition defines the trigger related conditions
  75494. */
  75495. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  75496. /** @hidden */
  75497. _prepare(): void;
  75498. /**
  75499. * Execute the action and play the animation.
  75500. */
  75501. execute(): void;
  75502. /**
  75503. * Serializes the actions and its related information.
  75504. * @param parent defines the object to serialize in
  75505. * @returns the serialized object
  75506. */
  75507. serialize(parent: any): any;
  75508. }
  75509. /**
  75510. * This defines an action responsible to stop an animation once triggered.
  75511. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75512. */
  75513. export class StopAnimationAction extends Action {
  75514. private _target;
  75515. /**
  75516. * Instantiate the action
  75517. * @param triggerOptions defines the trigger options
  75518. * @param target defines the target animation or animation name
  75519. * @param condition defines the trigger related conditions
  75520. */
  75521. constructor(triggerOptions: any, target: any, condition?: Condition);
  75522. /** @hidden */
  75523. _prepare(): void;
  75524. /**
  75525. * Execute the action and stop the animation.
  75526. */
  75527. execute(): void;
  75528. /**
  75529. * Serializes the actions and its related information.
  75530. * @param parent defines the object to serialize in
  75531. * @returns the serialized object
  75532. */
  75533. serialize(parent: any): any;
  75534. }
  75535. /**
  75536. * This defines an action responsible that does nothing once triggered.
  75537. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75538. */
  75539. export class DoNothingAction extends Action {
  75540. /**
  75541. * Instantiate the action
  75542. * @param triggerOptions defines the trigger options
  75543. * @param condition defines the trigger related conditions
  75544. */
  75545. constructor(triggerOptions?: any, condition?: Condition);
  75546. /**
  75547. * Execute the action and do nothing.
  75548. */
  75549. execute(): void;
  75550. /**
  75551. * Serializes the actions and its related information.
  75552. * @param parent defines the object to serialize in
  75553. * @returns the serialized object
  75554. */
  75555. serialize(parent: any): any;
  75556. }
  75557. /**
  75558. * This defines an action responsible to trigger several actions once triggered.
  75559. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75560. */
  75561. export class CombineAction extends Action {
  75562. /**
  75563. * The list of aggregated animations to run.
  75564. */
  75565. children: Action[];
  75566. /**
  75567. * Instantiate the action
  75568. * @param triggerOptions defines the trigger options
  75569. * @param children defines the list of aggregated animations to run
  75570. * @param condition defines the trigger related conditions
  75571. */
  75572. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  75573. /** @hidden */
  75574. _prepare(): void;
  75575. /**
  75576. * Execute the action and executes all the aggregated actions.
  75577. */
  75578. execute(evt: ActionEvent): void;
  75579. /**
  75580. * Serializes the actions and its related information.
  75581. * @param parent defines the object to serialize in
  75582. * @returns the serialized object
  75583. */
  75584. serialize(parent: any): any;
  75585. }
  75586. /**
  75587. * This defines an action responsible to run code (external event) once triggered.
  75588. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75589. */
  75590. export class ExecuteCodeAction extends Action {
  75591. /**
  75592. * The callback function to run.
  75593. */
  75594. func: (evt: ActionEvent) => void;
  75595. /**
  75596. * Instantiate the action
  75597. * @param triggerOptions defines the trigger options
  75598. * @param func defines the callback function to run
  75599. * @param condition defines the trigger related conditions
  75600. */
  75601. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  75602. /**
  75603. * Execute the action and run the attached code.
  75604. */
  75605. execute(evt: ActionEvent): void;
  75606. }
  75607. /**
  75608. * This defines an action responsible to set the parent property of the target once triggered.
  75609. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75610. */
  75611. export class SetParentAction extends Action {
  75612. private _parent;
  75613. private _target;
  75614. /**
  75615. * Instantiate the action
  75616. * @param triggerOptions defines the trigger options
  75617. * @param target defines the target containing the parent property
  75618. * @param parent defines from where the animation should start (animation frame)
  75619. * @param condition defines the trigger related conditions
  75620. */
  75621. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  75622. /** @hidden */
  75623. _prepare(): void;
  75624. /**
  75625. * Execute the action and set the parent property.
  75626. */
  75627. execute(): void;
  75628. /**
  75629. * Serializes the actions and its related information.
  75630. * @param parent defines the object to serialize in
  75631. * @returns the serialized object
  75632. */
  75633. serialize(parent: any): any;
  75634. }
  75635. }
  75636. declare module BABYLON {
  75637. /**
  75638. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  75639. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  75640. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75641. */
  75642. export class ActionManager extends AbstractActionManager {
  75643. /**
  75644. * Nothing
  75645. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75646. */
  75647. static readonly NothingTrigger: number;
  75648. /**
  75649. * On pick
  75650. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75651. */
  75652. static readonly OnPickTrigger: number;
  75653. /**
  75654. * On left pick
  75655. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75656. */
  75657. static readonly OnLeftPickTrigger: number;
  75658. /**
  75659. * On right pick
  75660. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75661. */
  75662. static readonly OnRightPickTrigger: number;
  75663. /**
  75664. * On center pick
  75665. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75666. */
  75667. static readonly OnCenterPickTrigger: number;
  75668. /**
  75669. * On pick down
  75670. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75671. */
  75672. static readonly OnPickDownTrigger: number;
  75673. /**
  75674. * On double pick
  75675. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75676. */
  75677. static readonly OnDoublePickTrigger: number;
  75678. /**
  75679. * On pick up
  75680. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75681. */
  75682. static readonly OnPickUpTrigger: number;
  75683. /**
  75684. * On pick out.
  75685. * This trigger will only be raised if you also declared a OnPickDown
  75686. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75687. */
  75688. static readonly OnPickOutTrigger: number;
  75689. /**
  75690. * On long press
  75691. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75692. */
  75693. static readonly OnLongPressTrigger: number;
  75694. /**
  75695. * On pointer over
  75696. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75697. */
  75698. static readonly OnPointerOverTrigger: number;
  75699. /**
  75700. * On pointer out
  75701. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75702. */
  75703. static readonly OnPointerOutTrigger: number;
  75704. /**
  75705. * On every frame
  75706. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75707. */
  75708. static readonly OnEveryFrameTrigger: number;
  75709. /**
  75710. * On intersection enter
  75711. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75712. */
  75713. static readonly OnIntersectionEnterTrigger: number;
  75714. /**
  75715. * On intersection exit
  75716. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75717. */
  75718. static readonly OnIntersectionExitTrigger: number;
  75719. /**
  75720. * On key down
  75721. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75722. */
  75723. static readonly OnKeyDownTrigger: number;
  75724. /**
  75725. * On key up
  75726. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75727. */
  75728. static readonly OnKeyUpTrigger: number;
  75729. private _scene;
  75730. /**
  75731. * Creates a new action manager
  75732. * @param scene defines the hosting scene
  75733. */
  75734. constructor(scene: Scene);
  75735. /**
  75736. * Releases all associated resources
  75737. */
  75738. dispose(): void;
  75739. /**
  75740. * Gets hosting scene
  75741. * @returns the hosting scene
  75742. */
  75743. getScene(): Scene;
  75744. /**
  75745. * Does this action manager handles actions of any of the given triggers
  75746. * @param triggers defines the triggers to be tested
  75747. * @return a boolean indicating whether one (or more) of the triggers is handled
  75748. */
  75749. hasSpecificTriggers(triggers: number[]): boolean;
  75750. /**
  75751. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  75752. * speed.
  75753. * @param triggerA defines the trigger to be tested
  75754. * @param triggerB defines the trigger to be tested
  75755. * @return a boolean indicating whether one (or more) of the triggers is handled
  75756. */
  75757. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  75758. /**
  75759. * Does this action manager handles actions of a given trigger
  75760. * @param trigger defines the trigger to be tested
  75761. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  75762. * @return whether the trigger is handled
  75763. */
  75764. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  75765. /**
  75766. * Does this action manager has pointer triggers
  75767. */
  75768. readonly hasPointerTriggers: boolean;
  75769. /**
  75770. * Does this action manager has pick triggers
  75771. */
  75772. readonly hasPickTriggers: boolean;
  75773. /**
  75774. * Registers an action to this action manager
  75775. * @param action defines the action to be registered
  75776. * @return the action amended (prepared) after registration
  75777. */
  75778. registerAction(action: IAction): Nullable<IAction>;
  75779. /**
  75780. * Unregisters an action to this action manager
  75781. * @param action defines the action to be unregistered
  75782. * @return a boolean indicating whether the action has been unregistered
  75783. */
  75784. unregisterAction(action: IAction): Boolean;
  75785. /**
  75786. * Process a specific trigger
  75787. * @param trigger defines the trigger to process
  75788. * @param evt defines the event details to be processed
  75789. */
  75790. processTrigger(trigger: number, evt?: IActionEvent): void;
  75791. /** @hidden */
  75792. _getEffectiveTarget(target: any, propertyPath: string): any;
  75793. /** @hidden */
  75794. _getProperty(propertyPath: string): string;
  75795. /**
  75796. * Serialize this manager to a JSON object
  75797. * @param name defines the property name to store this manager
  75798. * @returns a JSON representation of this manager
  75799. */
  75800. serialize(name: string): any;
  75801. /**
  75802. * Creates a new ActionManager from a JSON data
  75803. * @param parsedActions defines the JSON data to read from
  75804. * @param object defines the hosting mesh
  75805. * @param scene defines the hosting scene
  75806. */
  75807. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  75808. /**
  75809. * Get a trigger name by index
  75810. * @param trigger defines the trigger index
  75811. * @returns a trigger name
  75812. */
  75813. static GetTriggerName(trigger: number): string;
  75814. }
  75815. }
  75816. declare module BABYLON {
  75817. /**
  75818. * Class representing a ray with position and direction
  75819. */
  75820. export class Ray {
  75821. /** origin point */
  75822. origin: Vector3;
  75823. /** direction */
  75824. direction: Vector3;
  75825. /** length of the ray */
  75826. length: number;
  75827. private static readonly TmpVector3;
  75828. private _tmpRay;
  75829. /**
  75830. * Creates a new ray
  75831. * @param origin origin point
  75832. * @param direction direction
  75833. * @param length length of the ray
  75834. */
  75835. constructor(
  75836. /** origin point */
  75837. origin: Vector3,
  75838. /** direction */
  75839. direction: Vector3,
  75840. /** length of the ray */
  75841. length?: number);
  75842. /**
  75843. * Checks if the ray intersects a box
  75844. * @param minimum bound of the box
  75845. * @param maximum bound of the box
  75846. * @param intersectionTreshold extra extend to be added to the box in all direction
  75847. * @returns if the box was hit
  75848. */
  75849. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  75850. /**
  75851. * Checks if the ray intersects a box
  75852. * @param box the bounding box to check
  75853. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  75854. * @returns if the box was hit
  75855. */
  75856. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  75857. /**
  75858. * If the ray hits a sphere
  75859. * @param sphere the bounding sphere to check
  75860. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  75861. * @returns true if it hits the sphere
  75862. */
  75863. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  75864. /**
  75865. * If the ray hits a triange
  75866. * @param vertex0 triangle vertex
  75867. * @param vertex1 triangle vertex
  75868. * @param vertex2 triangle vertex
  75869. * @returns intersection information if hit
  75870. */
  75871. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  75872. /**
  75873. * Checks if ray intersects a plane
  75874. * @param plane the plane to check
  75875. * @returns the distance away it was hit
  75876. */
  75877. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  75878. /**
  75879. * Calculate the intercept of a ray on a given axis
  75880. * @param axis to check 'x' | 'y' | 'z'
  75881. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  75882. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  75883. */
  75884. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  75885. /**
  75886. * Checks if ray intersects a mesh
  75887. * @param mesh the mesh to check
  75888. * @param fastCheck if only the bounding box should checked
  75889. * @returns picking info of the intersecton
  75890. */
  75891. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  75892. /**
  75893. * Checks if ray intersects a mesh
  75894. * @param meshes the meshes to check
  75895. * @param fastCheck if only the bounding box should checked
  75896. * @param results array to store result in
  75897. * @returns Array of picking infos
  75898. */
  75899. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  75900. private _comparePickingInfo;
  75901. private static smallnum;
  75902. private static rayl;
  75903. /**
  75904. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  75905. * @param sega the first point of the segment to test the intersection against
  75906. * @param segb the second point of the segment to test the intersection against
  75907. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  75908. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  75909. */
  75910. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  75911. /**
  75912. * Update the ray from viewport position
  75913. * @param x position
  75914. * @param y y position
  75915. * @param viewportWidth viewport width
  75916. * @param viewportHeight viewport height
  75917. * @param world world matrix
  75918. * @param view view matrix
  75919. * @param projection projection matrix
  75920. * @returns this ray updated
  75921. */
  75922. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  75923. /**
  75924. * Creates a ray with origin and direction of 0,0,0
  75925. * @returns the new ray
  75926. */
  75927. static Zero(): Ray;
  75928. /**
  75929. * Creates a new ray from screen space and viewport
  75930. * @param x position
  75931. * @param y y position
  75932. * @param viewportWidth viewport width
  75933. * @param viewportHeight viewport height
  75934. * @param world world matrix
  75935. * @param view view matrix
  75936. * @param projection projection matrix
  75937. * @returns new ray
  75938. */
  75939. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  75940. /**
  75941. * 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
  75942. * transformed to the given world matrix.
  75943. * @param origin The origin point
  75944. * @param end The end point
  75945. * @param world a matrix to transform the ray to. Default is the identity matrix.
  75946. * @returns the new ray
  75947. */
  75948. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  75949. /**
  75950. * Transforms a ray by a matrix
  75951. * @param ray ray to transform
  75952. * @param matrix matrix to apply
  75953. * @returns the resulting new ray
  75954. */
  75955. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  75956. /**
  75957. * Transforms a ray by a matrix
  75958. * @param ray ray to transform
  75959. * @param matrix matrix to apply
  75960. * @param result ray to store result in
  75961. */
  75962. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  75963. /**
  75964. * Unproject a ray from screen space to object space
  75965. * @param sourceX defines the screen space x coordinate to use
  75966. * @param sourceY defines the screen space y coordinate to use
  75967. * @param viewportWidth defines the current width of the viewport
  75968. * @param viewportHeight defines the current height of the viewport
  75969. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  75970. * @param view defines the view matrix to use
  75971. * @param projection defines the projection matrix to use
  75972. */
  75973. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  75974. }
  75975. /**
  75976. * Type used to define predicate used to select faces when a mesh intersection is detected
  75977. */
  75978. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  75979. interface Scene {
  75980. /** @hidden */
  75981. _tempPickingRay: Nullable<Ray>;
  75982. /** @hidden */
  75983. _cachedRayForTransform: Ray;
  75984. /** @hidden */
  75985. _pickWithRayInverseMatrix: Matrix;
  75986. /** @hidden */
  75987. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  75988. /** @hidden */
  75989. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  75990. }
  75991. }
  75992. declare module BABYLON {
  75993. /**
  75994. * Groups all the scene component constants in one place to ease maintenance.
  75995. * @hidden
  75996. */
  75997. export class SceneComponentConstants {
  75998. static readonly NAME_EFFECTLAYER: string;
  75999. static readonly NAME_LAYER: string;
  76000. static readonly NAME_LENSFLARESYSTEM: string;
  76001. static readonly NAME_BOUNDINGBOXRENDERER: string;
  76002. static readonly NAME_PARTICLESYSTEM: string;
  76003. static readonly NAME_GAMEPAD: string;
  76004. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  76005. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  76006. static readonly NAME_DEPTHRENDERER: string;
  76007. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  76008. static readonly NAME_SPRITE: string;
  76009. static readonly NAME_OUTLINERENDERER: string;
  76010. static readonly NAME_PROCEDURALTEXTURE: string;
  76011. static readonly NAME_SHADOWGENERATOR: string;
  76012. static readonly NAME_OCTREE: string;
  76013. static readonly NAME_PHYSICSENGINE: string;
  76014. static readonly NAME_AUDIO: string;
  76015. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  76016. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  76017. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  76018. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  76019. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  76020. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  76021. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  76022. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  76023. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  76024. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  76025. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  76026. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  76027. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  76028. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  76029. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  76030. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  76031. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  76032. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  76033. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  76034. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  76035. static readonly STEP_AFTERRENDER_AUDIO: number;
  76036. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  76037. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  76038. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  76039. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  76040. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  76041. static readonly STEP_POINTERMOVE_SPRITE: number;
  76042. static readonly STEP_POINTERDOWN_SPRITE: number;
  76043. static readonly STEP_POINTERUP_SPRITE: number;
  76044. }
  76045. /**
  76046. * This represents a scene component.
  76047. *
  76048. * This is used to decouple the dependency the scene is having on the different workloads like
  76049. * layers, post processes...
  76050. */
  76051. export interface ISceneComponent {
  76052. /**
  76053. * The name of the component. Each component must have a unique name.
  76054. */
  76055. name: string;
  76056. /**
  76057. * The scene the component belongs to.
  76058. */
  76059. scene: Scene;
  76060. /**
  76061. * Register the component to one instance of a scene.
  76062. */
  76063. register(): void;
  76064. /**
  76065. * Rebuilds the elements related to this component in case of
  76066. * context lost for instance.
  76067. */
  76068. rebuild(): void;
  76069. /**
  76070. * Disposes the component and the associated ressources.
  76071. */
  76072. dispose(): void;
  76073. }
  76074. /**
  76075. * This represents a SERIALIZABLE scene component.
  76076. *
  76077. * This extends Scene Component to add Serialization methods on top.
  76078. */
  76079. export interface ISceneSerializableComponent extends ISceneComponent {
  76080. /**
  76081. * Adds all the elements from the container to the scene
  76082. * @param container the container holding the elements
  76083. */
  76084. addFromContainer(container: AbstractScene): void;
  76085. /**
  76086. * Removes all the elements in the container from the scene
  76087. * @param container contains the elements to remove
  76088. * @param dispose if the removed element should be disposed (default: false)
  76089. */
  76090. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  76091. /**
  76092. * Serializes the component data to the specified json object
  76093. * @param serializationObject The object to serialize to
  76094. */
  76095. serialize(serializationObject: any): void;
  76096. }
  76097. /**
  76098. * Strong typing of a Mesh related stage step action
  76099. */
  76100. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  76101. /**
  76102. * Strong typing of a Evaluate Sub Mesh related stage step action
  76103. */
  76104. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  76105. /**
  76106. * Strong typing of a Active Mesh related stage step action
  76107. */
  76108. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  76109. /**
  76110. * Strong typing of a Camera related stage step action
  76111. */
  76112. export type CameraStageAction = (camera: Camera) => void;
  76113. /**
  76114. * Strong typing of a Camera Frame buffer related stage step action
  76115. */
  76116. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  76117. /**
  76118. * Strong typing of a Render Target related stage step action
  76119. */
  76120. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  76121. /**
  76122. * Strong typing of a RenderingGroup related stage step action
  76123. */
  76124. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  76125. /**
  76126. * Strong typing of a Mesh Render related stage step action
  76127. */
  76128. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  76129. /**
  76130. * Strong typing of a simple stage step action
  76131. */
  76132. export type SimpleStageAction = () => void;
  76133. /**
  76134. * Strong typing of a render target action.
  76135. */
  76136. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  76137. /**
  76138. * Strong typing of a pointer move action.
  76139. */
  76140. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  76141. /**
  76142. * Strong typing of a pointer up/down action.
  76143. */
  76144. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  76145. /**
  76146. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  76147. * @hidden
  76148. */
  76149. export class Stage<T extends Function> extends Array<{
  76150. index: number;
  76151. component: ISceneComponent;
  76152. action: T;
  76153. }> {
  76154. /**
  76155. * Hide ctor from the rest of the world.
  76156. * @param items The items to add.
  76157. */
  76158. private constructor();
  76159. /**
  76160. * Creates a new Stage.
  76161. * @returns A new instance of a Stage
  76162. */
  76163. static Create<T extends Function>(): Stage<T>;
  76164. /**
  76165. * Registers a step in an ordered way in the targeted stage.
  76166. * @param index Defines the position to register the step in
  76167. * @param component Defines the component attached to the step
  76168. * @param action Defines the action to launch during the step
  76169. */
  76170. registerStep(index: number, component: ISceneComponent, action: T): void;
  76171. /**
  76172. * Clears all the steps from the stage.
  76173. */
  76174. clear(): void;
  76175. }
  76176. }
  76177. declare module BABYLON {
  76178. interface Scene {
  76179. /** @hidden */
  76180. _pointerOverSprite: Nullable<Sprite>;
  76181. /** @hidden */
  76182. _pickedDownSprite: Nullable<Sprite>;
  76183. /** @hidden */
  76184. _tempSpritePickingRay: Nullable<Ray>;
  76185. /**
  76186. * All of the sprite managers added to this scene
  76187. * @see http://doc.babylonjs.com/babylon101/sprites
  76188. */
  76189. spriteManagers: Array<ISpriteManager>;
  76190. /**
  76191. * An event triggered when sprites rendering is about to start
  76192. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  76193. */
  76194. onBeforeSpritesRenderingObservable: Observable<Scene>;
  76195. /**
  76196. * An event triggered when sprites rendering is done
  76197. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  76198. */
  76199. onAfterSpritesRenderingObservable: Observable<Scene>;
  76200. /** @hidden */
  76201. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  76202. /** Launch a ray to try to pick a sprite in the scene
  76203. * @param x position on screen
  76204. * @param y position on screen
  76205. * @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
  76206. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  76207. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  76208. * @returns a PickingInfo
  76209. */
  76210. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  76211. /** Use the given ray to pick a sprite in the scene
  76212. * @param ray The ray (in world space) to use to pick meshes
  76213. * @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
  76214. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  76215. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  76216. * @returns a PickingInfo
  76217. */
  76218. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  76219. /** @hidden */
  76220. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  76221. /** Launch a ray to try to pick sprites in the scene
  76222. * @param x position on screen
  76223. * @param y position on screen
  76224. * @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
  76225. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  76226. * @returns a PickingInfo array
  76227. */
  76228. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  76229. /** Use the given ray to pick sprites in the scene
  76230. * @param ray The ray (in world space) to use to pick meshes
  76231. * @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
  76232. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  76233. * @returns a PickingInfo array
  76234. */
  76235. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  76236. /**
  76237. * Force the sprite under the pointer
  76238. * @param sprite defines the sprite to use
  76239. */
  76240. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  76241. /**
  76242. * Gets the sprite under the pointer
  76243. * @returns a Sprite or null if no sprite is under the pointer
  76244. */
  76245. getPointerOverSprite(): Nullable<Sprite>;
  76246. }
  76247. /**
  76248. * Defines the sprite scene component responsible to manage sprites
  76249. * in a given scene.
  76250. */
  76251. export class SpriteSceneComponent implements ISceneComponent {
  76252. /**
  76253. * The component name helpfull to identify the component in the list of scene components.
  76254. */
  76255. readonly name: string;
  76256. /**
  76257. * The scene the component belongs to.
  76258. */
  76259. scene: Scene;
  76260. /** @hidden */
  76261. private _spritePredicate;
  76262. /**
  76263. * Creates a new instance of the component for the given scene
  76264. * @param scene Defines the scene to register the component in
  76265. */
  76266. constructor(scene: Scene);
  76267. /**
  76268. * Registers the component in a given scene
  76269. */
  76270. register(): void;
  76271. /**
  76272. * Rebuilds the elements related to this component in case of
  76273. * context lost for instance.
  76274. */
  76275. rebuild(): void;
  76276. /**
  76277. * Disposes the component and the associated ressources.
  76278. */
  76279. dispose(): void;
  76280. private _pickSpriteButKeepRay;
  76281. private _pointerMove;
  76282. private _pointerDown;
  76283. private _pointerUp;
  76284. }
  76285. }
  76286. declare module BABYLON {
  76287. /** @hidden */
  76288. export var fogFragmentDeclaration: {
  76289. name: string;
  76290. shader: string;
  76291. };
  76292. }
  76293. declare module BABYLON {
  76294. /** @hidden */
  76295. export var fogFragment: {
  76296. name: string;
  76297. shader: string;
  76298. };
  76299. }
  76300. declare module BABYLON {
  76301. /** @hidden */
  76302. export var spritesPixelShader: {
  76303. name: string;
  76304. shader: string;
  76305. };
  76306. }
  76307. declare module BABYLON {
  76308. /** @hidden */
  76309. export var fogVertexDeclaration: {
  76310. name: string;
  76311. shader: string;
  76312. };
  76313. }
  76314. declare module BABYLON {
  76315. /** @hidden */
  76316. export var spritesVertexShader: {
  76317. name: string;
  76318. shader: string;
  76319. };
  76320. }
  76321. declare module BABYLON {
  76322. /**
  76323. * Defines the minimum interface to fullfil in order to be a sprite manager.
  76324. */
  76325. export interface ISpriteManager extends IDisposable {
  76326. /**
  76327. * Restricts the camera to viewing objects with the same layerMask.
  76328. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  76329. */
  76330. layerMask: number;
  76331. /**
  76332. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  76333. */
  76334. isPickable: boolean;
  76335. /**
  76336. * Specifies the rendering group id for this mesh (0 by default)
  76337. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  76338. */
  76339. renderingGroupId: number;
  76340. /**
  76341. * Defines the list of sprites managed by the manager.
  76342. */
  76343. sprites: Array<Sprite>;
  76344. /**
  76345. * Tests the intersection of a sprite with a specific ray.
  76346. * @param ray The ray we are sending to test the collision
  76347. * @param camera The camera space we are sending rays in
  76348. * @param predicate A predicate allowing excluding sprites from the list of object to test
  76349. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  76350. * @returns picking info or null.
  76351. */
  76352. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  76353. /**
  76354. * Intersects the sprites with a ray
  76355. * @param ray defines the ray to intersect with
  76356. * @param camera defines the current active camera
  76357. * @param predicate defines a predicate used to select candidate sprites
  76358. * @returns null if no hit or a PickingInfo array
  76359. */
  76360. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  76361. /**
  76362. * Renders the list of sprites on screen.
  76363. */
  76364. render(): void;
  76365. }
  76366. /**
  76367. * Class used to manage multiple sprites on the same spritesheet
  76368. * @see http://doc.babylonjs.com/babylon101/sprites
  76369. */
  76370. export class SpriteManager implements ISpriteManager {
  76371. /** defines the manager's name */
  76372. name: string;
  76373. /** Gets the list of sprites */
  76374. sprites: Sprite[];
  76375. /** Gets or sets the rendering group id (0 by default) */
  76376. renderingGroupId: number;
  76377. /** Gets or sets camera layer mask */
  76378. layerMask: number;
  76379. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  76380. fogEnabled: boolean;
  76381. /** Gets or sets a boolean indicating if the sprites are pickable */
  76382. isPickable: boolean;
  76383. /** Defines the default width of a cell in the spritesheet */
  76384. cellWidth: number;
  76385. /** Defines the default height of a cell in the spritesheet */
  76386. cellHeight: number;
  76387. /** Associative array from JSON sprite data file */
  76388. private _cellData;
  76389. /** Array of sprite names from JSON sprite data file */
  76390. private _spriteMap;
  76391. /** True when packed cell data from JSON file is ready*/
  76392. private _packedAndReady;
  76393. /**
  76394. * An event triggered when the manager is disposed.
  76395. */
  76396. onDisposeObservable: Observable<SpriteManager>;
  76397. private _onDisposeObserver;
  76398. /**
  76399. * Callback called when the manager is disposed
  76400. */
  76401. onDispose: () => void;
  76402. private _capacity;
  76403. private _fromPacked;
  76404. private _spriteTexture;
  76405. private _epsilon;
  76406. private _scene;
  76407. private _vertexData;
  76408. private _buffer;
  76409. private _vertexBuffers;
  76410. private _indexBuffer;
  76411. private _effectBase;
  76412. private _effectFog;
  76413. /**
  76414. * Gets or sets the spritesheet texture
  76415. */
  76416. texture: Texture;
  76417. /**
  76418. * Creates a new sprite manager
  76419. * @param name defines the manager's name
  76420. * @param imgUrl defines the sprite sheet url
  76421. * @param capacity defines the maximum allowed number of sprites
  76422. * @param cellSize defines the size of a sprite cell
  76423. * @param scene defines the hosting scene
  76424. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  76425. * @param samplingMode defines the smapling mode to use with spritesheet
  76426. * @param fromPacked set to false; do not alter
  76427. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  76428. */
  76429. constructor(
  76430. /** defines the manager's name */
  76431. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  76432. private _makePacked;
  76433. private _appendSpriteVertex;
  76434. /**
  76435. * Intersects the sprites with a ray
  76436. * @param ray defines the ray to intersect with
  76437. * @param camera defines the current active camera
  76438. * @param predicate defines a predicate used to select candidate sprites
  76439. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  76440. * @returns null if no hit or a PickingInfo
  76441. */
  76442. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  76443. /**
  76444. * Intersects the sprites with a ray
  76445. * @param ray defines the ray to intersect with
  76446. * @param camera defines the current active camera
  76447. * @param predicate defines a predicate used to select candidate sprites
  76448. * @returns null if no hit or a PickingInfo array
  76449. */
  76450. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  76451. /**
  76452. * Render all child sprites
  76453. */
  76454. render(): void;
  76455. /**
  76456. * Release associated resources
  76457. */
  76458. dispose(): void;
  76459. }
  76460. }
  76461. declare module BABYLON {
  76462. /**
  76463. * Class used to represent a sprite
  76464. * @see http://doc.babylonjs.com/babylon101/sprites
  76465. */
  76466. export class Sprite {
  76467. /** defines the name */
  76468. name: string;
  76469. /** Gets or sets the current world position */
  76470. position: Vector3;
  76471. /** Gets or sets the main color */
  76472. color: Color4;
  76473. /** Gets or sets the width */
  76474. width: number;
  76475. /** Gets or sets the height */
  76476. height: number;
  76477. /** Gets or sets rotation angle */
  76478. angle: number;
  76479. /** Gets or sets the cell index in the sprite sheet */
  76480. cellIndex: number;
  76481. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  76482. cellRef: string;
  76483. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  76484. invertU: number;
  76485. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  76486. invertV: number;
  76487. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  76488. disposeWhenFinishedAnimating: boolean;
  76489. /** Gets the list of attached animations */
  76490. animations: Animation[];
  76491. /** Gets or sets a boolean indicating if the sprite can be picked */
  76492. isPickable: boolean;
  76493. /**
  76494. * Gets or sets the associated action manager
  76495. */
  76496. actionManager: Nullable<ActionManager>;
  76497. private _animationStarted;
  76498. private _loopAnimation;
  76499. private _fromIndex;
  76500. private _toIndex;
  76501. private _delay;
  76502. private _direction;
  76503. private _manager;
  76504. private _time;
  76505. private _onAnimationEnd;
  76506. /**
  76507. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  76508. */
  76509. isVisible: boolean;
  76510. /**
  76511. * Gets or sets the sprite size
  76512. */
  76513. size: number;
  76514. /**
  76515. * Creates a new Sprite
  76516. * @param name defines the name
  76517. * @param manager defines the manager
  76518. */
  76519. constructor(
  76520. /** defines the name */
  76521. name: string, manager: ISpriteManager);
  76522. /**
  76523. * Starts an animation
  76524. * @param from defines the initial key
  76525. * @param to defines the end key
  76526. * @param loop defines if the animation must loop
  76527. * @param delay defines the start delay (in ms)
  76528. * @param onAnimationEnd defines a callback to call when animation ends
  76529. */
  76530. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  76531. /** Stops current animation (if any) */
  76532. stopAnimation(): void;
  76533. /** @hidden */
  76534. _animate(deltaTime: number): void;
  76535. /** Release associated resources */
  76536. dispose(): void;
  76537. }
  76538. }
  76539. declare module BABYLON {
  76540. /**
  76541. * Information about the result of picking within a scene
  76542. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  76543. */
  76544. export class PickingInfo {
  76545. /** @hidden */
  76546. _pickingUnavailable: boolean;
  76547. /**
  76548. * If the pick collided with an object
  76549. */
  76550. hit: boolean;
  76551. /**
  76552. * Distance away where the pick collided
  76553. */
  76554. distance: number;
  76555. /**
  76556. * The location of pick collision
  76557. */
  76558. pickedPoint: Nullable<Vector3>;
  76559. /**
  76560. * The mesh corresponding the the pick collision
  76561. */
  76562. pickedMesh: Nullable<AbstractMesh>;
  76563. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  76564. bu: number;
  76565. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  76566. bv: number;
  76567. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  76568. faceId: number;
  76569. /** Id of the the submesh that was picked */
  76570. subMeshId: number;
  76571. /** If a sprite was picked, this will be the sprite the pick collided with */
  76572. pickedSprite: Nullable<Sprite>;
  76573. /**
  76574. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  76575. */
  76576. originMesh: Nullable<AbstractMesh>;
  76577. /**
  76578. * The ray that was used to perform the picking.
  76579. */
  76580. ray: Nullable<Ray>;
  76581. /**
  76582. * Gets the normal correspodning to the face the pick collided with
  76583. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  76584. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  76585. * @returns The normal correspodning to the face the pick collided with
  76586. */
  76587. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  76588. /**
  76589. * Gets the texture coordinates of where the pick occured
  76590. * @returns the vector containing the coordnates of the texture
  76591. */
  76592. getTextureCoordinates(): Nullable<Vector2>;
  76593. }
  76594. }
  76595. declare module BABYLON {
  76596. /**
  76597. * Gather the list of pointer event types as constants.
  76598. */
  76599. export class PointerEventTypes {
  76600. /**
  76601. * 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.
  76602. */
  76603. static readonly POINTERDOWN: number;
  76604. /**
  76605. * The pointerup event is fired when a pointer is no longer active.
  76606. */
  76607. static readonly POINTERUP: number;
  76608. /**
  76609. * The pointermove event is fired when a pointer changes coordinates.
  76610. */
  76611. static readonly POINTERMOVE: number;
  76612. /**
  76613. * The pointerwheel event is fired when a mouse wheel has been rotated.
  76614. */
  76615. static readonly POINTERWHEEL: number;
  76616. /**
  76617. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  76618. */
  76619. static readonly POINTERPICK: number;
  76620. /**
  76621. * The pointertap event is fired when a the object has been touched and released without drag.
  76622. */
  76623. static readonly POINTERTAP: number;
  76624. /**
  76625. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  76626. */
  76627. static readonly POINTERDOUBLETAP: number;
  76628. }
  76629. /**
  76630. * Base class of pointer info types.
  76631. */
  76632. export class PointerInfoBase {
  76633. /**
  76634. * Defines the type of event (PointerEventTypes)
  76635. */
  76636. type: number;
  76637. /**
  76638. * Defines the related dom event
  76639. */
  76640. event: PointerEvent | MouseWheelEvent;
  76641. /**
  76642. * Instantiates the base class of pointers info.
  76643. * @param type Defines the type of event (PointerEventTypes)
  76644. * @param event Defines the related dom event
  76645. */
  76646. constructor(
  76647. /**
  76648. * Defines the type of event (PointerEventTypes)
  76649. */
  76650. type: number,
  76651. /**
  76652. * Defines the related dom event
  76653. */
  76654. event: PointerEvent | MouseWheelEvent);
  76655. }
  76656. /**
  76657. * This class is used to store pointer related info for the onPrePointerObservable event.
  76658. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  76659. */
  76660. export class PointerInfoPre extends PointerInfoBase {
  76661. /**
  76662. * Ray from a pointer if availible (eg. 6dof controller)
  76663. */
  76664. ray: Nullable<Ray>;
  76665. /**
  76666. * Defines the local position of the pointer on the canvas.
  76667. */
  76668. localPosition: Vector2;
  76669. /**
  76670. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  76671. */
  76672. skipOnPointerObservable: boolean;
  76673. /**
  76674. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  76675. * @param type Defines the type of event (PointerEventTypes)
  76676. * @param event Defines the related dom event
  76677. * @param localX Defines the local x coordinates of the pointer when the event occured
  76678. * @param localY Defines the local y coordinates of the pointer when the event occured
  76679. */
  76680. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  76681. }
  76682. /**
  76683. * This type contains all the data related to a pointer event in Babylon.js.
  76684. * 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.
  76685. */
  76686. export class PointerInfo extends PointerInfoBase {
  76687. /**
  76688. * Defines the picking info associated to the info (if any)\
  76689. */
  76690. pickInfo: Nullable<PickingInfo>;
  76691. /**
  76692. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  76693. * @param type Defines the type of event (PointerEventTypes)
  76694. * @param event Defines the related dom event
  76695. * @param pickInfo Defines the picking info associated to the info (if any)\
  76696. */
  76697. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  76698. /**
  76699. * Defines the picking info associated to the info (if any)\
  76700. */
  76701. pickInfo: Nullable<PickingInfo>);
  76702. }
  76703. /**
  76704. * Data relating to a touch event on the screen.
  76705. */
  76706. export interface PointerTouch {
  76707. /**
  76708. * X coordinate of touch.
  76709. */
  76710. x: number;
  76711. /**
  76712. * Y coordinate of touch.
  76713. */
  76714. y: number;
  76715. /**
  76716. * Id of touch. Unique for each finger.
  76717. */
  76718. pointerId: number;
  76719. /**
  76720. * Event type passed from DOM.
  76721. */
  76722. type: any;
  76723. }
  76724. }
  76725. declare module BABYLON {
  76726. /**
  76727. * Manage the mouse inputs to control the movement of a free camera.
  76728. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  76729. */
  76730. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  76731. /**
  76732. * Define if touch is enabled in the mouse input
  76733. */
  76734. touchEnabled: boolean;
  76735. /**
  76736. * Defines the camera the input is attached to.
  76737. */
  76738. camera: FreeCamera;
  76739. /**
  76740. * Defines the buttons associated with the input to handle camera move.
  76741. */
  76742. buttons: number[];
  76743. /**
  76744. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  76745. */
  76746. angularSensibility: number;
  76747. private _pointerInput;
  76748. private _onMouseMove;
  76749. private _observer;
  76750. private previousPosition;
  76751. /**
  76752. * Observable for when a pointer move event occurs containing the move offset
  76753. */
  76754. onPointerMovedObservable: Observable<{
  76755. offsetX: number;
  76756. offsetY: number;
  76757. }>;
  76758. /**
  76759. * @hidden
  76760. * If the camera should be rotated automatically based on pointer movement
  76761. */
  76762. _allowCameraRotation: boolean;
  76763. /**
  76764. * Manage the mouse inputs to control the movement of a free camera.
  76765. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  76766. * @param touchEnabled Defines if touch is enabled or not
  76767. */
  76768. constructor(
  76769. /**
  76770. * Define if touch is enabled in the mouse input
  76771. */
  76772. touchEnabled?: boolean);
  76773. /**
  76774. * Attach the input controls to a specific dom element to get the input from.
  76775. * @param element Defines the element the controls should be listened from
  76776. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  76777. */
  76778. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  76779. /**
  76780. * Called on JS contextmenu event.
  76781. * Override this method to provide functionality.
  76782. */
  76783. protected onContextMenu(evt: PointerEvent): void;
  76784. /**
  76785. * Detach the current controls from the specified dom element.
  76786. * @param element Defines the element to stop listening the inputs from
  76787. */
  76788. detachControl(element: Nullable<HTMLElement>): void;
  76789. /**
  76790. * Gets the class name of the current intput.
  76791. * @returns the class name
  76792. */
  76793. getClassName(): string;
  76794. /**
  76795. * Get the friendly name associated with the input class.
  76796. * @returns the input friendly name
  76797. */
  76798. getSimpleName(): string;
  76799. }
  76800. }
  76801. declare module BABYLON {
  76802. /**
  76803. * Manage the touch inputs to control the movement of a free camera.
  76804. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  76805. */
  76806. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  76807. /**
  76808. * Defines the camera the input is attached to.
  76809. */
  76810. camera: FreeCamera;
  76811. /**
  76812. * Defines the touch sensibility for rotation.
  76813. * The higher the faster.
  76814. */
  76815. touchAngularSensibility: number;
  76816. /**
  76817. * Defines the touch sensibility for move.
  76818. * The higher the faster.
  76819. */
  76820. touchMoveSensibility: number;
  76821. private _offsetX;
  76822. private _offsetY;
  76823. private _pointerPressed;
  76824. private _pointerInput;
  76825. private _observer;
  76826. private _onLostFocus;
  76827. /**
  76828. * Attach the input controls to a specific dom element to get the input from.
  76829. * @param element Defines the element the controls should be listened from
  76830. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  76831. */
  76832. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  76833. /**
  76834. * Detach the current controls from the specified dom element.
  76835. * @param element Defines the element to stop listening the inputs from
  76836. */
  76837. detachControl(element: Nullable<HTMLElement>): void;
  76838. /**
  76839. * Update the current camera state depending on the inputs that have been used this frame.
  76840. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  76841. */
  76842. checkInputs(): void;
  76843. /**
  76844. * Gets the class name of the current intput.
  76845. * @returns the class name
  76846. */
  76847. getClassName(): string;
  76848. /**
  76849. * Get the friendly name associated with the input class.
  76850. * @returns the input friendly name
  76851. */
  76852. getSimpleName(): string;
  76853. }
  76854. }
  76855. declare module BABYLON {
  76856. /**
  76857. * Default Inputs manager for the FreeCamera.
  76858. * It groups all the default supported inputs for ease of use.
  76859. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  76860. */
  76861. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  76862. /**
  76863. * @hidden
  76864. */
  76865. _mouseInput: Nullable<FreeCameraMouseInput>;
  76866. /**
  76867. * Instantiates a new FreeCameraInputsManager.
  76868. * @param camera Defines the camera the inputs belong to
  76869. */
  76870. constructor(camera: FreeCamera);
  76871. /**
  76872. * Add keyboard input support to the input manager.
  76873. * @returns the current input manager
  76874. */
  76875. addKeyboard(): FreeCameraInputsManager;
  76876. /**
  76877. * Add mouse input support to the input manager.
  76878. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  76879. * @returns the current input manager
  76880. */
  76881. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  76882. /**
  76883. * Removes the mouse input support from the manager
  76884. * @returns the current input manager
  76885. */
  76886. removeMouse(): FreeCameraInputsManager;
  76887. /**
  76888. * Add touch input support to the input manager.
  76889. * @returns the current input manager
  76890. */
  76891. addTouch(): FreeCameraInputsManager;
  76892. /**
  76893. * Remove all attached input methods from a camera
  76894. */
  76895. clear(): void;
  76896. }
  76897. }
  76898. declare module BABYLON {
  76899. /**
  76900. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  76901. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  76902. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  76903. */
  76904. export class FreeCamera extends TargetCamera {
  76905. /**
  76906. * Define the collision ellipsoid of the camera.
  76907. * This is helpful to simulate a camera body like the player body around the camera
  76908. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  76909. */
  76910. ellipsoid: Vector3;
  76911. /**
  76912. * Define an offset for the position of the ellipsoid around the camera.
  76913. * This can be helpful to determine the center of the body near the gravity center of the body
  76914. * instead of its head.
  76915. */
  76916. ellipsoidOffset: Vector3;
  76917. /**
  76918. * Enable or disable collisions of the camera with the rest of the scene objects.
  76919. */
  76920. checkCollisions: boolean;
  76921. /**
  76922. * Enable or disable gravity on the camera.
  76923. */
  76924. applyGravity: boolean;
  76925. /**
  76926. * Define the input manager associated to the camera.
  76927. */
  76928. inputs: FreeCameraInputsManager;
  76929. /**
  76930. * Gets the input sensibility for a mouse input. (default is 2000.0)
  76931. * Higher values reduce sensitivity.
  76932. */
  76933. /**
  76934. * Sets the input sensibility for a mouse input. (default is 2000.0)
  76935. * Higher values reduce sensitivity.
  76936. */
  76937. angularSensibility: number;
  76938. /**
  76939. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  76940. */
  76941. keysUp: number[];
  76942. /**
  76943. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  76944. */
  76945. keysDown: number[];
  76946. /**
  76947. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  76948. */
  76949. keysLeft: number[];
  76950. /**
  76951. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  76952. */
  76953. keysRight: number[];
  76954. /**
  76955. * Event raised when the camera collide with a mesh in the scene.
  76956. */
  76957. onCollide: (collidedMesh: AbstractMesh) => void;
  76958. private _collider;
  76959. private _needMoveForGravity;
  76960. private _oldPosition;
  76961. private _diffPosition;
  76962. private _newPosition;
  76963. /** @hidden */
  76964. _localDirection: Vector3;
  76965. /** @hidden */
  76966. _transformedDirection: Vector3;
  76967. /**
  76968. * Instantiates a Free Camera.
  76969. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  76970. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  76971. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  76972. * @param name Define the name of the camera in the scene
  76973. * @param position Define the start position of the camera in the scene
  76974. * @param scene Define the scene the camera belongs to
  76975. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  76976. */
  76977. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  76978. /**
  76979. * Attached controls to the current camera.
  76980. * @param element Defines the element the controls should be listened from
  76981. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  76982. */
  76983. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  76984. /**
  76985. * Detach the current controls from the camera.
  76986. * The camera will stop reacting to inputs.
  76987. * @param element Defines the element to stop listening the inputs from
  76988. */
  76989. detachControl(element: HTMLElement): void;
  76990. private _collisionMask;
  76991. /**
  76992. * Define a collision mask to limit the list of object the camera can collide with
  76993. */
  76994. collisionMask: number;
  76995. /** @hidden */
  76996. _collideWithWorld(displacement: Vector3): void;
  76997. private _onCollisionPositionChange;
  76998. /** @hidden */
  76999. _checkInputs(): void;
  77000. /** @hidden */
  77001. _decideIfNeedsToMove(): boolean;
  77002. /** @hidden */
  77003. _updatePosition(): void;
  77004. /**
  77005. * Destroy the camera and release the current resources hold by it.
  77006. */
  77007. dispose(): void;
  77008. /**
  77009. * Gets the current object class name.
  77010. * @return the class name
  77011. */
  77012. getClassName(): string;
  77013. }
  77014. }
  77015. declare module BABYLON {
  77016. /**
  77017. * Represents a gamepad control stick position
  77018. */
  77019. export class StickValues {
  77020. /**
  77021. * The x component of the control stick
  77022. */
  77023. x: number;
  77024. /**
  77025. * The y component of the control stick
  77026. */
  77027. y: number;
  77028. /**
  77029. * Initializes the gamepad x and y control stick values
  77030. * @param x The x component of the gamepad control stick value
  77031. * @param y The y component of the gamepad control stick value
  77032. */
  77033. constructor(
  77034. /**
  77035. * The x component of the control stick
  77036. */
  77037. x: number,
  77038. /**
  77039. * The y component of the control stick
  77040. */
  77041. y: number);
  77042. }
  77043. /**
  77044. * An interface which manages callbacks for gamepad button changes
  77045. */
  77046. export interface GamepadButtonChanges {
  77047. /**
  77048. * Called when a gamepad has been changed
  77049. */
  77050. changed: boolean;
  77051. /**
  77052. * Called when a gamepad press event has been triggered
  77053. */
  77054. pressChanged: boolean;
  77055. /**
  77056. * Called when a touch event has been triggered
  77057. */
  77058. touchChanged: boolean;
  77059. /**
  77060. * Called when a value has changed
  77061. */
  77062. valueChanged: boolean;
  77063. }
  77064. /**
  77065. * Represents a gamepad
  77066. */
  77067. export class Gamepad {
  77068. /**
  77069. * The id of the gamepad
  77070. */
  77071. id: string;
  77072. /**
  77073. * The index of the gamepad
  77074. */
  77075. index: number;
  77076. /**
  77077. * The browser gamepad
  77078. */
  77079. browserGamepad: any;
  77080. /**
  77081. * Specifies what type of gamepad this represents
  77082. */
  77083. type: number;
  77084. private _leftStick;
  77085. private _rightStick;
  77086. /** @hidden */
  77087. _isConnected: boolean;
  77088. private _leftStickAxisX;
  77089. private _leftStickAxisY;
  77090. private _rightStickAxisX;
  77091. private _rightStickAxisY;
  77092. /**
  77093. * Triggered when the left control stick has been changed
  77094. */
  77095. private _onleftstickchanged;
  77096. /**
  77097. * Triggered when the right control stick has been changed
  77098. */
  77099. private _onrightstickchanged;
  77100. /**
  77101. * Represents a gamepad controller
  77102. */
  77103. static GAMEPAD: number;
  77104. /**
  77105. * Represents a generic controller
  77106. */
  77107. static GENERIC: number;
  77108. /**
  77109. * Represents an XBox controller
  77110. */
  77111. static XBOX: number;
  77112. /**
  77113. * Represents a pose-enabled controller
  77114. */
  77115. static POSE_ENABLED: number;
  77116. /**
  77117. * Represents an Dual Shock controller
  77118. */
  77119. static DUALSHOCK: number;
  77120. /**
  77121. * Specifies whether the left control stick should be Y-inverted
  77122. */
  77123. protected _invertLeftStickY: boolean;
  77124. /**
  77125. * Specifies if the gamepad has been connected
  77126. */
  77127. readonly isConnected: boolean;
  77128. /**
  77129. * Initializes the gamepad
  77130. * @param id The id of the gamepad
  77131. * @param index The index of the gamepad
  77132. * @param browserGamepad The browser gamepad
  77133. * @param leftStickX The x component of the left joystick
  77134. * @param leftStickY The y component of the left joystick
  77135. * @param rightStickX The x component of the right joystick
  77136. * @param rightStickY The y component of the right joystick
  77137. */
  77138. constructor(
  77139. /**
  77140. * The id of the gamepad
  77141. */
  77142. id: string,
  77143. /**
  77144. * The index of the gamepad
  77145. */
  77146. index: number,
  77147. /**
  77148. * The browser gamepad
  77149. */
  77150. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  77151. /**
  77152. * Callback triggered when the left joystick has changed
  77153. * @param callback
  77154. */
  77155. onleftstickchanged(callback: (values: StickValues) => void): void;
  77156. /**
  77157. * Callback triggered when the right joystick has changed
  77158. * @param callback
  77159. */
  77160. onrightstickchanged(callback: (values: StickValues) => void): void;
  77161. /**
  77162. * Gets the left joystick
  77163. */
  77164. /**
  77165. * Sets the left joystick values
  77166. */
  77167. leftStick: StickValues;
  77168. /**
  77169. * Gets the right joystick
  77170. */
  77171. /**
  77172. * Sets the right joystick value
  77173. */
  77174. rightStick: StickValues;
  77175. /**
  77176. * Updates the gamepad joystick positions
  77177. */
  77178. update(): void;
  77179. /**
  77180. * Disposes the gamepad
  77181. */
  77182. dispose(): void;
  77183. }
  77184. /**
  77185. * Represents a generic gamepad
  77186. */
  77187. export class GenericPad extends Gamepad {
  77188. private _buttons;
  77189. private _onbuttondown;
  77190. private _onbuttonup;
  77191. /**
  77192. * Observable triggered when a button has been pressed
  77193. */
  77194. onButtonDownObservable: Observable<number>;
  77195. /**
  77196. * Observable triggered when a button has been released
  77197. */
  77198. onButtonUpObservable: Observable<number>;
  77199. /**
  77200. * Callback triggered when a button has been pressed
  77201. * @param callback Called when a button has been pressed
  77202. */
  77203. onbuttondown(callback: (buttonPressed: number) => void): void;
  77204. /**
  77205. * Callback triggered when a button has been released
  77206. * @param callback Called when a button has been released
  77207. */
  77208. onbuttonup(callback: (buttonReleased: number) => void): void;
  77209. /**
  77210. * Initializes the generic gamepad
  77211. * @param id The id of the generic gamepad
  77212. * @param index The index of the generic gamepad
  77213. * @param browserGamepad The browser gamepad
  77214. */
  77215. constructor(id: string, index: number, browserGamepad: any);
  77216. private _setButtonValue;
  77217. /**
  77218. * Updates the generic gamepad
  77219. */
  77220. update(): void;
  77221. /**
  77222. * Disposes the generic gamepad
  77223. */
  77224. dispose(): void;
  77225. }
  77226. }
  77227. declare module BABYLON {
  77228. interface Engine {
  77229. /**
  77230. * Creates a raw texture
  77231. * @param data defines the data to store in the texture
  77232. * @param width defines the width of the texture
  77233. * @param height defines the height of the texture
  77234. * @param format defines the format of the data
  77235. * @param generateMipMaps defines if the engine should generate the mip levels
  77236. * @param invertY defines if data must be stored with Y axis inverted
  77237. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  77238. * @param compression defines the compression used (null by default)
  77239. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  77240. * @returns the raw texture inside an InternalTexture
  77241. */
  77242. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  77243. /**
  77244. * Update a raw texture
  77245. * @param texture defines the texture to update
  77246. * @param data defines the data to store in the texture
  77247. * @param format defines the format of the data
  77248. * @param invertY defines if data must be stored with Y axis inverted
  77249. */
  77250. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  77251. /**
  77252. * Update a raw texture
  77253. * @param texture defines the texture to update
  77254. * @param data defines the data to store in the texture
  77255. * @param format defines the format of the data
  77256. * @param invertY defines if data must be stored with Y axis inverted
  77257. * @param compression defines the compression used (null by default)
  77258. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  77259. */
  77260. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  77261. /**
  77262. * Creates a new raw cube texture
  77263. * @param data defines the array of data to use to create each face
  77264. * @param size defines the size of the textures
  77265. * @param format defines the format of the data
  77266. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  77267. * @param generateMipMaps defines if the engine should generate the mip levels
  77268. * @param invertY defines if data must be stored with Y axis inverted
  77269. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  77270. * @param compression defines the compression used (null by default)
  77271. * @returns the cube texture as an InternalTexture
  77272. */
  77273. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  77274. /**
  77275. * Update a raw cube texture
  77276. * @param texture defines the texture to udpdate
  77277. * @param data defines the data to store
  77278. * @param format defines the data format
  77279. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  77280. * @param invertY defines if data must be stored with Y axis inverted
  77281. */
  77282. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  77283. /**
  77284. * Update a raw cube texture
  77285. * @param texture defines the texture to udpdate
  77286. * @param data defines the data to store
  77287. * @param format defines the data format
  77288. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  77289. * @param invertY defines if data must be stored with Y axis inverted
  77290. * @param compression defines the compression used (null by default)
  77291. */
  77292. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  77293. /**
  77294. * Update a raw cube texture
  77295. * @param texture defines the texture to udpdate
  77296. * @param data defines the data to store
  77297. * @param format defines the data format
  77298. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  77299. * @param invertY defines if data must be stored with Y axis inverted
  77300. * @param compression defines the compression used (null by default)
  77301. * @param level defines which level of the texture to update
  77302. */
  77303. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  77304. /**
  77305. * Creates a new raw cube texture from a specified url
  77306. * @param url defines the url where the data is located
  77307. * @param scene defines the current scene
  77308. * @param size defines the size of the textures
  77309. * @param format defines the format of the data
  77310. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  77311. * @param noMipmap defines if the engine should avoid generating the mip levels
  77312. * @param callback defines a callback used to extract texture data from loaded data
  77313. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  77314. * @param onLoad defines a callback called when texture is loaded
  77315. * @param onError defines a callback called if there is an error
  77316. * @returns the cube texture as an InternalTexture
  77317. */
  77318. 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;
  77319. /**
  77320. * Creates a new raw cube texture from a specified url
  77321. * @param url defines the url where the data is located
  77322. * @param scene defines the current scene
  77323. * @param size defines the size of the textures
  77324. * @param format defines the format of the data
  77325. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  77326. * @param noMipmap defines if the engine should avoid generating the mip levels
  77327. * @param callback defines a callback used to extract texture data from loaded data
  77328. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  77329. * @param onLoad defines a callback called when texture is loaded
  77330. * @param onError defines a callback called if there is an error
  77331. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  77332. * @param invertY defines if data must be stored with Y axis inverted
  77333. * @returns the cube texture as an InternalTexture
  77334. */
  77335. 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;
  77336. /**
  77337. * Creates a new raw 3D texture
  77338. * @param data defines the data used to create the texture
  77339. * @param width defines the width of the texture
  77340. * @param height defines the height of the texture
  77341. * @param depth defines the depth of the texture
  77342. * @param format defines the format of the texture
  77343. * @param generateMipMaps defines if the engine must generate mip levels
  77344. * @param invertY defines if data must be stored with Y axis inverted
  77345. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  77346. * @param compression defines the compressed used (can be null)
  77347. * @param textureType defines the compressed used (can be null)
  77348. * @returns a new raw 3D texture (stored in an InternalTexture)
  77349. */
  77350. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  77351. /**
  77352. * Update a raw 3D texture
  77353. * @param texture defines the texture to update
  77354. * @param data defines the data to store
  77355. * @param format defines the data format
  77356. * @param invertY defines if data must be stored with Y axis inverted
  77357. */
  77358. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  77359. /**
  77360. * Update a raw 3D texture
  77361. * @param texture defines the texture to update
  77362. * @param data defines the data to store
  77363. * @param format defines the data format
  77364. * @param invertY defines if data must be stored with Y axis inverted
  77365. * @param compression defines the used compression (can be null)
  77366. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  77367. */
  77368. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  77369. }
  77370. }
  77371. declare module BABYLON {
  77372. /**
  77373. * Raw texture can help creating a texture directly from an array of data.
  77374. * This can be super useful if you either get the data from an uncompressed source or
  77375. * if you wish to create your texture pixel by pixel.
  77376. */
  77377. export class RawTexture extends Texture {
  77378. /**
  77379. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  77380. */
  77381. format: number;
  77382. private _engine;
  77383. /**
  77384. * Instantiates a new RawTexture.
  77385. * Raw texture can help creating a texture directly from an array of data.
  77386. * This can be super useful if you either get the data from an uncompressed source or
  77387. * if you wish to create your texture pixel by pixel.
  77388. * @param data define the array of data to use to create the texture
  77389. * @param width define the width of the texture
  77390. * @param height define the height of the texture
  77391. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  77392. * @param scene define the scene the texture belongs to
  77393. * @param generateMipMaps define whether mip maps should be generated or not
  77394. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77395. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77396. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77397. */
  77398. constructor(data: ArrayBufferView, width: number, height: number,
  77399. /**
  77400. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  77401. */
  77402. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  77403. /**
  77404. * Updates the texture underlying data.
  77405. * @param data Define the new data of the texture
  77406. */
  77407. update(data: ArrayBufferView): void;
  77408. /**
  77409. * Creates a luminance texture from some data.
  77410. * @param data Define the texture data
  77411. * @param width Define the width of the texture
  77412. * @param height Define the height of the texture
  77413. * @param scene Define the scene the texture belongs to
  77414. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77415. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77416. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77417. * @returns the luminance texture
  77418. */
  77419. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  77420. /**
  77421. * Creates a luminance alpha texture from some data.
  77422. * @param data Define the texture data
  77423. * @param width Define the width of the texture
  77424. * @param height Define the height of the texture
  77425. * @param scene Define the scene the texture belongs to
  77426. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77427. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77428. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77429. * @returns the luminance alpha texture
  77430. */
  77431. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  77432. /**
  77433. * Creates an alpha texture from some data.
  77434. * @param data Define the texture data
  77435. * @param width Define the width of the texture
  77436. * @param height Define the height of the texture
  77437. * @param scene Define the scene the texture belongs to
  77438. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77439. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77440. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77441. * @returns the alpha texture
  77442. */
  77443. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  77444. /**
  77445. * Creates a RGB texture from some data.
  77446. * @param data Define the texture data
  77447. * @param width Define the width of the texture
  77448. * @param height Define the height of the texture
  77449. * @param scene Define the scene the texture belongs to
  77450. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77451. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77452. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77453. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77454. * @returns the RGB alpha texture
  77455. */
  77456. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  77457. /**
  77458. * Creates a RGBA texture from some data.
  77459. * @param data Define the texture data
  77460. * @param width Define the width of the texture
  77461. * @param height Define the height of the texture
  77462. * @param scene Define the scene the texture belongs to
  77463. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77464. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77465. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77466. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77467. * @returns the RGBA texture
  77468. */
  77469. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  77470. /**
  77471. * Creates a R texture from some data.
  77472. * @param data Define the texture data
  77473. * @param width Define the width of the texture
  77474. * @param height Define the height of the texture
  77475. * @param scene Define the scene the texture belongs to
  77476. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77477. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77478. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77479. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77480. * @returns the R texture
  77481. */
  77482. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  77483. }
  77484. }
  77485. declare module BABYLON {
  77486. /**
  77487. * Interface for the size containing width and height
  77488. */
  77489. export interface ISize {
  77490. /**
  77491. * Width
  77492. */
  77493. width: number;
  77494. /**
  77495. * Heighht
  77496. */
  77497. height: number;
  77498. }
  77499. /**
  77500. * Size containing widht and height
  77501. */
  77502. export class Size implements ISize {
  77503. /**
  77504. * Width
  77505. */
  77506. width: number;
  77507. /**
  77508. * Height
  77509. */
  77510. height: number;
  77511. /**
  77512. * Creates a Size object from the given width and height (floats).
  77513. * @param width width of the new size
  77514. * @param height height of the new size
  77515. */
  77516. constructor(width: number, height: number);
  77517. /**
  77518. * Returns a string with the Size width and height
  77519. * @returns a string with the Size width and height
  77520. */
  77521. toString(): string;
  77522. /**
  77523. * "Size"
  77524. * @returns the string "Size"
  77525. */
  77526. getClassName(): string;
  77527. /**
  77528. * Returns the Size hash code.
  77529. * @returns a hash code for a unique width and height
  77530. */
  77531. getHashCode(): number;
  77532. /**
  77533. * Updates the current size from the given one.
  77534. * @param src the given size
  77535. */
  77536. copyFrom(src: Size): void;
  77537. /**
  77538. * Updates in place the current Size from the given floats.
  77539. * @param width width of the new size
  77540. * @param height height of the new size
  77541. * @returns the updated Size.
  77542. */
  77543. copyFromFloats(width: number, height: number): Size;
  77544. /**
  77545. * Updates in place the current Size from the given floats.
  77546. * @param width width to set
  77547. * @param height height to set
  77548. * @returns the updated Size.
  77549. */
  77550. set(width: number, height: number): Size;
  77551. /**
  77552. * Multiplies the width and height by numbers
  77553. * @param w factor to multiple the width by
  77554. * @param h factor to multiple the height by
  77555. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  77556. */
  77557. multiplyByFloats(w: number, h: number): Size;
  77558. /**
  77559. * Clones the size
  77560. * @returns a new Size copied from the given one.
  77561. */
  77562. clone(): Size;
  77563. /**
  77564. * True if the current Size and the given one width and height are strictly equal.
  77565. * @param other the other size to compare against
  77566. * @returns True if the current Size and the given one width and height are strictly equal.
  77567. */
  77568. equals(other: Size): boolean;
  77569. /**
  77570. * The surface of the Size : width * height (float).
  77571. */
  77572. readonly surface: number;
  77573. /**
  77574. * Create a new size of zero
  77575. * @returns a new Size set to (0.0, 0.0)
  77576. */
  77577. static Zero(): Size;
  77578. /**
  77579. * Sums the width and height of two sizes
  77580. * @param otherSize size to add to this size
  77581. * @returns a new Size set as the addition result of the current Size and the given one.
  77582. */
  77583. add(otherSize: Size): Size;
  77584. /**
  77585. * Subtracts the width and height of two
  77586. * @param otherSize size to subtract to this size
  77587. * @returns a new Size set as the subtraction result of the given one from the current Size.
  77588. */
  77589. subtract(otherSize: Size): Size;
  77590. /**
  77591. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  77592. * @param start starting size to lerp between
  77593. * @param end end size to lerp between
  77594. * @param amount amount to lerp between the start and end values
  77595. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  77596. */
  77597. static Lerp(start: Size, end: Size, amount: number): Size;
  77598. }
  77599. }
  77600. declare module BABYLON {
  77601. /**
  77602. * Defines a runtime animation
  77603. */
  77604. export class RuntimeAnimation {
  77605. private _events;
  77606. /**
  77607. * The current frame of the runtime animation
  77608. */
  77609. private _currentFrame;
  77610. /**
  77611. * The animation used by the runtime animation
  77612. */
  77613. private _animation;
  77614. /**
  77615. * The target of the runtime animation
  77616. */
  77617. private _target;
  77618. /**
  77619. * The initiating animatable
  77620. */
  77621. private _host;
  77622. /**
  77623. * The original value of the runtime animation
  77624. */
  77625. private _originalValue;
  77626. /**
  77627. * The original blend value of the runtime animation
  77628. */
  77629. private _originalBlendValue;
  77630. /**
  77631. * The offsets cache of the runtime animation
  77632. */
  77633. private _offsetsCache;
  77634. /**
  77635. * The high limits cache of the runtime animation
  77636. */
  77637. private _highLimitsCache;
  77638. /**
  77639. * Specifies if the runtime animation has been stopped
  77640. */
  77641. private _stopped;
  77642. /**
  77643. * The blending factor of the runtime animation
  77644. */
  77645. private _blendingFactor;
  77646. /**
  77647. * The BabylonJS scene
  77648. */
  77649. private _scene;
  77650. /**
  77651. * The current value of the runtime animation
  77652. */
  77653. private _currentValue;
  77654. /** @hidden */
  77655. _animationState: _IAnimationState;
  77656. /**
  77657. * The active target of the runtime animation
  77658. */
  77659. private _activeTargets;
  77660. private _currentActiveTarget;
  77661. private _directTarget;
  77662. /**
  77663. * The target path of the runtime animation
  77664. */
  77665. private _targetPath;
  77666. /**
  77667. * The weight of the runtime animation
  77668. */
  77669. private _weight;
  77670. /**
  77671. * The ratio offset of the runtime animation
  77672. */
  77673. private _ratioOffset;
  77674. /**
  77675. * The previous delay of the runtime animation
  77676. */
  77677. private _previousDelay;
  77678. /**
  77679. * The previous ratio of the runtime animation
  77680. */
  77681. private _previousRatio;
  77682. private _enableBlending;
  77683. private _keys;
  77684. private _minFrame;
  77685. private _maxFrame;
  77686. private _minValue;
  77687. private _maxValue;
  77688. private _targetIsArray;
  77689. /**
  77690. * Gets the current frame of the runtime animation
  77691. */
  77692. readonly currentFrame: number;
  77693. /**
  77694. * Gets the weight of the runtime animation
  77695. */
  77696. readonly weight: number;
  77697. /**
  77698. * Gets the current value of the runtime animation
  77699. */
  77700. readonly currentValue: any;
  77701. /**
  77702. * Gets the target path of the runtime animation
  77703. */
  77704. readonly targetPath: string;
  77705. /**
  77706. * Gets the actual target of the runtime animation
  77707. */
  77708. readonly target: any;
  77709. /** @hidden */
  77710. _onLoop: () => void;
  77711. /**
  77712. * Create a new RuntimeAnimation object
  77713. * @param target defines the target of the animation
  77714. * @param animation defines the source animation object
  77715. * @param scene defines the hosting scene
  77716. * @param host defines the initiating Animatable
  77717. */
  77718. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  77719. private _preparePath;
  77720. /**
  77721. * Gets the animation from the runtime animation
  77722. */
  77723. readonly animation: Animation;
  77724. /**
  77725. * Resets the runtime animation to the beginning
  77726. * @param restoreOriginal defines whether to restore the target property to the original value
  77727. */
  77728. reset(restoreOriginal?: boolean): void;
  77729. /**
  77730. * Specifies if the runtime animation is stopped
  77731. * @returns Boolean specifying if the runtime animation is stopped
  77732. */
  77733. isStopped(): boolean;
  77734. /**
  77735. * Disposes of the runtime animation
  77736. */
  77737. dispose(): void;
  77738. /**
  77739. * Apply the interpolated value to the target
  77740. * @param currentValue defines the value computed by the animation
  77741. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  77742. */
  77743. setValue(currentValue: any, weight: number): void;
  77744. private _getOriginalValues;
  77745. private _setValue;
  77746. /**
  77747. * Gets the loop pmode of the runtime animation
  77748. * @returns Loop Mode
  77749. */
  77750. private _getCorrectLoopMode;
  77751. /**
  77752. * Move the current animation to a given frame
  77753. * @param frame defines the frame to move to
  77754. */
  77755. goToFrame(frame: number): void;
  77756. /**
  77757. * @hidden Internal use only
  77758. */
  77759. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  77760. /**
  77761. * Execute the current animation
  77762. * @param delay defines the delay to add to the current frame
  77763. * @param from defines the lower bound of the animation range
  77764. * @param to defines the upper bound of the animation range
  77765. * @param loop defines if the current animation must loop
  77766. * @param speedRatio defines the current speed ratio
  77767. * @param weight defines the weight of the animation (default is -1 so no weight)
  77768. * @param onLoop optional callback called when animation loops
  77769. * @returns a boolean indicating if the animation is running
  77770. */
  77771. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  77772. }
  77773. }
  77774. declare module BABYLON {
  77775. /**
  77776. * Class used to store an actual running animation
  77777. */
  77778. export class Animatable {
  77779. /** defines the target object */
  77780. target: any;
  77781. /** defines the starting frame number (default is 0) */
  77782. fromFrame: number;
  77783. /** defines the ending frame number (default is 100) */
  77784. toFrame: number;
  77785. /** defines if the animation must loop (default is false) */
  77786. loopAnimation: boolean;
  77787. /** defines a callback to call when animation ends if it is not looping */
  77788. onAnimationEnd?: (() => void) | null | undefined;
  77789. /** defines a callback to call when animation loops */
  77790. onAnimationLoop?: (() => void) | null | undefined;
  77791. private _localDelayOffset;
  77792. private _pausedDelay;
  77793. private _runtimeAnimations;
  77794. private _paused;
  77795. private _scene;
  77796. private _speedRatio;
  77797. private _weight;
  77798. private _syncRoot;
  77799. /**
  77800. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  77801. * This will only apply for non looping animation (default is true)
  77802. */
  77803. disposeOnEnd: boolean;
  77804. /**
  77805. * Gets a boolean indicating if the animation has started
  77806. */
  77807. animationStarted: boolean;
  77808. /**
  77809. * Observer raised when the animation ends
  77810. */
  77811. onAnimationEndObservable: Observable<Animatable>;
  77812. /**
  77813. * Observer raised when the animation loops
  77814. */
  77815. onAnimationLoopObservable: Observable<Animatable>;
  77816. /**
  77817. * Gets the root Animatable used to synchronize and normalize animations
  77818. */
  77819. readonly syncRoot: Nullable<Animatable>;
  77820. /**
  77821. * Gets the current frame of the first RuntimeAnimation
  77822. * Used to synchronize Animatables
  77823. */
  77824. readonly masterFrame: number;
  77825. /**
  77826. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  77827. */
  77828. weight: number;
  77829. /**
  77830. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  77831. */
  77832. speedRatio: number;
  77833. /**
  77834. * Creates a new Animatable
  77835. * @param scene defines the hosting scene
  77836. * @param target defines the target object
  77837. * @param fromFrame defines the starting frame number (default is 0)
  77838. * @param toFrame defines the ending frame number (default is 100)
  77839. * @param loopAnimation defines if the animation must loop (default is false)
  77840. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  77841. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  77842. * @param animations defines a group of animation to add to the new Animatable
  77843. * @param onAnimationLoop defines a callback to call when animation loops
  77844. */
  77845. constructor(scene: Scene,
  77846. /** defines the target object */
  77847. target: any,
  77848. /** defines the starting frame number (default is 0) */
  77849. fromFrame?: number,
  77850. /** defines the ending frame number (default is 100) */
  77851. toFrame?: number,
  77852. /** defines if the animation must loop (default is false) */
  77853. loopAnimation?: boolean, speedRatio?: number,
  77854. /** defines a callback to call when animation ends if it is not looping */
  77855. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  77856. /** defines a callback to call when animation loops */
  77857. onAnimationLoop?: (() => void) | null | undefined);
  77858. /**
  77859. * Synchronize and normalize current Animatable with a source Animatable
  77860. * This is useful when using animation weights and when animations are not of the same length
  77861. * @param root defines the root Animatable to synchronize with
  77862. * @returns the current Animatable
  77863. */
  77864. syncWith(root: Animatable): Animatable;
  77865. /**
  77866. * Gets the list of runtime animations
  77867. * @returns an array of RuntimeAnimation
  77868. */
  77869. getAnimations(): RuntimeAnimation[];
  77870. /**
  77871. * Adds more animations to the current animatable
  77872. * @param target defines the target of the animations
  77873. * @param animations defines the new animations to add
  77874. */
  77875. appendAnimations(target: any, animations: Animation[]): void;
  77876. /**
  77877. * Gets the source animation for a specific property
  77878. * @param property defines the propertyu to look for
  77879. * @returns null or the source animation for the given property
  77880. */
  77881. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  77882. /**
  77883. * Gets the runtime animation for a specific property
  77884. * @param property defines the propertyu to look for
  77885. * @returns null or the runtime animation for the given property
  77886. */
  77887. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  77888. /**
  77889. * Resets the animatable to its original state
  77890. */
  77891. reset(): void;
  77892. /**
  77893. * Allows the animatable to blend with current running animations
  77894. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  77895. * @param blendingSpeed defines the blending speed to use
  77896. */
  77897. enableBlending(blendingSpeed: number): void;
  77898. /**
  77899. * Disable animation blending
  77900. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  77901. */
  77902. disableBlending(): void;
  77903. /**
  77904. * Jump directly to a given frame
  77905. * @param frame defines the frame to jump to
  77906. */
  77907. goToFrame(frame: number): void;
  77908. /**
  77909. * Pause the animation
  77910. */
  77911. pause(): void;
  77912. /**
  77913. * Restart the animation
  77914. */
  77915. restart(): void;
  77916. private _raiseOnAnimationEnd;
  77917. /**
  77918. * Stop and delete the current animation
  77919. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  77920. * @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)
  77921. */
  77922. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  77923. /**
  77924. * Wait asynchronously for the animation to end
  77925. * @returns a promise which will be fullfilled when the animation ends
  77926. */
  77927. waitAsync(): Promise<Animatable>;
  77928. /** @hidden */
  77929. _animate(delay: number): boolean;
  77930. }
  77931. interface Scene {
  77932. /** @hidden */
  77933. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  77934. /** @hidden */
  77935. _processLateAnimationBindingsForMatrices(holder: {
  77936. totalWeight: number;
  77937. animations: RuntimeAnimation[];
  77938. originalValue: Matrix;
  77939. }): any;
  77940. /** @hidden */
  77941. _processLateAnimationBindingsForQuaternions(holder: {
  77942. totalWeight: number;
  77943. animations: RuntimeAnimation[];
  77944. originalValue: Quaternion;
  77945. }, refQuaternion: Quaternion): Quaternion;
  77946. /** @hidden */
  77947. _processLateAnimationBindings(): void;
  77948. /**
  77949. * Will start the animation sequence of a given target
  77950. * @param target defines the target
  77951. * @param from defines from which frame should animation start
  77952. * @param to defines until which frame should animation run.
  77953. * @param weight defines the weight to apply to the animation (1.0 by default)
  77954. * @param loop defines if the animation loops
  77955. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  77956. * @param onAnimationEnd defines the function to be executed when the animation ends
  77957. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  77958. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  77959. * @param onAnimationLoop defines the callback to call when an animation loops
  77960. * @returns the animatable object created for this animation
  77961. */
  77962. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  77963. /**
  77964. * Will start the animation sequence of a given target
  77965. * @param target defines the target
  77966. * @param from defines from which frame should animation start
  77967. * @param to defines until which frame should animation run.
  77968. * @param loop defines if the animation loops
  77969. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  77970. * @param onAnimationEnd defines the function to be executed when the animation ends
  77971. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  77972. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  77973. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  77974. * @param onAnimationLoop defines the callback to call when an animation loops
  77975. * @returns the animatable object created for this animation
  77976. */
  77977. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  77978. /**
  77979. * Will start the animation sequence of a given target and its hierarchy
  77980. * @param target defines the target
  77981. * @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.
  77982. * @param from defines from which frame should animation start
  77983. * @param to defines until which frame should animation run.
  77984. * @param loop defines if the animation loops
  77985. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  77986. * @param onAnimationEnd defines the function to be executed when the animation ends
  77987. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  77988. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  77989. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  77990. * @param onAnimationLoop defines the callback to call when an animation loops
  77991. * @returns the list of created animatables
  77992. */
  77993. 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[];
  77994. /**
  77995. * Begin a new animation on a given node
  77996. * @param target defines the target where the animation will take place
  77997. * @param animations defines the list of animations to start
  77998. * @param from defines the initial value
  77999. * @param to defines the final value
  78000. * @param loop defines if you want animation to loop (off by default)
  78001. * @param speedRatio defines the speed ratio to apply to all animations
  78002. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  78003. * @param onAnimationLoop defines the callback to call when an animation loops
  78004. * @returns the list of created animatables
  78005. */
  78006. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  78007. /**
  78008. * Begin a new animation on a given node and its hierarchy
  78009. * @param target defines the root node where the animation will take place
  78010. * @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.
  78011. * @param animations defines the list of animations to start
  78012. * @param from defines the initial value
  78013. * @param to defines the final value
  78014. * @param loop defines if you want animation to loop (off by default)
  78015. * @param speedRatio defines the speed ratio to apply to all animations
  78016. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  78017. * @param onAnimationLoop defines the callback to call when an animation loops
  78018. * @returns the list of animatables created for all nodes
  78019. */
  78020. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  78021. /**
  78022. * Gets the animatable associated with a specific target
  78023. * @param target defines the target of the animatable
  78024. * @returns the required animatable if found
  78025. */
  78026. getAnimatableByTarget(target: any): Nullable<Animatable>;
  78027. /**
  78028. * Gets all animatables associated with a given target
  78029. * @param target defines the target to look animatables for
  78030. * @returns an array of Animatables
  78031. */
  78032. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  78033. /**
  78034. * Stops and removes all animations that have been applied to the scene
  78035. */
  78036. stopAllAnimations(): void;
  78037. }
  78038. interface Bone {
  78039. /**
  78040. * Copy an animation range from another bone
  78041. * @param source defines the source bone
  78042. * @param rangeName defines the range name to copy
  78043. * @param frameOffset defines the frame offset
  78044. * @param rescaleAsRequired defines if rescaling must be applied if required
  78045. * @param skelDimensionsRatio defines the scaling ratio
  78046. * @returns true if operation was successful
  78047. */
  78048. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  78049. }
  78050. }
  78051. declare module BABYLON {
  78052. /**
  78053. * Class used to override all child animations of a given target
  78054. */
  78055. export class AnimationPropertiesOverride {
  78056. /**
  78057. * Gets or sets a value indicating if animation blending must be used
  78058. */
  78059. enableBlending: boolean;
  78060. /**
  78061. * Gets or sets the blending speed to use when enableBlending is true
  78062. */
  78063. blendingSpeed: number;
  78064. /**
  78065. * Gets or sets the default loop mode to use
  78066. */
  78067. loopMode: number;
  78068. }
  78069. }
  78070. declare module BABYLON {
  78071. /**
  78072. * Class used to handle skinning animations
  78073. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  78074. */
  78075. export class Skeleton implements IAnimatable {
  78076. /** defines the skeleton name */
  78077. name: string;
  78078. /** defines the skeleton Id */
  78079. id: string;
  78080. /**
  78081. * Defines the list of child bones
  78082. */
  78083. bones: Bone[];
  78084. /**
  78085. * Defines an estimate of the dimension of the skeleton at rest
  78086. */
  78087. dimensionsAtRest: Vector3;
  78088. /**
  78089. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  78090. */
  78091. needInitialSkinMatrix: boolean;
  78092. /**
  78093. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  78094. */
  78095. overrideMesh: Nullable<AbstractMesh>;
  78096. /**
  78097. * Gets the list of animations attached to this skeleton
  78098. */
  78099. animations: Array<Animation>;
  78100. private _scene;
  78101. private _isDirty;
  78102. private _transformMatrices;
  78103. private _transformMatrixTexture;
  78104. private _meshesWithPoseMatrix;
  78105. private _animatables;
  78106. private _identity;
  78107. private _synchronizedWithMesh;
  78108. private _ranges;
  78109. private _lastAbsoluteTransformsUpdateId;
  78110. private _canUseTextureForBones;
  78111. private _uniqueId;
  78112. /** @hidden */
  78113. _numBonesWithLinkedTransformNode: number;
  78114. /** @hidden */
  78115. _hasWaitingData: Nullable<boolean>;
  78116. /**
  78117. * Specifies if the skeleton should be serialized
  78118. */
  78119. doNotSerialize: boolean;
  78120. private _useTextureToStoreBoneMatrices;
  78121. /**
  78122. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  78123. * Please note that this option is not available if the hardware does not support it
  78124. */
  78125. useTextureToStoreBoneMatrices: boolean;
  78126. private _animationPropertiesOverride;
  78127. /**
  78128. * Gets or sets the animation properties override
  78129. */
  78130. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  78131. /**
  78132. * List of inspectable custom properties (used by the Inspector)
  78133. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  78134. */
  78135. inspectableCustomProperties: IInspectable[];
  78136. /**
  78137. * An observable triggered before computing the skeleton's matrices
  78138. */
  78139. onBeforeComputeObservable: Observable<Skeleton>;
  78140. /**
  78141. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  78142. */
  78143. readonly isUsingTextureForMatrices: boolean;
  78144. /**
  78145. * Gets the unique ID of this skeleton
  78146. */
  78147. readonly uniqueId: number;
  78148. /**
  78149. * Creates a new skeleton
  78150. * @param name defines the skeleton name
  78151. * @param id defines the skeleton Id
  78152. * @param scene defines the hosting scene
  78153. */
  78154. constructor(
  78155. /** defines the skeleton name */
  78156. name: string,
  78157. /** defines the skeleton Id */
  78158. id: string, scene: Scene);
  78159. /**
  78160. * Gets the current object class name.
  78161. * @return the class name
  78162. */
  78163. getClassName(): string;
  78164. /**
  78165. * Returns an array containing the root bones
  78166. * @returns an array containing the root bones
  78167. */
  78168. getChildren(): Array<Bone>;
  78169. /**
  78170. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  78171. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  78172. * @returns a Float32Array containing matrices data
  78173. */
  78174. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  78175. /**
  78176. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  78177. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  78178. * @returns a raw texture containing the data
  78179. */
  78180. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  78181. /**
  78182. * Gets the current hosting scene
  78183. * @returns a scene object
  78184. */
  78185. getScene(): Scene;
  78186. /**
  78187. * Gets a string representing the current skeleton data
  78188. * @param fullDetails defines a boolean indicating if we want a verbose version
  78189. * @returns a string representing the current skeleton data
  78190. */
  78191. toString(fullDetails?: boolean): string;
  78192. /**
  78193. * Get bone's index searching by name
  78194. * @param name defines bone's name to search for
  78195. * @return the indice of the bone. Returns -1 if not found
  78196. */
  78197. getBoneIndexByName(name: string): number;
  78198. /**
  78199. * Creater a new animation range
  78200. * @param name defines the name of the range
  78201. * @param from defines the start key
  78202. * @param to defines the end key
  78203. */
  78204. createAnimationRange(name: string, from: number, to: number): void;
  78205. /**
  78206. * Delete a specific animation range
  78207. * @param name defines the name of the range
  78208. * @param deleteFrames defines if frames must be removed as well
  78209. */
  78210. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  78211. /**
  78212. * Gets a specific animation range
  78213. * @param name defines the name of the range to look for
  78214. * @returns the requested animation range or null if not found
  78215. */
  78216. getAnimationRange(name: string): Nullable<AnimationRange>;
  78217. /**
  78218. * Gets the list of all animation ranges defined on this skeleton
  78219. * @returns an array
  78220. */
  78221. getAnimationRanges(): Nullable<AnimationRange>[];
  78222. /**
  78223. * Copy animation range from a source skeleton.
  78224. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  78225. * @param source defines the source skeleton
  78226. * @param name defines the name of the range to copy
  78227. * @param rescaleAsRequired defines if rescaling must be applied if required
  78228. * @returns true if operation was successful
  78229. */
  78230. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  78231. /**
  78232. * Forces the skeleton to go to rest pose
  78233. */
  78234. returnToRest(): void;
  78235. private _getHighestAnimationFrame;
  78236. /**
  78237. * Begin a specific animation range
  78238. * @param name defines the name of the range to start
  78239. * @param loop defines if looping must be turned on (false by default)
  78240. * @param speedRatio defines the speed ratio to apply (1 by default)
  78241. * @param onAnimationEnd defines a callback which will be called when animation will end
  78242. * @returns a new animatable
  78243. */
  78244. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  78245. /** @hidden */
  78246. _markAsDirty(): void;
  78247. /** @hidden */
  78248. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  78249. /** @hidden */
  78250. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  78251. private _computeTransformMatrices;
  78252. /**
  78253. * Build all resources required to render a skeleton
  78254. */
  78255. prepare(): void;
  78256. /**
  78257. * Gets the list of animatables currently running for this skeleton
  78258. * @returns an array of animatables
  78259. */
  78260. getAnimatables(): IAnimatable[];
  78261. /**
  78262. * Clone the current skeleton
  78263. * @param name defines the name of the new skeleton
  78264. * @param id defines the id of the new skeleton
  78265. * @returns the new skeleton
  78266. */
  78267. clone(name: string, id: string): Skeleton;
  78268. /**
  78269. * Enable animation blending for this skeleton
  78270. * @param blendingSpeed defines the blending speed to apply
  78271. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78272. */
  78273. enableBlending(blendingSpeed?: number): void;
  78274. /**
  78275. * Releases all resources associated with the current skeleton
  78276. */
  78277. dispose(): void;
  78278. /**
  78279. * Serialize the skeleton in a JSON object
  78280. * @returns a JSON object
  78281. */
  78282. serialize(): any;
  78283. /**
  78284. * Creates a new skeleton from serialized data
  78285. * @param parsedSkeleton defines the serialized data
  78286. * @param scene defines the hosting scene
  78287. * @returns a new skeleton
  78288. */
  78289. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  78290. /**
  78291. * Compute all node absolute transforms
  78292. * @param forceUpdate defines if computation must be done even if cache is up to date
  78293. */
  78294. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  78295. /**
  78296. * Gets the root pose matrix
  78297. * @returns a matrix
  78298. */
  78299. getPoseMatrix(): Nullable<Matrix>;
  78300. /**
  78301. * Sorts bones per internal index
  78302. */
  78303. sortBones(): void;
  78304. private _sortBones;
  78305. }
  78306. }
  78307. declare module BABYLON {
  78308. /**
  78309. * Class used to store bone information
  78310. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  78311. */
  78312. export class Bone extends Node {
  78313. /**
  78314. * defines the bone name
  78315. */
  78316. name: string;
  78317. private static _tmpVecs;
  78318. private static _tmpQuat;
  78319. private static _tmpMats;
  78320. /**
  78321. * Gets the list of child bones
  78322. */
  78323. children: Bone[];
  78324. /** Gets the animations associated with this bone */
  78325. animations: Animation[];
  78326. /**
  78327. * Gets or sets bone length
  78328. */
  78329. length: number;
  78330. /**
  78331. * @hidden Internal only
  78332. * Set this value to map this bone to a different index in the transform matrices
  78333. * Set this value to -1 to exclude the bone from the transform matrices
  78334. */
  78335. _index: Nullable<number>;
  78336. private _skeleton;
  78337. private _localMatrix;
  78338. private _restPose;
  78339. private _baseMatrix;
  78340. private _absoluteTransform;
  78341. private _invertedAbsoluteTransform;
  78342. private _parent;
  78343. private _scalingDeterminant;
  78344. private _worldTransform;
  78345. private _localScaling;
  78346. private _localRotation;
  78347. private _localPosition;
  78348. private _needToDecompose;
  78349. private _needToCompose;
  78350. /** @hidden */
  78351. _linkedTransformNode: Nullable<TransformNode>;
  78352. /** @hidden */
  78353. _waitingTransformNodeId: Nullable<string>;
  78354. /** @hidden */
  78355. /** @hidden */
  78356. _matrix: Matrix;
  78357. /**
  78358. * Create a new bone
  78359. * @param name defines the bone name
  78360. * @param skeleton defines the parent skeleton
  78361. * @param parentBone defines the parent (can be null if the bone is the root)
  78362. * @param localMatrix defines the local matrix
  78363. * @param restPose defines the rest pose matrix
  78364. * @param baseMatrix defines the base matrix
  78365. * @param index defines index of the bone in the hiearchy
  78366. */
  78367. constructor(
  78368. /**
  78369. * defines the bone name
  78370. */
  78371. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  78372. /**
  78373. * Gets the current object class name.
  78374. * @return the class name
  78375. */
  78376. getClassName(): string;
  78377. /**
  78378. * Gets the parent skeleton
  78379. * @returns a skeleton
  78380. */
  78381. getSkeleton(): Skeleton;
  78382. /**
  78383. * Gets parent bone
  78384. * @returns a bone or null if the bone is the root of the bone hierarchy
  78385. */
  78386. getParent(): Nullable<Bone>;
  78387. /**
  78388. * Returns an array containing the root bones
  78389. * @returns an array containing the root bones
  78390. */
  78391. getChildren(): Array<Bone>;
  78392. /**
  78393. * Sets the parent bone
  78394. * @param parent defines the parent (can be null if the bone is the root)
  78395. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  78396. */
  78397. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  78398. /**
  78399. * Gets the local matrix
  78400. * @returns a matrix
  78401. */
  78402. getLocalMatrix(): Matrix;
  78403. /**
  78404. * Gets the base matrix (initial matrix which remains unchanged)
  78405. * @returns a matrix
  78406. */
  78407. getBaseMatrix(): Matrix;
  78408. /**
  78409. * Gets the rest pose matrix
  78410. * @returns a matrix
  78411. */
  78412. getRestPose(): Matrix;
  78413. /**
  78414. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  78415. */
  78416. getWorldMatrix(): Matrix;
  78417. /**
  78418. * Sets the local matrix to rest pose matrix
  78419. */
  78420. returnToRest(): void;
  78421. /**
  78422. * Gets the inverse of the absolute transform matrix.
  78423. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  78424. * @returns a matrix
  78425. */
  78426. getInvertedAbsoluteTransform(): Matrix;
  78427. /**
  78428. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  78429. * @returns a matrix
  78430. */
  78431. getAbsoluteTransform(): Matrix;
  78432. /**
  78433. * Links with the given transform node.
  78434. * The local matrix of this bone is copied from the transform node every frame.
  78435. * @param transformNode defines the transform node to link to
  78436. */
  78437. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  78438. /**
  78439. * Gets the node used to drive the bone's transformation
  78440. * @returns a transform node or null
  78441. */
  78442. getTransformNode(): Nullable<TransformNode>;
  78443. /** Gets or sets current position (in local space) */
  78444. position: Vector3;
  78445. /** Gets or sets current rotation (in local space) */
  78446. rotation: Vector3;
  78447. /** Gets or sets current rotation quaternion (in local space) */
  78448. rotationQuaternion: Quaternion;
  78449. /** Gets or sets current scaling (in local space) */
  78450. scaling: Vector3;
  78451. /**
  78452. * Gets the animation properties override
  78453. */
  78454. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  78455. private _decompose;
  78456. private _compose;
  78457. /**
  78458. * Update the base and local matrices
  78459. * @param matrix defines the new base or local matrix
  78460. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  78461. * @param updateLocalMatrix defines if the local matrix should be updated
  78462. */
  78463. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  78464. /** @hidden */
  78465. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  78466. /**
  78467. * Flag the bone as dirty (Forcing it to update everything)
  78468. */
  78469. markAsDirty(): void;
  78470. /** @hidden */
  78471. _markAsDirtyAndCompose(): void;
  78472. private _markAsDirtyAndDecompose;
  78473. /**
  78474. * Translate the bone in local or world space
  78475. * @param vec The amount to translate the bone
  78476. * @param space The space that the translation is in
  78477. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78478. */
  78479. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  78480. /**
  78481. * Set the postion of the bone in local or world space
  78482. * @param position The position to set the bone
  78483. * @param space The space that the position is in
  78484. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78485. */
  78486. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  78487. /**
  78488. * Set the absolute position of the bone (world space)
  78489. * @param position The position to set the bone
  78490. * @param mesh The mesh that this bone is attached to
  78491. */
  78492. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  78493. /**
  78494. * Scale the bone on the x, y and z axes (in local space)
  78495. * @param x The amount to scale the bone on the x axis
  78496. * @param y The amount to scale the bone on the y axis
  78497. * @param z The amount to scale the bone on the z axis
  78498. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  78499. */
  78500. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  78501. /**
  78502. * Set the bone scaling in local space
  78503. * @param scale defines the scaling vector
  78504. */
  78505. setScale(scale: Vector3): void;
  78506. /**
  78507. * Gets the current scaling in local space
  78508. * @returns the current scaling vector
  78509. */
  78510. getScale(): Vector3;
  78511. /**
  78512. * Gets the current scaling in local space and stores it in a target vector
  78513. * @param result defines the target vector
  78514. */
  78515. getScaleToRef(result: Vector3): void;
  78516. /**
  78517. * Set the yaw, pitch, and roll of the bone in local or world space
  78518. * @param yaw The rotation of the bone on the y axis
  78519. * @param pitch The rotation of the bone on the x axis
  78520. * @param roll The rotation of the bone on the z axis
  78521. * @param space The space that the axes of rotation are in
  78522. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78523. */
  78524. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  78525. /**
  78526. * Add a rotation to the bone on an axis in local or world space
  78527. * @param axis The axis to rotate the bone on
  78528. * @param amount The amount to rotate the bone
  78529. * @param space The space that the axis is in
  78530. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78531. */
  78532. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  78533. /**
  78534. * Set the rotation of the bone to a particular axis angle in local or world space
  78535. * @param axis The axis to rotate the bone on
  78536. * @param angle The angle that the bone should be rotated to
  78537. * @param space The space that the axis is in
  78538. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78539. */
  78540. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  78541. /**
  78542. * Set the euler rotation of the bone in local of world space
  78543. * @param rotation The euler rotation that the bone should be set to
  78544. * @param space The space that the rotation is in
  78545. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78546. */
  78547. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  78548. /**
  78549. * Set the quaternion rotation of the bone in local of world space
  78550. * @param quat The quaternion rotation that the bone should be set to
  78551. * @param space The space that the rotation is in
  78552. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78553. */
  78554. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  78555. /**
  78556. * Set the rotation matrix of the bone in local of world space
  78557. * @param rotMat The rotation matrix that the bone should be set to
  78558. * @param space The space that the rotation is in
  78559. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78560. */
  78561. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  78562. private _rotateWithMatrix;
  78563. private _getNegativeRotationToRef;
  78564. /**
  78565. * Get the position of the bone in local or world space
  78566. * @param space The space that the returned position is in
  78567. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78568. * @returns The position of the bone
  78569. */
  78570. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  78571. /**
  78572. * Copy the position of the bone to a vector3 in local or world space
  78573. * @param space The space that the returned position is in
  78574. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78575. * @param result The vector3 to copy the position to
  78576. */
  78577. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  78578. /**
  78579. * Get the absolute position of the bone (world space)
  78580. * @param mesh The mesh that this bone is attached to
  78581. * @returns The absolute position of the bone
  78582. */
  78583. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  78584. /**
  78585. * Copy the absolute position of the bone (world space) to the result param
  78586. * @param mesh The mesh that this bone is attached to
  78587. * @param result The vector3 to copy the absolute position to
  78588. */
  78589. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  78590. /**
  78591. * Compute the absolute transforms of this bone and its children
  78592. */
  78593. computeAbsoluteTransforms(): void;
  78594. /**
  78595. * Get the world direction from an axis that is in the local space of the bone
  78596. * @param localAxis The local direction that is used to compute the world direction
  78597. * @param mesh The mesh that this bone is attached to
  78598. * @returns The world direction
  78599. */
  78600. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  78601. /**
  78602. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  78603. * @param localAxis The local direction that is used to compute the world direction
  78604. * @param mesh The mesh that this bone is attached to
  78605. * @param result The vector3 that the world direction will be copied to
  78606. */
  78607. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  78608. /**
  78609. * Get the euler rotation of the bone in local or world space
  78610. * @param space The space that the rotation should be in
  78611. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78612. * @returns The euler rotation
  78613. */
  78614. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  78615. /**
  78616. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  78617. * @param space The space that the rotation should be in
  78618. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78619. * @param result The vector3 that the rotation should be copied to
  78620. */
  78621. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  78622. /**
  78623. * Get the quaternion rotation of the bone in either local or world space
  78624. * @param space The space that the rotation should be in
  78625. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78626. * @returns The quaternion rotation
  78627. */
  78628. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  78629. /**
  78630. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  78631. * @param space The space that the rotation should be in
  78632. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78633. * @param result The quaternion that the rotation should be copied to
  78634. */
  78635. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  78636. /**
  78637. * Get the rotation matrix of the bone in local or world space
  78638. * @param space The space that the rotation should be in
  78639. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78640. * @returns The rotation matrix
  78641. */
  78642. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  78643. /**
  78644. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  78645. * @param space The space that the rotation should be in
  78646. * @param mesh The mesh that this bone is attached to. This is only used in world space
  78647. * @param result The quaternion that the rotation should be copied to
  78648. */
  78649. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  78650. /**
  78651. * Get the world position of a point that is in the local space of the bone
  78652. * @param position The local position
  78653. * @param mesh The mesh that this bone is attached to
  78654. * @returns The world position
  78655. */
  78656. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  78657. /**
  78658. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  78659. * @param position The local position
  78660. * @param mesh The mesh that this bone is attached to
  78661. * @param result The vector3 that the world position should be copied to
  78662. */
  78663. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  78664. /**
  78665. * Get the local position of a point that is in world space
  78666. * @param position The world position
  78667. * @param mesh The mesh that this bone is attached to
  78668. * @returns The local position
  78669. */
  78670. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  78671. /**
  78672. * Get the local position of a point that is in world space and copy it to the result param
  78673. * @param position The world position
  78674. * @param mesh The mesh that this bone is attached to
  78675. * @param result The vector3 that the local position should be copied to
  78676. */
  78677. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  78678. }
  78679. }
  78680. declare module BABYLON {
  78681. /**
  78682. * 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.
  78683. * @see https://doc.babylonjs.com/how_to/transformnode
  78684. */
  78685. export class TransformNode extends Node {
  78686. /**
  78687. * Object will not rotate to face the camera
  78688. */
  78689. static BILLBOARDMODE_NONE: number;
  78690. /**
  78691. * Object will rotate to face the camera but only on the x axis
  78692. */
  78693. static BILLBOARDMODE_X: number;
  78694. /**
  78695. * Object will rotate to face the camera but only on the y axis
  78696. */
  78697. static BILLBOARDMODE_Y: number;
  78698. /**
  78699. * Object will rotate to face the camera but only on the z axis
  78700. */
  78701. static BILLBOARDMODE_Z: number;
  78702. /**
  78703. * Object will rotate to face the camera
  78704. */
  78705. static BILLBOARDMODE_ALL: number;
  78706. /**
  78707. * Object will rotate to face the camera's position instead of orientation
  78708. */
  78709. static BILLBOARDMODE_USE_POSITION: number;
  78710. private _forward;
  78711. private _forwardInverted;
  78712. private _up;
  78713. private _right;
  78714. private _rightInverted;
  78715. private _position;
  78716. private _rotation;
  78717. private _rotationQuaternion;
  78718. protected _scaling: Vector3;
  78719. protected _isDirty: boolean;
  78720. private _transformToBoneReferal;
  78721. private _isAbsoluteSynced;
  78722. private _billboardMode;
  78723. /**
  78724. * Gets or sets the billboard mode. Default is 0.
  78725. *
  78726. * | Value | Type | Description |
  78727. * | --- | --- | --- |
  78728. * | 0 | BILLBOARDMODE_NONE | |
  78729. * | 1 | BILLBOARDMODE_X | |
  78730. * | 2 | BILLBOARDMODE_Y | |
  78731. * | 4 | BILLBOARDMODE_Z | |
  78732. * | 7 | BILLBOARDMODE_ALL | |
  78733. *
  78734. */
  78735. billboardMode: number;
  78736. private _preserveParentRotationForBillboard;
  78737. /**
  78738. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  78739. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  78740. */
  78741. preserveParentRotationForBillboard: boolean;
  78742. /**
  78743. * 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
  78744. */
  78745. scalingDeterminant: number;
  78746. private _infiniteDistance;
  78747. /**
  78748. * Gets or sets the distance of the object to max, often used by skybox
  78749. */
  78750. infiniteDistance: boolean;
  78751. /**
  78752. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  78753. * By default the system will update normals to compensate
  78754. */
  78755. ignoreNonUniformScaling: boolean;
  78756. /**
  78757. * 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
  78758. */
  78759. reIntegrateRotationIntoRotationQuaternion: boolean;
  78760. /** @hidden */
  78761. _poseMatrix: Nullable<Matrix>;
  78762. /** @hidden */
  78763. _localMatrix: Matrix;
  78764. private _usePivotMatrix;
  78765. private _absolutePosition;
  78766. private _absoluteScaling;
  78767. private _absoluteRotationQuaternion;
  78768. private _pivotMatrix;
  78769. private _pivotMatrixInverse;
  78770. protected _postMultiplyPivotMatrix: boolean;
  78771. protected _isWorldMatrixFrozen: boolean;
  78772. /** @hidden */
  78773. _indexInSceneTransformNodesArray: number;
  78774. /**
  78775. * An event triggered after the world matrix is updated
  78776. */
  78777. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  78778. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  78779. /**
  78780. * Gets a string identifying the name of the class
  78781. * @returns "TransformNode" string
  78782. */
  78783. getClassName(): string;
  78784. /**
  78785. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  78786. */
  78787. position: Vector3;
  78788. /**
  78789. * 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)).
  78790. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  78791. */
  78792. rotation: Vector3;
  78793. /**
  78794. * 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)).
  78795. */
  78796. scaling: Vector3;
  78797. /**
  78798. * 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).
  78799. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  78800. */
  78801. rotationQuaternion: Nullable<Quaternion>;
  78802. /**
  78803. * The forward direction of that transform in world space.
  78804. */
  78805. readonly forward: Vector3;
  78806. /**
  78807. * The up direction of that transform in world space.
  78808. */
  78809. readonly up: Vector3;
  78810. /**
  78811. * The right direction of that transform in world space.
  78812. */
  78813. readonly right: Vector3;
  78814. /**
  78815. * Copies the parameter passed Matrix into the mesh Pose matrix.
  78816. * @param matrix the matrix to copy the pose from
  78817. * @returns this TransformNode.
  78818. */
  78819. updatePoseMatrix(matrix: Matrix): TransformNode;
  78820. /**
  78821. * Returns the mesh Pose matrix.
  78822. * @returns the pose matrix
  78823. */
  78824. getPoseMatrix(): Matrix;
  78825. /** @hidden */
  78826. _isSynchronized(): boolean;
  78827. /** @hidden */
  78828. _initCache(): void;
  78829. /**
  78830. * Flag the transform node as dirty (Forcing it to update everything)
  78831. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  78832. * @returns this transform node
  78833. */
  78834. markAsDirty(property: string): TransformNode;
  78835. /**
  78836. * Returns the current mesh absolute position.
  78837. * Returns a Vector3.
  78838. */
  78839. readonly absolutePosition: Vector3;
  78840. /**
  78841. * Returns the current mesh absolute scaling.
  78842. * Returns a Vector3.
  78843. */
  78844. readonly absoluteScaling: Vector3;
  78845. /**
  78846. * Returns the current mesh absolute rotation.
  78847. * Returns a Quaternion.
  78848. */
  78849. readonly absoluteRotationQuaternion: Quaternion;
  78850. /**
  78851. * Sets a new matrix to apply before all other transformation
  78852. * @param matrix defines the transform matrix
  78853. * @returns the current TransformNode
  78854. */
  78855. setPreTransformMatrix(matrix: Matrix): TransformNode;
  78856. /**
  78857. * Sets a new pivot matrix to the current node
  78858. * @param matrix defines the new pivot matrix to use
  78859. * @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
  78860. * @returns the current TransformNode
  78861. */
  78862. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  78863. /**
  78864. * Returns the mesh pivot matrix.
  78865. * Default : Identity.
  78866. * @returns the matrix
  78867. */
  78868. getPivotMatrix(): Matrix;
  78869. /**
  78870. * Instantiate (when possible) or clone that node with its hierarchy
  78871. * @param newParent defines the new parent to use for the instance (or clone)
  78872. * @returns an instance (or a clone) of the current node with its hiearchy
  78873. */
  78874. instantiateHierarychy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  78875. /**
  78876. * Prevents the World matrix to be computed any longer
  78877. * @param newWorldMatrix defines an optional matrix to use as world matrix
  78878. * @returns the TransformNode.
  78879. */
  78880. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  78881. /**
  78882. * Allows back the World matrix computation.
  78883. * @returns the TransformNode.
  78884. */
  78885. unfreezeWorldMatrix(): this;
  78886. /**
  78887. * True if the World matrix has been frozen.
  78888. */
  78889. readonly isWorldMatrixFrozen: boolean;
  78890. /**
  78891. * Retuns the mesh absolute position in the World.
  78892. * @returns a Vector3.
  78893. */
  78894. getAbsolutePosition(): Vector3;
  78895. /**
  78896. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  78897. * @param absolutePosition the absolute position to set
  78898. * @returns the TransformNode.
  78899. */
  78900. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  78901. /**
  78902. * Sets the mesh position in its local space.
  78903. * @param vector3 the position to set in localspace
  78904. * @returns the TransformNode.
  78905. */
  78906. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  78907. /**
  78908. * Returns the mesh position in the local space from the current World matrix values.
  78909. * @returns a new Vector3.
  78910. */
  78911. getPositionExpressedInLocalSpace(): Vector3;
  78912. /**
  78913. * Translates the mesh along the passed Vector3 in its local space.
  78914. * @param vector3 the distance to translate in localspace
  78915. * @returns the TransformNode.
  78916. */
  78917. locallyTranslate(vector3: Vector3): TransformNode;
  78918. private static _lookAtVectorCache;
  78919. /**
  78920. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  78921. * @param targetPoint the position (must be in same space as current mesh) to look at
  78922. * @param yawCor optional yaw (y-axis) correction in radians
  78923. * @param pitchCor optional pitch (x-axis) correction in radians
  78924. * @param rollCor optional roll (z-axis) correction in radians
  78925. * @param space the choosen space of the target
  78926. * @returns the TransformNode.
  78927. */
  78928. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  78929. /**
  78930. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  78931. * This Vector3 is expressed in the World space.
  78932. * @param localAxis axis to rotate
  78933. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  78934. */
  78935. getDirection(localAxis: Vector3): Vector3;
  78936. /**
  78937. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  78938. * localAxis is expressed in the mesh local space.
  78939. * result is computed in the Wordl space from the mesh World matrix.
  78940. * @param localAxis axis to rotate
  78941. * @param result the resulting transformnode
  78942. * @returns this TransformNode.
  78943. */
  78944. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  78945. /**
  78946. * Sets this transform node rotation to the given local axis.
  78947. * @param localAxis the axis in local space
  78948. * @param yawCor optional yaw (y-axis) correction in radians
  78949. * @param pitchCor optional pitch (x-axis) correction in radians
  78950. * @param rollCor optional roll (z-axis) correction in radians
  78951. * @returns this TransformNode
  78952. */
  78953. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  78954. /**
  78955. * Sets a new pivot point to the current node
  78956. * @param point defines the new pivot point to use
  78957. * @param space defines if the point is in world or local space (local by default)
  78958. * @returns the current TransformNode
  78959. */
  78960. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  78961. /**
  78962. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  78963. * @returns the pivot point
  78964. */
  78965. getPivotPoint(): Vector3;
  78966. /**
  78967. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  78968. * @param result the vector3 to store the result
  78969. * @returns this TransformNode.
  78970. */
  78971. getPivotPointToRef(result: Vector3): TransformNode;
  78972. /**
  78973. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  78974. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  78975. */
  78976. getAbsolutePivotPoint(): Vector3;
  78977. /**
  78978. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  78979. * @param result vector3 to store the result
  78980. * @returns this TransformNode.
  78981. */
  78982. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  78983. /**
  78984. * Defines the passed node as the parent of the current node.
  78985. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  78986. * @see https://doc.babylonjs.com/how_to/parenting
  78987. * @param node the node ot set as the parent
  78988. * @returns this TransformNode.
  78989. */
  78990. setParent(node: Nullable<Node>): TransformNode;
  78991. private _nonUniformScaling;
  78992. /**
  78993. * True if the scaling property of this object is non uniform eg. (1,2,1)
  78994. */
  78995. readonly nonUniformScaling: boolean;
  78996. /** @hidden */
  78997. _updateNonUniformScalingState(value: boolean): boolean;
  78998. /**
  78999. * Attach the current TransformNode to another TransformNode associated with a bone
  79000. * @param bone Bone affecting the TransformNode
  79001. * @param affectedTransformNode TransformNode associated with the bone
  79002. * @returns this object
  79003. */
  79004. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  79005. /**
  79006. * Detach the transform node if its associated with a bone
  79007. * @returns this object
  79008. */
  79009. detachFromBone(): TransformNode;
  79010. private static _rotationAxisCache;
  79011. /**
  79012. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  79013. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  79014. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  79015. * The passed axis is also normalized.
  79016. * @param axis the axis to rotate around
  79017. * @param amount the amount to rotate in radians
  79018. * @param space Space to rotate in (Default: local)
  79019. * @returns the TransformNode.
  79020. */
  79021. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  79022. /**
  79023. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  79024. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  79025. * The passed axis is also normalized. .
  79026. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  79027. * @param point the point to rotate around
  79028. * @param axis the axis to rotate around
  79029. * @param amount the amount to rotate in radians
  79030. * @returns the TransformNode
  79031. */
  79032. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  79033. /**
  79034. * Translates the mesh along the axis vector for the passed distance in the given space.
  79035. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  79036. * @param axis the axis to translate in
  79037. * @param distance the distance to translate
  79038. * @param space Space to rotate in (Default: local)
  79039. * @returns the TransformNode.
  79040. */
  79041. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  79042. /**
  79043. * Adds a rotation step to the mesh current rotation.
  79044. * x, y, z are Euler angles expressed in radians.
  79045. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  79046. * This means this rotation is made in the mesh local space only.
  79047. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  79048. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  79049. * ```javascript
  79050. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  79051. * ```
  79052. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  79053. * 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.
  79054. * @param x Rotation to add
  79055. * @param y Rotation to add
  79056. * @param z Rotation to add
  79057. * @returns the TransformNode.
  79058. */
  79059. addRotation(x: number, y: number, z: number): TransformNode;
  79060. /**
  79061. * @hidden
  79062. */
  79063. protected _getEffectiveParent(): Nullable<Node>;
  79064. /**
  79065. * Computes the world matrix of the node
  79066. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  79067. * @returns the world matrix
  79068. */
  79069. computeWorldMatrix(force?: boolean): Matrix;
  79070. protected _afterComputeWorldMatrix(): void;
  79071. /**
  79072. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  79073. * @param func callback function to add
  79074. *
  79075. * @returns the TransformNode.
  79076. */
  79077. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  79078. /**
  79079. * Removes a registered callback function.
  79080. * @param func callback function to remove
  79081. * @returns the TransformNode.
  79082. */
  79083. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  79084. /**
  79085. * Gets the position of the current mesh in camera space
  79086. * @param camera defines the camera to use
  79087. * @returns a position
  79088. */
  79089. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  79090. /**
  79091. * Returns the distance from the mesh to the active camera
  79092. * @param camera defines the camera to use
  79093. * @returns the distance
  79094. */
  79095. getDistanceToCamera(camera?: Nullable<Camera>): number;
  79096. /**
  79097. * Clone the current transform node
  79098. * @param name Name of the new clone
  79099. * @param newParent New parent for the clone
  79100. * @param doNotCloneChildren Do not clone children hierarchy
  79101. * @returns the new transform node
  79102. */
  79103. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  79104. /**
  79105. * Serializes the objects information.
  79106. * @param currentSerializationObject defines the object to serialize in
  79107. * @returns the serialized object
  79108. */
  79109. serialize(currentSerializationObject?: any): any;
  79110. /**
  79111. * Returns a new TransformNode object parsed from the source provided.
  79112. * @param parsedTransformNode is the source.
  79113. * @param scene the scne the object belongs to
  79114. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  79115. * @returns a new TransformNode object parsed from the source provided.
  79116. */
  79117. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  79118. /**
  79119. * Get all child-transformNodes of this node
  79120. * @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
  79121. * @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
  79122. * @returns an array of TransformNode
  79123. */
  79124. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  79125. /**
  79126. * Releases resources associated with this transform node.
  79127. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  79128. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  79129. */
  79130. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  79131. /**
  79132. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  79133. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  79134. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  79135. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  79136. * @returns the current mesh
  79137. */
  79138. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  79139. private _syncAbsoluteScalingAndRotation;
  79140. }
  79141. }
  79142. declare module BABYLON {
  79143. /**
  79144. * Defines the types of pose enabled controllers that are supported
  79145. */
  79146. export enum PoseEnabledControllerType {
  79147. /**
  79148. * HTC Vive
  79149. */
  79150. VIVE = 0,
  79151. /**
  79152. * Oculus Rift
  79153. */
  79154. OCULUS = 1,
  79155. /**
  79156. * Windows mixed reality
  79157. */
  79158. WINDOWS = 2,
  79159. /**
  79160. * Samsung gear VR
  79161. */
  79162. GEAR_VR = 3,
  79163. /**
  79164. * Google Daydream
  79165. */
  79166. DAYDREAM = 4,
  79167. /**
  79168. * Generic
  79169. */
  79170. GENERIC = 5
  79171. }
  79172. /**
  79173. * Defines the MutableGamepadButton interface for the state of a gamepad button
  79174. */
  79175. export interface MutableGamepadButton {
  79176. /**
  79177. * Value of the button/trigger
  79178. */
  79179. value: number;
  79180. /**
  79181. * If the button/trigger is currently touched
  79182. */
  79183. touched: boolean;
  79184. /**
  79185. * If the button/trigger is currently pressed
  79186. */
  79187. pressed: boolean;
  79188. }
  79189. /**
  79190. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  79191. * @hidden
  79192. */
  79193. export interface ExtendedGamepadButton extends GamepadButton {
  79194. /**
  79195. * If the button/trigger is currently pressed
  79196. */
  79197. readonly pressed: boolean;
  79198. /**
  79199. * If the button/trigger is currently touched
  79200. */
  79201. readonly touched: boolean;
  79202. /**
  79203. * Value of the button/trigger
  79204. */
  79205. readonly value: number;
  79206. }
  79207. /** @hidden */
  79208. export interface _GamePadFactory {
  79209. /**
  79210. * Returns wether or not the current gamepad can be created for this type of controller.
  79211. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  79212. * @returns true if it can be created, otherwise false
  79213. */
  79214. canCreate(gamepadInfo: any): boolean;
  79215. /**
  79216. * Creates a new instance of the Gamepad.
  79217. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  79218. * @returns the new gamepad instance
  79219. */
  79220. create(gamepadInfo: any): Gamepad;
  79221. }
  79222. /**
  79223. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  79224. */
  79225. export class PoseEnabledControllerHelper {
  79226. /** @hidden */
  79227. static _ControllerFactories: _GamePadFactory[];
  79228. /** @hidden */
  79229. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  79230. /**
  79231. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  79232. * @param vrGamepad the gamepad to initialized
  79233. * @returns a vr controller of the type the gamepad identified as
  79234. */
  79235. static InitiateController(vrGamepad: any): Gamepad;
  79236. }
  79237. /**
  79238. * Defines the PoseEnabledController object that contains state of a vr capable controller
  79239. */
  79240. export class PoseEnabledController extends Gamepad implements PoseControlled {
  79241. /**
  79242. * If the controller is used in a webXR session
  79243. */
  79244. isXR: boolean;
  79245. private _deviceRoomPosition;
  79246. private _deviceRoomRotationQuaternion;
  79247. /**
  79248. * The device position in babylon space
  79249. */
  79250. devicePosition: Vector3;
  79251. /**
  79252. * The device rotation in babylon space
  79253. */
  79254. deviceRotationQuaternion: Quaternion;
  79255. /**
  79256. * The scale factor of the device in babylon space
  79257. */
  79258. deviceScaleFactor: number;
  79259. /**
  79260. * (Likely devicePosition should be used instead) The device position in its room space
  79261. */
  79262. position: Vector3;
  79263. /**
  79264. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  79265. */
  79266. rotationQuaternion: Quaternion;
  79267. /**
  79268. * The type of controller (Eg. Windows mixed reality)
  79269. */
  79270. controllerType: PoseEnabledControllerType;
  79271. protected _calculatedPosition: Vector3;
  79272. private _calculatedRotation;
  79273. /**
  79274. * The raw pose from the device
  79275. */
  79276. rawPose: DevicePose;
  79277. private _trackPosition;
  79278. private _maxRotationDistFromHeadset;
  79279. private _draggedRoomRotation;
  79280. /**
  79281. * @hidden
  79282. */
  79283. _disableTrackPosition(fixedPosition: Vector3): void;
  79284. /**
  79285. * Internal, the mesh attached to the controller
  79286. * @hidden
  79287. */
  79288. _mesh: Nullable<AbstractMesh>;
  79289. private _poseControlledCamera;
  79290. private _leftHandSystemQuaternion;
  79291. /**
  79292. * Internal, matrix used to convert room space to babylon space
  79293. * @hidden
  79294. */
  79295. _deviceToWorld: Matrix;
  79296. /**
  79297. * Node to be used when casting a ray from the controller
  79298. * @hidden
  79299. */
  79300. _pointingPoseNode: Nullable<TransformNode>;
  79301. /**
  79302. * Name of the child mesh that can be used to cast a ray from the controller
  79303. */
  79304. static readonly POINTING_POSE: string;
  79305. /**
  79306. * Creates a new PoseEnabledController from a gamepad
  79307. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  79308. */
  79309. constructor(browserGamepad: any);
  79310. private _workingMatrix;
  79311. /**
  79312. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  79313. */
  79314. update(): void;
  79315. /**
  79316. * Updates only the pose device and mesh without doing any button event checking
  79317. */
  79318. protected _updatePoseAndMesh(): void;
  79319. /**
  79320. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  79321. * @param poseData raw pose fromthe device
  79322. */
  79323. updateFromDevice(poseData: DevicePose): void;
  79324. /**
  79325. * @hidden
  79326. */
  79327. _meshAttachedObservable: Observable<AbstractMesh>;
  79328. /**
  79329. * Attaches a mesh to the controller
  79330. * @param mesh the mesh to be attached
  79331. */
  79332. attachToMesh(mesh: AbstractMesh): void;
  79333. /**
  79334. * Attaches the controllers mesh to a camera
  79335. * @param camera the camera the mesh should be attached to
  79336. */
  79337. attachToPoseControlledCamera(camera: TargetCamera): void;
  79338. /**
  79339. * Disposes of the controller
  79340. */
  79341. dispose(): void;
  79342. /**
  79343. * The mesh that is attached to the controller
  79344. */
  79345. readonly mesh: Nullable<AbstractMesh>;
  79346. /**
  79347. * Gets the ray of the controller in the direction the controller is pointing
  79348. * @param length the length the resulting ray should be
  79349. * @returns a ray in the direction the controller is pointing
  79350. */
  79351. getForwardRay(length?: number): Ray;
  79352. }
  79353. }
  79354. declare module BABYLON {
  79355. /**
  79356. * Defines the WebVRController object that represents controllers tracked in 3D space
  79357. */
  79358. export abstract class WebVRController extends PoseEnabledController {
  79359. /**
  79360. * Internal, the default controller model for the controller
  79361. */
  79362. protected _defaultModel: AbstractMesh;
  79363. /**
  79364. * Fired when the trigger state has changed
  79365. */
  79366. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  79367. /**
  79368. * Fired when the main button state has changed
  79369. */
  79370. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  79371. /**
  79372. * Fired when the secondary button state has changed
  79373. */
  79374. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  79375. /**
  79376. * Fired when the pad state has changed
  79377. */
  79378. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  79379. /**
  79380. * Fired when controllers stick values have changed
  79381. */
  79382. onPadValuesChangedObservable: Observable<StickValues>;
  79383. /**
  79384. * Array of button availible on the controller
  79385. */
  79386. protected _buttons: Array<MutableGamepadButton>;
  79387. private _onButtonStateChange;
  79388. /**
  79389. * Fired when a controller button's state has changed
  79390. * @param callback the callback containing the button that was modified
  79391. */
  79392. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  79393. /**
  79394. * X and Y axis corresponding to the controllers joystick
  79395. */
  79396. pad: StickValues;
  79397. /**
  79398. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  79399. */
  79400. hand: string;
  79401. /**
  79402. * The default controller model for the controller
  79403. */
  79404. readonly defaultModel: AbstractMesh;
  79405. /**
  79406. * Creates a new WebVRController from a gamepad
  79407. * @param vrGamepad the gamepad that the WebVRController should be created from
  79408. */
  79409. constructor(vrGamepad: any);
  79410. /**
  79411. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  79412. */
  79413. update(): void;
  79414. /**
  79415. * Function to be called when a button is modified
  79416. */
  79417. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  79418. /**
  79419. * Loads a mesh and attaches it to the controller
  79420. * @param scene the scene the mesh should be added to
  79421. * @param meshLoaded callback for when the mesh has been loaded
  79422. */
  79423. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  79424. private _setButtonValue;
  79425. private _changes;
  79426. private _checkChanges;
  79427. /**
  79428. * Disposes of th webVRCOntroller
  79429. */
  79430. dispose(): void;
  79431. }
  79432. }
  79433. declare module BABYLON {
  79434. /**
  79435. * The HemisphericLight simulates the ambient environment light,
  79436. * so the passed direction is the light reflection direction, not the incoming direction.
  79437. */
  79438. export class HemisphericLight extends Light {
  79439. /**
  79440. * The groundColor is the light in the opposite direction to the one specified during creation.
  79441. * 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.
  79442. */
  79443. groundColor: Color3;
  79444. /**
  79445. * The light reflection direction, not the incoming direction.
  79446. */
  79447. direction: Vector3;
  79448. /**
  79449. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  79450. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  79451. * The HemisphericLight can't cast shadows.
  79452. * Documentation : https://doc.babylonjs.com/babylon101/lights
  79453. * @param name The friendly name of the light
  79454. * @param direction The direction of the light reflection
  79455. * @param scene The scene the light belongs to
  79456. */
  79457. constructor(name: string, direction: Vector3, scene: Scene);
  79458. protected _buildUniformLayout(): void;
  79459. /**
  79460. * Returns the string "HemisphericLight".
  79461. * @return The class name
  79462. */
  79463. getClassName(): string;
  79464. /**
  79465. * Sets the HemisphericLight direction towards the passed target (Vector3).
  79466. * Returns the updated direction.
  79467. * @param target The target the direction should point to
  79468. * @return The computed direction
  79469. */
  79470. setDirectionToTarget(target: Vector3): Vector3;
  79471. /**
  79472. * Returns the shadow generator associated to the light.
  79473. * @returns Always null for hemispheric lights because it does not support shadows.
  79474. */
  79475. getShadowGenerator(): Nullable<IShadowGenerator>;
  79476. /**
  79477. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  79478. * @param effect The effect to update
  79479. * @param lightIndex The index of the light in the effect to update
  79480. * @returns The hemispheric light
  79481. */
  79482. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  79483. /**
  79484. * Computes the world matrix of the node
  79485. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  79486. * @param useWasUpdatedFlag defines a reserved property
  79487. * @returns the world matrix
  79488. */
  79489. computeWorldMatrix(): Matrix;
  79490. /**
  79491. * Returns the integer 3.
  79492. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  79493. */
  79494. getTypeID(): number;
  79495. /**
  79496. * Prepares the list of defines specific to the light type.
  79497. * @param defines the list of defines
  79498. * @param lightIndex defines the index of the light for the effect
  79499. */
  79500. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  79501. }
  79502. }
  79503. declare module BABYLON {
  79504. /** @hidden */
  79505. export var vrMultiviewToSingleviewPixelShader: {
  79506. name: string;
  79507. shader: string;
  79508. };
  79509. }
  79510. declare module BABYLON {
  79511. /**
  79512. * Renders to multiple views with a single draw call
  79513. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  79514. */
  79515. export class MultiviewRenderTarget extends RenderTargetTexture {
  79516. /**
  79517. * Creates a multiview render target
  79518. * @param scene scene used with the render target
  79519. * @param size the size of the render target (used for each view)
  79520. */
  79521. constructor(scene: Scene, size?: number | {
  79522. width: number;
  79523. height: number;
  79524. } | {
  79525. ratio: number;
  79526. });
  79527. /**
  79528. * @hidden
  79529. * @param faceIndex the face index, if its a cube texture
  79530. */
  79531. _bindFrameBuffer(faceIndex?: number): void;
  79532. /**
  79533. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  79534. * @returns the view count
  79535. */
  79536. getViewCount(): number;
  79537. }
  79538. }
  79539. declare module BABYLON {
  79540. /**
  79541. * Reprasents a camera frustum
  79542. */
  79543. export class Frustum {
  79544. /**
  79545. * Gets the planes representing the frustum
  79546. * @param transform matrix to be applied to the returned planes
  79547. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  79548. */
  79549. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  79550. /**
  79551. * Gets the near frustum plane transformed by the transform matrix
  79552. * @param transform transformation matrix to be applied to the resulting frustum plane
  79553. * @param frustumPlane the resuling frustum plane
  79554. */
  79555. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  79556. /**
  79557. * Gets the far frustum plane transformed by the transform matrix
  79558. * @param transform transformation matrix to be applied to the resulting frustum plane
  79559. * @param frustumPlane the resuling frustum plane
  79560. */
  79561. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  79562. /**
  79563. * Gets the left frustum plane transformed by the transform matrix
  79564. * @param transform transformation matrix to be applied to the resulting frustum plane
  79565. * @param frustumPlane the resuling frustum plane
  79566. */
  79567. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  79568. /**
  79569. * Gets the right frustum plane transformed by the transform matrix
  79570. * @param transform transformation matrix to be applied to the resulting frustum plane
  79571. * @param frustumPlane the resuling frustum plane
  79572. */
  79573. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  79574. /**
  79575. * Gets the top frustum plane transformed by the transform matrix
  79576. * @param transform transformation matrix to be applied to the resulting frustum plane
  79577. * @param frustumPlane the resuling frustum plane
  79578. */
  79579. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  79580. /**
  79581. * Gets the bottom frustum plane transformed by the transform matrix
  79582. * @param transform transformation matrix to be applied to the resulting frustum plane
  79583. * @param frustumPlane the resuling frustum plane
  79584. */
  79585. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  79586. /**
  79587. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  79588. * @param transform transformation matrix to be applied to the resulting frustum planes
  79589. * @param frustumPlanes the resuling frustum planes
  79590. */
  79591. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  79592. }
  79593. }
  79594. declare module BABYLON {
  79595. interface Engine {
  79596. /**
  79597. * Creates a new multiview render target
  79598. * @param width defines the width of the texture
  79599. * @param height defines the height of the texture
  79600. * @returns the created multiview texture
  79601. */
  79602. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  79603. /**
  79604. * Binds a multiview framebuffer to be drawn to
  79605. * @param multiviewTexture texture to bind
  79606. */
  79607. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  79608. }
  79609. interface Camera {
  79610. /**
  79611. * @hidden
  79612. * 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)
  79613. */
  79614. _useMultiviewToSingleView: boolean;
  79615. /**
  79616. * @hidden
  79617. * 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)
  79618. */
  79619. _multiviewTexture: Nullable<RenderTargetTexture>;
  79620. /**
  79621. * @hidden
  79622. * ensures the multiview texture of the camera exists and has the specified width/height
  79623. * @param width height to set on the multiview texture
  79624. * @param height width to set on the multiview texture
  79625. */
  79626. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  79627. }
  79628. interface Scene {
  79629. /** @hidden */
  79630. _transformMatrixR: Matrix;
  79631. /** @hidden */
  79632. _multiviewSceneUbo: Nullable<UniformBuffer>;
  79633. /** @hidden */
  79634. _createMultiviewUbo(): void;
  79635. /** @hidden */
  79636. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  79637. /** @hidden */
  79638. _renderMultiviewToSingleView(camera: Camera): void;
  79639. }
  79640. }
  79641. declare module BABYLON {
  79642. /**
  79643. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  79644. * This will not be used for webXR as it supports displaying texture arrays directly
  79645. */
  79646. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  79647. /**
  79648. * Initializes a VRMultiviewToSingleview
  79649. * @param name name of the post process
  79650. * @param camera camera to be applied to
  79651. * @param scaleFactor scaling factor to the size of the output texture
  79652. */
  79653. constructor(name: string, camera: Camera, scaleFactor: number);
  79654. }
  79655. }
  79656. declare module BABYLON {
  79657. interface Engine {
  79658. /** @hidden */
  79659. _vrDisplay: any;
  79660. /** @hidden */
  79661. _vrSupported: boolean;
  79662. /** @hidden */
  79663. _oldSize: Size;
  79664. /** @hidden */
  79665. _oldHardwareScaleFactor: number;
  79666. /** @hidden */
  79667. _vrExclusivePointerMode: boolean;
  79668. /** @hidden */
  79669. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  79670. /** @hidden */
  79671. _onVRDisplayPointerRestricted: () => void;
  79672. /** @hidden */
  79673. _onVRDisplayPointerUnrestricted: () => void;
  79674. /** @hidden */
  79675. _onVrDisplayConnect: Nullable<(display: any) => void>;
  79676. /** @hidden */
  79677. _onVrDisplayDisconnect: Nullable<() => void>;
  79678. /** @hidden */
  79679. _onVrDisplayPresentChange: Nullable<() => void>;
  79680. /**
  79681. * Observable signaled when VR display mode changes
  79682. */
  79683. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  79684. /**
  79685. * Observable signaled when VR request present is complete
  79686. */
  79687. onVRRequestPresentComplete: Observable<boolean>;
  79688. /**
  79689. * Observable signaled when VR request present starts
  79690. */
  79691. onVRRequestPresentStart: Observable<Engine>;
  79692. /**
  79693. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  79694. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  79695. */
  79696. isInVRExclusivePointerMode: boolean;
  79697. /**
  79698. * Gets a boolean indicating if a webVR device was detected
  79699. * @returns true if a webVR device was detected
  79700. */
  79701. isVRDevicePresent(): boolean;
  79702. /**
  79703. * Gets the current webVR device
  79704. * @returns the current webVR device (or null)
  79705. */
  79706. getVRDevice(): any;
  79707. /**
  79708. * Initializes a webVR display and starts listening to display change events
  79709. * The onVRDisplayChangedObservable will be notified upon these changes
  79710. * @returns A promise containing a VRDisplay and if vr is supported
  79711. */
  79712. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  79713. /** @hidden */
  79714. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  79715. /**
  79716. * Call this function to switch to webVR mode
  79717. * Will do nothing if webVR is not supported or if there is no webVR device
  79718. * @see http://doc.babylonjs.com/how_to/webvr_camera
  79719. */
  79720. enableVR(): void;
  79721. /** @hidden */
  79722. _onVRFullScreenTriggered(): void;
  79723. }
  79724. }
  79725. declare module BABYLON {
  79726. /**
  79727. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  79728. * IMPORTANT!! The data is right-hand data.
  79729. * @export
  79730. * @interface DevicePose
  79731. */
  79732. export interface DevicePose {
  79733. /**
  79734. * The position of the device, values in array are [x,y,z].
  79735. */
  79736. readonly position: Nullable<Float32Array>;
  79737. /**
  79738. * The linearVelocity of the device, values in array are [x,y,z].
  79739. */
  79740. readonly linearVelocity: Nullable<Float32Array>;
  79741. /**
  79742. * The linearAcceleration of the device, values in array are [x,y,z].
  79743. */
  79744. readonly linearAcceleration: Nullable<Float32Array>;
  79745. /**
  79746. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  79747. */
  79748. readonly orientation: Nullable<Float32Array>;
  79749. /**
  79750. * The angularVelocity of the device, values in array are [x,y,z].
  79751. */
  79752. readonly angularVelocity: Nullable<Float32Array>;
  79753. /**
  79754. * The angularAcceleration of the device, values in array are [x,y,z].
  79755. */
  79756. readonly angularAcceleration: Nullable<Float32Array>;
  79757. }
  79758. /**
  79759. * Interface representing a pose controlled object in Babylon.
  79760. * A pose controlled object has both regular pose values as well as pose values
  79761. * from an external device such as a VR head mounted display
  79762. */
  79763. export interface PoseControlled {
  79764. /**
  79765. * The position of the object in babylon space.
  79766. */
  79767. position: Vector3;
  79768. /**
  79769. * The rotation quaternion of the object in babylon space.
  79770. */
  79771. rotationQuaternion: Quaternion;
  79772. /**
  79773. * The position of the device in babylon space.
  79774. */
  79775. devicePosition?: Vector3;
  79776. /**
  79777. * The rotation quaternion of the device in babylon space.
  79778. */
  79779. deviceRotationQuaternion: Quaternion;
  79780. /**
  79781. * The raw pose coming from the device.
  79782. */
  79783. rawPose: Nullable<DevicePose>;
  79784. /**
  79785. * The scale of the device to be used when translating from device space to babylon space.
  79786. */
  79787. deviceScaleFactor: number;
  79788. /**
  79789. * Updates the poseControlled values based on the input device pose.
  79790. * @param poseData the pose data to update the object with
  79791. */
  79792. updateFromDevice(poseData: DevicePose): void;
  79793. }
  79794. /**
  79795. * Set of options to customize the webVRCamera
  79796. */
  79797. export interface WebVROptions {
  79798. /**
  79799. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  79800. */
  79801. trackPosition?: boolean;
  79802. /**
  79803. * Sets the scale of the vrDevice in babylon space. (default: 1)
  79804. */
  79805. positionScale?: number;
  79806. /**
  79807. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  79808. */
  79809. displayName?: string;
  79810. /**
  79811. * Should the native controller meshes be initialized. (default: true)
  79812. */
  79813. controllerMeshes?: boolean;
  79814. /**
  79815. * Creating a default HemiLight only on controllers. (default: true)
  79816. */
  79817. defaultLightingOnControllers?: boolean;
  79818. /**
  79819. * If you don't want to use the default VR button of the helper. (default: false)
  79820. */
  79821. useCustomVRButton?: boolean;
  79822. /**
  79823. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  79824. */
  79825. customVRButton?: HTMLButtonElement;
  79826. /**
  79827. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  79828. */
  79829. rayLength?: number;
  79830. /**
  79831. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  79832. */
  79833. defaultHeight?: number;
  79834. /**
  79835. * If multiview should be used if availible (default: false)
  79836. */
  79837. useMultiview?: boolean;
  79838. }
  79839. /**
  79840. * This represents a WebVR camera.
  79841. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  79842. * @example http://doc.babylonjs.com/how_to/webvr_camera
  79843. */
  79844. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  79845. private webVROptions;
  79846. /**
  79847. * @hidden
  79848. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  79849. */
  79850. _vrDevice: any;
  79851. /**
  79852. * The rawPose of the vrDevice.
  79853. */
  79854. rawPose: Nullable<DevicePose>;
  79855. private _onVREnabled;
  79856. private _specsVersion;
  79857. private _attached;
  79858. private _frameData;
  79859. protected _descendants: Array<Node>;
  79860. private _deviceRoomPosition;
  79861. /** @hidden */
  79862. _deviceRoomRotationQuaternion: Quaternion;
  79863. private _standingMatrix;
  79864. /**
  79865. * Represents device position in babylon space.
  79866. */
  79867. devicePosition: Vector3;
  79868. /**
  79869. * Represents device rotation in babylon space.
  79870. */
  79871. deviceRotationQuaternion: Quaternion;
  79872. /**
  79873. * The scale of the device to be used when translating from device space to babylon space.
  79874. */
  79875. deviceScaleFactor: number;
  79876. private _deviceToWorld;
  79877. private _worldToDevice;
  79878. /**
  79879. * References to the webVR controllers for the vrDevice.
  79880. */
  79881. controllers: Array<WebVRController>;
  79882. /**
  79883. * Emits an event when a controller is attached.
  79884. */
  79885. onControllersAttachedObservable: Observable<WebVRController[]>;
  79886. /**
  79887. * Emits an event when a controller's mesh has been loaded;
  79888. */
  79889. onControllerMeshLoadedObservable: Observable<WebVRController>;
  79890. /**
  79891. * Emits an event when the HMD's pose has been updated.
  79892. */
  79893. onPoseUpdatedFromDeviceObservable: Observable<any>;
  79894. private _poseSet;
  79895. /**
  79896. * If the rig cameras be used as parent instead of this camera.
  79897. */
  79898. rigParenting: boolean;
  79899. private _lightOnControllers;
  79900. private _defaultHeight?;
  79901. /**
  79902. * Instantiates a WebVRFreeCamera.
  79903. * @param name The name of the WebVRFreeCamera
  79904. * @param position The starting anchor position for the camera
  79905. * @param scene The scene the camera belongs to
  79906. * @param webVROptions a set of customizable options for the webVRCamera
  79907. */
  79908. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  79909. /**
  79910. * Gets the device distance from the ground in meters.
  79911. * @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.
  79912. */
  79913. deviceDistanceToRoomGround(): number;
  79914. /**
  79915. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  79916. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  79917. */
  79918. useStandingMatrix(callback?: (bool: boolean) => void): void;
  79919. /**
  79920. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  79921. * @returns A promise with a boolean set to if the standing matrix is supported.
  79922. */
  79923. useStandingMatrixAsync(): Promise<boolean>;
  79924. /**
  79925. * Disposes the camera
  79926. */
  79927. dispose(): void;
  79928. /**
  79929. * Gets a vrController by name.
  79930. * @param name The name of the controller to retreive
  79931. * @returns the controller matching the name specified or null if not found
  79932. */
  79933. getControllerByName(name: string): Nullable<WebVRController>;
  79934. private _leftController;
  79935. /**
  79936. * The controller corresponding to the users left hand.
  79937. */
  79938. readonly leftController: Nullable<WebVRController>;
  79939. private _rightController;
  79940. /**
  79941. * The controller corresponding to the users right hand.
  79942. */
  79943. readonly rightController: Nullable<WebVRController>;
  79944. /**
  79945. * Casts a ray forward from the vrCamera's gaze.
  79946. * @param length Length of the ray (default: 100)
  79947. * @returns the ray corresponding to the gaze
  79948. */
  79949. getForwardRay(length?: number): Ray;
  79950. /**
  79951. * @hidden
  79952. * Updates the camera based on device's frame data
  79953. */
  79954. _checkInputs(): void;
  79955. /**
  79956. * Updates the poseControlled values based on the input device pose.
  79957. * @param poseData Pose coming from the device
  79958. */
  79959. updateFromDevice(poseData: DevicePose): void;
  79960. private _htmlElementAttached;
  79961. private _detachIfAttached;
  79962. /**
  79963. * WebVR's attach control will start broadcasting frames to the device.
  79964. * Note that in certain browsers (chrome for example) this function must be called
  79965. * within a user-interaction callback. Example:
  79966. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  79967. *
  79968. * @param element html element to attach the vrDevice to
  79969. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  79970. */
  79971. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79972. /**
  79973. * Detaches the camera from the html element and disables VR
  79974. *
  79975. * @param element html element to detach from
  79976. */
  79977. detachControl(element: HTMLElement): void;
  79978. /**
  79979. * @returns the name of this class
  79980. */
  79981. getClassName(): string;
  79982. /**
  79983. * Calls resetPose on the vrDisplay
  79984. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  79985. */
  79986. resetToCurrentRotation(): void;
  79987. /**
  79988. * @hidden
  79989. * Updates the rig cameras (left and right eye)
  79990. */
  79991. _updateRigCameras(): void;
  79992. private _workingVector;
  79993. private _oneVector;
  79994. private _workingMatrix;
  79995. private updateCacheCalled;
  79996. private _correctPositionIfNotTrackPosition;
  79997. /**
  79998. * @hidden
  79999. * Updates the cached values of the camera
  80000. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  80001. */
  80002. _updateCache(ignoreParentClass?: boolean): void;
  80003. /**
  80004. * @hidden
  80005. * Get current device position in babylon world
  80006. */
  80007. _computeDevicePosition(): void;
  80008. /**
  80009. * Updates the current device position and rotation in the babylon world
  80010. */
  80011. update(): void;
  80012. /**
  80013. * @hidden
  80014. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  80015. * @returns an identity matrix
  80016. */
  80017. _getViewMatrix(): Matrix;
  80018. private _tmpMatrix;
  80019. /**
  80020. * This function is called by the two RIG cameras.
  80021. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  80022. * @hidden
  80023. */
  80024. _getWebVRViewMatrix(): Matrix;
  80025. /** @hidden */
  80026. _getWebVRProjectionMatrix(): Matrix;
  80027. private _onGamepadConnectedObserver;
  80028. private _onGamepadDisconnectedObserver;
  80029. private _updateCacheWhenTrackingDisabledObserver;
  80030. /**
  80031. * Initializes the controllers and their meshes
  80032. */
  80033. initControllers(): void;
  80034. }
  80035. }
  80036. declare module BABYLON {
  80037. /**
  80038. * Size options for a post process
  80039. */
  80040. export type PostProcessOptions = {
  80041. width: number;
  80042. height: number;
  80043. };
  80044. /**
  80045. * PostProcess can be used to apply a shader to a texture after it has been rendered
  80046. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  80047. */
  80048. export class PostProcess {
  80049. /** Name of the PostProcess. */
  80050. name: string;
  80051. /**
  80052. * Gets or sets the unique id of the post process
  80053. */
  80054. uniqueId: number;
  80055. /**
  80056. * Width of the texture to apply the post process on
  80057. */
  80058. width: number;
  80059. /**
  80060. * Height of the texture to apply the post process on
  80061. */
  80062. height: number;
  80063. /**
  80064. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  80065. * @hidden
  80066. */
  80067. _outputTexture: Nullable<InternalTexture>;
  80068. /**
  80069. * Sampling mode used by the shader
  80070. * See https://doc.babylonjs.com/classes/3.1/texture
  80071. */
  80072. renderTargetSamplingMode: number;
  80073. /**
  80074. * Clear color to use when screen clearing
  80075. */
  80076. clearColor: Color4;
  80077. /**
  80078. * If the buffer needs to be cleared before applying the post process. (default: true)
  80079. * Should be set to false if shader will overwrite all previous pixels.
  80080. */
  80081. autoClear: boolean;
  80082. /**
  80083. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  80084. */
  80085. alphaMode: number;
  80086. /**
  80087. * Sets the setAlphaBlendConstants of the babylon engine
  80088. */
  80089. alphaConstants: Color4;
  80090. /**
  80091. * Animations to be used for the post processing
  80092. */
  80093. animations: Animation[];
  80094. /**
  80095. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  80096. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  80097. */
  80098. enablePixelPerfectMode: boolean;
  80099. /**
  80100. * Force the postprocess to be applied without taking in account viewport
  80101. */
  80102. forceFullscreenViewport: boolean;
  80103. /**
  80104. * List of inspectable custom properties (used by the Inspector)
  80105. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80106. */
  80107. inspectableCustomProperties: IInspectable[];
  80108. /**
  80109. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  80110. *
  80111. * | Value | Type | Description |
  80112. * | ----- | ----------------------------------- | ----------- |
  80113. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  80114. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  80115. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  80116. *
  80117. */
  80118. scaleMode: number;
  80119. /**
  80120. * Force textures to be a power of two (default: false)
  80121. */
  80122. alwaysForcePOT: boolean;
  80123. private _samples;
  80124. /**
  80125. * Number of sample textures (default: 1)
  80126. */
  80127. samples: number;
  80128. /**
  80129. * Modify the scale of the post process to be the same as the viewport (default: false)
  80130. */
  80131. adaptScaleToCurrentViewport: boolean;
  80132. private _camera;
  80133. private _scene;
  80134. private _engine;
  80135. private _options;
  80136. private _reusable;
  80137. private _textureType;
  80138. /**
  80139. * Smart array of input and output textures for the post process.
  80140. * @hidden
  80141. */
  80142. _textures: SmartArray<InternalTexture>;
  80143. /**
  80144. * The index in _textures that corresponds to the output texture.
  80145. * @hidden
  80146. */
  80147. _currentRenderTextureInd: number;
  80148. private _effect;
  80149. private _samplers;
  80150. private _fragmentUrl;
  80151. private _vertexUrl;
  80152. private _parameters;
  80153. private _scaleRatio;
  80154. protected _indexParameters: any;
  80155. private _shareOutputWithPostProcess;
  80156. private _texelSize;
  80157. private _forcedOutputTexture;
  80158. /**
  80159. * Returns the fragment url or shader name used in the post process.
  80160. * @returns the fragment url or name in the shader store.
  80161. */
  80162. getEffectName(): string;
  80163. /**
  80164. * An event triggered when the postprocess is activated.
  80165. */
  80166. onActivateObservable: Observable<Camera>;
  80167. private _onActivateObserver;
  80168. /**
  80169. * A function that is added to the onActivateObservable
  80170. */
  80171. onActivate: Nullable<(camera: Camera) => void>;
  80172. /**
  80173. * An event triggered when the postprocess changes its size.
  80174. */
  80175. onSizeChangedObservable: Observable<PostProcess>;
  80176. private _onSizeChangedObserver;
  80177. /**
  80178. * A function that is added to the onSizeChangedObservable
  80179. */
  80180. onSizeChanged: (postProcess: PostProcess) => void;
  80181. /**
  80182. * An event triggered when the postprocess applies its effect.
  80183. */
  80184. onApplyObservable: Observable<Effect>;
  80185. private _onApplyObserver;
  80186. /**
  80187. * A function that is added to the onApplyObservable
  80188. */
  80189. onApply: (effect: Effect) => void;
  80190. /**
  80191. * An event triggered before rendering the postprocess
  80192. */
  80193. onBeforeRenderObservable: Observable<Effect>;
  80194. private _onBeforeRenderObserver;
  80195. /**
  80196. * A function that is added to the onBeforeRenderObservable
  80197. */
  80198. onBeforeRender: (effect: Effect) => void;
  80199. /**
  80200. * An event triggered after rendering the postprocess
  80201. */
  80202. onAfterRenderObservable: Observable<Effect>;
  80203. private _onAfterRenderObserver;
  80204. /**
  80205. * A function that is added to the onAfterRenderObservable
  80206. */
  80207. onAfterRender: (efect: Effect) => void;
  80208. /**
  80209. * 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
  80210. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  80211. */
  80212. inputTexture: InternalTexture;
  80213. /**
  80214. * Gets the camera which post process is applied to.
  80215. * @returns The camera the post process is applied to.
  80216. */
  80217. getCamera(): Camera;
  80218. /**
  80219. * Gets the texel size of the postprocess.
  80220. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  80221. */
  80222. readonly texelSize: Vector2;
  80223. /**
  80224. * Creates a new instance PostProcess
  80225. * @param name The name of the PostProcess.
  80226. * @param fragmentUrl The url of the fragment shader to be used.
  80227. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  80228. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  80229. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  80230. * @param camera The camera to apply the render pass to.
  80231. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  80232. * @param engine The engine which the post process will be applied. (default: current engine)
  80233. * @param reusable If the post process can be reused on the same frame. (default: false)
  80234. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  80235. * @param textureType Type of textures used when performing the post process. (default: 0)
  80236. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  80237. * @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
  80238. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  80239. */
  80240. constructor(
  80241. /** Name of the PostProcess. */
  80242. 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);
  80243. /**
  80244. * Gets a string idenfifying the name of the class
  80245. * @returns "PostProcess" string
  80246. */
  80247. getClassName(): string;
  80248. /**
  80249. * Gets the engine which this post process belongs to.
  80250. * @returns The engine the post process was enabled with.
  80251. */
  80252. getEngine(): Engine;
  80253. /**
  80254. * The effect that is created when initializing the post process.
  80255. * @returns The created effect corresponding the the postprocess.
  80256. */
  80257. getEffect(): Effect;
  80258. /**
  80259. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  80260. * @param postProcess The post process to share the output with.
  80261. * @returns This post process.
  80262. */
  80263. shareOutputWith(postProcess: PostProcess): PostProcess;
  80264. /**
  80265. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  80266. * This should be called if the post process that shares output with this post process is disabled/disposed.
  80267. */
  80268. useOwnOutput(): void;
  80269. /**
  80270. * Updates the effect with the current post process compile time values and recompiles the shader.
  80271. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  80272. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  80273. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  80274. * @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
  80275. * @param onCompiled Called when the shader has been compiled.
  80276. * @param onError Called if there is an error when compiling a shader.
  80277. */
  80278. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  80279. /**
  80280. * The post process is reusable if it can be used multiple times within one frame.
  80281. * @returns If the post process is reusable
  80282. */
  80283. isReusable(): boolean;
  80284. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  80285. markTextureDirty(): void;
  80286. /**
  80287. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  80288. * 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.
  80289. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  80290. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  80291. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  80292. * @returns The target texture that was bound to be written to.
  80293. */
  80294. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  80295. /**
  80296. * If the post process is supported.
  80297. */
  80298. readonly isSupported: boolean;
  80299. /**
  80300. * The aspect ratio of the output texture.
  80301. */
  80302. readonly aspectRatio: number;
  80303. /**
  80304. * Get a value indicating if the post-process is ready to be used
  80305. * @returns true if the post-process is ready (shader is compiled)
  80306. */
  80307. isReady(): boolean;
  80308. /**
  80309. * Binds all textures and uniforms to the shader, this will be run on every pass.
  80310. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  80311. */
  80312. apply(): Nullable<Effect>;
  80313. private _disposeTextures;
  80314. /**
  80315. * Disposes the post process.
  80316. * @param camera The camera to dispose the post process on.
  80317. */
  80318. dispose(camera?: Camera): void;
  80319. }
  80320. }
  80321. declare module BABYLON {
  80322. /** @hidden */
  80323. export var kernelBlurVaryingDeclaration: {
  80324. name: string;
  80325. shader: string;
  80326. };
  80327. }
  80328. declare module BABYLON {
  80329. /** @hidden */
  80330. export var kernelBlurFragment: {
  80331. name: string;
  80332. shader: string;
  80333. };
  80334. }
  80335. declare module BABYLON {
  80336. /** @hidden */
  80337. export var kernelBlurFragment2: {
  80338. name: string;
  80339. shader: string;
  80340. };
  80341. }
  80342. declare module BABYLON {
  80343. /** @hidden */
  80344. export var kernelBlurPixelShader: {
  80345. name: string;
  80346. shader: string;
  80347. };
  80348. }
  80349. declare module BABYLON {
  80350. /** @hidden */
  80351. export var kernelBlurVertex: {
  80352. name: string;
  80353. shader: string;
  80354. };
  80355. }
  80356. declare module BABYLON {
  80357. /** @hidden */
  80358. export var kernelBlurVertexShader: {
  80359. name: string;
  80360. shader: string;
  80361. };
  80362. }
  80363. declare module BABYLON {
  80364. /**
  80365. * The Blur Post Process which blurs an image based on a kernel and direction.
  80366. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  80367. */
  80368. export class BlurPostProcess extends PostProcess {
  80369. /** The direction in which to blur the image. */
  80370. direction: Vector2;
  80371. private blockCompilation;
  80372. protected _kernel: number;
  80373. protected _idealKernel: number;
  80374. protected _packedFloat: boolean;
  80375. private _staticDefines;
  80376. /**
  80377. * Sets the length in pixels of the blur sample region
  80378. */
  80379. /**
  80380. * Gets the length in pixels of the blur sample region
  80381. */
  80382. kernel: number;
  80383. /**
  80384. * Sets wether or not the blur needs to unpack/repack floats
  80385. */
  80386. /**
  80387. * Gets wether or not the blur is unpacking/repacking floats
  80388. */
  80389. packedFloat: boolean;
  80390. /**
  80391. * Creates a new instance BlurPostProcess
  80392. * @param name The name of the effect.
  80393. * @param direction The direction in which to blur the image.
  80394. * @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.
  80395. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  80396. * @param camera The camera to apply the render pass to.
  80397. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  80398. * @param engine The engine which the post process will be applied. (default: current engine)
  80399. * @param reusable If the post process can be reused on the same frame. (default: false)
  80400. * @param textureType Type of textures used when performing the post process. (default: 0)
  80401. * @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)
  80402. */
  80403. constructor(name: string,
  80404. /** The direction in which to blur the image. */
  80405. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  80406. /**
  80407. * Updates the effect with the current post process compile time values and recompiles the shader.
  80408. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  80409. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  80410. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  80411. * @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
  80412. * @param onCompiled Called when the shader has been compiled.
  80413. * @param onError Called if there is an error when compiling a shader.
  80414. */
  80415. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  80416. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  80417. /**
  80418. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  80419. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  80420. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  80421. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  80422. * The gaps between physical kernels are compensated for in the weighting of the samples
  80423. * @param idealKernel Ideal blur kernel.
  80424. * @return Nearest best kernel.
  80425. */
  80426. protected _nearestBestKernel(idealKernel: number): number;
  80427. /**
  80428. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  80429. * @param x The point on the Gaussian distribution to sample.
  80430. * @return the value of the Gaussian function at x.
  80431. */
  80432. protected _gaussianWeight(x: number): number;
  80433. /**
  80434. * Generates a string that can be used as a floating point number in GLSL.
  80435. * @param x Value to print.
  80436. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  80437. * @return GLSL float string.
  80438. */
  80439. protected _glslFloat(x: number, decimalFigures?: number): string;
  80440. }
  80441. }
  80442. declare module BABYLON {
  80443. /**
  80444. * Mirror texture can be used to simulate the view from a mirror in a scene.
  80445. * It will dynamically be rendered every frame to adapt to the camera point of view.
  80446. * You can then easily use it as a reflectionTexture on a flat surface.
  80447. * In case the surface is not a plane, please consider relying on reflection probes.
  80448. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  80449. */
  80450. export class MirrorTexture extends RenderTargetTexture {
  80451. private scene;
  80452. /**
  80453. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  80454. * 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.
  80455. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  80456. */
  80457. mirrorPlane: Plane;
  80458. /**
  80459. * Define the blur ratio used to blur the reflection if needed.
  80460. */
  80461. blurRatio: number;
  80462. /**
  80463. * Define the adaptive blur kernel used to blur the reflection if needed.
  80464. * This will autocompute the closest best match for the `blurKernel`
  80465. */
  80466. adaptiveBlurKernel: number;
  80467. /**
  80468. * Define the blur kernel used to blur the reflection if needed.
  80469. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  80470. */
  80471. blurKernel: number;
  80472. /**
  80473. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  80474. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  80475. */
  80476. blurKernelX: number;
  80477. /**
  80478. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  80479. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  80480. */
  80481. blurKernelY: number;
  80482. private _autoComputeBlurKernel;
  80483. protected _onRatioRescale(): void;
  80484. private _updateGammaSpace;
  80485. private _imageProcessingConfigChangeObserver;
  80486. private _transformMatrix;
  80487. private _mirrorMatrix;
  80488. private _savedViewMatrix;
  80489. private _blurX;
  80490. private _blurY;
  80491. private _adaptiveBlurKernel;
  80492. private _blurKernelX;
  80493. private _blurKernelY;
  80494. private _blurRatio;
  80495. /**
  80496. * Instantiates a Mirror Texture.
  80497. * Mirror texture can be used to simulate the view from a mirror in a scene.
  80498. * It will dynamically be rendered every frame to adapt to the camera point of view.
  80499. * You can then easily use it as a reflectionTexture on a flat surface.
  80500. * In case the surface is not a plane, please consider relying on reflection probes.
  80501. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  80502. * @param name
  80503. * @param size
  80504. * @param scene
  80505. * @param generateMipMaps
  80506. * @param type
  80507. * @param samplingMode
  80508. * @param generateDepthBuffer
  80509. */
  80510. constructor(name: string, size: number | {
  80511. width: number;
  80512. height: number;
  80513. } | {
  80514. ratio: number;
  80515. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  80516. private _preparePostProcesses;
  80517. /**
  80518. * Clone the mirror texture.
  80519. * @returns the cloned texture
  80520. */
  80521. clone(): MirrorTexture;
  80522. /**
  80523. * Serialize the texture to a JSON representation you could use in Parse later on
  80524. * @returns the serialized JSON representation
  80525. */
  80526. serialize(): any;
  80527. /**
  80528. * Dispose the texture and release its associated resources.
  80529. */
  80530. dispose(): void;
  80531. }
  80532. }
  80533. declare module BABYLON {
  80534. /**
  80535. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  80536. * @see http://doc.babylonjs.com/babylon101/materials#texture
  80537. */
  80538. export class Texture extends BaseTexture {
  80539. /** @hidden */
  80540. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  80541. /** @hidden */
  80542. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  80543. /** @hidden */
  80544. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  80545. /** nearest is mag = nearest and min = nearest and mip = linear */
  80546. static readonly NEAREST_SAMPLINGMODE: number;
  80547. /** nearest is mag = nearest and min = nearest and mip = linear */
  80548. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  80549. /** Bilinear is mag = linear and min = linear and mip = nearest */
  80550. static readonly BILINEAR_SAMPLINGMODE: number;
  80551. /** Bilinear is mag = linear and min = linear and mip = nearest */
  80552. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  80553. /** Trilinear is mag = linear and min = linear and mip = linear */
  80554. static readonly TRILINEAR_SAMPLINGMODE: number;
  80555. /** Trilinear is mag = linear and min = linear and mip = linear */
  80556. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  80557. /** mag = nearest and min = nearest and mip = nearest */
  80558. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  80559. /** mag = nearest and min = linear and mip = nearest */
  80560. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  80561. /** mag = nearest and min = linear and mip = linear */
  80562. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  80563. /** mag = nearest and min = linear and mip = none */
  80564. static readonly NEAREST_LINEAR: number;
  80565. /** mag = nearest and min = nearest and mip = none */
  80566. static readonly NEAREST_NEAREST: number;
  80567. /** mag = linear and min = nearest and mip = nearest */
  80568. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  80569. /** mag = linear and min = nearest and mip = linear */
  80570. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  80571. /** mag = linear and min = linear and mip = none */
  80572. static readonly LINEAR_LINEAR: number;
  80573. /** mag = linear and min = nearest and mip = none */
  80574. static readonly LINEAR_NEAREST: number;
  80575. /** Explicit coordinates mode */
  80576. static readonly EXPLICIT_MODE: number;
  80577. /** Spherical coordinates mode */
  80578. static readonly SPHERICAL_MODE: number;
  80579. /** Planar coordinates mode */
  80580. static readonly PLANAR_MODE: number;
  80581. /** Cubic coordinates mode */
  80582. static readonly CUBIC_MODE: number;
  80583. /** Projection coordinates mode */
  80584. static readonly PROJECTION_MODE: number;
  80585. /** Inverse Cubic coordinates mode */
  80586. static readonly SKYBOX_MODE: number;
  80587. /** Inverse Cubic coordinates mode */
  80588. static readonly INVCUBIC_MODE: number;
  80589. /** Equirectangular coordinates mode */
  80590. static readonly EQUIRECTANGULAR_MODE: number;
  80591. /** Equirectangular Fixed coordinates mode */
  80592. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  80593. /** Equirectangular Fixed Mirrored coordinates mode */
  80594. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  80595. /** Texture is not repeating outside of 0..1 UVs */
  80596. static readonly CLAMP_ADDRESSMODE: number;
  80597. /** Texture is repeating outside of 0..1 UVs */
  80598. static readonly WRAP_ADDRESSMODE: number;
  80599. /** Texture is repeating and mirrored */
  80600. static readonly MIRROR_ADDRESSMODE: number;
  80601. /**
  80602. * 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
  80603. */
  80604. static UseSerializedUrlIfAny: boolean;
  80605. /**
  80606. * Define the url of the texture.
  80607. */
  80608. url: Nullable<string>;
  80609. /**
  80610. * Define an offset on the texture to offset the u coordinates of the UVs
  80611. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  80612. */
  80613. uOffset: number;
  80614. /**
  80615. * Define an offset on the texture to offset the v coordinates of the UVs
  80616. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  80617. */
  80618. vOffset: number;
  80619. /**
  80620. * Define an offset on the texture to scale the u coordinates of the UVs
  80621. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  80622. */
  80623. uScale: number;
  80624. /**
  80625. * Define an offset on the texture to scale the v coordinates of the UVs
  80626. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  80627. */
  80628. vScale: number;
  80629. /**
  80630. * Define an offset on the texture to rotate around the u coordinates of the UVs
  80631. * @see http://doc.babylonjs.com/how_to/more_materials
  80632. */
  80633. uAng: number;
  80634. /**
  80635. * Define an offset on the texture to rotate around the v coordinates of the UVs
  80636. * @see http://doc.babylonjs.com/how_to/more_materials
  80637. */
  80638. vAng: number;
  80639. /**
  80640. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  80641. * @see http://doc.babylonjs.com/how_to/more_materials
  80642. */
  80643. wAng: number;
  80644. /**
  80645. * Defines the center of rotation (U)
  80646. */
  80647. uRotationCenter: number;
  80648. /**
  80649. * Defines the center of rotation (V)
  80650. */
  80651. vRotationCenter: number;
  80652. /**
  80653. * Defines the center of rotation (W)
  80654. */
  80655. wRotationCenter: number;
  80656. /**
  80657. * Are mip maps generated for this texture or not.
  80658. */
  80659. readonly noMipmap: boolean;
  80660. /**
  80661. * List of inspectable custom properties (used by the Inspector)
  80662. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80663. */
  80664. inspectableCustomProperties: Nullable<IInspectable[]>;
  80665. private _noMipmap;
  80666. /** @hidden */
  80667. _invertY: boolean;
  80668. private _rowGenerationMatrix;
  80669. private _cachedTextureMatrix;
  80670. private _projectionModeMatrix;
  80671. private _t0;
  80672. private _t1;
  80673. private _t2;
  80674. private _cachedUOffset;
  80675. private _cachedVOffset;
  80676. private _cachedUScale;
  80677. private _cachedVScale;
  80678. private _cachedUAng;
  80679. private _cachedVAng;
  80680. private _cachedWAng;
  80681. private _cachedProjectionMatrixId;
  80682. private _cachedCoordinatesMode;
  80683. /** @hidden */
  80684. protected _initialSamplingMode: number;
  80685. /** @hidden */
  80686. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  80687. private _deleteBuffer;
  80688. protected _format: Nullable<number>;
  80689. private _delayedOnLoad;
  80690. private _delayedOnError;
  80691. /**
  80692. * Observable triggered once the texture has been loaded.
  80693. */
  80694. onLoadObservable: Observable<Texture>;
  80695. protected _isBlocking: boolean;
  80696. /**
  80697. * Is the texture preventing material to render while loading.
  80698. * If false, a default texture will be used instead of the loading one during the preparation step.
  80699. */
  80700. isBlocking: boolean;
  80701. /**
  80702. * Get the current sampling mode associated with the texture.
  80703. */
  80704. readonly samplingMode: number;
  80705. /**
  80706. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  80707. */
  80708. readonly invertY: boolean;
  80709. /**
  80710. * Instantiates a new texture.
  80711. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  80712. * @see http://doc.babylonjs.com/babylon101/materials#texture
  80713. * @param url define the url of the picture to load as a texture
  80714. * @param scene define the scene or engine the texture will belong to
  80715. * @param noMipmap define if the texture will require mip maps or not
  80716. * @param invertY define if the texture needs to be inverted on the y axis during loading
  80717. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  80718. * @param onLoad define a callback triggered when the texture has been loaded
  80719. * @param onError define a callback triggered when an error occurred during the loading session
  80720. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  80721. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  80722. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  80723. */
  80724. 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);
  80725. /**
  80726. * Update the url (and optional buffer) of this texture if url was null during construction.
  80727. * @param url the url of the texture
  80728. * @param buffer the buffer of the texture (defaults to null)
  80729. * @param onLoad callback called when the texture is loaded (defaults to null)
  80730. */
  80731. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  80732. /**
  80733. * Finish the loading sequence of a texture flagged as delayed load.
  80734. * @hidden
  80735. */
  80736. delayLoad(): void;
  80737. private _prepareRowForTextureGeneration;
  80738. /**
  80739. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  80740. * @returns the transform matrix of the texture.
  80741. */
  80742. getTextureMatrix(): Matrix;
  80743. /**
  80744. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  80745. * @returns The reflection texture transform
  80746. */
  80747. getReflectionTextureMatrix(): Matrix;
  80748. /**
  80749. * Clones the texture.
  80750. * @returns the cloned texture
  80751. */
  80752. clone(): Texture;
  80753. /**
  80754. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  80755. * @returns The JSON representation of the texture
  80756. */
  80757. serialize(): any;
  80758. /**
  80759. * Get the current class name of the texture useful for serialization or dynamic coding.
  80760. * @returns "Texture"
  80761. */
  80762. getClassName(): string;
  80763. /**
  80764. * Dispose the texture and release its associated resources.
  80765. */
  80766. dispose(): void;
  80767. /**
  80768. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  80769. * @param parsedTexture Define the JSON representation of the texture
  80770. * @param scene Define the scene the parsed texture should be instantiated in
  80771. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  80772. * @returns The parsed texture if successful
  80773. */
  80774. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  80775. /**
  80776. * Creates a texture from its base 64 representation.
  80777. * @param data Define the base64 payload without the data: prefix
  80778. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  80779. * @param scene Define the scene the texture should belong to
  80780. * @param noMipmap Forces the texture to not create mip map information if true
  80781. * @param invertY define if the texture needs to be inverted on the y axis during loading
  80782. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  80783. * @param onLoad define a callback triggered when the texture has been loaded
  80784. * @param onError define a callback triggered when an error occurred during the loading session
  80785. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  80786. * @returns the created texture
  80787. */
  80788. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  80789. /**
  80790. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  80791. * @param data Define the base64 payload without the data: prefix
  80792. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  80793. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  80794. * @param scene Define the scene the texture should belong to
  80795. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  80796. * @param noMipmap Forces the texture to not create mip map information if true
  80797. * @param invertY define if the texture needs to be inverted on the y axis during loading
  80798. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  80799. * @param onLoad define a callback triggered when the texture has been loaded
  80800. * @param onError define a callback triggered when an error occurred during the loading session
  80801. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  80802. * @returns the created texture
  80803. */
  80804. 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;
  80805. }
  80806. }
  80807. declare module BABYLON {
  80808. /**
  80809. * PostProcessManager is used to manage one or more post processes or post process pipelines
  80810. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  80811. */
  80812. export class PostProcessManager {
  80813. private _scene;
  80814. private _indexBuffer;
  80815. private _vertexBuffers;
  80816. /**
  80817. * Creates a new instance PostProcess
  80818. * @param scene The scene that the post process is associated with.
  80819. */
  80820. constructor(scene: Scene);
  80821. private _prepareBuffers;
  80822. private _buildIndexBuffer;
  80823. /**
  80824. * Rebuilds the vertex buffers of the manager.
  80825. * @hidden
  80826. */
  80827. _rebuild(): void;
  80828. /**
  80829. * Prepares a frame to be run through a post process.
  80830. * @param sourceTexture The input texture to the post procesess. (default: null)
  80831. * @param postProcesses An array of post processes to be run. (default: null)
  80832. * @returns True if the post processes were able to be run.
  80833. * @hidden
  80834. */
  80835. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  80836. /**
  80837. * Manually render a set of post processes to a texture.
  80838. * @param postProcesses An array of post processes to be run.
  80839. * @param targetTexture The target texture to render to.
  80840. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  80841. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  80842. * @param lodLevel defines which lod of the texture to render to
  80843. */
  80844. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  80845. /**
  80846. * Finalize the result of the output of the postprocesses.
  80847. * @param doNotPresent If true the result will not be displayed to the screen.
  80848. * @param targetTexture The target texture to render to.
  80849. * @param faceIndex The index of the face to bind the target texture to.
  80850. * @param postProcesses The array of post processes to render.
  80851. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  80852. * @hidden
  80853. */
  80854. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  80855. /**
  80856. * Disposes of the post process manager.
  80857. */
  80858. dispose(): void;
  80859. }
  80860. }
  80861. declare module BABYLON {
  80862. /** Interface used by value gradients (color, factor, ...) */
  80863. export interface IValueGradient {
  80864. /**
  80865. * Gets or sets the gradient value (between 0 and 1)
  80866. */
  80867. gradient: number;
  80868. }
  80869. /** Class used to store color4 gradient */
  80870. export class ColorGradient implements IValueGradient {
  80871. /**
  80872. * Gets or sets the gradient value (between 0 and 1)
  80873. */
  80874. gradient: number;
  80875. /**
  80876. * Gets or sets first associated color
  80877. */
  80878. color1: Color4;
  80879. /**
  80880. * Gets or sets second associated color
  80881. */
  80882. color2?: Color4;
  80883. /**
  80884. * Will get a color picked randomly between color1 and color2.
  80885. * If color2 is undefined then color1 will be used
  80886. * @param result defines the target Color4 to store the result in
  80887. */
  80888. getColorToRef(result: Color4): void;
  80889. }
  80890. /** Class used to store color 3 gradient */
  80891. export class Color3Gradient implements IValueGradient {
  80892. /**
  80893. * Gets or sets the gradient value (between 0 and 1)
  80894. */
  80895. gradient: number;
  80896. /**
  80897. * Gets or sets the associated color
  80898. */
  80899. color: Color3;
  80900. }
  80901. /** Class used to store factor gradient */
  80902. export class FactorGradient implements IValueGradient {
  80903. /**
  80904. * Gets or sets the gradient value (between 0 and 1)
  80905. */
  80906. gradient: number;
  80907. /**
  80908. * Gets or sets first associated factor
  80909. */
  80910. factor1: number;
  80911. /**
  80912. * Gets or sets second associated factor
  80913. */
  80914. factor2?: number;
  80915. /**
  80916. * Will get a number picked randomly between factor1 and factor2.
  80917. * If factor2 is undefined then factor1 will be used
  80918. * @returns the picked number
  80919. */
  80920. getFactor(): number;
  80921. }
  80922. /**
  80923. * Helper used to simplify some generic gradient tasks
  80924. */
  80925. export class GradientHelper {
  80926. /**
  80927. * Gets the current gradient from an array of IValueGradient
  80928. * @param ratio defines the current ratio to get
  80929. * @param gradients defines the array of IValueGradient
  80930. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  80931. */
  80932. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  80933. }
  80934. }
  80935. declare module BABYLON {
  80936. interface AbstractScene {
  80937. /**
  80938. * The list of procedural textures added to the scene
  80939. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  80940. */
  80941. proceduralTextures: Array<ProceduralTexture>;
  80942. }
  80943. /**
  80944. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  80945. * in a given scene.
  80946. */
  80947. export class ProceduralTextureSceneComponent implements ISceneComponent {
  80948. /**
  80949. * The component name helpfull to identify the component in the list of scene components.
  80950. */
  80951. readonly name: string;
  80952. /**
  80953. * The scene the component belongs to.
  80954. */
  80955. scene: Scene;
  80956. /**
  80957. * Creates a new instance of the component for the given scene
  80958. * @param scene Defines the scene to register the component in
  80959. */
  80960. constructor(scene: Scene);
  80961. /**
  80962. * Registers the component in a given scene
  80963. */
  80964. register(): void;
  80965. /**
  80966. * Rebuilds the elements related to this component in case of
  80967. * context lost for instance.
  80968. */
  80969. rebuild(): void;
  80970. /**
  80971. * Disposes the component and the associated ressources.
  80972. */
  80973. dispose(): void;
  80974. private _beforeClear;
  80975. }
  80976. }
  80977. declare module BABYLON {
  80978. interface Engine {
  80979. /**
  80980. * Creates a new render target cube texture
  80981. * @param size defines the size of the texture
  80982. * @param options defines the options used to create the texture
  80983. * @returns a new render target cube texture stored in an InternalTexture
  80984. */
  80985. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  80986. }
  80987. }
  80988. declare module BABYLON {
  80989. /** @hidden */
  80990. export var proceduralVertexShader: {
  80991. name: string;
  80992. shader: string;
  80993. };
  80994. }
  80995. declare module BABYLON {
  80996. /**
  80997. * 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.
  80998. * This is the base class of any Procedural texture and contains most of the shareable code.
  80999. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81000. */
  81001. export class ProceduralTexture extends Texture {
  81002. isCube: boolean;
  81003. /**
  81004. * Define if the texture is enabled or not (disabled texture will not render)
  81005. */
  81006. isEnabled: boolean;
  81007. /**
  81008. * Define if the texture must be cleared before rendering (default is true)
  81009. */
  81010. autoClear: boolean;
  81011. /**
  81012. * Callback called when the texture is generated
  81013. */
  81014. onGenerated: () => void;
  81015. /**
  81016. * Event raised when the texture is generated
  81017. */
  81018. onGeneratedObservable: Observable<ProceduralTexture>;
  81019. /** @hidden */
  81020. _generateMipMaps: boolean;
  81021. /** @hidden **/
  81022. _effect: Effect;
  81023. /** @hidden */
  81024. _textures: {
  81025. [key: string]: Texture;
  81026. };
  81027. private _size;
  81028. private _currentRefreshId;
  81029. private _refreshRate;
  81030. private _vertexBuffers;
  81031. private _indexBuffer;
  81032. private _uniforms;
  81033. private _samplers;
  81034. private _fragment;
  81035. private _floats;
  81036. private _ints;
  81037. private _floatsArrays;
  81038. private _colors3;
  81039. private _colors4;
  81040. private _vectors2;
  81041. private _vectors3;
  81042. private _matrices;
  81043. private _fallbackTexture;
  81044. private _fallbackTextureUsed;
  81045. private _engine;
  81046. private _cachedDefines;
  81047. private _contentUpdateId;
  81048. private _contentData;
  81049. /**
  81050. * Instantiates a new procedural texture.
  81051. * 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.
  81052. * This is the base class of any Procedural texture and contains most of the shareable code.
  81053. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81054. * @param name Define the name of the texture
  81055. * @param size Define the size of the texture to create
  81056. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  81057. * @param scene Define the scene the texture belongs to
  81058. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  81059. * @param generateMipMaps Define if the texture should creates mip maps or not
  81060. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  81061. */
  81062. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  81063. /**
  81064. * The effect that is created when initializing the post process.
  81065. * @returns The created effect corresponding the the postprocess.
  81066. */
  81067. getEffect(): Effect;
  81068. /**
  81069. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  81070. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  81071. */
  81072. getContent(): Nullable<ArrayBufferView>;
  81073. private _createIndexBuffer;
  81074. /** @hidden */
  81075. _rebuild(): void;
  81076. /**
  81077. * Resets the texture in order to recreate its associated resources.
  81078. * This can be called in case of context loss
  81079. */
  81080. reset(): void;
  81081. protected _getDefines(): string;
  81082. /**
  81083. * Is the texture ready to be used ? (rendered at least once)
  81084. * @returns true if ready, otherwise, false.
  81085. */
  81086. isReady(): boolean;
  81087. /**
  81088. * Resets the refresh counter of the texture and start bak from scratch.
  81089. * Could be useful to regenerate the texture if it is setup to render only once.
  81090. */
  81091. resetRefreshCounter(): void;
  81092. /**
  81093. * Set the fragment shader to use in order to render the texture.
  81094. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  81095. */
  81096. setFragment(fragment: any): void;
  81097. /**
  81098. * Define the refresh rate of the texture or the rendering frequency.
  81099. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  81100. */
  81101. refreshRate: number;
  81102. /** @hidden */
  81103. _shouldRender(): boolean;
  81104. /**
  81105. * Get the size the texture is rendering at.
  81106. * @returns the size (texture is always squared)
  81107. */
  81108. getRenderSize(): number;
  81109. /**
  81110. * Resize the texture to new value.
  81111. * @param size Define the new size the texture should have
  81112. * @param generateMipMaps Define whether the new texture should create mip maps
  81113. */
  81114. resize(size: number, generateMipMaps: boolean): void;
  81115. private _checkUniform;
  81116. /**
  81117. * Set a texture in the shader program used to render.
  81118. * @param name Define the name of the uniform samplers as defined in the shader
  81119. * @param texture Define the texture to bind to this sampler
  81120. * @return the texture itself allowing "fluent" like uniform updates
  81121. */
  81122. setTexture(name: string, texture: Texture): ProceduralTexture;
  81123. /**
  81124. * Set a float in the shader.
  81125. * @param name Define the name of the uniform as defined in the shader
  81126. * @param value Define the value to give to the uniform
  81127. * @return the texture itself allowing "fluent" like uniform updates
  81128. */
  81129. setFloat(name: string, value: number): ProceduralTexture;
  81130. /**
  81131. * Set a int in the shader.
  81132. * @param name Define the name of the uniform as defined in the shader
  81133. * @param value Define the value to give to the uniform
  81134. * @return the texture itself allowing "fluent" like uniform updates
  81135. */
  81136. setInt(name: string, value: number): ProceduralTexture;
  81137. /**
  81138. * Set an array of floats in the shader.
  81139. * @param name Define the name of the uniform as defined in the shader
  81140. * @param value Define the value to give to the uniform
  81141. * @return the texture itself allowing "fluent" like uniform updates
  81142. */
  81143. setFloats(name: string, value: number[]): ProceduralTexture;
  81144. /**
  81145. * Set a vec3 in the shader from a Color3.
  81146. * @param name Define the name of the uniform as defined in the shader
  81147. * @param value Define the value to give to the uniform
  81148. * @return the texture itself allowing "fluent" like uniform updates
  81149. */
  81150. setColor3(name: string, value: Color3): ProceduralTexture;
  81151. /**
  81152. * Set a vec4 in the shader from a Color4.
  81153. * @param name Define the name of the uniform as defined in the shader
  81154. * @param value Define the value to give to the uniform
  81155. * @return the texture itself allowing "fluent" like uniform updates
  81156. */
  81157. setColor4(name: string, value: Color4): ProceduralTexture;
  81158. /**
  81159. * Set a vec2 in the shader from a Vector2.
  81160. * @param name Define the name of the uniform as defined in the shader
  81161. * @param value Define the value to give to the uniform
  81162. * @return the texture itself allowing "fluent" like uniform updates
  81163. */
  81164. setVector2(name: string, value: Vector2): ProceduralTexture;
  81165. /**
  81166. * Set a vec3 in the shader from a Vector3.
  81167. * @param name Define the name of the uniform as defined in the shader
  81168. * @param value Define the value to give to the uniform
  81169. * @return the texture itself allowing "fluent" like uniform updates
  81170. */
  81171. setVector3(name: string, value: Vector3): ProceduralTexture;
  81172. /**
  81173. * Set a mat4 in the shader from a MAtrix.
  81174. * @param name Define the name of the uniform as defined in the shader
  81175. * @param value Define the value to give to the uniform
  81176. * @return the texture itself allowing "fluent" like uniform updates
  81177. */
  81178. setMatrix(name: string, value: Matrix): ProceduralTexture;
  81179. /**
  81180. * Render the texture to its associated render target.
  81181. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  81182. */
  81183. render(useCameraPostProcess?: boolean): void;
  81184. /**
  81185. * Clone the texture.
  81186. * @returns the cloned texture
  81187. */
  81188. clone(): ProceduralTexture;
  81189. /**
  81190. * Dispose the texture and release its asoociated resources.
  81191. */
  81192. dispose(): void;
  81193. }
  81194. }
  81195. declare module BABYLON {
  81196. /**
  81197. * This represents the base class for particle system in Babylon.
  81198. * 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.
  81199. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  81200. * @example https://doc.babylonjs.com/babylon101/particles
  81201. */
  81202. export class BaseParticleSystem {
  81203. /**
  81204. * Source color is added to the destination color without alpha affecting the result
  81205. */
  81206. static BLENDMODE_ONEONE: number;
  81207. /**
  81208. * Blend current color and particle color using particle’s alpha
  81209. */
  81210. static BLENDMODE_STANDARD: number;
  81211. /**
  81212. * Add current color and particle color multiplied by particle’s alpha
  81213. */
  81214. static BLENDMODE_ADD: number;
  81215. /**
  81216. * Multiply current color with particle color
  81217. */
  81218. static BLENDMODE_MULTIPLY: number;
  81219. /**
  81220. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  81221. */
  81222. static BLENDMODE_MULTIPLYADD: number;
  81223. /**
  81224. * List of animations used by the particle system.
  81225. */
  81226. animations: Animation[];
  81227. /**
  81228. * The id of the Particle system.
  81229. */
  81230. id: string;
  81231. /**
  81232. * The friendly name of the Particle system.
  81233. */
  81234. name: string;
  81235. /**
  81236. * The rendering group used by the Particle system to chose when to render.
  81237. */
  81238. renderingGroupId: number;
  81239. /**
  81240. * The emitter represents the Mesh or position we are attaching the particle system to.
  81241. */
  81242. emitter: Nullable<AbstractMesh | Vector3>;
  81243. /**
  81244. * The maximum number of particles to emit per frame
  81245. */
  81246. emitRate: number;
  81247. /**
  81248. * If you want to launch only a few particles at once, that can be done, as well.
  81249. */
  81250. manualEmitCount: number;
  81251. /**
  81252. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  81253. */
  81254. updateSpeed: number;
  81255. /**
  81256. * The amount of time the particle system is running (depends of the overall update speed).
  81257. */
  81258. targetStopDuration: number;
  81259. /**
  81260. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  81261. */
  81262. disposeOnStop: boolean;
  81263. /**
  81264. * Minimum power of emitting particles.
  81265. */
  81266. minEmitPower: number;
  81267. /**
  81268. * Maximum power of emitting particles.
  81269. */
  81270. maxEmitPower: number;
  81271. /**
  81272. * Minimum life time of emitting particles.
  81273. */
  81274. minLifeTime: number;
  81275. /**
  81276. * Maximum life time of emitting particles.
  81277. */
  81278. maxLifeTime: number;
  81279. /**
  81280. * Minimum Size of emitting particles.
  81281. */
  81282. minSize: number;
  81283. /**
  81284. * Maximum Size of emitting particles.
  81285. */
  81286. maxSize: number;
  81287. /**
  81288. * Minimum scale of emitting particles on X axis.
  81289. */
  81290. minScaleX: number;
  81291. /**
  81292. * Maximum scale of emitting particles on X axis.
  81293. */
  81294. maxScaleX: number;
  81295. /**
  81296. * Minimum scale of emitting particles on Y axis.
  81297. */
  81298. minScaleY: number;
  81299. /**
  81300. * Maximum scale of emitting particles on Y axis.
  81301. */
  81302. maxScaleY: number;
  81303. /**
  81304. * Gets or sets the minimal initial rotation in radians.
  81305. */
  81306. minInitialRotation: number;
  81307. /**
  81308. * Gets or sets the maximal initial rotation in radians.
  81309. */
  81310. maxInitialRotation: number;
  81311. /**
  81312. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  81313. */
  81314. minAngularSpeed: number;
  81315. /**
  81316. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  81317. */
  81318. maxAngularSpeed: number;
  81319. /**
  81320. * The texture used to render each particle. (this can be a spritesheet)
  81321. */
  81322. particleTexture: Nullable<Texture>;
  81323. /**
  81324. * The layer mask we are rendering the particles through.
  81325. */
  81326. layerMask: number;
  81327. /**
  81328. * This can help using your own shader to render the particle system.
  81329. * The according effect will be created
  81330. */
  81331. customShader: any;
  81332. /**
  81333. * By default particle system starts as soon as they are created. This prevents the
  81334. * automatic start to happen and let you decide when to start emitting particles.
  81335. */
  81336. preventAutoStart: boolean;
  81337. private _noiseTexture;
  81338. /**
  81339. * Gets or sets a texture used to add random noise to particle positions
  81340. */
  81341. noiseTexture: Nullable<ProceduralTexture>;
  81342. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  81343. noiseStrength: Vector3;
  81344. /**
  81345. * Callback triggered when the particle animation is ending.
  81346. */
  81347. onAnimationEnd: Nullable<() => void>;
  81348. /**
  81349. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  81350. */
  81351. blendMode: number;
  81352. /**
  81353. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  81354. * to override the particles.
  81355. */
  81356. forceDepthWrite: boolean;
  81357. /** 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 */
  81358. preWarmCycles: number;
  81359. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  81360. preWarmStepOffset: number;
  81361. /**
  81362. * 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)
  81363. */
  81364. spriteCellChangeSpeed: number;
  81365. /**
  81366. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  81367. */
  81368. startSpriteCellID: number;
  81369. /**
  81370. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  81371. */
  81372. endSpriteCellID: number;
  81373. /**
  81374. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  81375. */
  81376. spriteCellWidth: number;
  81377. /**
  81378. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  81379. */
  81380. spriteCellHeight: number;
  81381. /**
  81382. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  81383. */
  81384. spriteRandomStartCell: boolean;
  81385. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  81386. translationPivot: Vector2;
  81387. /** @hidden */
  81388. protected _isAnimationSheetEnabled: boolean;
  81389. /**
  81390. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  81391. */
  81392. beginAnimationOnStart: boolean;
  81393. /**
  81394. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  81395. */
  81396. beginAnimationFrom: number;
  81397. /**
  81398. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  81399. */
  81400. beginAnimationTo: number;
  81401. /**
  81402. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  81403. */
  81404. beginAnimationLoop: boolean;
  81405. /**
  81406. * Gets or sets a world offset applied to all particles
  81407. */
  81408. worldOffset: Vector3;
  81409. /**
  81410. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  81411. */
  81412. isAnimationSheetEnabled: boolean;
  81413. /**
  81414. * Get hosting scene
  81415. * @returns the scene
  81416. */
  81417. getScene(): Scene;
  81418. /**
  81419. * You can use gravity if you want to give an orientation to your particles.
  81420. */
  81421. gravity: Vector3;
  81422. protected _colorGradients: Nullable<Array<ColorGradient>>;
  81423. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  81424. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  81425. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  81426. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  81427. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  81428. protected _dragGradients: Nullable<Array<FactorGradient>>;
  81429. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  81430. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  81431. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  81432. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  81433. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  81434. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  81435. /**
  81436. * Defines the delay in milliseconds before starting the system (0 by default)
  81437. */
  81438. startDelay: number;
  81439. /**
  81440. * Gets the current list of drag gradients.
  81441. * You must use addDragGradient and removeDragGradient to udpate this list
  81442. * @returns the list of drag gradients
  81443. */
  81444. getDragGradients(): Nullable<Array<FactorGradient>>;
  81445. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  81446. limitVelocityDamping: number;
  81447. /**
  81448. * Gets the current list of limit velocity gradients.
  81449. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  81450. * @returns the list of limit velocity gradients
  81451. */
  81452. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  81453. /**
  81454. * Gets the current list of color gradients.
  81455. * You must use addColorGradient and removeColorGradient to udpate this list
  81456. * @returns the list of color gradients
  81457. */
  81458. getColorGradients(): Nullable<Array<ColorGradient>>;
  81459. /**
  81460. * Gets the current list of size gradients.
  81461. * You must use addSizeGradient and removeSizeGradient to udpate this list
  81462. * @returns the list of size gradients
  81463. */
  81464. getSizeGradients(): Nullable<Array<FactorGradient>>;
  81465. /**
  81466. * Gets the current list of color remap gradients.
  81467. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  81468. * @returns the list of color remap gradients
  81469. */
  81470. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  81471. /**
  81472. * Gets the current list of alpha remap gradients.
  81473. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  81474. * @returns the list of alpha remap gradients
  81475. */
  81476. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  81477. /**
  81478. * Gets the current list of life time gradients.
  81479. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  81480. * @returns the list of life time gradients
  81481. */
  81482. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  81483. /**
  81484. * Gets the current list of angular speed gradients.
  81485. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  81486. * @returns the list of angular speed gradients
  81487. */
  81488. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  81489. /**
  81490. * Gets the current list of velocity gradients.
  81491. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  81492. * @returns the list of velocity gradients
  81493. */
  81494. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  81495. /**
  81496. * Gets the current list of start size gradients.
  81497. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  81498. * @returns the list of start size gradients
  81499. */
  81500. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  81501. /**
  81502. * Gets the current list of emit rate gradients.
  81503. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  81504. * @returns the list of emit rate gradients
  81505. */
  81506. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  81507. /**
  81508. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  81509. * This only works when particleEmitterTyps is a BoxParticleEmitter
  81510. */
  81511. direction1: Vector3;
  81512. /**
  81513. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  81514. * This only works when particleEmitterTyps is a BoxParticleEmitter
  81515. */
  81516. direction2: Vector3;
  81517. /**
  81518. * 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.
  81519. * This only works when particleEmitterTyps is a BoxParticleEmitter
  81520. */
  81521. minEmitBox: Vector3;
  81522. /**
  81523. * 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.
  81524. * This only works when particleEmitterTyps is a BoxParticleEmitter
  81525. */
  81526. maxEmitBox: Vector3;
  81527. /**
  81528. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  81529. */
  81530. color1: Color4;
  81531. /**
  81532. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  81533. */
  81534. color2: Color4;
  81535. /**
  81536. * Color the particle will have at the end of its lifetime
  81537. */
  81538. colorDead: Color4;
  81539. /**
  81540. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  81541. */
  81542. textureMask: Color4;
  81543. /**
  81544. * The particle emitter type defines the emitter used by the particle system.
  81545. * It can be for example box, sphere, or cone...
  81546. */
  81547. particleEmitterType: IParticleEmitterType;
  81548. /** @hidden */
  81549. _isSubEmitter: boolean;
  81550. /**
  81551. * Gets or sets the billboard mode to use when isBillboardBased = true.
  81552. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  81553. */
  81554. billboardMode: number;
  81555. protected _isBillboardBased: boolean;
  81556. /**
  81557. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  81558. */
  81559. isBillboardBased: boolean;
  81560. /**
  81561. * The scene the particle system belongs to.
  81562. */
  81563. protected _scene: Scene;
  81564. /**
  81565. * Local cache of defines for image processing.
  81566. */
  81567. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  81568. /**
  81569. * Default configuration related to image processing available in the standard Material.
  81570. */
  81571. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  81572. /**
  81573. * Gets the image processing configuration used either in this material.
  81574. */
  81575. /**
  81576. * Sets the Default image processing configuration used either in the this material.
  81577. *
  81578. * If sets to null, the scene one is in use.
  81579. */
  81580. imageProcessingConfiguration: ImageProcessingConfiguration;
  81581. /**
  81582. * Attaches a new image processing configuration to the Standard Material.
  81583. * @param configuration
  81584. */
  81585. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  81586. /** @hidden */
  81587. protected _reset(): void;
  81588. /** @hidden */
  81589. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  81590. /**
  81591. * Instantiates a particle system.
  81592. * 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.
  81593. * @param name The name of the particle system
  81594. */
  81595. constructor(name: string);
  81596. /**
  81597. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  81598. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  81599. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  81600. * @returns the emitter
  81601. */
  81602. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  81603. /**
  81604. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  81605. * @param radius The radius of the hemisphere to emit from
  81606. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  81607. * @returns the emitter
  81608. */
  81609. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  81610. /**
  81611. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  81612. * @param radius The radius of the sphere to emit from
  81613. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  81614. * @returns the emitter
  81615. */
  81616. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  81617. /**
  81618. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  81619. * @param radius The radius of the sphere to emit from
  81620. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  81621. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  81622. * @returns the emitter
  81623. */
  81624. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  81625. /**
  81626. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  81627. * @param radius The radius of the emission cylinder
  81628. * @param height The height of the emission cylinder
  81629. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  81630. * @param directionRandomizer How much to randomize the particle direction [0-1]
  81631. * @returns the emitter
  81632. */
  81633. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  81634. /**
  81635. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  81636. * @param radius The radius of the cylinder to emit from
  81637. * @param height The height of the emission cylinder
  81638. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  81639. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  81640. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  81641. * @returns the emitter
  81642. */
  81643. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  81644. /**
  81645. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  81646. * @param radius The radius of the cone to emit from
  81647. * @param angle The base angle of the cone
  81648. * @returns the emitter
  81649. */
  81650. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  81651. /**
  81652. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  81653. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  81654. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  81655. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  81656. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  81657. * @returns the emitter
  81658. */
  81659. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  81660. }
  81661. }
  81662. declare module BABYLON {
  81663. /**
  81664. * Type of sub emitter
  81665. */
  81666. export enum SubEmitterType {
  81667. /**
  81668. * Attached to the particle over it's lifetime
  81669. */
  81670. ATTACHED = 0,
  81671. /**
  81672. * Created when the particle dies
  81673. */
  81674. END = 1
  81675. }
  81676. /**
  81677. * Sub emitter class used to emit particles from an existing particle
  81678. */
  81679. export class SubEmitter {
  81680. /**
  81681. * the particle system to be used by the sub emitter
  81682. */
  81683. particleSystem: ParticleSystem;
  81684. /**
  81685. * Type of the submitter (Default: END)
  81686. */
  81687. type: SubEmitterType;
  81688. /**
  81689. * 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)
  81690. * Note: This only is supported when using an emitter of type Mesh
  81691. */
  81692. inheritDirection: boolean;
  81693. /**
  81694. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  81695. */
  81696. inheritedVelocityAmount: number;
  81697. /**
  81698. * Creates a sub emitter
  81699. * @param particleSystem the particle system to be used by the sub emitter
  81700. */
  81701. constructor(
  81702. /**
  81703. * the particle system to be used by the sub emitter
  81704. */
  81705. particleSystem: ParticleSystem);
  81706. /**
  81707. * Clones the sub emitter
  81708. * @returns the cloned sub emitter
  81709. */
  81710. clone(): SubEmitter;
  81711. /**
  81712. * Serialize current object to a JSON object
  81713. * @returns the serialized object
  81714. */
  81715. serialize(): any;
  81716. /** @hidden */
  81717. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  81718. /**
  81719. * Creates a new SubEmitter from a serialized JSON version
  81720. * @param serializationObject defines the JSON object to read from
  81721. * @param scene defines the hosting scene
  81722. * @param rootUrl defines the rootUrl for data loading
  81723. * @returns a new SubEmitter
  81724. */
  81725. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  81726. /** Release associated resources */
  81727. dispose(): void;
  81728. }
  81729. }
  81730. declare module BABYLON {
  81731. /** @hidden */
  81732. export var clipPlaneFragmentDeclaration: {
  81733. name: string;
  81734. shader: string;
  81735. };
  81736. }
  81737. declare module BABYLON {
  81738. /** @hidden */
  81739. export var imageProcessingDeclaration: {
  81740. name: string;
  81741. shader: string;
  81742. };
  81743. }
  81744. declare module BABYLON {
  81745. /** @hidden */
  81746. export var imageProcessingFunctions: {
  81747. name: string;
  81748. shader: string;
  81749. };
  81750. }
  81751. declare module BABYLON {
  81752. /** @hidden */
  81753. export var clipPlaneFragment: {
  81754. name: string;
  81755. shader: string;
  81756. };
  81757. }
  81758. declare module BABYLON {
  81759. /** @hidden */
  81760. export var particlesPixelShader: {
  81761. name: string;
  81762. shader: string;
  81763. };
  81764. }
  81765. declare module BABYLON {
  81766. /** @hidden */
  81767. export var clipPlaneVertexDeclaration: {
  81768. name: string;
  81769. shader: string;
  81770. };
  81771. }
  81772. declare module BABYLON {
  81773. /** @hidden */
  81774. export var clipPlaneVertex: {
  81775. name: string;
  81776. shader: string;
  81777. };
  81778. }
  81779. declare module BABYLON {
  81780. /** @hidden */
  81781. export var particlesVertexShader: {
  81782. name: string;
  81783. shader: string;
  81784. };
  81785. }
  81786. declare module BABYLON {
  81787. /**
  81788. * This represents a particle system in Babylon.
  81789. * 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.
  81790. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  81791. * @example https://doc.babylonjs.com/babylon101/particles
  81792. */
  81793. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  81794. /**
  81795. * Billboard mode will only apply to Y axis
  81796. */
  81797. static readonly BILLBOARDMODE_Y: number;
  81798. /**
  81799. * Billboard mode will apply to all axes
  81800. */
  81801. static readonly BILLBOARDMODE_ALL: number;
  81802. /**
  81803. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  81804. */
  81805. static readonly BILLBOARDMODE_STRETCHED: number;
  81806. /**
  81807. * This function can be defined to provide custom update for active particles.
  81808. * This function will be called instead of regular update (age, position, color, etc.).
  81809. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  81810. */
  81811. updateFunction: (particles: Particle[]) => void;
  81812. private _emitterWorldMatrix;
  81813. /**
  81814. * This function can be defined to specify initial direction for every new particle.
  81815. * It by default use the emitterType defined function
  81816. */
  81817. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  81818. /**
  81819. * This function can be defined to specify initial position for every new particle.
  81820. * It by default use the emitterType defined function
  81821. */
  81822. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  81823. /**
  81824. * @hidden
  81825. */
  81826. _inheritedVelocityOffset: Vector3;
  81827. /**
  81828. * An event triggered when the system is disposed
  81829. */
  81830. onDisposeObservable: Observable<ParticleSystem>;
  81831. private _onDisposeObserver;
  81832. /**
  81833. * Sets a callback that will be triggered when the system is disposed
  81834. */
  81835. onDispose: () => void;
  81836. private _particles;
  81837. private _epsilon;
  81838. private _capacity;
  81839. private _stockParticles;
  81840. private _newPartsExcess;
  81841. private _vertexData;
  81842. private _vertexBuffer;
  81843. private _vertexBuffers;
  81844. private _spriteBuffer;
  81845. private _indexBuffer;
  81846. private _effect;
  81847. private _customEffect;
  81848. private _cachedDefines;
  81849. private _scaledColorStep;
  81850. private _colorDiff;
  81851. private _scaledDirection;
  81852. private _scaledGravity;
  81853. private _currentRenderId;
  81854. private _alive;
  81855. private _useInstancing;
  81856. private _started;
  81857. private _stopped;
  81858. private _actualFrame;
  81859. private _scaledUpdateSpeed;
  81860. private _vertexBufferSize;
  81861. /** @hidden */
  81862. _currentEmitRateGradient: Nullable<FactorGradient>;
  81863. /** @hidden */
  81864. _currentEmitRate1: number;
  81865. /** @hidden */
  81866. _currentEmitRate2: number;
  81867. /** @hidden */
  81868. _currentStartSizeGradient: Nullable<FactorGradient>;
  81869. /** @hidden */
  81870. _currentStartSize1: number;
  81871. /** @hidden */
  81872. _currentStartSize2: number;
  81873. private readonly _rawTextureWidth;
  81874. private _rampGradientsTexture;
  81875. private _useRampGradients;
  81876. /** Gets or sets a boolean indicating that ramp gradients must be used
  81877. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  81878. */
  81879. useRampGradients: boolean;
  81880. /**
  81881. * 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.
  81882. * 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: [])
  81883. */
  81884. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  81885. private _subEmitters;
  81886. /**
  81887. * @hidden
  81888. * If the particle systems emitter should be disposed when the particle system is disposed
  81889. */
  81890. _disposeEmitterOnDispose: boolean;
  81891. /**
  81892. * The current active Sub-systems, this property is used by the root particle system only.
  81893. */
  81894. activeSubSystems: Array<ParticleSystem>;
  81895. private _rootParticleSystem;
  81896. /**
  81897. * Gets the current list of active particles
  81898. */
  81899. readonly particles: Particle[];
  81900. /**
  81901. * Returns the string "ParticleSystem"
  81902. * @returns a string containing the class name
  81903. */
  81904. getClassName(): string;
  81905. /**
  81906. * Instantiates a particle system.
  81907. * 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.
  81908. * @param name The name of the particle system
  81909. * @param capacity The max number of particles alive at the same time
  81910. * @param scene The scene the particle system belongs to
  81911. * @param customEffect a custom effect used to change the way particles are rendered by default
  81912. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  81913. * @param epsilon Offset used to render the particles
  81914. */
  81915. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  81916. private _addFactorGradient;
  81917. private _removeFactorGradient;
  81918. /**
  81919. * Adds a new life time gradient
  81920. * @param gradient defines the gradient to use (between 0 and 1)
  81921. * @param factor defines the life time factor to affect to the specified gradient
  81922. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81923. * @returns the current particle system
  81924. */
  81925. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81926. /**
  81927. * Remove a specific life time gradient
  81928. * @param gradient defines the gradient to remove
  81929. * @returns the current particle system
  81930. */
  81931. removeLifeTimeGradient(gradient: number): IParticleSystem;
  81932. /**
  81933. * Adds a new size gradient
  81934. * @param gradient defines the gradient to use (between 0 and 1)
  81935. * @param factor defines the size factor to affect to the specified gradient
  81936. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81937. * @returns the current particle system
  81938. */
  81939. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81940. /**
  81941. * Remove a specific size gradient
  81942. * @param gradient defines the gradient to remove
  81943. * @returns the current particle system
  81944. */
  81945. removeSizeGradient(gradient: number): IParticleSystem;
  81946. /**
  81947. * Adds a new color remap gradient
  81948. * @param gradient defines the gradient to use (between 0 and 1)
  81949. * @param min defines the color remap minimal range
  81950. * @param max defines the color remap maximal range
  81951. * @returns the current particle system
  81952. */
  81953. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  81954. /**
  81955. * Remove a specific color remap gradient
  81956. * @param gradient defines the gradient to remove
  81957. * @returns the current particle system
  81958. */
  81959. removeColorRemapGradient(gradient: number): IParticleSystem;
  81960. /**
  81961. * Adds a new alpha remap gradient
  81962. * @param gradient defines the gradient to use (between 0 and 1)
  81963. * @param min defines the alpha remap minimal range
  81964. * @param max defines the alpha remap maximal range
  81965. * @returns the current particle system
  81966. */
  81967. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  81968. /**
  81969. * Remove a specific alpha remap gradient
  81970. * @param gradient defines the gradient to remove
  81971. * @returns the current particle system
  81972. */
  81973. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  81974. /**
  81975. * Adds a new angular speed gradient
  81976. * @param gradient defines the gradient to use (between 0 and 1)
  81977. * @param factor defines the angular speed to affect to the specified gradient
  81978. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81979. * @returns the current particle system
  81980. */
  81981. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81982. /**
  81983. * Remove a specific angular speed gradient
  81984. * @param gradient defines the gradient to remove
  81985. * @returns the current particle system
  81986. */
  81987. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  81988. /**
  81989. * Adds a new velocity gradient
  81990. * @param gradient defines the gradient to use (between 0 and 1)
  81991. * @param factor defines the velocity to affect to the specified gradient
  81992. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81993. * @returns the current particle system
  81994. */
  81995. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81996. /**
  81997. * Remove a specific velocity gradient
  81998. * @param gradient defines the gradient to remove
  81999. * @returns the current particle system
  82000. */
  82001. removeVelocityGradient(gradient: number): IParticleSystem;
  82002. /**
  82003. * Adds a new limit velocity gradient
  82004. * @param gradient defines the gradient to use (between 0 and 1)
  82005. * @param factor defines the limit velocity value to affect to the specified gradient
  82006. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82007. * @returns the current particle system
  82008. */
  82009. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82010. /**
  82011. * Remove a specific limit velocity gradient
  82012. * @param gradient defines the gradient to remove
  82013. * @returns the current particle system
  82014. */
  82015. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  82016. /**
  82017. * Adds a new drag gradient
  82018. * @param gradient defines the gradient to use (between 0 and 1)
  82019. * @param factor defines the drag value to affect to the specified gradient
  82020. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82021. * @returns the current particle system
  82022. */
  82023. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82024. /**
  82025. * Remove a specific drag gradient
  82026. * @param gradient defines the gradient to remove
  82027. * @returns the current particle system
  82028. */
  82029. removeDragGradient(gradient: number): IParticleSystem;
  82030. /**
  82031. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  82032. * @param gradient defines the gradient to use (between 0 and 1)
  82033. * @param factor defines the emit rate value to affect to the specified gradient
  82034. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82035. * @returns the current particle system
  82036. */
  82037. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82038. /**
  82039. * Remove a specific emit rate gradient
  82040. * @param gradient defines the gradient to remove
  82041. * @returns the current particle system
  82042. */
  82043. removeEmitRateGradient(gradient: number): IParticleSystem;
  82044. /**
  82045. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  82046. * @param gradient defines the gradient to use (between 0 and 1)
  82047. * @param factor defines the start size value to affect to the specified gradient
  82048. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82049. * @returns the current particle system
  82050. */
  82051. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82052. /**
  82053. * Remove a specific start size gradient
  82054. * @param gradient defines the gradient to remove
  82055. * @returns the current particle system
  82056. */
  82057. removeStartSizeGradient(gradient: number): IParticleSystem;
  82058. private _createRampGradientTexture;
  82059. /**
  82060. * Gets the current list of ramp gradients.
  82061. * You must use addRampGradient and removeRampGradient to udpate this list
  82062. * @returns the list of ramp gradients
  82063. */
  82064. getRampGradients(): Nullable<Array<Color3Gradient>>;
  82065. /**
  82066. * Adds a new ramp gradient used to remap particle colors
  82067. * @param gradient defines the gradient to use (between 0 and 1)
  82068. * @param color defines the color to affect to the specified gradient
  82069. * @returns the current particle system
  82070. */
  82071. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  82072. /**
  82073. * Remove a specific ramp gradient
  82074. * @param gradient defines the gradient to remove
  82075. * @returns the current particle system
  82076. */
  82077. removeRampGradient(gradient: number): ParticleSystem;
  82078. /**
  82079. * Adds a new color gradient
  82080. * @param gradient defines the gradient to use (between 0 and 1)
  82081. * @param color1 defines the color to affect to the specified gradient
  82082. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  82083. * @returns this particle system
  82084. */
  82085. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  82086. /**
  82087. * Remove a specific color gradient
  82088. * @param gradient defines the gradient to remove
  82089. * @returns this particle system
  82090. */
  82091. removeColorGradient(gradient: number): IParticleSystem;
  82092. private _fetchR;
  82093. protected _reset(): void;
  82094. private _resetEffect;
  82095. private _createVertexBuffers;
  82096. private _createIndexBuffer;
  82097. /**
  82098. * Gets the maximum number of particles active at the same time.
  82099. * @returns The max number of active particles.
  82100. */
  82101. getCapacity(): number;
  82102. /**
  82103. * Gets whether there are still active particles in the system.
  82104. * @returns True if it is alive, otherwise false.
  82105. */
  82106. isAlive(): boolean;
  82107. /**
  82108. * Gets if the system has been started. (Note: this will still be true after stop is called)
  82109. * @returns True if it has been started, otherwise false.
  82110. */
  82111. isStarted(): boolean;
  82112. private _prepareSubEmitterInternalArray;
  82113. /**
  82114. * Starts the particle system and begins to emit
  82115. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  82116. */
  82117. start(delay?: number): void;
  82118. /**
  82119. * Stops the particle system.
  82120. * @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.
  82121. */
  82122. stop(stopSubEmitters?: boolean): void;
  82123. /**
  82124. * Remove all active particles
  82125. */
  82126. reset(): void;
  82127. /**
  82128. * @hidden (for internal use only)
  82129. */
  82130. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  82131. /**
  82132. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  82133. * Its lifetime will start back at 0.
  82134. */
  82135. recycleParticle: (particle: Particle) => void;
  82136. private _stopSubEmitters;
  82137. private _createParticle;
  82138. private _removeFromRoot;
  82139. private _emitFromParticle;
  82140. private _update;
  82141. /** @hidden */
  82142. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  82143. /** @hidden */
  82144. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  82145. /** @hidden */
  82146. private _getEffect;
  82147. /**
  82148. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  82149. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  82150. */
  82151. animate(preWarmOnly?: boolean): void;
  82152. private _appendParticleVertices;
  82153. /**
  82154. * Rebuilds the particle system.
  82155. */
  82156. rebuild(): void;
  82157. /**
  82158. * Is this system ready to be used/rendered
  82159. * @return true if the system is ready
  82160. */
  82161. isReady(): boolean;
  82162. private _render;
  82163. /**
  82164. * Renders the particle system in its current state.
  82165. * @returns the current number of particles
  82166. */
  82167. render(): number;
  82168. /**
  82169. * Disposes the particle system and free the associated resources
  82170. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  82171. */
  82172. dispose(disposeTexture?: boolean): void;
  82173. /**
  82174. * Clones the particle system.
  82175. * @param name The name of the cloned object
  82176. * @param newEmitter The new emitter to use
  82177. * @returns the cloned particle system
  82178. */
  82179. clone(name: string, newEmitter: any): ParticleSystem;
  82180. /**
  82181. * Serializes the particle system to a JSON object.
  82182. * @returns the JSON object
  82183. */
  82184. serialize(): any;
  82185. /** @hidden */
  82186. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  82187. /** @hidden */
  82188. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  82189. /**
  82190. * Parses a JSON object to create a particle system.
  82191. * @param parsedParticleSystem The JSON object to parse
  82192. * @param scene The scene to create the particle system in
  82193. * @param rootUrl The root url to use to load external dependencies like texture
  82194. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  82195. * @returns the Parsed particle system
  82196. */
  82197. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  82198. }
  82199. }
  82200. declare module BABYLON {
  82201. /**
  82202. * A particle represents one of the element emitted by a particle system.
  82203. * This is mainly define by its coordinates, direction, velocity and age.
  82204. */
  82205. export class Particle {
  82206. /**
  82207. * The particle system the particle belongs to.
  82208. */
  82209. particleSystem: ParticleSystem;
  82210. private static _Count;
  82211. /**
  82212. * Unique ID of the particle
  82213. */
  82214. id: number;
  82215. /**
  82216. * The world position of the particle in the scene.
  82217. */
  82218. position: Vector3;
  82219. /**
  82220. * The world direction of the particle in the scene.
  82221. */
  82222. direction: Vector3;
  82223. /**
  82224. * The color of the particle.
  82225. */
  82226. color: Color4;
  82227. /**
  82228. * The color change of the particle per step.
  82229. */
  82230. colorStep: Color4;
  82231. /**
  82232. * Defines how long will the life of the particle be.
  82233. */
  82234. lifeTime: number;
  82235. /**
  82236. * The current age of the particle.
  82237. */
  82238. age: number;
  82239. /**
  82240. * The current size of the particle.
  82241. */
  82242. size: number;
  82243. /**
  82244. * The current scale of the particle.
  82245. */
  82246. scale: Vector2;
  82247. /**
  82248. * The current angle of the particle.
  82249. */
  82250. angle: number;
  82251. /**
  82252. * Defines how fast is the angle changing.
  82253. */
  82254. angularSpeed: number;
  82255. /**
  82256. * Defines the cell index used by the particle to be rendered from a sprite.
  82257. */
  82258. cellIndex: number;
  82259. /**
  82260. * The information required to support color remapping
  82261. */
  82262. remapData: Vector4;
  82263. /** @hidden */
  82264. _randomCellOffset?: number;
  82265. /** @hidden */
  82266. _initialDirection: Nullable<Vector3>;
  82267. /** @hidden */
  82268. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  82269. /** @hidden */
  82270. _initialStartSpriteCellID: number;
  82271. /** @hidden */
  82272. _initialEndSpriteCellID: number;
  82273. /** @hidden */
  82274. _currentColorGradient: Nullable<ColorGradient>;
  82275. /** @hidden */
  82276. _currentColor1: Color4;
  82277. /** @hidden */
  82278. _currentColor2: Color4;
  82279. /** @hidden */
  82280. _currentSizeGradient: Nullable<FactorGradient>;
  82281. /** @hidden */
  82282. _currentSize1: number;
  82283. /** @hidden */
  82284. _currentSize2: number;
  82285. /** @hidden */
  82286. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  82287. /** @hidden */
  82288. _currentAngularSpeed1: number;
  82289. /** @hidden */
  82290. _currentAngularSpeed2: number;
  82291. /** @hidden */
  82292. _currentVelocityGradient: Nullable<FactorGradient>;
  82293. /** @hidden */
  82294. _currentVelocity1: number;
  82295. /** @hidden */
  82296. _currentVelocity2: number;
  82297. /** @hidden */
  82298. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  82299. /** @hidden */
  82300. _currentLimitVelocity1: number;
  82301. /** @hidden */
  82302. _currentLimitVelocity2: number;
  82303. /** @hidden */
  82304. _currentDragGradient: Nullable<FactorGradient>;
  82305. /** @hidden */
  82306. _currentDrag1: number;
  82307. /** @hidden */
  82308. _currentDrag2: number;
  82309. /** @hidden */
  82310. _randomNoiseCoordinates1: Vector3;
  82311. /** @hidden */
  82312. _randomNoiseCoordinates2: Vector3;
  82313. /**
  82314. * Creates a new instance Particle
  82315. * @param particleSystem the particle system the particle belongs to
  82316. */
  82317. constructor(
  82318. /**
  82319. * The particle system the particle belongs to.
  82320. */
  82321. particleSystem: ParticleSystem);
  82322. private updateCellInfoFromSystem;
  82323. /**
  82324. * Defines how the sprite cell index is updated for the particle
  82325. */
  82326. updateCellIndex(): void;
  82327. /** @hidden */
  82328. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  82329. /** @hidden */
  82330. _inheritParticleInfoToSubEmitters(): void;
  82331. /** @hidden */
  82332. _reset(): void;
  82333. /**
  82334. * Copy the properties of particle to another one.
  82335. * @param other the particle to copy the information to.
  82336. */
  82337. copyTo(other: Particle): void;
  82338. }
  82339. }
  82340. declare module BABYLON {
  82341. /**
  82342. * Particle emitter represents a volume emitting particles.
  82343. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  82344. */
  82345. export interface IParticleEmitterType {
  82346. /**
  82347. * Called by the particle System when the direction is computed for the created particle.
  82348. * @param worldMatrix is the world matrix of the particle system
  82349. * @param directionToUpdate is the direction vector to update with the result
  82350. * @param particle is the particle we are computed the direction for
  82351. */
  82352. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82353. /**
  82354. * Called by the particle System when the position is computed for the created particle.
  82355. * @param worldMatrix is the world matrix of the particle system
  82356. * @param positionToUpdate is the position vector to update with the result
  82357. * @param particle is the particle we are computed the position for
  82358. */
  82359. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82360. /**
  82361. * Clones the current emitter and returns a copy of it
  82362. * @returns the new emitter
  82363. */
  82364. clone(): IParticleEmitterType;
  82365. /**
  82366. * Called by the GPUParticleSystem to setup the update shader
  82367. * @param effect defines the update shader
  82368. */
  82369. applyToShader(effect: Effect): void;
  82370. /**
  82371. * Returns a string to use to update the GPU particles update shader
  82372. * @returns the effect defines string
  82373. */
  82374. getEffectDefines(): string;
  82375. /**
  82376. * Returns a string representing the class name
  82377. * @returns a string containing the class name
  82378. */
  82379. getClassName(): string;
  82380. /**
  82381. * Serializes the particle system to a JSON object.
  82382. * @returns the JSON object
  82383. */
  82384. serialize(): any;
  82385. /**
  82386. * Parse properties from a JSON object
  82387. * @param serializationObject defines the JSON object
  82388. */
  82389. parse(serializationObject: any): void;
  82390. }
  82391. }
  82392. declare module BABYLON {
  82393. /**
  82394. * Particle emitter emitting particles from the inside of a box.
  82395. * It emits the particles randomly between 2 given directions.
  82396. */
  82397. export class BoxParticleEmitter implements IParticleEmitterType {
  82398. /**
  82399. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82400. */
  82401. direction1: Vector3;
  82402. /**
  82403. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82404. */
  82405. direction2: Vector3;
  82406. /**
  82407. * 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.
  82408. */
  82409. minEmitBox: Vector3;
  82410. /**
  82411. * 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.
  82412. */
  82413. maxEmitBox: Vector3;
  82414. /**
  82415. * Creates a new instance BoxParticleEmitter
  82416. */
  82417. constructor();
  82418. /**
  82419. * Called by the particle System when the direction is computed for the created particle.
  82420. * @param worldMatrix is the world matrix of the particle system
  82421. * @param directionToUpdate is the direction vector to update with the result
  82422. * @param particle is the particle we are computed the direction for
  82423. */
  82424. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82425. /**
  82426. * Called by the particle System when the position is computed for the created particle.
  82427. * @param worldMatrix is the world matrix of the particle system
  82428. * @param positionToUpdate is the position vector to update with the result
  82429. * @param particle is the particle we are computed the position for
  82430. */
  82431. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82432. /**
  82433. * Clones the current emitter and returns a copy of it
  82434. * @returns the new emitter
  82435. */
  82436. clone(): BoxParticleEmitter;
  82437. /**
  82438. * Called by the GPUParticleSystem to setup the update shader
  82439. * @param effect defines the update shader
  82440. */
  82441. applyToShader(effect: Effect): void;
  82442. /**
  82443. * Returns a string to use to update the GPU particles update shader
  82444. * @returns a string containng the defines string
  82445. */
  82446. getEffectDefines(): string;
  82447. /**
  82448. * Returns the string "BoxParticleEmitter"
  82449. * @returns a string containing the class name
  82450. */
  82451. getClassName(): string;
  82452. /**
  82453. * Serializes the particle system to a JSON object.
  82454. * @returns the JSON object
  82455. */
  82456. serialize(): any;
  82457. /**
  82458. * Parse properties from a JSON object
  82459. * @param serializationObject defines the JSON object
  82460. */
  82461. parse(serializationObject: any): void;
  82462. }
  82463. }
  82464. declare module BABYLON {
  82465. /**
  82466. * Particle emitter emitting particles from the inside of a cone.
  82467. * It emits the particles alongside the cone volume from the base to the particle.
  82468. * The emission direction might be randomized.
  82469. */
  82470. export class ConeParticleEmitter implements IParticleEmitterType {
  82471. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  82472. directionRandomizer: number;
  82473. private _radius;
  82474. private _angle;
  82475. private _height;
  82476. /**
  82477. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  82478. */
  82479. radiusRange: number;
  82480. /**
  82481. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  82482. */
  82483. heightRange: number;
  82484. /**
  82485. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  82486. */
  82487. emitFromSpawnPointOnly: boolean;
  82488. /**
  82489. * Gets or sets the radius of the emission cone
  82490. */
  82491. radius: number;
  82492. /**
  82493. * Gets or sets the angle of the emission cone
  82494. */
  82495. angle: number;
  82496. private _buildHeight;
  82497. /**
  82498. * Creates a new instance ConeParticleEmitter
  82499. * @param radius the radius of the emission cone (1 by default)
  82500. * @param angle the cone base angle (PI by default)
  82501. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  82502. */
  82503. constructor(radius?: number, angle?: number,
  82504. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  82505. directionRandomizer?: number);
  82506. /**
  82507. * Called by the particle System when the direction is computed for the created particle.
  82508. * @param worldMatrix is the world matrix of the particle system
  82509. * @param directionToUpdate is the direction vector to update with the result
  82510. * @param particle is the particle we are computed the direction for
  82511. */
  82512. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82513. /**
  82514. * Called by the particle System when the position is computed for the created particle.
  82515. * @param worldMatrix is the world matrix of the particle system
  82516. * @param positionToUpdate is the position vector to update with the result
  82517. * @param particle is the particle we are computed the position for
  82518. */
  82519. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82520. /**
  82521. * Clones the current emitter and returns a copy of it
  82522. * @returns the new emitter
  82523. */
  82524. clone(): ConeParticleEmitter;
  82525. /**
  82526. * Called by the GPUParticleSystem to setup the update shader
  82527. * @param effect defines the update shader
  82528. */
  82529. applyToShader(effect: Effect): void;
  82530. /**
  82531. * Returns a string to use to update the GPU particles update shader
  82532. * @returns a string containng the defines string
  82533. */
  82534. getEffectDefines(): string;
  82535. /**
  82536. * Returns the string "ConeParticleEmitter"
  82537. * @returns a string containing the class name
  82538. */
  82539. getClassName(): string;
  82540. /**
  82541. * Serializes the particle system to a JSON object.
  82542. * @returns the JSON object
  82543. */
  82544. serialize(): any;
  82545. /**
  82546. * Parse properties from a JSON object
  82547. * @param serializationObject defines the JSON object
  82548. */
  82549. parse(serializationObject: any): void;
  82550. }
  82551. }
  82552. declare module BABYLON {
  82553. /**
  82554. * Particle emitter emitting particles from the inside of a cylinder.
  82555. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  82556. */
  82557. export class CylinderParticleEmitter implements IParticleEmitterType {
  82558. /**
  82559. * The radius of the emission cylinder.
  82560. */
  82561. radius: number;
  82562. /**
  82563. * The height of the emission cylinder.
  82564. */
  82565. height: number;
  82566. /**
  82567. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82568. */
  82569. radiusRange: number;
  82570. /**
  82571. * How much to randomize the particle direction [0-1].
  82572. */
  82573. directionRandomizer: number;
  82574. /**
  82575. * Creates a new instance CylinderParticleEmitter
  82576. * @param radius the radius of the emission cylinder (1 by default)
  82577. * @param height the height of the emission cylinder (1 by default)
  82578. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82579. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  82580. */
  82581. constructor(
  82582. /**
  82583. * The radius of the emission cylinder.
  82584. */
  82585. radius?: number,
  82586. /**
  82587. * The height of the emission cylinder.
  82588. */
  82589. height?: number,
  82590. /**
  82591. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82592. */
  82593. radiusRange?: number,
  82594. /**
  82595. * How much to randomize the particle direction [0-1].
  82596. */
  82597. directionRandomizer?: number);
  82598. /**
  82599. * Called by the particle System when the direction is computed for the created particle.
  82600. * @param worldMatrix is the world matrix of the particle system
  82601. * @param directionToUpdate is the direction vector to update with the result
  82602. * @param particle is the particle we are computed the direction for
  82603. */
  82604. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82605. /**
  82606. * Called by the particle System when the position is computed for the created particle.
  82607. * @param worldMatrix is the world matrix of the particle system
  82608. * @param positionToUpdate is the position vector to update with the result
  82609. * @param particle is the particle we are computed the position for
  82610. */
  82611. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82612. /**
  82613. * Clones the current emitter and returns a copy of it
  82614. * @returns the new emitter
  82615. */
  82616. clone(): CylinderParticleEmitter;
  82617. /**
  82618. * Called by the GPUParticleSystem to setup the update shader
  82619. * @param effect defines the update shader
  82620. */
  82621. applyToShader(effect: Effect): void;
  82622. /**
  82623. * Returns a string to use to update the GPU particles update shader
  82624. * @returns a string containng the defines string
  82625. */
  82626. getEffectDefines(): string;
  82627. /**
  82628. * Returns the string "CylinderParticleEmitter"
  82629. * @returns a string containing the class name
  82630. */
  82631. getClassName(): string;
  82632. /**
  82633. * Serializes the particle system to a JSON object.
  82634. * @returns the JSON object
  82635. */
  82636. serialize(): any;
  82637. /**
  82638. * Parse properties from a JSON object
  82639. * @param serializationObject defines the JSON object
  82640. */
  82641. parse(serializationObject: any): void;
  82642. }
  82643. /**
  82644. * Particle emitter emitting particles from the inside of a cylinder.
  82645. * It emits the particles randomly between two vectors.
  82646. */
  82647. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  82648. /**
  82649. * The min limit of the emission direction.
  82650. */
  82651. direction1: Vector3;
  82652. /**
  82653. * The max limit of the emission direction.
  82654. */
  82655. direction2: Vector3;
  82656. /**
  82657. * Creates a new instance CylinderDirectedParticleEmitter
  82658. * @param radius the radius of the emission cylinder (1 by default)
  82659. * @param height the height of the emission cylinder (1 by default)
  82660. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82661. * @param direction1 the min limit of the emission direction (up vector by default)
  82662. * @param direction2 the max limit of the emission direction (up vector by default)
  82663. */
  82664. constructor(radius?: number, height?: number, radiusRange?: number,
  82665. /**
  82666. * The min limit of the emission direction.
  82667. */
  82668. direction1?: Vector3,
  82669. /**
  82670. * The max limit of the emission direction.
  82671. */
  82672. direction2?: Vector3);
  82673. /**
  82674. * Called by the particle System when the direction is computed for the created particle.
  82675. * @param worldMatrix is the world matrix of the particle system
  82676. * @param directionToUpdate is the direction vector to update with the result
  82677. * @param particle is the particle we are computed the direction for
  82678. */
  82679. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82680. /**
  82681. * Clones the current emitter and returns a copy of it
  82682. * @returns the new emitter
  82683. */
  82684. clone(): CylinderDirectedParticleEmitter;
  82685. /**
  82686. * Called by the GPUParticleSystem to setup the update shader
  82687. * @param effect defines the update shader
  82688. */
  82689. applyToShader(effect: Effect): void;
  82690. /**
  82691. * Returns a string to use to update the GPU particles update shader
  82692. * @returns a string containng the defines string
  82693. */
  82694. getEffectDefines(): string;
  82695. /**
  82696. * Returns the string "CylinderDirectedParticleEmitter"
  82697. * @returns a string containing the class name
  82698. */
  82699. getClassName(): string;
  82700. /**
  82701. * Serializes the particle system to a JSON object.
  82702. * @returns the JSON object
  82703. */
  82704. serialize(): any;
  82705. /**
  82706. * Parse properties from a JSON object
  82707. * @param serializationObject defines the JSON object
  82708. */
  82709. parse(serializationObject: any): void;
  82710. }
  82711. }
  82712. declare module BABYLON {
  82713. /**
  82714. * Particle emitter emitting particles from the inside of a hemisphere.
  82715. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  82716. */
  82717. export class HemisphericParticleEmitter implements IParticleEmitterType {
  82718. /**
  82719. * The radius of the emission hemisphere.
  82720. */
  82721. radius: number;
  82722. /**
  82723. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82724. */
  82725. radiusRange: number;
  82726. /**
  82727. * How much to randomize the particle direction [0-1].
  82728. */
  82729. directionRandomizer: number;
  82730. /**
  82731. * Creates a new instance HemisphericParticleEmitter
  82732. * @param radius the radius of the emission hemisphere (1 by default)
  82733. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82734. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  82735. */
  82736. constructor(
  82737. /**
  82738. * The radius of the emission hemisphere.
  82739. */
  82740. radius?: number,
  82741. /**
  82742. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82743. */
  82744. radiusRange?: number,
  82745. /**
  82746. * How much to randomize the particle direction [0-1].
  82747. */
  82748. directionRandomizer?: number);
  82749. /**
  82750. * Called by the particle System when the direction is computed for the created particle.
  82751. * @param worldMatrix is the world matrix of the particle system
  82752. * @param directionToUpdate is the direction vector to update with the result
  82753. * @param particle is the particle we are computed the direction for
  82754. */
  82755. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82756. /**
  82757. * Called by the particle System when the position is computed for the created particle.
  82758. * @param worldMatrix is the world matrix of the particle system
  82759. * @param positionToUpdate is the position vector to update with the result
  82760. * @param particle is the particle we are computed the position for
  82761. */
  82762. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82763. /**
  82764. * Clones the current emitter and returns a copy of it
  82765. * @returns the new emitter
  82766. */
  82767. clone(): HemisphericParticleEmitter;
  82768. /**
  82769. * Called by the GPUParticleSystem to setup the update shader
  82770. * @param effect defines the update shader
  82771. */
  82772. applyToShader(effect: Effect): void;
  82773. /**
  82774. * Returns a string to use to update the GPU particles update shader
  82775. * @returns a string containng the defines string
  82776. */
  82777. getEffectDefines(): string;
  82778. /**
  82779. * Returns the string "HemisphericParticleEmitter"
  82780. * @returns a string containing the class name
  82781. */
  82782. getClassName(): string;
  82783. /**
  82784. * Serializes the particle system to a JSON object.
  82785. * @returns the JSON object
  82786. */
  82787. serialize(): any;
  82788. /**
  82789. * Parse properties from a JSON object
  82790. * @param serializationObject defines the JSON object
  82791. */
  82792. parse(serializationObject: any): void;
  82793. }
  82794. }
  82795. declare module BABYLON {
  82796. /**
  82797. * Particle emitter emitting particles from a point.
  82798. * It emits the particles randomly between 2 given directions.
  82799. */
  82800. export class PointParticleEmitter implements IParticleEmitterType {
  82801. /**
  82802. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82803. */
  82804. direction1: Vector3;
  82805. /**
  82806. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82807. */
  82808. direction2: Vector3;
  82809. /**
  82810. * Creates a new instance PointParticleEmitter
  82811. */
  82812. constructor();
  82813. /**
  82814. * Called by the particle System when the direction is computed for the created particle.
  82815. * @param worldMatrix is the world matrix of the particle system
  82816. * @param directionToUpdate is the direction vector to update with the result
  82817. * @param particle is the particle we are computed the direction for
  82818. */
  82819. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82820. /**
  82821. * Called by the particle System when the position is computed for the created particle.
  82822. * @param worldMatrix is the world matrix of the particle system
  82823. * @param positionToUpdate is the position vector to update with the result
  82824. * @param particle is the particle we are computed the position for
  82825. */
  82826. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82827. /**
  82828. * Clones the current emitter and returns a copy of it
  82829. * @returns the new emitter
  82830. */
  82831. clone(): PointParticleEmitter;
  82832. /**
  82833. * Called by the GPUParticleSystem to setup the update shader
  82834. * @param effect defines the update shader
  82835. */
  82836. applyToShader(effect: Effect): void;
  82837. /**
  82838. * Returns a string to use to update the GPU particles update shader
  82839. * @returns a string containng the defines string
  82840. */
  82841. getEffectDefines(): string;
  82842. /**
  82843. * Returns the string "PointParticleEmitter"
  82844. * @returns a string containing the class name
  82845. */
  82846. getClassName(): string;
  82847. /**
  82848. * Serializes the particle system to a JSON object.
  82849. * @returns the JSON object
  82850. */
  82851. serialize(): any;
  82852. /**
  82853. * Parse properties from a JSON object
  82854. * @param serializationObject defines the JSON object
  82855. */
  82856. parse(serializationObject: any): void;
  82857. }
  82858. }
  82859. declare module BABYLON {
  82860. /**
  82861. * Particle emitter emitting particles from the inside of a sphere.
  82862. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  82863. */
  82864. export class SphereParticleEmitter implements IParticleEmitterType {
  82865. /**
  82866. * The radius of the emission sphere.
  82867. */
  82868. radius: number;
  82869. /**
  82870. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82871. */
  82872. radiusRange: number;
  82873. /**
  82874. * How much to randomize the particle direction [0-1].
  82875. */
  82876. directionRandomizer: number;
  82877. /**
  82878. * Creates a new instance SphereParticleEmitter
  82879. * @param radius the radius of the emission sphere (1 by default)
  82880. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82881. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  82882. */
  82883. constructor(
  82884. /**
  82885. * The radius of the emission sphere.
  82886. */
  82887. radius?: number,
  82888. /**
  82889. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82890. */
  82891. radiusRange?: number,
  82892. /**
  82893. * How much to randomize the particle direction [0-1].
  82894. */
  82895. directionRandomizer?: number);
  82896. /**
  82897. * Called by the particle System when the direction is computed for the created particle.
  82898. * @param worldMatrix is the world matrix of the particle system
  82899. * @param directionToUpdate is the direction vector to update with the result
  82900. * @param particle is the particle we are computed the direction for
  82901. */
  82902. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82903. /**
  82904. * Called by the particle System when the position is computed for the created particle.
  82905. * @param worldMatrix is the world matrix of the particle system
  82906. * @param positionToUpdate is the position vector to update with the result
  82907. * @param particle is the particle we are computed the position for
  82908. */
  82909. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82910. /**
  82911. * Clones the current emitter and returns a copy of it
  82912. * @returns the new emitter
  82913. */
  82914. clone(): SphereParticleEmitter;
  82915. /**
  82916. * Called by the GPUParticleSystem to setup the update shader
  82917. * @param effect defines the update shader
  82918. */
  82919. applyToShader(effect: Effect): void;
  82920. /**
  82921. * Returns a string to use to update the GPU particles update shader
  82922. * @returns a string containng the defines string
  82923. */
  82924. getEffectDefines(): string;
  82925. /**
  82926. * Returns the string "SphereParticleEmitter"
  82927. * @returns a string containing the class name
  82928. */
  82929. getClassName(): string;
  82930. /**
  82931. * Serializes the particle system to a JSON object.
  82932. * @returns the JSON object
  82933. */
  82934. serialize(): any;
  82935. /**
  82936. * Parse properties from a JSON object
  82937. * @param serializationObject defines the JSON object
  82938. */
  82939. parse(serializationObject: any): void;
  82940. }
  82941. /**
  82942. * Particle emitter emitting particles from the inside of a sphere.
  82943. * It emits the particles randomly between two vectors.
  82944. */
  82945. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  82946. /**
  82947. * The min limit of the emission direction.
  82948. */
  82949. direction1: Vector3;
  82950. /**
  82951. * The max limit of the emission direction.
  82952. */
  82953. direction2: Vector3;
  82954. /**
  82955. * Creates a new instance SphereDirectedParticleEmitter
  82956. * @param radius the radius of the emission sphere (1 by default)
  82957. * @param direction1 the min limit of the emission direction (up vector by default)
  82958. * @param direction2 the max limit of the emission direction (up vector by default)
  82959. */
  82960. constructor(radius?: number,
  82961. /**
  82962. * The min limit of the emission direction.
  82963. */
  82964. direction1?: Vector3,
  82965. /**
  82966. * The max limit of the emission direction.
  82967. */
  82968. direction2?: Vector3);
  82969. /**
  82970. * Called by the particle System when the direction is computed for the created particle.
  82971. * @param worldMatrix is the world matrix of the particle system
  82972. * @param directionToUpdate is the direction vector to update with the result
  82973. * @param particle is the particle we are computed the direction for
  82974. */
  82975. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82976. /**
  82977. * Clones the current emitter and returns a copy of it
  82978. * @returns the new emitter
  82979. */
  82980. clone(): SphereDirectedParticleEmitter;
  82981. /**
  82982. * Called by the GPUParticleSystem to setup the update shader
  82983. * @param effect defines the update shader
  82984. */
  82985. applyToShader(effect: Effect): void;
  82986. /**
  82987. * Returns a string to use to update the GPU particles update shader
  82988. * @returns a string containng the defines string
  82989. */
  82990. getEffectDefines(): string;
  82991. /**
  82992. * Returns the string "SphereDirectedParticleEmitter"
  82993. * @returns a string containing the class name
  82994. */
  82995. getClassName(): string;
  82996. /**
  82997. * Serializes the particle system to a JSON object.
  82998. * @returns the JSON object
  82999. */
  83000. serialize(): any;
  83001. /**
  83002. * Parse properties from a JSON object
  83003. * @param serializationObject defines the JSON object
  83004. */
  83005. parse(serializationObject: any): void;
  83006. }
  83007. }
  83008. declare module BABYLON {
  83009. /**
  83010. * Interface representing a particle system in Babylon.js.
  83011. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  83012. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  83013. */
  83014. export interface IParticleSystem {
  83015. /**
  83016. * List of animations used by the particle system.
  83017. */
  83018. animations: Animation[];
  83019. /**
  83020. * The id of the Particle system.
  83021. */
  83022. id: string;
  83023. /**
  83024. * The name of the Particle system.
  83025. */
  83026. name: string;
  83027. /**
  83028. * The emitter represents the Mesh or position we are attaching the particle system to.
  83029. */
  83030. emitter: Nullable<AbstractMesh | Vector3>;
  83031. /**
  83032. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  83033. */
  83034. isBillboardBased: boolean;
  83035. /**
  83036. * The rendering group used by the Particle system to chose when to render.
  83037. */
  83038. renderingGroupId: number;
  83039. /**
  83040. * The layer mask we are rendering the particles through.
  83041. */
  83042. layerMask: number;
  83043. /**
  83044. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  83045. */
  83046. updateSpeed: number;
  83047. /**
  83048. * The amount of time the particle system is running (depends of the overall update speed).
  83049. */
  83050. targetStopDuration: number;
  83051. /**
  83052. * The texture used to render each particle. (this can be a spritesheet)
  83053. */
  83054. particleTexture: Nullable<Texture>;
  83055. /**
  83056. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  83057. */
  83058. blendMode: number;
  83059. /**
  83060. * Minimum life time of emitting particles.
  83061. */
  83062. minLifeTime: number;
  83063. /**
  83064. * Maximum life time of emitting particles.
  83065. */
  83066. maxLifeTime: number;
  83067. /**
  83068. * Minimum Size of emitting particles.
  83069. */
  83070. minSize: number;
  83071. /**
  83072. * Maximum Size of emitting particles.
  83073. */
  83074. maxSize: number;
  83075. /**
  83076. * Minimum scale of emitting particles on X axis.
  83077. */
  83078. minScaleX: number;
  83079. /**
  83080. * Maximum scale of emitting particles on X axis.
  83081. */
  83082. maxScaleX: number;
  83083. /**
  83084. * Minimum scale of emitting particles on Y axis.
  83085. */
  83086. minScaleY: number;
  83087. /**
  83088. * Maximum scale of emitting particles on Y axis.
  83089. */
  83090. maxScaleY: number;
  83091. /**
  83092. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  83093. */
  83094. color1: Color4;
  83095. /**
  83096. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  83097. */
  83098. color2: Color4;
  83099. /**
  83100. * Color the particle will have at the end of its lifetime.
  83101. */
  83102. colorDead: Color4;
  83103. /**
  83104. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  83105. */
  83106. emitRate: number;
  83107. /**
  83108. * You can use gravity if you want to give an orientation to your particles.
  83109. */
  83110. gravity: Vector3;
  83111. /**
  83112. * Minimum power of emitting particles.
  83113. */
  83114. minEmitPower: number;
  83115. /**
  83116. * Maximum power of emitting particles.
  83117. */
  83118. maxEmitPower: number;
  83119. /**
  83120. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  83121. */
  83122. minAngularSpeed: number;
  83123. /**
  83124. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  83125. */
  83126. maxAngularSpeed: number;
  83127. /**
  83128. * Gets or sets the minimal initial rotation in radians.
  83129. */
  83130. minInitialRotation: number;
  83131. /**
  83132. * Gets or sets the maximal initial rotation in radians.
  83133. */
  83134. maxInitialRotation: number;
  83135. /**
  83136. * The particle emitter type defines the emitter used by the particle system.
  83137. * It can be for example box, sphere, or cone...
  83138. */
  83139. particleEmitterType: Nullable<IParticleEmitterType>;
  83140. /**
  83141. * Defines the delay in milliseconds before starting the system (0 by default)
  83142. */
  83143. startDelay: number;
  83144. /**
  83145. * 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
  83146. */
  83147. preWarmCycles: number;
  83148. /**
  83149. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  83150. */
  83151. preWarmStepOffset: number;
  83152. /**
  83153. * 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)
  83154. */
  83155. spriteCellChangeSpeed: number;
  83156. /**
  83157. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  83158. */
  83159. startSpriteCellID: number;
  83160. /**
  83161. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  83162. */
  83163. endSpriteCellID: number;
  83164. /**
  83165. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  83166. */
  83167. spriteCellWidth: number;
  83168. /**
  83169. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  83170. */
  83171. spriteCellHeight: number;
  83172. /**
  83173. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  83174. */
  83175. spriteRandomStartCell: boolean;
  83176. /**
  83177. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  83178. */
  83179. isAnimationSheetEnabled: boolean;
  83180. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  83181. translationPivot: Vector2;
  83182. /**
  83183. * Gets or sets a texture used to add random noise to particle positions
  83184. */
  83185. noiseTexture: Nullable<BaseTexture>;
  83186. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  83187. noiseStrength: Vector3;
  83188. /**
  83189. * Gets or sets the billboard mode to use when isBillboardBased = true.
  83190. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  83191. */
  83192. billboardMode: number;
  83193. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  83194. limitVelocityDamping: number;
  83195. /**
  83196. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  83197. */
  83198. beginAnimationOnStart: boolean;
  83199. /**
  83200. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  83201. */
  83202. beginAnimationFrom: number;
  83203. /**
  83204. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  83205. */
  83206. beginAnimationTo: number;
  83207. /**
  83208. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  83209. */
  83210. beginAnimationLoop: boolean;
  83211. /**
  83212. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  83213. */
  83214. disposeOnStop: boolean;
  83215. /**
  83216. * Gets the maximum number of particles active at the same time.
  83217. * @returns The max number of active particles.
  83218. */
  83219. getCapacity(): number;
  83220. /**
  83221. * Gets if the system has been started. (Note: this will still be true after stop is called)
  83222. * @returns True if it has been started, otherwise false.
  83223. */
  83224. isStarted(): boolean;
  83225. /**
  83226. * Animates the particle system for this frame.
  83227. */
  83228. animate(): void;
  83229. /**
  83230. * Renders the particle system in its current state.
  83231. * @returns the current number of particles
  83232. */
  83233. render(): number;
  83234. /**
  83235. * Dispose the particle system and frees its associated resources.
  83236. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  83237. */
  83238. dispose(disposeTexture?: boolean): void;
  83239. /**
  83240. * Clones the particle system.
  83241. * @param name The name of the cloned object
  83242. * @param newEmitter The new emitter to use
  83243. * @returns the cloned particle system
  83244. */
  83245. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  83246. /**
  83247. * Serializes the particle system to a JSON object.
  83248. * @returns the JSON object
  83249. */
  83250. serialize(): any;
  83251. /**
  83252. * Rebuild the particle system
  83253. */
  83254. rebuild(): void;
  83255. /**
  83256. * Starts the particle system and begins to emit
  83257. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  83258. */
  83259. start(delay?: number): void;
  83260. /**
  83261. * Stops the particle system.
  83262. */
  83263. stop(): void;
  83264. /**
  83265. * Remove all active particles
  83266. */
  83267. reset(): void;
  83268. /**
  83269. * Is this system ready to be used/rendered
  83270. * @return true if the system is ready
  83271. */
  83272. isReady(): boolean;
  83273. /**
  83274. * Adds a new color gradient
  83275. * @param gradient defines the gradient to use (between 0 and 1)
  83276. * @param color1 defines the color to affect to the specified gradient
  83277. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  83278. * @returns the current particle system
  83279. */
  83280. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  83281. /**
  83282. * Remove a specific color gradient
  83283. * @param gradient defines the gradient to remove
  83284. * @returns the current particle system
  83285. */
  83286. removeColorGradient(gradient: number): IParticleSystem;
  83287. /**
  83288. * Adds a new size gradient
  83289. * @param gradient defines the gradient to use (between 0 and 1)
  83290. * @param factor defines the size factor to affect to the specified gradient
  83291. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83292. * @returns the current particle system
  83293. */
  83294. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83295. /**
  83296. * Remove a specific size gradient
  83297. * @param gradient defines the gradient to remove
  83298. * @returns the current particle system
  83299. */
  83300. removeSizeGradient(gradient: number): IParticleSystem;
  83301. /**
  83302. * Gets the current list of color gradients.
  83303. * You must use addColorGradient and removeColorGradient to udpate this list
  83304. * @returns the list of color gradients
  83305. */
  83306. getColorGradients(): Nullable<Array<ColorGradient>>;
  83307. /**
  83308. * Gets the current list of size gradients.
  83309. * You must use addSizeGradient and removeSizeGradient to udpate this list
  83310. * @returns the list of size gradients
  83311. */
  83312. getSizeGradients(): Nullable<Array<FactorGradient>>;
  83313. /**
  83314. * Gets the current list of angular speed gradients.
  83315. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  83316. * @returns the list of angular speed gradients
  83317. */
  83318. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  83319. /**
  83320. * Adds a new angular speed gradient
  83321. * @param gradient defines the gradient to use (between 0 and 1)
  83322. * @param factor defines the angular speed to affect to the specified gradient
  83323. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83324. * @returns the current particle system
  83325. */
  83326. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83327. /**
  83328. * Remove a specific angular speed gradient
  83329. * @param gradient defines the gradient to remove
  83330. * @returns the current particle system
  83331. */
  83332. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  83333. /**
  83334. * Gets the current list of velocity gradients.
  83335. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  83336. * @returns the list of velocity gradients
  83337. */
  83338. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  83339. /**
  83340. * Adds a new velocity gradient
  83341. * @param gradient defines the gradient to use (between 0 and 1)
  83342. * @param factor defines the velocity to affect to the specified gradient
  83343. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83344. * @returns the current particle system
  83345. */
  83346. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83347. /**
  83348. * Remove a specific velocity gradient
  83349. * @param gradient defines the gradient to remove
  83350. * @returns the current particle system
  83351. */
  83352. removeVelocityGradient(gradient: number): IParticleSystem;
  83353. /**
  83354. * Gets the current list of limit velocity gradients.
  83355. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  83356. * @returns the list of limit velocity gradients
  83357. */
  83358. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  83359. /**
  83360. * Adds a new limit velocity gradient
  83361. * @param gradient defines the gradient to use (between 0 and 1)
  83362. * @param factor defines the limit velocity to affect to the specified gradient
  83363. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83364. * @returns the current particle system
  83365. */
  83366. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83367. /**
  83368. * Remove a specific limit velocity gradient
  83369. * @param gradient defines the gradient to remove
  83370. * @returns the current particle system
  83371. */
  83372. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  83373. /**
  83374. * Adds a new drag gradient
  83375. * @param gradient defines the gradient to use (between 0 and 1)
  83376. * @param factor defines the drag to affect to the specified gradient
  83377. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83378. * @returns the current particle system
  83379. */
  83380. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83381. /**
  83382. * Remove a specific drag gradient
  83383. * @param gradient defines the gradient to remove
  83384. * @returns the current particle system
  83385. */
  83386. removeDragGradient(gradient: number): IParticleSystem;
  83387. /**
  83388. * Gets the current list of drag gradients.
  83389. * You must use addDragGradient and removeDragGradient to udpate this list
  83390. * @returns the list of drag gradients
  83391. */
  83392. getDragGradients(): Nullable<Array<FactorGradient>>;
  83393. /**
  83394. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  83395. * @param gradient defines the gradient to use (between 0 and 1)
  83396. * @param factor defines the emit rate to affect to the specified gradient
  83397. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83398. * @returns the current particle system
  83399. */
  83400. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83401. /**
  83402. * Remove a specific emit rate gradient
  83403. * @param gradient defines the gradient to remove
  83404. * @returns the current particle system
  83405. */
  83406. removeEmitRateGradient(gradient: number): IParticleSystem;
  83407. /**
  83408. * Gets the current list of emit rate gradients.
  83409. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  83410. * @returns the list of emit rate gradients
  83411. */
  83412. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  83413. /**
  83414. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  83415. * @param gradient defines the gradient to use (between 0 and 1)
  83416. * @param factor defines the start size to affect to the specified gradient
  83417. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83418. * @returns the current particle system
  83419. */
  83420. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83421. /**
  83422. * Remove a specific start size gradient
  83423. * @param gradient defines the gradient to remove
  83424. * @returns the current particle system
  83425. */
  83426. removeStartSizeGradient(gradient: number): IParticleSystem;
  83427. /**
  83428. * Gets the current list of start size gradients.
  83429. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  83430. * @returns the list of start size gradients
  83431. */
  83432. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  83433. /**
  83434. * Adds a new life time gradient
  83435. * @param gradient defines the gradient to use (between 0 and 1)
  83436. * @param factor defines the life time factor to affect to the specified gradient
  83437. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83438. * @returns the current particle system
  83439. */
  83440. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83441. /**
  83442. * Remove a specific life time gradient
  83443. * @param gradient defines the gradient to remove
  83444. * @returns the current particle system
  83445. */
  83446. removeLifeTimeGradient(gradient: number): IParticleSystem;
  83447. /**
  83448. * Gets the current list of life time gradients.
  83449. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  83450. * @returns the list of life time gradients
  83451. */
  83452. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  83453. /**
  83454. * Gets the current list of color gradients.
  83455. * You must use addColorGradient and removeColorGradient to udpate this list
  83456. * @returns the list of color gradients
  83457. */
  83458. getColorGradients(): Nullable<Array<ColorGradient>>;
  83459. /**
  83460. * Adds a new ramp gradient used to remap particle colors
  83461. * @param gradient defines the gradient to use (between 0 and 1)
  83462. * @param color defines the color to affect to the specified gradient
  83463. * @returns the current particle system
  83464. */
  83465. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  83466. /**
  83467. * Gets the current list of ramp gradients.
  83468. * You must use addRampGradient and removeRampGradient to udpate this list
  83469. * @returns the list of ramp gradients
  83470. */
  83471. getRampGradients(): Nullable<Array<Color3Gradient>>;
  83472. /** Gets or sets a boolean indicating that ramp gradients must be used
  83473. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  83474. */
  83475. useRampGradients: boolean;
  83476. /**
  83477. * Adds a new color remap gradient
  83478. * @param gradient defines the gradient to use (between 0 and 1)
  83479. * @param min defines the color remap minimal range
  83480. * @param max defines the color remap maximal range
  83481. * @returns the current particle system
  83482. */
  83483. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  83484. /**
  83485. * Gets the current list of color remap gradients.
  83486. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  83487. * @returns the list of color remap gradients
  83488. */
  83489. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  83490. /**
  83491. * Adds a new alpha remap gradient
  83492. * @param gradient defines the gradient to use (between 0 and 1)
  83493. * @param min defines the alpha remap minimal range
  83494. * @param max defines the alpha remap maximal range
  83495. * @returns the current particle system
  83496. */
  83497. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  83498. /**
  83499. * Gets the current list of alpha remap gradients.
  83500. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  83501. * @returns the list of alpha remap gradients
  83502. */
  83503. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  83504. /**
  83505. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  83506. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  83507. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  83508. * @returns the emitter
  83509. */
  83510. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  83511. /**
  83512. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  83513. * @param radius The radius of the hemisphere to emit from
  83514. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  83515. * @returns the emitter
  83516. */
  83517. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  83518. /**
  83519. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  83520. * @param radius The radius of the sphere to emit from
  83521. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  83522. * @returns the emitter
  83523. */
  83524. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  83525. /**
  83526. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  83527. * @param radius The radius of the sphere to emit from
  83528. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  83529. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  83530. * @returns the emitter
  83531. */
  83532. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  83533. /**
  83534. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  83535. * @param radius The radius of the emission cylinder
  83536. * @param height The height of the emission cylinder
  83537. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  83538. * @param directionRandomizer How much to randomize the particle direction [0-1]
  83539. * @returns the emitter
  83540. */
  83541. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  83542. /**
  83543. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  83544. * @param radius The radius of the cylinder to emit from
  83545. * @param height The height of the emission cylinder
  83546. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83547. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  83548. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  83549. * @returns the emitter
  83550. */
  83551. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  83552. /**
  83553. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  83554. * @param radius The radius of the cone to emit from
  83555. * @param angle The base angle of the cone
  83556. * @returns the emitter
  83557. */
  83558. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  83559. /**
  83560. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  83561. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  83562. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  83563. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  83564. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  83565. * @returns the emitter
  83566. */
  83567. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  83568. /**
  83569. * Get hosting scene
  83570. * @returns the scene
  83571. */
  83572. getScene(): Scene;
  83573. }
  83574. }
  83575. declare module BABYLON {
  83576. /**
  83577. * Creates an instance based on a source mesh.
  83578. */
  83579. export class InstancedMesh extends AbstractMesh {
  83580. private _sourceMesh;
  83581. private _currentLOD;
  83582. /** @hidden */
  83583. _indexInSourceMeshInstanceArray: number;
  83584. constructor(name: string, source: Mesh);
  83585. /**
  83586. * Returns the string "InstancedMesh".
  83587. */
  83588. getClassName(): string;
  83589. /** Gets the list of lights affecting that mesh */
  83590. readonly lightSources: Light[];
  83591. _resyncLightSources(): void;
  83592. _resyncLighSource(light: Light): void;
  83593. _removeLightSource(light: Light, dispose: boolean): void;
  83594. /**
  83595. * If the source mesh receives shadows
  83596. */
  83597. readonly receiveShadows: boolean;
  83598. /**
  83599. * The material of the source mesh
  83600. */
  83601. readonly material: Nullable<Material>;
  83602. /**
  83603. * Visibility of the source mesh
  83604. */
  83605. readonly visibility: number;
  83606. /**
  83607. * Skeleton of the source mesh
  83608. */
  83609. readonly skeleton: Nullable<Skeleton>;
  83610. /**
  83611. * Rendering ground id of the source mesh
  83612. */
  83613. renderingGroupId: number;
  83614. /**
  83615. * Returns the total number of vertices (integer).
  83616. */
  83617. getTotalVertices(): number;
  83618. /**
  83619. * Returns a positive integer : the total number of indices in this mesh geometry.
  83620. * @returns the numner of indices or zero if the mesh has no geometry.
  83621. */
  83622. getTotalIndices(): number;
  83623. /**
  83624. * The source mesh of the instance
  83625. */
  83626. readonly sourceMesh: Mesh;
  83627. /**
  83628. * Is this node ready to be used/rendered
  83629. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  83630. * @return {boolean} is it ready
  83631. */
  83632. isReady(completeCheck?: boolean): boolean;
  83633. /**
  83634. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  83635. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  83636. * @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.
  83637. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  83638. */
  83639. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  83640. /**
  83641. * Sets the vertex data of the mesh geometry for the requested `kind`.
  83642. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  83643. * The `data` are either a numeric array either a Float32Array.
  83644. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  83645. * 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).
  83646. * Note that a new underlying VertexBuffer object is created each call.
  83647. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  83648. *
  83649. * Possible `kind` values :
  83650. * - VertexBuffer.PositionKind
  83651. * - VertexBuffer.UVKind
  83652. * - VertexBuffer.UV2Kind
  83653. * - VertexBuffer.UV3Kind
  83654. * - VertexBuffer.UV4Kind
  83655. * - VertexBuffer.UV5Kind
  83656. * - VertexBuffer.UV6Kind
  83657. * - VertexBuffer.ColorKind
  83658. * - VertexBuffer.MatricesIndicesKind
  83659. * - VertexBuffer.MatricesIndicesExtraKind
  83660. * - VertexBuffer.MatricesWeightsKind
  83661. * - VertexBuffer.MatricesWeightsExtraKind
  83662. *
  83663. * Returns the Mesh.
  83664. */
  83665. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  83666. /**
  83667. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  83668. * If the mesh has no geometry, it is simply returned as it is.
  83669. * The `data` are either a numeric array either a Float32Array.
  83670. * No new underlying VertexBuffer object is created.
  83671. * 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.
  83672. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  83673. *
  83674. * Possible `kind` values :
  83675. * - VertexBuffer.PositionKind
  83676. * - VertexBuffer.UVKind
  83677. * - VertexBuffer.UV2Kind
  83678. * - VertexBuffer.UV3Kind
  83679. * - VertexBuffer.UV4Kind
  83680. * - VertexBuffer.UV5Kind
  83681. * - VertexBuffer.UV6Kind
  83682. * - VertexBuffer.ColorKind
  83683. * - VertexBuffer.MatricesIndicesKind
  83684. * - VertexBuffer.MatricesIndicesExtraKind
  83685. * - VertexBuffer.MatricesWeightsKind
  83686. * - VertexBuffer.MatricesWeightsExtraKind
  83687. *
  83688. * Returns the Mesh.
  83689. */
  83690. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  83691. /**
  83692. * Sets the mesh indices.
  83693. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  83694. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  83695. * This method creates a new index buffer each call.
  83696. * Returns the Mesh.
  83697. */
  83698. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  83699. /**
  83700. * Boolean : True if the mesh owns the requested kind of data.
  83701. */
  83702. isVerticesDataPresent(kind: string): boolean;
  83703. /**
  83704. * Returns an array of indices (IndicesArray).
  83705. */
  83706. getIndices(): Nullable<IndicesArray>;
  83707. readonly _positions: Nullable<Vector3[]>;
  83708. /**
  83709. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  83710. * This means the mesh underlying bounding box and sphere are recomputed.
  83711. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  83712. * @returns the current mesh
  83713. */
  83714. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  83715. /** @hidden */
  83716. _preActivate(): InstancedMesh;
  83717. /** @hidden */
  83718. _activate(renderId: number, intermediateRendering: boolean): boolean;
  83719. /** @hidden */
  83720. _postActivate(): void;
  83721. getWorldMatrix(): Matrix;
  83722. readonly isAnInstance: boolean;
  83723. /**
  83724. * Returns the current associated LOD AbstractMesh.
  83725. */
  83726. getLOD(camera: Camera): AbstractMesh;
  83727. /** @hidden */
  83728. _syncSubMeshes(): InstancedMesh;
  83729. /** @hidden */
  83730. _generatePointsArray(): boolean;
  83731. /**
  83732. * Creates a new InstancedMesh from the current mesh.
  83733. * - name (string) : the cloned mesh name
  83734. * - newParent (optional Node) : the optional Node to parent the clone to.
  83735. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  83736. *
  83737. * Returns the clone.
  83738. */
  83739. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  83740. /**
  83741. * Disposes the InstancedMesh.
  83742. * Returns nothing.
  83743. */
  83744. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  83745. }
  83746. }
  83747. declare module BABYLON {
  83748. /**
  83749. * Defines the options associated with the creation of a shader material.
  83750. */
  83751. export interface IShaderMaterialOptions {
  83752. /**
  83753. * Does the material work in alpha blend mode
  83754. */
  83755. needAlphaBlending: boolean;
  83756. /**
  83757. * Does the material work in alpha test mode
  83758. */
  83759. needAlphaTesting: boolean;
  83760. /**
  83761. * The list of attribute names used in the shader
  83762. */
  83763. attributes: string[];
  83764. /**
  83765. * The list of unifrom names used in the shader
  83766. */
  83767. uniforms: string[];
  83768. /**
  83769. * The list of UBO names used in the shader
  83770. */
  83771. uniformBuffers: string[];
  83772. /**
  83773. * The list of sampler names used in the shader
  83774. */
  83775. samplers: string[];
  83776. /**
  83777. * The list of defines used in the shader
  83778. */
  83779. defines: string[];
  83780. }
  83781. /**
  83782. * 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.
  83783. *
  83784. * This returned material effects how the mesh will look based on the code in the shaders.
  83785. *
  83786. * @see http://doc.babylonjs.com/how_to/shader_material
  83787. */
  83788. export class ShaderMaterial extends Material {
  83789. private _shaderPath;
  83790. private _options;
  83791. private _textures;
  83792. private _textureArrays;
  83793. private _floats;
  83794. private _ints;
  83795. private _floatsArrays;
  83796. private _colors3;
  83797. private _colors3Arrays;
  83798. private _colors4;
  83799. private _colors4Arrays;
  83800. private _vectors2;
  83801. private _vectors3;
  83802. private _vectors4;
  83803. private _matrices;
  83804. private _matrices3x3;
  83805. private _matrices2x2;
  83806. private _vectors2Arrays;
  83807. private _vectors3Arrays;
  83808. private _vectors4Arrays;
  83809. private _cachedWorldViewMatrix;
  83810. private _cachedWorldViewProjectionMatrix;
  83811. private _renderId;
  83812. /**
  83813. * Instantiate a new shader material.
  83814. * 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.
  83815. * This returned material effects how the mesh will look based on the code in the shaders.
  83816. * @see http://doc.babylonjs.com/how_to/shader_material
  83817. * @param name Define the name of the material in the scene
  83818. * @param scene Define the scene the material belongs to
  83819. * @param shaderPath Defines the route to the shader code in one of three ways:
  83820. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  83821. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  83822. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  83823. * @param options Define the options used to create the shader
  83824. */
  83825. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  83826. /**
  83827. * Gets the options used to compile the shader.
  83828. * They can be modified to trigger a new compilation
  83829. */
  83830. readonly options: IShaderMaterialOptions;
  83831. /**
  83832. * Gets the current class name of the material e.g. "ShaderMaterial"
  83833. * Mainly use in serialization.
  83834. * @returns the class name
  83835. */
  83836. getClassName(): string;
  83837. /**
  83838. * Specifies if the material will require alpha blending
  83839. * @returns a boolean specifying if alpha blending is needed
  83840. */
  83841. needAlphaBlending(): boolean;
  83842. /**
  83843. * Specifies if this material should be rendered in alpha test mode
  83844. * @returns a boolean specifying if an alpha test is needed.
  83845. */
  83846. needAlphaTesting(): boolean;
  83847. private _checkUniform;
  83848. /**
  83849. * Set a texture in the shader.
  83850. * @param name Define the name of the uniform samplers as defined in the shader
  83851. * @param texture Define the texture to bind to this sampler
  83852. * @return the material itself allowing "fluent" like uniform updates
  83853. */
  83854. setTexture(name: string, texture: Texture): ShaderMaterial;
  83855. /**
  83856. * Set a texture array in the shader.
  83857. * @param name Define the name of the uniform sampler array as defined in the shader
  83858. * @param textures Define the list of textures to bind to this sampler
  83859. * @return the material itself allowing "fluent" like uniform updates
  83860. */
  83861. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  83862. /**
  83863. * Set a float in the shader.
  83864. * @param name Define the name of the uniform as defined in the shader
  83865. * @param value Define the value to give to the uniform
  83866. * @return the material itself allowing "fluent" like uniform updates
  83867. */
  83868. setFloat(name: string, value: number): ShaderMaterial;
  83869. /**
  83870. * Set a int in the shader.
  83871. * @param name Define the name of the uniform as defined in the shader
  83872. * @param value Define the value to give to the uniform
  83873. * @return the material itself allowing "fluent" like uniform updates
  83874. */
  83875. setInt(name: string, value: number): ShaderMaterial;
  83876. /**
  83877. * Set an array of floats in the shader.
  83878. * @param name Define the name of the uniform as defined in the shader
  83879. * @param value Define the value to give to the uniform
  83880. * @return the material itself allowing "fluent" like uniform updates
  83881. */
  83882. setFloats(name: string, value: number[]): ShaderMaterial;
  83883. /**
  83884. * Set a vec3 in the shader from a Color3.
  83885. * @param name Define the name of the uniform as defined in the shader
  83886. * @param value Define the value to give to the uniform
  83887. * @return the material itself allowing "fluent" like uniform updates
  83888. */
  83889. setColor3(name: string, value: Color3): ShaderMaterial;
  83890. /**
  83891. * Set a vec3 array in the shader from a Color3 array.
  83892. * @param name Define the name of the uniform as defined in the shader
  83893. * @param value Define the value to give to the uniform
  83894. * @return the material itself allowing "fluent" like uniform updates
  83895. */
  83896. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  83897. /**
  83898. * Set a vec4 in the shader from a Color4.
  83899. * @param name Define the name of the uniform as defined in the shader
  83900. * @param value Define the value to give to the uniform
  83901. * @return the material itself allowing "fluent" like uniform updates
  83902. */
  83903. setColor4(name: string, value: Color4): ShaderMaterial;
  83904. /**
  83905. * Set a vec4 array in the shader from a Color4 array.
  83906. * @param name Define the name of the uniform as defined in the shader
  83907. * @param value Define the value to give to the uniform
  83908. * @return the material itself allowing "fluent" like uniform updates
  83909. */
  83910. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  83911. /**
  83912. * Set a vec2 in the shader from a Vector2.
  83913. * @param name Define the name of the uniform as defined in the shader
  83914. * @param value Define the value to give to the uniform
  83915. * @return the material itself allowing "fluent" like uniform updates
  83916. */
  83917. setVector2(name: string, value: Vector2): ShaderMaterial;
  83918. /**
  83919. * Set a vec3 in the shader from a Vector3.
  83920. * @param name Define the name of the uniform as defined in the shader
  83921. * @param value Define the value to give to the uniform
  83922. * @return the material itself allowing "fluent" like uniform updates
  83923. */
  83924. setVector3(name: string, value: Vector3): ShaderMaterial;
  83925. /**
  83926. * Set a vec4 in the shader from a Vector4.
  83927. * @param name Define the name of the uniform as defined in the shader
  83928. * @param value Define the value to give to the uniform
  83929. * @return the material itself allowing "fluent" like uniform updates
  83930. */
  83931. setVector4(name: string, value: Vector4): ShaderMaterial;
  83932. /**
  83933. * Set a mat4 in the shader from a Matrix.
  83934. * @param name Define the name of the uniform as defined in the shader
  83935. * @param value Define the value to give to the uniform
  83936. * @return the material itself allowing "fluent" like uniform updates
  83937. */
  83938. setMatrix(name: string, value: Matrix): ShaderMaterial;
  83939. /**
  83940. * Set a mat3 in the shader from a Float32Array.
  83941. * @param name Define the name of the uniform as defined in the shader
  83942. * @param value Define the value to give to the uniform
  83943. * @return the material itself allowing "fluent" like uniform updates
  83944. */
  83945. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  83946. /**
  83947. * Set a mat2 in the shader from a Float32Array.
  83948. * @param name Define the name of the uniform as defined in the shader
  83949. * @param value Define the value to give to the uniform
  83950. * @return the material itself allowing "fluent" like uniform updates
  83951. */
  83952. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  83953. /**
  83954. * Set a vec2 array in the shader from a number array.
  83955. * @param name Define the name of the uniform as defined in the shader
  83956. * @param value Define the value to give to the uniform
  83957. * @return the material itself allowing "fluent" like uniform updates
  83958. */
  83959. setArray2(name: string, value: number[]): ShaderMaterial;
  83960. /**
  83961. * Set a vec3 array in the shader from a number array.
  83962. * @param name Define the name of the uniform as defined in the shader
  83963. * @param value Define the value to give to the uniform
  83964. * @return the material itself allowing "fluent" like uniform updates
  83965. */
  83966. setArray3(name: string, value: number[]): ShaderMaterial;
  83967. /**
  83968. * Set a vec4 array in the shader from a number array.
  83969. * @param name Define the name of the uniform as defined in the shader
  83970. * @param value Define the value to give to the uniform
  83971. * @return the material itself allowing "fluent" like uniform updates
  83972. */
  83973. setArray4(name: string, value: number[]): ShaderMaterial;
  83974. private _checkCache;
  83975. /**
  83976. * Specifies that the submesh is ready to be used
  83977. * @param mesh defines the mesh to check
  83978. * @param subMesh defines which submesh to check
  83979. * @param useInstances specifies that instances should be used
  83980. * @returns a boolean indicating that the submesh is ready or not
  83981. */
  83982. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  83983. /**
  83984. * Checks if the material is ready to render the requested mesh
  83985. * @param mesh Define the mesh to render
  83986. * @param useInstances Define whether or not the material is used with instances
  83987. * @returns true if ready, otherwise false
  83988. */
  83989. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  83990. /**
  83991. * Binds the world matrix to the material
  83992. * @param world defines the world transformation matrix
  83993. */
  83994. bindOnlyWorldMatrix(world: Matrix): void;
  83995. /**
  83996. * Binds the material to the mesh
  83997. * @param world defines the world transformation matrix
  83998. * @param mesh defines the mesh to bind the material to
  83999. */
  84000. bind(world: Matrix, mesh?: Mesh): void;
  84001. /**
  84002. * Gets the active textures from the material
  84003. * @returns an array of textures
  84004. */
  84005. getActiveTextures(): BaseTexture[];
  84006. /**
  84007. * Specifies if the material uses a texture
  84008. * @param texture defines the texture to check against the material
  84009. * @returns a boolean specifying if the material uses the texture
  84010. */
  84011. hasTexture(texture: BaseTexture): boolean;
  84012. /**
  84013. * Makes a duplicate of the material, and gives it a new name
  84014. * @param name defines the new name for the duplicated material
  84015. * @returns the cloned material
  84016. */
  84017. clone(name: string): ShaderMaterial;
  84018. /**
  84019. * Disposes the material
  84020. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  84021. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  84022. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  84023. */
  84024. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  84025. /**
  84026. * Serializes this material in a JSON representation
  84027. * @returns the serialized material object
  84028. */
  84029. serialize(): any;
  84030. /**
  84031. * Creates a shader material from parsed shader material data
  84032. * @param source defines the JSON represnetation of the material
  84033. * @param scene defines the hosting scene
  84034. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  84035. * @returns a new material
  84036. */
  84037. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  84038. }
  84039. }
  84040. declare module BABYLON {
  84041. /** @hidden */
  84042. export var colorPixelShader: {
  84043. name: string;
  84044. shader: string;
  84045. };
  84046. }
  84047. declare module BABYLON {
  84048. /** @hidden */
  84049. export var colorVertexShader: {
  84050. name: string;
  84051. shader: string;
  84052. };
  84053. }
  84054. declare module BABYLON {
  84055. /**
  84056. * Line mesh
  84057. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  84058. */
  84059. export class LinesMesh extends Mesh {
  84060. /**
  84061. * If vertex color should be applied to the mesh
  84062. */
  84063. readonly useVertexColor?: boolean | undefined;
  84064. /**
  84065. * If vertex alpha should be applied to the mesh
  84066. */
  84067. readonly useVertexAlpha?: boolean | undefined;
  84068. /**
  84069. * Color of the line (Default: White)
  84070. */
  84071. color: Color3;
  84072. /**
  84073. * Alpha of the line (Default: 1)
  84074. */
  84075. alpha: number;
  84076. /**
  84077. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  84078. * This margin is expressed in world space coordinates, so its value may vary.
  84079. * Default value is 0.1
  84080. */
  84081. intersectionThreshold: number;
  84082. private _colorShader;
  84083. private color4;
  84084. /**
  84085. * Creates a new LinesMesh
  84086. * @param name defines the name
  84087. * @param scene defines the hosting scene
  84088. * @param parent defines the parent mesh if any
  84089. * @param source defines the optional source LinesMesh used to clone data from
  84090. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  84091. * When false, achieved by calling a clone(), also passing False.
  84092. * This will make creation of children, recursive.
  84093. * @param useVertexColor defines if this LinesMesh supports vertex color
  84094. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  84095. */
  84096. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  84097. /**
  84098. * If vertex color should be applied to the mesh
  84099. */
  84100. useVertexColor?: boolean | undefined,
  84101. /**
  84102. * If vertex alpha should be applied to the mesh
  84103. */
  84104. useVertexAlpha?: boolean | undefined);
  84105. private _addClipPlaneDefine;
  84106. private _removeClipPlaneDefine;
  84107. isReady(): boolean;
  84108. /**
  84109. * Returns the string "LineMesh"
  84110. */
  84111. getClassName(): string;
  84112. /**
  84113. * @hidden
  84114. */
  84115. /**
  84116. * @hidden
  84117. */
  84118. material: Material;
  84119. /**
  84120. * @hidden
  84121. */
  84122. readonly checkCollisions: boolean;
  84123. /** @hidden */
  84124. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  84125. /** @hidden */
  84126. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  84127. /**
  84128. * Disposes of the line mesh
  84129. * @param doNotRecurse If children should be disposed
  84130. */
  84131. dispose(doNotRecurse?: boolean): void;
  84132. /**
  84133. * Returns a new LineMesh object cloned from the current one.
  84134. */
  84135. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  84136. /**
  84137. * Creates a new InstancedLinesMesh object from the mesh model.
  84138. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  84139. * @param name defines the name of the new instance
  84140. * @returns a new InstancedLinesMesh
  84141. */
  84142. createInstance(name: string): InstancedLinesMesh;
  84143. }
  84144. /**
  84145. * Creates an instance based on a source LinesMesh
  84146. */
  84147. export class InstancedLinesMesh extends InstancedMesh {
  84148. /**
  84149. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  84150. * This margin is expressed in world space coordinates, so its value may vary.
  84151. * Initilized with the intersectionThreshold value of the source LinesMesh
  84152. */
  84153. intersectionThreshold: number;
  84154. constructor(name: string, source: LinesMesh);
  84155. /**
  84156. * Returns the string "InstancedLinesMesh".
  84157. */
  84158. getClassName(): string;
  84159. }
  84160. }
  84161. declare module BABYLON {
  84162. /** @hidden */
  84163. export var linePixelShader: {
  84164. name: string;
  84165. shader: string;
  84166. };
  84167. }
  84168. declare module BABYLON {
  84169. /** @hidden */
  84170. export var lineVertexShader: {
  84171. name: string;
  84172. shader: string;
  84173. };
  84174. }
  84175. declare module BABYLON {
  84176. interface AbstractMesh {
  84177. /**
  84178. * Gets the edgesRenderer associated with the mesh
  84179. */
  84180. edgesRenderer: Nullable<EdgesRenderer>;
  84181. }
  84182. interface LinesMesh {
  84183. /**
  84184. * Enables the edge rendering mode on the mesh.
  84185. * This mode makes the mesh edges visible
  84186. * @param epsilon defines the maximal distance between two angles to detect a face
  84187. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  84188. * @returns the currentAbstractMesh
  84189. * @see https://www.babylonjs-playground.com/#19O9TU#0
  84190. */
  84191. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  84192. }
  84193. interface InstancedLinesMesh {
  84194. /**
  84195. * Enables the edge rendering mode on the mesh.
  84196. * This mode makes the mesh edges visible
  84197. * @param epsilon defines the maximal distance between two angles to detect a face
  84198. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  84199. * @returns the current InstancedLinesMesh
  84200. * @see https://www.babylonjs-playground.com/#19O9TU#0
  84201. */
  84202. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  84203. }
  84204. /**
  84205. * Defines the minimum contract an Edges renderer should follow.
  84206. */
  84207. export interface IEdgesRenderer extends IDisposable {
  84208. /**
  84209. * Gets or sets a boolean indicating if the edgesRenderer is active
  84210. */
  84211. isEnabled: boolean;
  84212. /**
  84213. * Renders the edges of the attached mesh,
  84214. */
  84215. render(): void;
  84216. /**
  84217. * Checks wether or not the edges renderer is ready to render.
  84218. * @return true if ready, otherwise false.
  84219. */
  84220. isReady(): boolean;
  84221. }
  84222. /**
  84223. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  84224. */
  84225. export class EdgesRenderer implements IEdgesRenderer {
  84226. /**
  84227. * Define the size of the edges with an orthographic camera
  84228. */
  84229. edgesWidthScalerForOrthographic: number;
  84230. /**
  84231. * Define the size of the edges with a perspective camera
  84232. */
  84233. edgesWidthScalerForPerspective: number;
  84234. protected _source: AbstractMesh;
  84235. protected _linesPositions: number[];
  84236. protected _linesNormals: number[];
  84237. protected _linesIndices: number[];
  84238. protected _epsilon: number;
  84239. protected _indicesCount: number;
  84240. protected _lineShader: ShaderMaterial;
  84241. protected _ib: DataBuffer;
  84242. protected _buffers: {
  84243. [key: string]: Nullable<VertexBuffer>;
  84244. };
  84245. protected _checkVerticesInsteadOfIndices: boolean;
  84246. private _meshRebuildObserver;
  84247. private _meshDisposeObserver;
  84248. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  84249. isEnabled: boolean;
  84250. /**
  84251. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  84252. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  84253. * @param source Mesh used to create edges
  84254. * @param epsilon sum of angles in adjacency to check for edge
  84255. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  84256. * @param generateEdgesLines - should generate Lines or only prepare resources.
  84257. */
  84258. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  84259. protected _prepareRessources(): void;
  84260. /** @hidden */
  84261. _rebuild(): void;
  84262. /**
  84263. * Releases the required resources for the edges renderer
  84264. */
  84265. dispose(): void;
  84266. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  84267. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  84268. /**
  84269. * Checks if the pair of p0 and p1 is en edge
  84270. * @param faceIndex
  84271. * @param edge
  84272. * @param faceNormals
  84273. * @param p0
  84274. * @param p1
  84275. * @private
  84276. */
  84277. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  84278. /**
  84279. * push line into the position, normal and index buffer
  84280. * @protected
  84281. */
  84282. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  84283. /**
  84284. * Generates lines edges from adjacencjes
  84285. * @private
  84286. */
  84287. _generateEdgesLines(): void;
  84288. /**
  84289. * Checks wether or not the edges renderer is ready to render.
  84290. * @return true if ready, otherwise false.
  84291. */
  84292. isReady(): boolean;
  84293. /**
  84294. * Renders the edges of the attached mesh,
  84295. */
  84296. render(): void;
  84297. }
  84298. /**
  84299. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  84300. */
  84301. export class LineEdgesRenderer extends EdgesRenderer {
  84302. /**
  84303. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  84304. * @param source LineMesh used to generate edges
  84305. * @param epsilon not important (specified angle for edge detection)
  84306. * @param checkVerticesInsteadOfIndices not important for LineMesh
  84307. */
  84308. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  84309. /**
  84310. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  84311. */
  84312. _generateEdgesLines(): void;
  84313. }
  84314. }
  84315. declare module BABYLON {
  84316. /**
  84317. * This represents the object necessary to create a rendering group.
  84318. * This is exclusively used and created by the rendering manager.
  84319. * To modify the behavior, you use the available helpers in your scene or meshes.
  84320. * @hidden
  84321. */
  84322. export class RenderingGroup {
  84323. index: number;
  84324. private static _zeroVector;
  84325. private _scene;
  84326. private _opaqueSubMeshes;
  84327. private _transparentSubMeshes;
  84328. private _alphaTestSubMeshes;
  84329. private _depthOnlySubMeshes;
  84330. private _particleSystems;
  84331. private _spriteManagers;
  84332. private _opaqueSortCompareFn;
  84333. private _alphaTestSortCompareFn;
  84334. private _transparentSortCompareFn;
  84335. private _renderOpaque;
  84336. private _renderAlphaTest;
  84337. private _renderTransparent;
  84338. /** @hidden */
  84339. _edgesRenderers: SmartArray<IEdgesRenderer>;
  84340. onBeforeTransparentRendering: () => void;
  84341. /**
  84342. * Set the opaque sort comparison function.
  84343. * If null the sub meshes will be render in the order they were created
  84344. */
  84345. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  84346. /**
  84347. * Set the alpha test sort comparison function.
  84348. * If null the sub meshes will be render in the order they were created
  84349. */
  84350. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  84351. /**
  84352. * Set the transparent sort comparison function.
  84353. * If null the sub meshes will be render in the order they were created
  84354. */
  84355. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  84356. /**
  84357. * Creates a new rendering group.
  84358. * @param index The rendering group index
  84359. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  84360. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  84361. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  84362. */
  84363. 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>);
  84364. /**
  84365. * Render all the sub meshes contained in the group.
  84366. * @param customRenderFunction Used to override the default render behaviour of the group.
  84367. * @returns true if rendered some submeshes.
  84368. */
  84369. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  84370. /**
  84371. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  84372. * @param subMeshes The submeshes to render
  84373. */
  84374. private renderOpaqueSorted;
  84375. /**
  84376. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  84377. * @param subMeshes The submeshes to render
  84378. */
  84379. private renderAlphaTestSorted;
  84380. /**
  84381. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  84382. * @param subMeshes The submeshes to render
  84383. */
  84384. private renderTransparentSorted;
  84385. /**
  84386. * Renders the submeshes in a specified order.
  84387. * @param subMeshes The submeshes to sort before render
  84388. * @param sortCompareFn The comparison function use to sort
  84389. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  84390. * @param transparent Specifies to activate blending if true
  84391. */
  84392. private static renderSorted;
  84393. /**
  84394. * Renders the submeshes in the order they were dispatched (no sort applied).
  84395. * @param subMeshes The submeshes to render
  84396. */
  84397. private static renderUnsorted;
  84398. /**
  84399. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  84400. * are rendered back to front if in the same alpha index.
  84401. *
  84402. * @param a The first submesh
  84403. * @param b The second submesh
  84404. * @returns The result of the comparison
  84405. */
  84406. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  84407. /**
  84408. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  84409. * are rendered back to front.
  84410. *
  84411. * @param a The first submesh
  84412. * @param b The second submesh
  84413. * @returns The result of the comparison
  84414. */
  84415. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  84416. /**
  84417. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  84418. * are rendered front to back (prevent overdraw).
  84419. *
  84420. * @param a The first submesh
  84421. * @param b The second submesh
  84422. * @returns The result of the comparison
  84423. */
  84424. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  84425. /**
  84426. * Resets the different lists of submeshes to prepare a new frame.
  84427. */
  84428. prepare(): void;
  84429. dispose(): void;
  84430. /**
  84431. * Inserts the submesh in its correct queue depending on its material.
  84432. * @param subMesh The submesh to dispatch
  84433. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  84434. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  84435. */
  84436. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  84437. dispatchSprites(spriteManager: ISpriteManager): void;
  84438. dispatchParticles(particleSystem: IParticleSystem): void;
  84439. private _renderParticles;
  84440. private _renderSprites;
  84441. }
  84442. }
  84443. declare module BABYLON {
  84444. /**
  84445. * Interface describing the different options available in the rendering manager
  84446. * regarding Auto Clear between groups.
  84447. */
  84448. export interface IRenderingManagerAutoClearSetup {
  84449. /**
  84450. * Defines whether or not autoclear is enable.
  84451. */
  84452. autoClear: boolean;
  84453. /**
  84454. * Defines whether or not to autoclear the depth buffer.
  84455. */
  84456. depth: boolean;
  84457. /**
  84458. * Defines whether or not to autoclear the stencil buffer.
  84459. */
  84460. stencil: boolean;
  84461. }
  84462. /**
  84463. * This class is used by the onRenderingGroupObservable
  84464. */
  84465. export class RenderingGroupInfo {
  84466. /**
  84467. * The Scene that being rendered
  84468. */
  84469. scene: Scene;
  84470. /**
  84471. * The camera currently used for the rendering pass
  84472. */
  84473. camera: Nullable<Camera>;
  84474. /**
  84475. * The ID of the renderingGroup being processed
  84476. */
  84477. renderingGroupId: number;
  84478. }
  84479. /**
  84480. * This is the manager responsible of all the rendering for meshes sprites and particles.
  84481. * It is enable to manage the different groups as well as the different necessary sort functions.
  84482. * This should not be used directly aside of the few static configurations
  84483. */
  84484. export class RenderingManager {
  84485. /**
  84486. * The max id used for rendering groups (not included)
  84487. */
  84488. static MAX_RENDERINGGROUPS: number;
  84489. /**
  84490. * The min id used for rendering groups (included)
  84491. */
  84492. static MIN_RENDERINGGROUPS: number;
  84493. /**
  84494. * Used to globally prevent autoclearing scenes.
  84495. */
  84496. static AUTOCLEAR: boolean;
  84497. /**
  84498. * @hidden
  84499. */
  84500. _useSceneAutoClearSetup: boolean;
  84501. private _scene;
  84502. private _renderingGroups;
  84503. private _depthStencilBufferAlreadyCleaned;
  84504. private _autoClearDepthStencil;
  84505. private _customOpaqueSortCompareFn;
  84506. private _customAlphaTestSortCompareFn;
  84507. private _customTransparentSortCompareFn;
  84508. private _renderingGroupInfo;
  84509. /**
  84510. * Instantiates a new rendering group for a particular scene
  84511. * @param scene Defines the scene the groups belongs to
  84512. */
  84513. constructor(scene: Scene);
  84514. private _clearDepthStencilBuffer;
  84515. /**
  84516. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  84517. * @hidden
  84518. */
  84519. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  84520. /**
  84521. * Resets the different information of the group to prepare a new frame
  84522. * @hidden
  84523. */
  84524. reset(): void;
  84525. /**
  84526. * Dispose and release the group and its associated resources.
  84527. * @hidden
  84528. */
  84529. dispose(): void;
  84530. /**
  84531. * Clear the info related to rendering groups preventing retention points during dispose.
  84532. */
  84533. freeRenderingGroups(): void;
  84534. private _prepareRenderingGroup;
  84535. /**
  84536. * Add a sprite manager to the rendering manager in order to render it this frame.
  84537. * @param spriteManager Define the sprite manager to render
  84538. */
  84539. dispatchSprites(spriteManager: ISpriteManager): void;
  84540. /**
  84541. * Add a particle system to the rendering manager in order to render it this frame.
  84542. * @param particleSystem Define the particle system to render
  84543. */
  84544. dispatchParticles(particleSystem: IParticleSystem): void;
  84545. /**
  84546. * Add a submesh to the manager in order to render it this frame
  84547. * @param subMesh The submesh to dispatch
  84548. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  84549. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  84550. */
  84551. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  84552. /**
  84553. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  84554. * This allowed control for front to back rendering or reversly depending of the special needs.
  84555. *
  84556. * @param renderingGroupId The rendering group id corresponding to its index
  84557. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  84558. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  84559. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  84560. */
  84561. 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;
  84562. /**
  84563. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  84564. *
  84565. * @param renderingGroupId The rendering group id corresponding to its index
  84566. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  84567. * @param depth Automatically clears depth between groups if true and autoClear is true.
  84568. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  84569. */
  84570. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  84571. /**
  84572. * Gets the current auto clear configuration for one rendering group of the rendering
  84573. * manager.
  84574. * @param index the rendering group index to get the information for
  84575. * @returns The auto clear setup for the requested rendering group
  84576. */
  84577. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  84578. }
  84579. }
  84580. declare module BABYLON {
  84581. /**
  84582. * This Helps creating a texture that will be created from a camera in your scene.
  84583. * It is basically a dynamic texture that could be used to create special effects for instance.
  84584. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  84585. */
  84586. export class RenderTargetTexture extends Texture {
  84587. isCube: boolean;
  84588. /**
  84589. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  84590. */
  84591. static readonly REFRESHRATE_RENDER_ONCE: number;
  84592. /**
  84593. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  84594. */
  84595. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  84596. /**
  84597. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  84598. * the central point of your effect and can save a lot of performances.
  84599. */
  84600. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  84601. /**
  84602. * Use this predicate to dynamically define the list of mesh you want to render.
  84603. * If set, the renderList property will be overwritten.
  84604. */
  84605. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  84606. private _renderList;
  84607. /**
  84608. * Use this list to define the list of mesh you want to render.
  84609. */
  84610. renderList: Nullable<Array<AbstractMesh>>;
  84611. private _hookArray;
  84612. /**
  84613. * Define if particles should be rendered in your texture.
  84614. */
  84615. renderParticles: boolean;
  84616. /**
  84617. * Define if sprites should be rendered in your texture.
  84618. */
  84619. renderSprites: boolean;
  84620. /**
  84621. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  84622. */
  84623. coordinatesMode: number;
  84624. /**
  84625. * Define the camera used to render the texture.
  84626. */
  84627. activeCamera: Nullable<Camera>;
  84628. /**
  84629. * Override the render function of the texture with your own one.
  84630. */
  84631. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  84632. /**
  84633. * Define if camera post processes should be use while rendering the texture.
  84634. */
  84635. useCameraPostProcesses: boolean;
  84636. /**
  84637. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  84638. */
  84639. ignoreCameraViewport: boolean;
  84640. private _postProcessManager;
  84641. private _postProcesses;
  84642. private _resizeObserver;
  84643. /**
  84644. * An event triggered when the texture is unbind.
  84645. */
  84646. onBeforeBindObservable: Observable<RenderTargetTexture>;
  84647. /**
  84648. * An event triggered when the texture is unbind.
  84649. */
  84650. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  84651. private _onAfterUnbindObserver;
  84652. /**
  84653. * Set a after unbind callback in the texture.
  84654. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  84655. */
  84656. onAfterUnbind: () => void;
  84657. /**
  84658. * An event triggered before rendering the texture
  84659. */
  84660. onBeforeRenderObservable: Observable<number>;
  84661. private _onBeforeRenderObserver;
  84662. /**
  84663. * Set a before render callback in the texture.
  84664. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  84665. */
  84666. onBeforeRender: (faceIndex: number) => void;
  84667. /**
  84668. * An event triggered after rendering the texture
  84669. */
  84670. onAfterRenderObservable: Observable<number>;
  84671. private _onAfterRenderObserver;
  84672. /**
  84673. * Set a after render callback in the texture.
  84674. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  84675. */
  84676. onAfterRender: (faceIndex: number) => void;
  84677. /**
  84678. * An event triggered after the texture clear
  84679. */
  84680. onClearObservable: Observable<Engine>;
  84681. private _onClearObserver;
  84682. /**
  84683. * Set a clear callback in the texture.
  84684. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  84685. */
  84686. onClear: (Engine: Engine) => void;
  84687. /**
  84688. * An event triggered when the texture is resized.
  84689. */
  84690. onResizeObservable: Observable<RenderTargetTexture>;
  84691. /**
  84692. * Define the clear color of the Render Target if it should be different from the scene.
  84693. */
  84694. clearColor: Color4;
  84695. protected _size: number | {
  84696. width: number;
  84697. height: number;
  84698. };
  84699. protected _initialSizeParameter: number | {
  84700. width: number;
  84701. height: number;
  84702. } | {
  84703. ratio: number;
  84704. };
  84705. protected _sizeRatio: Nullable<number>;
  84706. /** @hidden */
  84707. _generateMipMaps: boolean;
  84708. protected _renderingManager: RenderingManager;
  84709. /** @hidden */
  84710. _waitingRenderList: string[];
  84711. protected _doNotChangeAspectRatio: boolean;
  84712. protected _currentRefreshId: number;
  84713. protected _refreshRate: number;
  84714. protected _textureMatrix: Matrix;
  84715. protected _samples: number;
  84716. protected _renderTargetOptions: RenderTargetCreationOptions;
  84717. /**
  84718. * Gets render target creation options that were used.
  84719. */
  84720. readonly renderTargetOptions: RenderTargetCreationOptions;
  84721. protected _engine: Engine;
  84722. protected _onRatioRescale(): void;
  84723. /**
  84724. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  84725. * It must define where the camera used to render the texture is set
  84726. */
  84727. boundingBoxPosition: Vector3;
  84728. private _boundingBoxSize;
  84729. /**
  84730. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  84731. * When defined, the cubemap will switch to local mode
  84732. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  84733. * @example https://www.babylonjs-playground.com/#RNASML
  84734. */
  84735. boundingBoxSize: Vector3;
  84736. /**
  84737. * In case the RTT has been created with a depth texture, get the associated
  84738. * depth texture.
  84739. * Otherwise, return null.
  84740. */
  84741. depthStencilTexture: Nullable<InternalTexture>;
  84742. /**
  84743. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  84744. * or used a shadow, depth texture...
  84745. * @param name The friendly name of the texture
  84746. * @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)
  84747. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  84748. * @param generateMipMaps True if mip maps need to be generated after render.
  84749. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  84750. * @param type The type of the buffer in the RTT (int, half float, float...)
  84751. * @param isCube True if a cube texture needs to be created
  84752. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  84753. * @param generateDepthBuffer True to generate a depth buffer
  84754. * @param generateStencilBuffer True to generate a stencil buffer
  84755. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  84756. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  84757. * @param delayAllocation if the texture allocation should be delayed (default: false)
  84758. */
  84759. constructor(name: string, size: number | {
  84760. width: number;
  84761. height: number;
  84762. } | {
  84763. ratio: number;
  84764. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  84765. /**
  84766. * Creates a depth stencil texture.
  84767. * This is only available in WebGL 2 or with the depth texture extension available.
  84768. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  84769. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  84770. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  84771. */
  84772. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  84773. private _processSizeParameter;
  84774. /**
  84775. * Define the number of samples to use in case of MSAA.
  84776. * It defaults to one meaning no MSAA has been enabled.
  84777. */
  84778. samples: number;
  84779. /**
  84780. * Resets the refresh counter of the texture and start bak from scratch.
  84781. * Could be useful to regenerate the texture if it is setup to render only once.
  84782. */
  84783. resetRefreshCounter(): void;
  84784. /**
  84785. * Define the refresh rate of the texture or the rendering frequency.
  84786. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  84787. */
  84788. refreshRate: number;
  84789. /**
  84790. * Adds a post process to the render target rendering passes.
  84791. * @param postProcess define the post process to add
  84792. */
  84793. addPostProcess(postProcess: PostProcess): void;
  84794. /**
  84795. * Clear all the post processes attached to the render target
  84796. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  84797. */
  84798. clearPostProcesses(dispose?: boolean): void;
  84799. /**
  84800. * Remove one of the post process from the list of attached post processes to the texture
  84801. * @param postProcess define the post process to remove from the list
  84802. */
  84803. removePostProcess(postProcess: PostProcess): void;
  84804. /** @hidden */
  84805. _shouldRender(): boolean;
  84806. /**
  84807. * Gets the actual render size of the texture.
  84808. * @returns the width of the render size
  84809. */
  84810. getRenderSize(): number;
  84811. /**
  84812. * Gets the actual render width of the texture.
  84813. * @returns the width of the render size
  84814. */
  84815. getRenderWidth(): number;
  84816. /**
  84817. * Gets the actual render height of the texture.
  84818. * @returns the height of the render size
  84819. */
  84820. getRenderHeight(): number;
  84821. /**
  84822. * Get if the texture can be rescaled or not.
  84823. */
  84824. readonly canRescale: boolean;
  84825. /**
  84826. * Resize the texture using a ratio.
  84827. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  84828. */
  84829. scale(ratio: number): void;
  84830. /**
  84831. * Get the texture reflection matrix used to rotate/transform the reflection.
  84832. * @returns the reflection matrix
  84833. */
  84834. getReflectionTextureMatrix(): Matrix;
  84835. /**
  84836. * Resize the texture to a new desired size.
  84837. * Be carrefull as it will recreate all the data in the new texture.
  84838. * @param size Define the new size. It can be:
  84839. * - a number for squared texture,
  84840. * - an object containing { width: number, height: number }
  84841. * - or an object containing a ratio { ratio: number }
  84842. */
  84843. resize(size: number | {
  84844. width: number;
  84845. height: number;
  84846. } | {
  84847. ratio: number;
  84848. }): void;
  84849. /**
  84850. * Renders all the objects from the render list into the texture.
  84851. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  84852. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  84853. */
  84854. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  84855. private _bestReflectionRenderTargetDimension;
  84856. /**
  84857. * @hidden
  84858. * @param faceIndex face index to bind to if this is a cubetexture
  84859. */
  84860. _bindFrameBuffer(faceIndex?: number): void;
  84861. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  84862. private renderToTarget;
  84863. /**
  84864. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  84865. * This allowed control for front to back rendering or reversly depending of the special needs.
  84866. *
  84867. * @param renderingGroupId The rendering group id corresponding to its index
  84868. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  84869. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  84870. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  84871. */
  84872. 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;
  84873. /**
  84874. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  84875. *
  84876. * @param renderingGroupId The rendering group id corresponding to its index
  84877. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  84878. */
  84879. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  84880. /**
  84881. * Clones the texture.
  84882. * @returns the cloned texture
  84883. */
  84884. clone(): RenderTargetTexture;
  84885. /**
  84886. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  84887. * @returns The JSON representation of the texture
  84888. */
  84889. serialize(): any;
  84890. /**
  84891. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  84892. */
  84893. disposeFramebufferObjects(): void;
  84894. /**
  84895. * Dispose the texture and release its associated resources.
  84896. */
  84897. dispose(): void;
  84898. /** @hidden */
  84899. _rebuild(): void;
  84900. /**
  84901. * Clear the info related to rendering groups preventing retention point in material dispose.
  84902. */
  84903. freeRenderingGroups(): void;
  84904. /**
  84905. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  84906. * @returns the view count
  84907. */
  84908. getViewCount(): number;
  84909. }
  84910. }
  84911. declare module BABYLON {
  84912. /**
  84913. * Base class for the main features of a material in Babylon.js
  84914. */
  84915. export class Material implements IAnimatable {
  84916. /**
  84917. * Returns the triangle fill mode
  84918. */
  84919. static readonly TriangleFillMode: number;
  84920. /**
  84921. * Returns the wireframe mode
  84922. */
  84923. static readonly WireFrameFillMode: number;
  84924. /**
  84925. * Returns the point fill mode
  84926. */
  84927. static readonly PointFillMode: number;
  84928. /**
  84929. * Returns the point list draw mode
  84930. */
  84931. static readonly PointListDrawMode: number;
  84932. /**
  84933. * Returns the line list draw mode
  84934. */
  84935. static readonly LineListDrawMode: number;
  84936. /**
  84937. * Returns the line loop draw mode
  84938. */
  84939. static readonly LineLoopDrawMode: number;
  84940. /**
  84941. * Returns the line strip draw mode
  84942. */
  84943. static readonly LineStripDrawMode: number;
  84944. /**
  84945. * Returns the triangle strip draw mode
  84946. */
  84947. static readonly TriangleStripDrawMode: number;
  84948. /**
  84949. * Returns the triangle fan draw mode
  84950. */
  84951. static readonly TriangleFanDrawMode: number;
  84952. /**
  84953. * Stores the clock-wise side orientation
  84954. */
  84955. static readonly ClockWiseSideOrientation: number;
  84956. /**
  84957. * Stores the counter clock-wise side orientation
  84958. */
  84959. static readonly CounterClockWiseSideOrientation: number;
  84960. /**
  84961. * The dirty texture flag value
  84962. */
  84963. static readonly TextureDirtyFlag: number;
  84964. /**
  84965. * The dirty light flag value
  84966. */
  84967. static readonly LightDirtyFlag: number;
  84968. /**
  84969. * The dirty fresnel flag value
  84970. */
  84971. static readonly FresnelDirtyFlag: number;
  84972. /**
  84973. * The dirty attribute flag value
  84974. */
  84975. static readonly AttributesDirtyFlag: number;
  84976. /**
  84977. * The dirty misc flag value
  84978. */
  84979. static readonly MiscDirtyFlag: number;
  84980. /**
  84981. * The all dirty flag value
  84982. */
  84983. static readonly AllDirtyFlag: number;
  84984. /**
  84985. * The ID of the material
  84986. */
  84987. id: string;
  84988. /**
  84989. * Gets or sets the unique id of the material
  84990. */
  84991. uniqueId: number;
  84992. /**
  84993. * The name of the material
  84994. */
  84995. name: string;
  84996. /**
  84997. * Gets or sets user defined metadata
  84998. */
  84999. metadata: any;
  85000. /**
  85001. * For internal use only. Please do not use.
  85002. */
  85003. reservedDataStore: any;
  85004. /**
  85005. * Specifies if the ready state should be checked on each call
  85006. */
  85007. checkReadyOnEveryCall: boolean;
  85008. /**
  85009. * Specifies if the ready state should be checked once
  85010. */
  85011. checkReadyOnlyOnce: boolean;
  85012. /**
  85013. * The state of the material
  85014. */
  85015. state: string;
  85016. /**
  85017. * The alpha value of the material
  85018. */
  85019. protected _alpha: number;
  85020. /**
  85021. * List of inspectable custom properties (used by the Inspector)
  85022. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  85023. */
  85024. inspectableCustomProperties: IInspectable[];
  85025. /**
  85026. * Sets the alpha value of the material
  85027. */
  85028. /**
  85029. * Gets the alpha value of the material
  85030. */
  85031. alpha: number;
  85032. /**
  85033. * Specifies if back face culling is enabled
  85034. */
  85035. protected _backFaceCulling: boolean;
  85036. /**
  85037. * Sets the back-face culling state
  85038. */
  85039. /**
  85040. * Gets the back-face culling state
  85041. */
  85042. backFaceCulling: boolean;
  85043. /**
  85044. * Stores the value for side orientation
  85045. */
  85046. sideOrientation: number;
  85047. /**
  85048. * Callback triggered when the material is compiled
  85049. */
  85050. onCompiled: Nullable<(effect: Effect) => void>;
  85051. /**
  85052. * Callback triggered when an error occurs
  85053. */
  85054. onError: Nullable<(effect: Effect, errors: string) => void>;
  85055. /**
  85056. * Callback triggered to get the render target textures
  85057. */
  85058. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  85059. /**
  85060. * Gets a boolean indicating that current material needs to register RTT
  85061. */
  85062. readonly hasRenderTargetTextures: boolean;
  85063. /**
  85064. * Specifies if the material should be serialized
  85065. */
  85066. doNotSerialize: boolean;
  85067. /**
  85068. * @hidden
  85069. */
  85070. _storeEffectOnSubMeshes: boolean;
  85071. /**
  85072. * Stores the animations for the material
  85073. */
  85074. animations: Nullable<Array<Animation>>;
  85075. /**
  85076. * An event triggered when the material is disposed
  85077. */
  85078. onDisposeObservable: Observable<Material>;
  85079. /**
  85080. * An observer which watches for dispose events
  85081. */
  85082. private _onDisposeObserver;
  85083. private _onUnBindObservable;
  85084. /**
  85085. * Called during a dispose event
  85086. */
  85087. onDispose: () => void;
  85088. private _onBindObservable;
  85089. /**
  85090. * An event triggered when the material is bound
  85091. */
  85092. readonly onBindObservable: Observable<AbstractMesh>;
  85093. /**
  85094. * An observer which watches for bind events
  85095. */
  85096. private _onBindObserver;
  85097. /**
  85098. * Called during a bind event
  85099. */
  85100. onBind: (Mesh: AbstractMesh) => void;
  85101. /**
  85102. * An event triggered when the material is unbound
  85103. */
  85104. readonly onUnBindObservable: Observable<Material>;
  85105. /**
  85106. * Stores the value of the alpha mode
  85107. */
  85108. private _alphaMode;
  85109. /**
  85110. * Sets the value of the alpha mode.
  85111. *
  85112. * | Value | Type | Description |
  85113. * | --- | --- | --- |
  85114. * | 0 | ALPHA_DISABLE | |
  85115. * | 1 | ALPHA_ADD | |
  85116. * | 2 | ALPHA_COMBINE | |
  85117. * | 3 | ALPHA_SUBTRACT | |
  85118. * | 4 | ALPHA_MULTIPLY | |
  85119. * | 5 | ALPHA_MAXIMIZED | |
  85120. * | 6 | ALPHA_ONEONE | |
  85121. * | 7 | ALPHA_PREMULTIPLIED | |
  85122. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  85123. * | 9 | ALPHA_INTERPOLATE | |
  85124. * | 10 | ALPHA_SCREENMODE | |
  85125. *
  85126. */
  85127. /**
  85128. * Gets the value of the alpha mode
  85129. */
  85130. alphaMode: number;
  85131. /**
  85132. * Stores the state of the need depth pre-pass value
  85133. */
  85134. private _needDepthPrePass;
  85135. /**
  85136. * Sets the need depth pre-pass value
  85137. */
  85138. /**
  85139. * Gets the depth pre-pass value
  85140. */
  85141. needDepthPrePass: boolean;
  85142. /**
  85143. * Specifies if depth writing should be disabled
  85144. */
  85145. disableDepthWrite: boolean;
  85146. /**
  85147. * Specifies if depth writing should be forced
  85148. */
  85149. forceDepthWrite: boolean;
  85150. /**
  85151. * Specifies if there should be a separate pass for culling
  85152. */
  85153. separateCullingPass: boolean;
  85154. /**
  85155. * Stores the state specifing if fog should be enabled
  85156. */
  85157. private _fogEnabled;
  85158. /**
  85159. * Sets the state for enabling fog
  85160. */
  85161. /**
  85162. * Gets the value of the fog enabled state
  85163. */
  85164. fogEnabled: boolean;
  85165. /**
  85166. * Stores the size of points
  85167. */
  85168. pointSize: number;
  85169. /**
  85170. * Stores the z offset value
  85171. */
  85172. zOffset: number;
  85173. /**
  85174. * Gets a value specifying if wireframe mode is enabled
  85175. */
  85176. /**
  85177. * Sets the state of wireframe mode
  85178. */
  85179. wireframe: boolean;
  85180. /**
  85181. * Gets the value specifying if point clouds are enabled
  85182. */
  85183. /**
  85184. * Sets the state of point cloud mode
  85185. */
  85186. pointsCloud: boolean;
  85187. /**
  85188. * Gets the material fill mode
  85189. */
  85190. /**
  85191. * Sets the material fill mode
  85192. */
  85193. fillMode: number;
  85194. /**
  85195. * @hidden
  85196. * Stores the effects for the material
  85197. */
  85198. _effect: Nullable<Effect>;
  85199. /**
  85200. * @hidden
  85201. * Specifies if the material was previously ready
  85202. */
  85203. _wasPreviouslyReady: boolean;
  85204. /**
  85205. * Specifies if uniform buffers should be used
  85206. */
  85207. private _useUBO;
  85208. /**
  85209. * Stores a reference to the scene
  85210. */
  85211. private _scene;
  85212. /**
  85213. * Stores the fill mode state
  85214. */
  85215. private _fillMode;
  85216. /**
  85217. * Specifies if the depth write state should be cached
  85218. */
  85219. private _cachedDepthWriteState;
  85220. /**
  85221. * Stores the uniform buffer
  85222. */
  85223. protected _uniformBuffer: UniformBuffer;
  85224. /** @hidden */
  85225. _indexInSceneMaterialArray: number;
  85226. /** @hidden */
  85227. meshMap: Nullable<{
  85228. [id: string]: AbstractMesh | undefined;
  85229. }>;
  85230. /**
  85231. * Creates a material instance
  85232. * @param name defines the name of the material
  85233. * @param scene defines the scene to reference
  85234. * @param doNotAdd specifies if the material should be added to the scene
  85235. */
  85236. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  85237. /**
  85238. * Returns a string representation of the current material
  85239. * @param fullDetails defines a boolean indicating which levels of logging is desired
  85240. * @returns a string with material information
  85241. */
  85242. toString(fullDetails?: boolean): string;
  85243. /**
  85244. * Gets the class name of the material
  85245. * @returns a string with the class name of the material
  85246. */
  85247. getClassName(): string;
  85248. /**
  85249. * Specifies if updates for the material been locked
  85250. */
  85251. readonly isFrozen: boolean;
  85252. /**
  85253. * Locks updates for the material
  85254. */
  85255. freeze(): void;
  85256. /**
  85257. * Unlocks updates for the material
  85258. */
  85259. unfreeze(): void;
  85260. /**
  85261. * Specifies if the material is ready to be used
  85262. * @param mesh defines the mesh to check
  85263. * @param useInstances specifies if instances should be used
  85264. * @returns a boolean indicating if the material is ready to be used
  85265. */
  85266. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  85267. /**
  85268. * Specifies that the submesh is ready to be used
  85269. * @param mesh defines the mesh to check
  85270. * @param subMesh defines which submesh to check
  85271. * @param useInstances specifies that instances should be used
  85272. * @returns a boolean indicating that the submesh is ready or not
  85273. */
  85274. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  85275. /**
  85276. * Returns the material effect
  85277. * @returns the effect associated with the material
  85278. */
  85279. getEffect(): Nullable<Effect>;
  85280. /**
  85281. * Returns the current scene
  85282. * @returns a Scene
  85283. */
  85284. getScene(): Scene;
  85285. /**
  85286. * Specifies if the material will require alpha blending
  85287. * @returns a boolean specifying if alpha blending is needed
  85288. */
  85289. needAlphaBlending(): boolean;
  85290. /**
  85291. * Specifies if the mesh will require alpha blending
  85292. * @param mesh defines the mesh to check
  85293. * @returns a boolean specifying if alpha blending is needed for the mesh
  85294. */
  85295. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  85296. /**
  85297. * Specifies if this material should be rendered in alpha test mode
  85298. * @returns a boolean specifying if an alpha test is needed.
  85299. */
  85300. needAlphaTesting(): boolean;
  85301. /**
  85302. * Gets the texture used for the alpha test
  85303. * @returns the texture to use for alpha testing
  85304. */
  85305. getAlphaTestTexture(): Nullable<BaseTexture>;
  85306. /**
  85307. * Marks the material to indicate that it needs to be re-calculated
  85308. */
  85309. markDirty(): void;
  85310. /** @hidden */
  85311. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  85312. /**
  85313. * Binds the material to the mesh
  85314. * @param world defines the world transformation matrix
  85315. * @param mesh defines the mesh to bind the material to
  85316. */
  85317. bind(world: Matrix, mesh?: Mesh): void;
  85318. /**
  85319. * Binds the submesh to the material
  85320. * @param world defines the world transformation matrix
  85321. * @param mesh defines the mesh containing the submesh
  85322. * @param subMesh defines the submesh to bind the material to
  85323. */
  85324. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  85325. /**
  85326. * Binds the world matrix to the material
  85327. * @param world defines the world transformation matrix
  85328. */
  85329. bindOnlyWorldMatrix(world: Matrix): void;
  85330. /**
  85331. * Binds the scene's uniform buffer to the effect.
  85332. * @param effect defines the effect to bind to the scene uniform buffer
  85333. * @param sceneUbo defines the uniform buffer storing scene data
  85334. */
  85335. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  85336. /**
  85337. * Binds the view matrix to the effect
  85338. * @param effect defines the effect to bind the view matrix to
  85339. */
  85340. bindView(effect: Effect): void;
  85341. /**
  85342. * Binds the view projection matrix to the effect
  85343. * @param effect defines the effect to bind the view projection matrix to
  85344. */
  85345. bindViewProjection(effect: Effect): void;
  85346. /**
  85347. * Specifies if material alpha testing should be turned on for the mesh
  85348. * @param mesh defines the mesh to check
  85349. */
  85350. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  85351. /**
  85352. * Processes to execute after binding the material to a mesh
  85353. * @param mesh defines the rendered mesh
  85354. */
  85355. protected _afterBind(mesh?: Mesh): void;
  85356. /**
  85357. * Unbinds the material from the mesh
  85358. */
  85359. unbind(): void;
  85360. /**
  85361. * Gets the active textures from the material
  85362. * @returns an array of textures
  85363. */
  85364. getActiveTextures(): BaseTexture[];
  85365. /**
  85366. * Specifies if the material uses a texture
  85367. * @param texture defines the texture to check against the material
  85368. * @returns a boolean specifying if the material uses the texture
  85369. */
  85370. hasTexture(texture: BaseTexture): boolean;
  85371. /**
  85372. * Makes a duplicate of the material, and gives it a new name
  85373. * @param name defines the new name for the duplicated material
  85374. * @returns the cloned material
  85375. */
  85376. clone(name: string): Nullable<Material>;
  85377. /**
  85378. * Gets the meshes bound to the material
  85379. * @returns an array of meshes bound to the material
  85380. */
  85381. getBindedMeshes(): AbstractMesh[];
  85382. /**
  85383. * Force shader compilation
  85384. * @param mesh defines the mesh associated with this material
  85385. * @param onCompiled defines a function to execute once the material is compiled
  85386. * @param options defines the options to configure the compilation
  85387. */
  85388. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  85389. clipPlane: boolean;
  85390. }>): void;
  85391. /**
  85392. * Force shader compilation
  85393. * @param mesh defines the mesh that will use this material
  85394. * @param options defines additional options for compiling the shaders
  85395. * @returns a promise that resolves when the compilation completes
  85396. */
  85397. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  85398. clipPlane: boolean;
  85399. }>): Promise<void>;
  85400. private static readonly _AllDirtyCallBack;
  85401. private static readonly _ImageProcessingDirtyCallBack;
  85402. private static readonly _TextureDirtyCallBack;
  85403. private static readonly _FresnelDirtyCallBack;
  85404. private static readonly _MiscDirtyCallBack;
  85405. private static readonly _LightsDirtyCallBack;
  85406. private static readonly _AttributeDirtyCallBack;
  85407. private static _FresnelAndMiscDirtyCallBack;
  85408. private static _TextureAndMiscDirtyCallBack;
  85409. private static readonly _DirtyCallbackArray;
  85410. private static readonly _RunDirtyCallBacks;
  85411. /**
  85412. * Marks a define in the material to indicate that it needs to be re-computed
  85413. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  85414. */
  85415. markAsDirty(flag: number): void;
  85416. /**
  85417. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  85418. * @param func defines a function which checks material defines against the submeshes
  85419. */
  85420. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  85421. /**
  85422. * Indicates that we need to re-calculated for all submeshes
  85423. */
  85424. protected _markAllSubMeshesAsAllDirty(): void;
  85425. /**
  85426. * Indicates that image processing needs to be re-calculated for all submeshes
  85427. */
  85428. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  85429. /**
  85430. * Indicates that textures need to be re-calculated for all submeshes
  85431. */
  85432. protected _markAllSubMeshesAsTexturesDirty(): void;
  85433. /**
  85434. * Indicates that fresnel needs to be re-calculated for all submeshes
  85435. */
  85436. protected _markAllSubMeshesAsFresnelDirty(): void;
  85437. /**
  85438. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  85439. */
  85440. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  85441. /**
  85442. * Indicates that lights need to be re-calculated for all submeshes
  85443. */
  85444. protected _markAllSubMeshesAsLightsDirty(): void;
  85445. /**
  85446. * Indicates that attributes need to be re-calculated for all submeshes
  85447. */
  85448. protected _markAllSubMeshesAsAttributesDirty(): void;
  85449. /**
  85450. * Indicates that misc needs to be re-calculated for all submeshes
  85451. */
  85452. protected _markAllSubMeshesAsMiscDirty(): void;
  85453. /**
  85454. * Indicates that textures and misc need to be re-calculated for all submeshes
  85455. */
  85456. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  85457. /**
  85458. * Disposes the material
  85459. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  85460. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  85461. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  85462. */
  85463. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  85464. /** @hidden */
  85465. private releaseVertexArrayObject;
  85466. /**
  85467. * Serializes this material
  85468. * @returns the serialized material object
  85469. */
  85470. serialize(): any;
  85471. /**
  85472. * Creates a material from parsed material data
  85473. * @param parsedMaterial defines parsed material data
  85474. * @param scene defines the hosting scene
  85475. * @param rootUrl defines the root URL to use to load textures
  85476. * @returns a new material
  85477. */
  85478. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  85479. }
  85480. }
  85481. declare module BABYLON {
  85482. /**
  85483. * A multi-material is used to apply different materials to different parts of the same object without the need of
  85484. * separate meshes. This can be use to improve performances.
  85485. * @see http://doc.babylonjs.com/how_to/multi_materials
  85486. */
  85487. export class MultiMaterial extends Material {
  85488. private _subMaterials;
  85489. /**
  85490. * Gets or Sets the list of Materials used within the multi material.
  85491. * They need to be ordered according to the submeshes order in the associated mesh
  85492. */
  85493. subMaterials: Nullable<Material>[];
  85494. /**
  85495. * Function used to align with Node.getChildren()
  85496. * @returns the list of Materials used within the multi material
  85497. */
  85498. getChildren(): Nullable<Material>[];
  85499. /**
  85500. * Instantiates a new Multi Material
  85501. * A multi-material is used to apply different materials to different parts of the same object without the need of
  85502. * separate meshes. This can be use to improve performances.
  85503. * @see http://doc.babylonjs.com/how_to/multi_materials
  85504. * @param name Define the name in the scene
  85505. * @param scene Define the scene the material belongs to
  85506. */
  85507. constructor(name: string, scene: Scene);
  85508. private _hookArray;
  85509. /**
  85510. * Get one of the submaterial by its index in the submaterials array
  85511. * @param index The index to look the sub material at
  85512. * @returns The Material if the index has been defined
  85513. */
  85514. getSubMaterial(index: number): Nullable<Material>;
  85515. /**
  85516. * Get the list of active textures for the whole sub materials list.
  85517. * @returns All the textures that will be used during the rendering
  85518. */
  85519. getActiveTextures(): BaseTexture[];
  85520. /**
  85521. * Gets the current class name of the material e.g. "MultiMaterial"
  85522. * Mainly use in serialization.
  85523. * @returns the class name
  85524. */
  85525. getClassName(): string;
  85526. /**
  85527. * Checks if the material is ready to render the requested sub mesh
  85528. * @param mesh Define the mesh the submesh belongs to
  85529. * @param subMesh Define the sub mesh to look readyness for
  85530. * @param useInstances Define whether or not the material is used with instances
  85531. * @returns true if ready, otherwise false
  85532. */
  85533. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  85534. /**
  85535. * Clones the current material and its related sub materials
  85536. * @param name Define the name of the newly cloned material
  85537. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  85538. * @returns the cloned material
  85539. */
  85540. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  85541. /**
  85542. * Serializes the materials into a JSON representation.
  85543. * @returns the JSON representation
  85544. */
  85545. serialize(): any;
  85546. /**
  85547. * Dispose the material and release its associated resources
  85548. * @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)
  85549. * @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)
  85550. * @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)
  85551. */
  85552. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  85553. /**
  85554. * Creates a MultiMaterial from parsed MultiMaterial data.
  85555. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  85556. * @param scene defines the hosting scene
  85557. * @returns a new MultiMaterial
  85558. */
  85559. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  85560. }
  85561. }
  85562. declare module BABYLON {
  85563. /**
  85564. * Base class for submeshes
  85565. */
  85566. export class BaseSubMesh {
  85567. /** @hidden */
  85568. _materialDefines: Nullable<MaterialDefines>;
  85569. /** @hidden */
  85570. _materialEffect: Nullable<Effect>;
  85571. /**
  85572. * Gets associated effect
  85573. */
  85574. readonly effect: Nullable<Effect>;
  85575. /**
  85576. * Sets associated effect (effect used to render this submesh)
  85577. * @param effect defines the effect to associate with
  85578. * @param defines defines the set of defines used to compile this effect
  85579. */
  85580. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  85581. }
  85582. /**
  85583. * Defines a subdivision inside a mesh
  85584. */
  85585. export class SubMesh extends BaseSubMesh implements ICullable {
  85586. /** the material index to use */
  85587. materialIndex: number;
  85588. /** vertex index start */
  85589. verticesStart: number;
  85590. /** vertices count */
  85591. verticesCount: number;
  85592. /** index start */
  85593. indexStart: number;
  85594. /** indices count */
  85595. indexCount: number;
  85596. /** @hidden */
  85597. _linesIndexCount: number;
  85598. private _mesh;
  85599. private _renderingMesh;
  85600. private _boundingInfo;
  85601. private _linesIndexBuffer;
  85602. /** @hidden */
  85603. _lastColliderWorldVertices: Nullable<Vector3[]>;
  85604. /** @hidden */
  85605. _trianglePlanes: Plane[];
  85606. /** @hidden */
  85607. _lastColliderTransformMatrix: Nullable<Matrix>;
  85608. /** @hidden */
  85609. _renderId: number;
  85610. /** @hidden */
  85611. _alphaIndex: number;
  85612. /** @hidden */
  85613. _distanceToCamera: number;
  85614. /** @hidden */
  85615. _id: number;
  85616. private _currentMaterial;
  85617. /**
  85618. * Add a new submesh to a mesh
  85619. * @param materialIndex defines the material index to use
  85620. * @param verticesStart defines vertex index start
  85621. * @param verticesCount defines vertices count
  85622. * @param indexStart defines index start
  85623. * @param indexCount defines indices count
  85624. * @param mesh defines the parent mesh
  85625. * @param renderingMesh defines an optional rendering mesh
  85626. * @param createBoundingBox defines if bounding box should be created for this submesh
  85627. * @returns the new submesh
  85628. */
  85629. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  85630. /**
  85631. * Creates a new submesh
  85632. * @param materialIndex defines the material index to use
  85633. * @param verticesStart defines vertex index start
  85634. * @param verticesCount defines vertices count
  85635. * @param indexStart defines index start
  85636. * @param indexCount defines indices count
  85637. * @param mesh defines the parent mesh
  85638. * @param renderingMesh defines an optional rendering mesh
  85639. * @param createBoundingBox defines if bounding box should be created for this submesh
  85640. */
  85641. constructor(
  85642. /** the material index to use */
  85643. materialIndex: number,
  85644. /** vertex index start */
  85645. verticesStart: number,
  85646. /** vertices count */
  85647. verticesCount: number,
  85648. /** index start */
  85649. indexStart: number,
  85650. /** indices count */
  85651. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  85652. /**
  85653. * Returns true if this submesh covers the entire parent mesh
  85654. * @ignorenaming
  85655. */
  85656. readonly IsGlobal: boolean;
  85657. /**
  85658. * Returns the submesh BoudingInfo object
  85659. * @returns current bounding info (or mesh's one if the submesh is global)
  85660. */
  85661. getBoundingInfo(): BoundingInfo;
  85662. /**
  85663. * Sets the submesh BoundingInfo
  85664. * @param boundingInfo defines the new bounding info to use
  85665. * @returns the SubMesh
  85666. */
  85667. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  85668. /**
  85669. * Returns the mesh of the current submesh
  85670. * @return the parent mesh
  85671. */
  85672. getMesh(): AbstractMesh;
  85673. /**
  85674. * Returns the rendering mesh of the submesh
  85675. * @returns the rendering mesh (could be different from parent mesh)
  85676. */
  85677. getRenderingMesh(): Mesh;
  85678. /**
  85679. * Returns the submesh material
  85680. * @returns null or the current material
  85681. */
  85682. getMaterial(): Nullable<Material>;
  85683. /**
  85684. * Sets a new updated BoundingInfo object to the submesh
  85685. * @param data defines an optional position array to use to determine the bounding info
  85686. * @returns the SubMesh
  85687. */
  85688. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  85689. /** @hidden */
  85690. _checkCollision(collider: Collider): boolean;
  85691. /**
  85692. * Updates the submesh BoundingInfo
  85693. * @param world defines the world matrix to use to update the bounding info
  85694. * @returns the submesh
  85695. */
  85696. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  85697. /**
  85698. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  85699. * @param frustumPlanes defines the frustum planes
  85700. * @returns true if the submesh is intersecting with the frustum
  85701. */
  85702. isInFrustum(frustumPlanes: Plane[]): boolean;
  85703. /**
  85704. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  85705. * @param frustumPlanes defines the frustum planes
  85706. * @returns true if the submesh is inside the frustum
  85707. */
  85708. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  85709. /**
  85710. * Renders the submesh
  85711. * @param enableAlphaMode defines if alpha needs to be used
  85712. * @returns the submesh
  85713. */
  85714. render(enableAlphaMode: boolean): SubMesh;
  85715. /**
  85716. * @hidden
  85717. */
  85718. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  85719. /**
  85720. * Checks if the submesh intersects with a ray
  85721. * @param ray defines the ray to test
  85722. * @returns true is the passed ray intersects the submesh bounding box
  85723. */
  85724. canIntersects(ray: Ray): boolean;
  85725. /**
  85726. * Intersects current submesh with a ray
  85727. * @param ray defines the ray to test
  85728. * @param positions defines mesh's positions array
  85729. * @param indices defines mesh's indices array
  85730. * @param fastCheck defines if only bounding info should be used
  85731. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  85732. * @returns intersection info or null if no intersection
  85733. */
  85734. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  85735. /** @hidden */
  85736. private _intersectLines;
  85737. /** @hidden */
  85738. private _intersectUnIndexedLines;
  85739. /** @hidden */
  85740. private _intersectTriangles;
  85741. /** @hidden */
  85742. private _intersectUnIndexedTriangles;
  85743. /** @hidden */
  85744. _rebuild(): void;
  85745. /**
  85746. * Creates a new submesh from the passed mesh
  85747. * @param newMesh defines the new hosting mesh
  85748. * @param newRenderingMesh defines an optional rendering mesh
  85749. * @returns the new submesh
  85750. */
  85751. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  85752. /**
  85753. * Release associated resources
  85754. */
  85755. dispose(): void;
  85756. /**
  85757. * Gets the class name
  85758. * @returns the string "SubMesh".
  85759. */
  85760. getClassName(): string;
  85761. /**
  85762. * Creates a new submesh from indices data
  85763. * @param materialIndex the index of the main mesh material
  85764. * @param startIndex the index where to start the copy in the mesh indices array
  85765. * @param indexCount the number of indices to copy then from the startIndex
  85766. * @param mesh the main mesh to create the submesh from
  85767. * @param renderingMesh the optional rendering mesh
  85768. * @returns a new submesh
  85769. */
  85770. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  85771. }
  85772. }
  85773. declare module BABYLON {
  85774. /**
  85775. * Class used to represent data loading progression
  85776. */
  85777. export class SceneLoaderFlags {
  85778. private static _ForceFullSceneLoadingForIncremental;
  85779. private static _ShowLoadingScreen;
  85780. private static _CleanBoneMatrixWeights;
  85781. private static _loggingLevel;
  85782. /**
  85783. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  85784. */
  85785. static ForceFullSceneLoadingForIncremental: boolean;
  85786. /**
  85787. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  85788. */
  85789. static ShowLoadingScreen: boolean;
  85790. /**
  85791. * Defines the current logging level (while loading the scene)
  85792. * @ignorenaming
  85793. */
  85794. static loggingLevel: number;
  85795. /**
  85796. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  85797. */
  85798. static CleanBoneMatrixWeights: boolean;
  85799. }
  85800. }
  85801. declare module BABYLON {
  85802. /**
  85803. * Class used to store geometry data (vertex buffers + index buffer)
  85804. */
  85805. export class Geometry implements IGetSetVerticesData {
  85806. /**
  85807. * Gets or sets the ID of the geometry
  85808. */
  85809. id: string;
  85810. /**
  85811. * Gets or sets the unique ID of the geometry
  85812. */
  85813. uniqueId: number;
  85814. /**
  85815. * Gets the delay loading state of the geometry (none by default which means not delayed)
  85816. */
  85817. delayLoadState: number;
  85818. /**
  85819. * Gets the file containing the data to load when running in delay load state
  85820. */
  85821. delayLoadingFile: Nullable<string>;
  85822. /**
  85823. * Callback called when the geometry is updated
  85824. */
  85825. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  85826. private _scene;
  85827. private _engine;
  85828. private _meshes;
  85829. private _totalVertices;
  85830. /** @hidden */
  85831. _indices: IndicesArray;
  85832. /** @hidden */
  85833. _vertexBuffers: {
  85834. [key: string]: VertexBuffer;
  85835. };
  85836. private _isDisposed;
  85837. private _extend;
  85838. private _boundingBias;
  85839. /** @hidden */
  85840. _delayInfo: Array<string>;
  85841. private _indexBuffer;
  85842. private _indexBufferIsUpdatable;
  85843. /** @hidden */
  85844. _boundingInfo: Nullable<BoundingInfo>;
  85845. /** @hidden */
  85846. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  85847. /** @hidden */
  85848. _softwareSkinningFrameId: number;
  85849. private _vertexArrayObjects;
  85850. private _updatable;
  85851. /** @hidden */
  85852. _positions: Nullable<Vector3[]>;
  85853. /**
  85854. * 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
  85855. */
  85856. /**
  85857. * 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
  85858. */
  85859. boundingBias: Vector2;
  85860. /**
  85861. * Static function used to attach a new empty geometry to a mesh
  85862. * @param mesh defines the mesh to attach the geometry to
  85863. * @returns the new Geometry
  85864. */
  85865. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  85866. /**
  85867. * Creates a new geometry
  85868. * @param id defines the unique ID
  85869. * @param scene defines the hosting scene
  85870. * @param vertexData defines the VertexData used to get geometry data
  85871. * @param updatable defines if geometry must be updatable (false by default)
  85872. * @param mesh defines the mesh that will be associated with the geometry
  85873. */
  85874. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  85875. /**
  85876. * Gets the current extend of the geometry
  85877. */
  85878. readonly extend: {
  85879. minimum: Vector3;
  85880. maximum: Vector3;
  85881. };
  85882. /**
  85883. * Gets the hosting scene
  85884. * @returns the hosting Scene
  85885. */
  85886. getScene(): Scene;
  85887. /**
  85888. * Gets the hosting engine
  85889. * @returns the hosting Engine
  85890. */
  85891. getEngine(): Engine;
  85892. /**
  85893. * Defines if the geometry is ready to use
  85894. * @returns true if the geometry is ready to be used
  85895. */
  85896. isReady(): boolean;
  85897. /**
  85898. * Gets a value indicating that the geometry should not be serialized
  85899. */
  85900. readonly doNotSerialize: boolean;
  85901. /** @hidden */
  85902. _rebuild(): void;
  85903. /**
  85904. * Affects all geometry data in one call
  85905. * @param vertexData defines the geometry data
  85906. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  85907. */
  85908. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  85909. /**
  85910. * Set specific vertex data
  85911. * @param kind defines the data kind (Position, normal, etc...)
  85912. * @param data defines the vertex data to use
  85913. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  85914. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  85915. */
  85916. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  85917. /**
  85918. * Removes a specific vertex data
  85919. * @param kind defines the data kind (Position, normal, etc...)
  85920. */
  85921. removeVerticesData(kind: string): void;
  85922. /**
  85923. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  85924. * @param buffer defines the vertex buffer to use
  85925. * @param totalVertices defines the total number of vertices for position kind (could be null)
  85926. */
  85927. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  85928. /**
  85929. * Update a specific vertex buffer
  85930. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  85931. * It will do nothing if the buffer is not updatable
  85932. * @param kind defines the data kind (Position, normal, etc...)
  85933. * @param data defines the data to use
  85934. * @param offset defines the offset in the target buffer where to store the data
  85935. * @param useBytes set to true if the offset is in bytes
  85936. */
  85937. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  85938. /**
  85939. * Update a specific vertex buffer
  85940. * This function will create a new buffer if the current one is not updatable
  85941. * @param kind defines the data kind (Position, normal, etc...)
  85942. * @param data defines the data to use
  85943. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  85944. */
  85945. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  85946. private _updateBoundingInfo;
  85947. /** @hidden */
  85948. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  85949. /**
  85950. * Gets total number of vertices
  85951. * @returns the total number of vertices
  85952. */
  85953. getTotalVertices(): number;
  85954. /**
  85955. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  85956. * @param kind defines the data kind (Position, normal, etc...)
  85957. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85958. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85959. * @returns a float array containing vertex data
  85960. */
  85961. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  85962. /**
  85963. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  85964. * @param kind defines the data kind (Position, normal, etc...)
  85965. * @returns true if the vertex buffer with the specified kind is updatable
  85966. */
  85967. isVertexBufferUpdatable(kind: string): boolean;
  85968. /**
  85969. * Gets a specific vertex buffer
  85970. * @param kind defines the data kind (Position, normal, etc...)
  85971. * @returns a VertexBuffer
  85972. */
  85973. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  85974. /**
  85975. * Returns all vertex buffers
  85976. * @return an object holding all vertex buffers indexed by kind
  85977. */
  85978. getVertexBuffers(): Nullable<{
  85979. [key: string]: VertexBuffer;
  85980. }>;
  85981. /**
  85982. * Gets a boolean indicating if specific vertex buffer is present
  85983. * @param kind defines the data kind (Position, normal, etc...)
  85984. * @returns true if data is present
  85985. */
  85986. isVerticesDataPresent(kind: string): boolean;
  85987. /**
  85988. * Gets a list of all attached data kinds (Position, normal, etc...)
  85989. * @returns a list of string containing all kinds
  85990. */
  85991. getVerticesDataKinds(): string[];
  85992. /**
  85993. * Update index buffer
  85994. * @param indices defines the indices to store in the index buffer
  85995. * @param offset defines the offset in the target buffer where to store the data
  85996. * @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)
  85997. */
  85998. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  85999. /**
  86000. * Creates a new index buffer
  86001. * @param indices defines the indices to store in the index buffer
  86002. * @param totalVertices defines the total number of vertices (could be null)
  86003. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  86004. */
  86005. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  86006. /**
  86007. * Return the total number of indices
  86008. * @returns the total number of indices
  86009. */
  86010. getTotalIndices(): number;
  86011. /**
  86012. * Gets the index buffer array
  86013. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  86014. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86015. * @returns the index buffer array
  86016. */
  86017. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  86018. /**
  86019. * Gets the index buffer
  86020. * @return the index buffer
  86021. */
  86022. getIndexBuffer(): Nullable<DataBuffer>;
  86023. /** @hidden */
  86024. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  86025. /**
  86026. * Release the associated resources for a specific mesh
  86027. * @param mesh defines the source mesh
  86028. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  86029. */
  86030. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  86031. /**
  86032. * Apply current geometry to a given mesh
  86033. * @param mesh defines the mesh to apply geometry to
  86034. */
  86035. applyToMesh(mesh: Mesh): void;
  86036. private _updateExtend;
  86037. private _applyToMesh;
  86038. private notifyUpdate;
  86039. /**
  86040. * Load the geometry if it was flagged as delay loaded
  86041. * @param scene defines the hosting scene
  86042. * @param onLoaded defines a callback called when the geometry is loaded
  86043. */
  86044. load(scene: Scene, onLoaded?: () => void): void;
  86045. private _queueLoad;
  86046. /**
  86047. * Invert the geometry to move from a right handed system to a left handed one.
  86048. */
  86049. toLeftHanded(): void;
  86050. /** @hidden */
  86051. _resetPointsArrayCache(): void;
  86052. /** @hidden */
  86053. _generatePointsArray(): boolean;
  86054. /**
  86055. * Gets a value indicating if the geometry is disposed
  86056. * @returns true if the geometry was disposed
  86057. */
  86058. isDisposed(): boolean;
  86059. private _disposeVertexArrayObjects;
  86060. /**
  86061. * Free all associated resources
  86062. */
  86063. dispose(): void;
  86064. /**
  86065. * Clone the current geometry into a new geometry
  86066. * @param id defines the unique ID of the new geometry
  86067. * @returns a new geometry object
  86068. */
  86069. copy(id: string): Geometry;
  86070. /**
  86071. * Serialize the current geometry info (and not the vertices data) into a JSON object
  86072. * @return a JSON representation of the current geometry data (without the vertices data)
  86073. */
  86074. serialize(): any;
  86075. private toNumberArray;
  86076. /**
  86077. * Serialize all vertices data into a JSON oject
  86078. * @returns a JSON representation of the current geometry data
  86079. */
  86080. serializeVerticeData(): any;
  86081. /**
  86082. * Extracts a clone of a mesh geometry
  86083. * @param mesh defines the source mesh
  86084. * @param id defines the unique ID of the new geometry object
  86085. * @returns the new geometry object
  86086. */
  86087. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  86088. /**
  86089. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  86090. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  86091. * Be aware Math.random() could cause collisions, but:
  86092. * "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"
  86093. * @returns a string containing a new GUID
  86094. */
  86095. static RandomId(): string;
  86096. /** @hidden */
  86097. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  86098. private static _CleanMatricesWeights;
  86099. /**
  86100. * Create a new geometry from persisted data (Using .babylon file format)
  86101. * @param parsedVertexData defines the persisted data
  86102. * @param scene defines the hosting scene
  86103. * @param rootUrl defines the root url to use to load assets (like delayed data)
  86104. * @returns the new geometry object
  86105. */
  86106. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  86107. }
  86108. }
  86109. declare module BABYLON {
  86110. /**
  86111. * Define an interface for all classes that will get and set the data on vertices
  86112. */
  86113. export interface IGetSetVerticesData {
  86114. /**
  86115. * Gets a boolean indicating if specific vertex data is present
  86116. * @param kind defines the vertex data kind to use
  86117. * @returns true is data kind is present
  86118. */
  86119. isVerticesDataPresent(kind: string): boolean;
  86120. /**
  86121. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  86122. * @param kind defines the data kind (Position, normal, etc...)
  86123. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  86124. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86125. * @returns a float array containing vertex data
  86126. */
  86127. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  86128. /**
  86129. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  86130. * @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.
  86131. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86132. * @returns the indices array or an empty array if the mesh has no geometry
  86133. */
  86134. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  86135. /**
  86136. * Set specific vertex data
  86137. * @param kind defines the data kind (Position, normal, etc...)
  86138. * @param data defines the vertex data to use
  86139. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  86140. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  86141. */
  86142. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  86143. /**
  86144. * Update a specific associated vertex buffer
  86145. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  86146. * - VertexBuffer.PositionKind
  86147. * - VertexBuffer.UVKind
  86148. * - VertexBuffer.UV2Kind
  86149. * - VertexBuffer.UV3Kind
  86150. * - VertexBuffer.UV4Kind
  86151. * - VertexBuffer.UV5Kind
  86152. * - VertexBuffer.UV6Kind
  86153. * - VertexBuffer.ColorKind
  86154. * - VertexBuffer.MatricesIndicesKind
  86155. * - VertexBuffer.MatricesIndicesExtraKind
  86156. * - VertexBuffer.MatricesWeightsKind
  86157. * - VertexBuffer.MatricesWeightsExtraKind
  86158. * @param data defines the data source
  86159. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  86160. * @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)
  86161. */
  86162. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  86163. /**
  86164. * Creates a new index buffer
  86165. * @param indices defines the indices to store in the index buffer
  86166. * @param totalVertices defines the total number of vertices (could be null)
  86167. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  86168. */
  86169. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  86170. }
  86171. /**
  86172. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  86173. */
  86174. export class VertexData {
  86175. /**
  86176. * Mesh side orientation : usually the external or front surface
  86177. */
  86178. static readonly FRONTSIDE: number;
  86179. /**
  86180. * Mesh side orientation : usually the internal or back surface
  86181. */
  86182. static readonly BACKSIDE: number;
  86183. /**
  86184. * Mesh side orientation : both internal and external or front and back surfaces
  86185. */
  86186. static readonly DOUBLESIDE: number;
  86187. /**
  86188. * Mesh side orientation : by default, `FRONTSIDE`
  86189. */
  86190. static readonly DEFAULTSIDE: number;
  86191. /**
  86192. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  86193. */
  86194. positions: Nullable<FloatArray>;
  86195. /**
  86196. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  86197. */
  86198. normals: Nullable<FloatArray>;
  86199. /**
  86200. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  86201. */
  86202. tangents: Nullable<FloatArray>;
  86203. /**
  86204. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86205. */
  86206. uvs: Nullable<FloatArray>;
  86207. /**
  86208. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86209. */
  86210. uvs2: Nullable<FloatArray>;
  86211. /**
  86212. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86213. */
  86214. uvs3: Nullable<FloatArray>;
  86215. /**
  86216. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86217. */
  86218. uvs4: Nullable<FloatArray>;
  86219. /**
  86220. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86221. */
  86222. uvs5: Nullable<FloatArray>;
  86223. /**
  86224. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86225. */
  86226. uvs6: Nullable<FloatArray>;
  86227. /**
  86228. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  86229. */
  86230. colors: Nullable<FloatArray>;
  86231. /**
  86232. * 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).
  86233. */
  86234. matricesIndices: Nullable<FloatArray>;
  86235. /**
  86236. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  86237. */
  86238. matricesWeights: Nullable<FloatArray>;
  86239. /**
  86240. * An array extending the number of possible indices
  86241. */
  86242. matricesIndicesExtra: Nullable<FloatArray>;
  86243. /**
  86244. * An array extending the number of possible weights when the number of indices is extended
  86245. */
  86246. matricesWeightsExtra: Nullable<FloatArray>;
  86247. /**
  86248. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  86249. */
  86250. indices: Nullable<IndicesArray>;
  86251. /**
  86252. * Uses the passed data array to set the set the values for the specified kind of data
  86253. * @param data a linear array of floating numbers
  86254. * @param kind the type of data that is being set, eg positions, colors etc
  86255. */
  86256. set(data: FloatArray, kind: string): void;
  86257. /**
  86258. * Associates the vertexData to the passed Mesh.
  86259. * Sets it as updatable or not (default `false`)
  86260. * @param mesh the mesh the vertexData is applied to
  86261. * @param updatable when used and having the value true allows new data to update the vertexData
  86262. * @returns the VertexData
  86263. */
  86264. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  86265. /**
  86266. * Associates the vertexData to the passed Geometry.
  86267. * Sets it as updatable or not (default `false`)
  86268. * @param geometry the geometry the vertexData is applied to
  86269. * @param updatable when used and having the value true allows new data to update the vertexData
  86270. * @returns VertexData
  86271. */
  86272. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  86273. /**
  86274. * Updates the associated mesh
  86275. * @param mesh the mesh to be updated
  86276. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  86277. * @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
  86278. * @returns VertexData
  86279. */
  86280. updateMesh(mesh: Mesh): VertexData;
  86281. /**
  86282. * Updates the associated geometry
  86283. * @param geometry the geometry to be updated
  86284. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  86285. * @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
  86286. * @returns VertexData.
  86287. */
  86288. updateGeometry(geometry: Geometry): VertexData;
  86289. private _applyTo;
  86290. private _update;
  86291. /**
  86292. * Transforms each position and each normal of the vertexData according to the passed Matrix
  86293. * @param matrix the transforming matrix
  86294. * @returns the VertexData
  86295. */
  86296. transform(matrix: Matrix): VertexData;
  86297. /**
  86298. * Merges the passed VertexData into the current one
  86299. * @param other the VertexData to be merged into the current one
  86300. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  86301. * @returns the modified VertexData
  86302. */
  86303. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  86304. private _mergeElement;
  86305. private _validate;
  86306. /**
  86307. * Serializes the VertexData
  86308. * @returns a serialized object
  86309. */
  86310. serialize(): any;
  86311. /**
  86312. * Extracts the vertexData from a mesh
  86313. * @param mesh the mesh from which to extract the VertexData
  86314. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  86315. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  86316. * @returns the object VertexData associated to the passed mesh
  86317. */
  86318. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  86319. /**
  86320. * Extracts the vertexData from the geometry
  86321. * @param geometry the geometry from which to extract the VertexData
  86322. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  86323. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  86324. * @returns the object VertexData associated to the passed mesh
  86325. */
  86326. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  86327. private static _ExtractFrom;
  86328. /**
  86329. * Creates the VertexData for a Ribbon
  86330. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  86331. * * pathArray array of paths, each of which an array of successive Vector3
  86332. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  86333. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  86334. * * 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
  86335. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86336. * * 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)
  86337. * * 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)
  86338. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  86339. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  86340. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  86341. * @returns the VertexData of the ribbon
  86342. */
  86343. static CreateRibbon(options: {
  86344. pathArray: Vector3[][];
  86345. closeArray?: boolean;
  86346. closePath?: boolean;
  86347. offset?: number;
  86348. sideOrientation?: number;
  86349. frontUVs?: Vector4;
  86350. backUVs?: Vector4;
  86351. invertUV?: boolean;
  86352. uvs?: Vector2[];
  86353. colors?: Color4[];
  86354. }): VertexData;
  86355. /**
  86356. * Creates the VertexData for a box
  86357. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86358. * * size sets the width, height and depth of the box to the value of size, optional default 1
  86359. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  86360. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  86361. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  86362. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  86363. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  86364. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86365. * * 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)
  86366. * * 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)
  86367. * @returns the VertexData of the box
  86368. */
  86369. static CreateBox(options: {
  86370. size?: number;
  86371. width?: number;
  86372. height?: number;
  86373. depth?: number;
  86374. faceUV?: Vector4[];
  86375. faceColors?: Color4[];
  86376. sideOrientation?: number;
  86377. frontUVs?: Vector4;
  86378. backUVs?: Vector4;
  86379. }): VertexData;
  86380. /**
  86381. * Creates the VertexData for a tiled box
  86382. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86383. * * faceTiles sets the pattern, tile size and number of tiles for a face
  86384. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  86385. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  86386. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86387. * @returns the VertexData of the box
  86388. */
  86389. static CreateTiledBox(options: {
  86390. pattern?: number;
  86391. width?: number;
  86392. height?: number;
  86393. depth?: number;
  86394. tileSize?: number;
  86395. tileWidth?: number;
  86396. tileHeight?: number;
  86397. alignHorizontal?: number;
  86398. alignVertical?: number;
  86399. faceUV?: Vector4[];
  86400. faceColors?: Color4[];
  86401. sideOrientation?: number;
  86402. }): VertexData;
  86403. /**
  86404. * Creates the VertexData for a tiled plane
  86405. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86406. * * pattern a limited pattern arrangement depending on the number
  86407. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  86408. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  86409. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  86410. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86411. * * 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)
  86412. * * 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)
  86413. * @returns the VertexData of the tiled plane
  86414. */
  86415. static CreateTiledPlane(options: {
  86416. pattern?: number;
  86417. tileSize?: number;
  86418. tileWidth?: number;
  86419. tileHeight?: number;
  86420. size?: number;
  86421. width?: number;
  86422. height?: number;
  86423. alignHorizontal?: number;
  86424. alignVertical?: number;
  86425. sideOrientation?: number;
  86426. frontUVs?: Vector4;
  86427. backUVs?: Vector4;
  86428. }): VertexData;
  86429. /**
  86430. * Creates the VertexData for an ellipsoid, defaults to a sphere
  86431. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86432. * * segments sets the number of horizontal strips optional, default 32
  86433. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  86434. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  86435. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  86436. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  86437. * * 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
  86438. * * 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
  86439. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86440. * * 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)
  86441. * * 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)
  86442. * @returns the VertexData of the ellipsoid
  86443. */
  86444. static CreateSphere(options: {
  86445. segments?: number;
  86446. diameter?: number;
  86447. diameterX?: number;
  86448. diameterY?: number;
  86449. diameterZ?: number;
  86450. arc?: number;
  86451. slice?: number;
  86452. sideOrientation?: number;
  86453. frontUVs?: Vector4;
  86454. backUVs?: Vector4;
  86455. }): VertexData;
  86456. /**
  86457. * Creates the VertexData for a cylinder, cone or prism
  86458. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86459. * * height sets the height (y direction) of the cylinder, optional, default 2
  86460. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  86461. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  86462. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  86463. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  86464. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  86465. * * 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
  86466. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86467. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86468. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  86469. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  86470. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86471. * * 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)
  86472. * * 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)
  86473. * @returns the VertexData of the cylinder, cone or prism
  86474. */
  86475. static CreateCylinder(options: {
  86476. height?: number;
  86477. diameterTop?: number;
  86478. diameterBottom?: number;
  86479. diameter?: number;
  86480. tessellation?: number;
  86481. subdivisions?: number;
  86482. arc?: number;
  86483. faceColors?: Color4[];
  86484. faceUV?: Vector4[];
  86485. hasRings?: boolean;
  86486. enclose?: boolean;
  86487. sideOrientation?: number;
  86488. frontUVs?: Vector4;
  86489. backUVs?: Vector4;
  86490. }): VertexData;
  86491. /**
  86492. * Creates the VertexData for a torus
  86493. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86494. * * diameter the diameter of the torus, optional default 1
  86495. * * thickness the diameter of the tube forming the torus, optional default 0.5
  86496. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  86497. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86498. * * 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)
  86499. * * 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)
  86500. * @returns the VertexData of the torus
  86501. */
  86502. static CreateTorus(options: {
  86503. diameter?: number;
  86504. thickness?: number;
  86505. tessellation?: number;
  86506. sideOrientation?: number;
  86507. frontUVs?: Vector4;
  86508. backUVs?: Vector4;
  86509. }): VertexData;
  86510. /**
  86511. * Creates the VertexData of the LineSystem
  86512. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  86513. * - lines an array of lines, each line being an array of successive Vector3
  86514. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  86515. * @returns the VertexData of the LineSystem
  86516. */
  86517. static CreateLineSystem(options: {
  86518. lines: Vector3[][];
  86519. colors?: Nullable<Color4[][]>;
  86520. }): VertexData;
  86521. /**
  86522. * Create the VertexData for a DashedLines
  86523. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  86524. * - points an array successive Vector3
  86525. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  86526. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  86527. * - dashNb the intended total number of dashes, optional, default 200
  86528. * @returns the VertexData for the DashedLines
  86529. */
  86530. static CreateDashedLines(options: {
  86531. points: Vector3[];
  86532. dashSize?: number;
  86533. gapSize?: number;
  86534. dashNb?: number;
  86535. }): VertexData;
  86536. /**
  86537. * Creates the VertexData for a Ground
  86538. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  86539. * - width the width (x direction) of the ground, optional, default 1
  86540. * - height the height (z direction) of the ground, optional, default 1
  86541. * - subdivisions the number of subdivisions per side, optional, default 1
  86542. * @returns the VertexData of the Ground
  86543. */
  86544. static CreateGround(options: {
  86545. width?: number;
  86546. height?: number;
  86547. subdivisions?: number;
  86548. subdivisionsX?: number;
  86549. subdivisionsY?: number;
  86550. }): VertexData;
  86551. /**
  86552. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  86553. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  86554. * * xmin the ground minimum X coordinate, optional, default -1
  86555. * * zmin the ground minimum Z coordinate, optional, default -1
  86556. * * xmax the ground maximum X coordinate, optional, default 1
  86557. * * zmax the ground maximum Z coordinate, optional, default 1
  86558. * * 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}
  86559. * * 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}
  86560. * @returns the VertexData of the TiledGround
  86561. */
  86562. static CreateTiledGround(options: {
  86563. xmin: number;
  86564. zmin: number;
  86565. xmax: number;
  86566. zmax: number;
  86567. subdivisions?: {
  86568. w: number;
  86569. h: number;
  86570. };
  86571. precision?: {
  86572. w: number;
  86573. h: number;
  86574. };
  86575. }): VertexData;
  86576. /**
  86577. * Creates the VertexData of the Ground designed from a heightmap
  86578. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  86579. * * width the width (x direction) of the ground
  86580. * * height the height (z direction) of the ground
  86581. * * subdivisions the number of subdivisions per side
  86582. * * minHeight the minimum altitude on the ground, optional, default 0
  86583. * * maxHeight the maximum altitude on the ground, optional default 1
  86584. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  86585. * * buffer the array holding the image color data
  86586. * * bufferWidth the width of image
  86587. * * bufferHeight the height of image
  86588. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  86589. * @returns the VertexData of the Ground designed from a heightmap
  86590. */
  86591. static CreateGroundFromHeightMap(options: {
  86592. width: number;
  86593. height: number;
  86594. subdivisions: number;
  86595. minHeight: number;
  86596. maxHeight: number;
  86597. colorFilter: Color3;
  86598. buffer: Uint8Array;
  86599. bufferWidth: number;
  86600. bufferHeight: number;
  86601. alphaFilter: number;
  86602. }): VertexData;
  86603. /**
  86604. * Creates the VertexData for a Plane
  86605. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  86606. * * size sets the width and height of the plane to the value of size, optional default 1
  86607. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  86608. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  86609. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86610. * * 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)
  86611. * * 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)
  86612. * @returns the VertexData of the box
  86613. */
  86614. static CreatePlane(options: {
  86615. size?: number;
  86616. width?: number;
  86617. height?: number;
  86618. sideOrientation?: number;
  86619. frontUVs?: Vector4;
  86620. backUVs?: Vector4;
  86621. }): VertexData;
  86622. /**
  86623. * Creates the VertexData of the Disc or regular Polygon
  86624. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  86625. * * radius the radius of the disc, optional default 0.5
  86626. * * tessellation the number of polygon sides, optional, default 64
  86627. * * 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
  86628. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86629. * * 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)
  86630. * * 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)
  86631. * @returns the VertexData of the box
  86632. */
  86633. static CreateDisc(options: {
  86634. radius?: number;
  86635. tessellation?: number;
  86636. arc?: number;
  86637. sideOrientation?: number;
  86638. frontUVs?: Vector4;
  86639. backUVs?: Vector4;
  86640. }): VertexData;
  86641. /**
  86642. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  86643. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  86644. * @param polygon a mesh built from polygonTriangulation.build()
  86645. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86646. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86647. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86648. * @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)
  86649. * @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)
  86650. * @returns the VertexData of the Polygon
  86651. */
  86652. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  86653. /**
  86654. * Creates the VertexData of the IcoSphere
  86655. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  86656. * * radius the radius of the IcoSphere, optional default 1
  86657. * * radiusX allows stretching in the x direction, optional, default radius
  86658. * * radiusY allows stretching in the y direction, optional, default radius
  86659. * * radiusZ allows stretching in the z direction, optional, default radius
  86660. * * flat when true creates a flat shaded mesh, optional, default true
  86661. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  86662. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86663. * * 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)
  86664. * * 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)
  86665. * @returns the VertexData of the IcoSphere
  86666. */
  86667. static CreateIcoSphere(options: {
  86668. radius?: number;
  86669. radiusX?: number;
  86670. radiusY?: number;
  86671. radiusZ?: number;
  86672. flat?: boolean;
  86673. subdivisions?: number;
  86674. sideOrientation?: number;
  86675. frontUVs?: Vector4;
  86676. backUVs?: Vector4;
  86677. }): VertexData;
  86678. /**
  86679. * Creates the VertexData for a Polyhedron
  86680. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  86681. * * type provided types are:
  86682. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  86683. * * 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)
  86684. * * size the size of the IcoSphere, optional default 1
  86685. * * sizeX allows stretching in the x direction, optional, default size
  86686. * * sizeY allows stretching in the y direction, optional, default size
  86687. * * sizeZ allows stretching in the z direction, optional, default size
  86688. * * 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
  86689. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86690. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86691. * * flat when true creates a flat shaded mesh, optional, default true
  86692. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  86693. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86694. * * 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)
  86695. * * 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)
  86696. * @returns the VertexData of the Polyhedron
  86697. */
  86698. static CreatePolyhedron(options: {
  86699. type?: number;
  86700. size?: number;
  86701. sizeX?: number;
  86702. sizeY?: number;
  86703. sizeZ?: number;
  86704. custom?: any;
  86705. faceUV?: Vector4[];
  86706. faceColors?: Color4[];
  86707. flat?: boolean;
  86708. sideOrientation?: number;
  86709. frontUVs?: Vector4;
  86710. backUVs?: Vector4;
  86711. }): VertexData;
  86712. /**
  86713. * Creates the VertexData for a TorusKnot
  86714. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  86715. * * radius the radius of the torus knot, optional, default 2
  86716. * * tube the thickness of the tube, optional, default 0.5
  86717. * * radialSegments the number of sides on each tube segments, optional, default 32
  86718. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  86719. * * p the number of windings around the z axis, optional, default 2
  86720. * * q the number of windings around the x axis, optional, default 3
  86721. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86722. * * 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)
  86723. * * 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)
  86724. * @returns the VertexData of the Torus Knot
  86725. */
  86726. static CreateTorusKnot(options: {
  86727. radius?: number;
  86728. tube?: number;
  86729. radialSegments?: number;
  86730. tubularSegments?: number;
  86731. p?: number;
  86732. q?: number;
  86733. sideOrientation?: number;
  86734. frontUVs?: Vector4;
  86735. backUVs?: Vector4;
  86736. }): VertexData;
  86737. /**
  86738. * Compute normals for given positions and indices
  86739. * @param positions an array of vertex positions, [...., x, y, z, ......]
  86740. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  86741. * @param normals an array of vertex normals, [...., x, y, z, ......]
  86742. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  86743. * * facetNormals : optional array of facet normals (vector3)
  86744. * * facetPositions : optional array of facet positions (vector3)
  86745. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  86746. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  86747. * * bInfo : optional bounding info, required for facetPartitioning computation
  86748. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  86749. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  86750. * * useRightHandedSystem: optional boolean to for right handed system computation
  86751. * * depthSort : optional boolean to enable the facet depth sort computation
  86752. * * distanceTo : optional Vector3 to compute the facet depth from this location
  86753. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  86754. */
  86755. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  86756. facetNormals?: any;
  86757. facetPositions?: any;
  86758. facetPartitioning?: any;
  86759. ratio?: number;
  86760. bInfo?: any;
  86761. bbSize?: Vector3;
  86762. subDiv?: any;
  86763. useRightHandedSystem?: boolean;
  86764. depthSort?: boolean;
  86765. distanceTo?: Vector3;
  86766. depthSortedFacets?: any;
  86767. }): void;
  86768. /** @hidden */
  86769. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  86770. /**
  86771. * Applies VertexData created from the imported parameters to the geometry
  86772. * @param parsedVertexData the parsed data from an imported file
  86773. * @param geometry the geometry to apply the VertexData to
  86774. */
  86775. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  86776. }
  86777. }
  86778. declare module BABYLON {
  86779. /**
  86780. * Defines a target to use with MorphTargetManager
  86781. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  86782. */
  86783. export class MorphTarget implements IAnimatable {
  86784. /** defines the name of the target */
  86785. name: string;
  86786. /**
  86787. * Gets or sets the list of animations
  86788. */
  86789. animations: Animation[];
  86790. private _scene;
  86791. private _positions;
  86792. private _normals;
  86793. private _tangents;
  86794. private _uvs;
  86795. private _influence;
  86796. /**
  86797. * Observable raised when the influence changes
  86798. */
  86799. onInfluenceChanged: Observable<boolean>;
  86800. /** @hidden */
  86801. _onDataLayoutChanged: Observable<void>;
  86802. /**
  86803. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  86804. */
  86805. influence: number;
  86806. /**
  86807. * Gets or sets the id of the morph Target
  86808. */
  86809. id: string;
  86810. private _animationPropertiesOverride;
  86811. /**
  86812. * Gets or sets the animation properties override
  86813. */
  86814. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  86815. /**
  86816. * Creates a new MorphTarget
  86817. * @param name defines the name of the target
  86818. * @param influence defines the influence to use
  86819. * @param scene defines the scene the morphtarget belongs to
  86820. */
  86821. constructor(
  86822. /** defines the name of the target */
  86823. name: string, influence?: number, scene?: Nullable<Scene>);
  86824. /**
  86825. * Gets a boolean defining if the target contains position data
  86826. */
  86827. readonly hasPositions: boolean;
  86828. /**
  86829. * Gets a boolean defining if the target contains normal data
  86830. */
  86831. readonly hasNormals: boolean;
  86832. /**
  86833. * Gets a boolean defining if the target contains tangent data
  86834. */
  86835. readonly hasTangents: boolean;
  86836. /**
  86837. * Gets a boolean defining if the target contains texture coordinates data
  86838. */
  86839. readonly hasUVs: boolean;
  86840. /**
  86841. * Affects position data to this target
  86842. * @param data defines the position data to use
  86843. */
  86844. setPositions(data: Nullable<FloatArray>): void;
  86845. /**
  86846. * Gets the position data stored in this target
  86847. * @returns a FloatArray containing the position data (or null if not present)
  86848. */
  86849. getPositions(): Nullable<FloatArray>;
  86850. /**
  86851. * Affects normal data to this target
  86852. * @param data defines the normal data to use
  86853. */
  86854. setNormals(data: Nullable<FloatArray>): void;
  86855. /**
  86856. * Gets the normal data stored in this target
  86857. * @returns a FloatArray containing the normal data (or null if not present)
  86858. */
  86859. getNormals(): Nullable<FloatArray>;
  86860. /**
  86861. * Affects tangent data to this target
  86862. * @param data defines the tangent data to use
  86863. */
  86864. setTangents(data: Nullable<FloatArray>): void;
  86865. /**
  86866. * Gets the tangent data stored in this target
  86867. * @returns a FloatArray containing the tangent data (or null if not present)
  86868. */
  86869. getTangents(): Nullable<FloatArray>;
  86870. /**
  86871. * Affects texture coordinates data to this target
  86872. * @param data defines the texture coordinates data to use
  86873. */
  86874. setUVs(data: Nullable<FloatArray>): void;
  86875. /**
  86876. * Gets the texture coordinates data stored in this target
  86877. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  86878. */
  86879. getUVs(): Nullable<FloatArray>;
  86880. /**
  86881. * Serializes the current target into a Serialization object
  86882. * @returns the serialized object
  86883. */
  86884. serialize(): any;
  86885. /**
  86886. * Returns the string "MorphTarget"
  86887. * @returns "MorphTarget"
  86888. */
  86889. getClassName(): string;
  86890. /**
  86891. * Creates a new target from serialized data
  86892. * @param serializationObject defines the serialized data to use
  86893. * @returns a new MorphTarget
  86894. */
  86895. static Parse(serializationObject: any): MorphTarget;
  86896. /**
  86897. * Creates a MorphTarget from mesh data
  86898. * @param mesh defines the source mesh
  86899. * @param name defines the name to use for the new target
  86900. * @param influence defines the influence to attach to the target
  86901. * @returns a new MorphTarget
  86902. */
  86903. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  86904. }
  86905. }
  86906. declare module BABYLON {
  86907. /**
  86908. * This class is used to deform meshes using morphing between different targets
  86909. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  86910. */
  86911. export class MorphTargetManager {
  86912. private _targets;
  86913. private _targetInfluenceChangedObservers;
  86914. private _targetDataLayoutChangedObservers;
  86915. private _activeTargets;
  86916. private _scene;
  86917. private _influences;
  86918. private _supportsNormals;
  86919. private _supportsTangents;
  86920. private _supportsUVs;
  86921. private _vertexCount;
  86922. private _uniqueId;
  86923. private _tempInfluences;
  86924. /**
  86925. * Gets or sets a boolean indicating if normals must be morphed
  86926. */
  86927. enableNormalMorphing: boolean;
  86928. /**
  86929. * Gets or sets a boolean indicating if tangents must be morphed
  86930. */
  86931. enableTangentMorphing: boolean;
  86932. /**
  86933. * Gets or sets a boolean indicating if UV must be morphed
  86934. */
  86935. enableUVMorphing: boolean;
  86936. /**
  86937. * Creates a new MorphTargetManager
  86938. * @param scene defines the current scene
  86939. */
  86940. constructor(scene?: Nullable<Scene>);
  86941. /**
  86942. * Gets the unique ID of this manager
  86943. */
  86944. readonly uniqueId: number;
  86945. /**
  86946. * Gets the number of vertices handled by this manager
  86947. */
  86948. readonly vertexCount: number;
  86949. /**
  86950. * Gets a boolean indicating if this manager supports morphing of normals
  86951. */
  86952. readonly supportsNormals: boolean;
  86953. /**
  86954. * Gets a boolean indicating if this manager supports morphing of tangents
  86955. */
  86956. readonly supportsTangents: boolean;
  86957. /**
  86958. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  86959. */
  86960. readonly supportsUVs: boolean;
  86961. /**
  86962. * Gets the number of targets stored in this manager
  86963. */
  86964. readonly numTargets: number;
  86965. /**
  86966. * Gets the number of influencers (ie. the number of targets with influences > 0)
  86967. */
  86968. readonly numInfluencers: number;
  86969. /**
  86970. * Gets the list of influences (one per target)
  86971. */
  86972. readonly influences: Float32Array;
  86973. /**
  86974. * Gets the active target at specified index. An active target is a target with an influence > 0
  86975. * @param index defines the index to check
  86976. * @returns the requested target
  86977. */
  86978. getActiveTarget(index: number): MorphTarget;
  86979. /**
  86980. * Gets the target at specified index
  86981. * @param index defines the index to check
  86982. * @returns the requested target
  86983. */
  86984. getTarget(index: number): MorphTarget;
  86985. /**
  86986. * Add a new target to this manager
  86987. * @param target defines the target to add
  86988. */
  86989. addTarget(target: MorphTarget): void;
  86990. /**
  86991. * Removes a target from the manager
  86992. * @param target defines the target to remove
  86993. */
  86994. removeTarget(target: MorphTarget): void;
  86995. /**
  86996. * Serializes the current manager into a Serialization object
  86997. * @returns the serialized object
  86998. */
  86999. serialize(): any;
  87000. private _syncActiveTargets;
  87001. /**
  87002. * Syncrhonize the targets with all the meshes using this morph target manager
  87003. */
  87004. synchronize(): void;
  87005. /**
  87006. * Creates a new MorphTargetManager from serialized data
  87007. * @param serializationObject defines the serialized data
  87008. * @param scene defines the hosting scene
  87009. * @returns the new MorphTargetManager
  87010. */
  87011. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  87012. }
  87013. }
  87014. declare module BABYLON {
  87015. /**
  87016. * Class used to represent a specific level of detail of a mesh
  87017. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  87018. */
  87019. export class MeshLODLevel {
  87020. /** Defines the distance where this level should star being displayed */
  87021. distance: number;
  87022. /** Defines the mesh to use to render this level */
  87023. mesh: Nullable<Mesh>;
  87024. /**
  87025. * Creates a new LOD level
  87026. * @param distance defines the distance where this level should star being displayed
  87027. * @param mesh defines the mesh to use to render this level
  87028. */
  87029. constructor(
  87030. /** Defines the distance where this level should star being displayed */
  87031. distance: number,
  87032. /** Defines the mesh to use to render this level */
  87033. mesh: Nullable<Mesh>);
  87034. }
  87035. }
  87036. declare module BABYLON {
  87037. /**
  87038. * Mesh representing the gorund
  87039. */
  87040. export class GroundMesh extends Mesh {
  87041. /** If octree should be generated */
  87042. generateOctree: boolean;
  87043. private _heightQuads;
  87044. /** @hidden */
  87045. _subdivisionsX: number;
  87046. /** @hidden */
  87047. _subdivisionsY: number;
  87048. /** @hidden */
  87049. _width: number;
  87050. /** @hidden */
  87051. _height: number;
  87052. /** @hidden */
  87053. _minX: number;
  87054. /** @hidden */
  87055. _maxX: number;
  87056. /** @hidden */
  87057. _minZ: number;
  87058. /** @hidden */
  87059. _maxZ: number;
  87060. constructor(name: string, scene: Scene);
  87061. /**
  87062. * "GroundMesh"
  87063. * @returns "GroundMesh"
  87064. */
  87065. getClassName(): string;
  87066. /**
  87067. * The minimum of x and y subdivisions
  87068. */
  87069. readonly subdivisions: number;
  87070. /**
  87071. * X subdivisions
  87072. */
  87073. readonly subdivisionsX: number;
  87074. /**
  87075. * Y subdivisions
  87076. */
  87077. readonly subdivisionsY: number;
  87078. /**
  87079. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  87080. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  87081. * @param chunksCount the number of subdivisions for x and y
  87082. * @param octreeBlocksSize (Default: 32)
  87083. */
  87084. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  87085. /**
  87086. * Returns a height (y) value in the Worl system :
  87087. * the ground altitude at the coordinates (x, z) expressed in the World system.
  87088. * @param x x coordinate
  87089. * @param z z coordinate
  87090. * @returns the ground y position if (x, z) are outside the ground surface.
  87091. */
  87092. getHeightAtCoordinates(x: number, z: number): number;
  87093. /**
  87094. * Returns a normalized vector (Vector3) orthogonal to the ground
  87095. * at the ground coordinates (x, z) expressed in the World system.
  87096. * @param x x coordinate
  87097. * @param z z coordinate
  87098. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  87099. */
  87100. getNormalAtCoordinates(x: number, z: number): Vector3;
  87101. /**
  87102. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  87103. * at the ground coordinates (x, z) expressed in the World system.
  87104. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  87105. * @param x x coordinate
  87106. * @param z z coordinate
  87107. * @param ref vector to store the result
  87108. * @returns the GroundMesh.
  87109. */
  87110. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  87111. /**
  87112. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  87113. * if the ground has been updated.
  87114. * This can be used in the render loop.
  87115. * @returns the GroundMesh.
  87116. */
  87117. updateCoordinateHeights(): GroundMesh;
  87118. private _getFacetAt;
  87119. private _initHeightQuads;
  87120. private _computeHeightQuads;
  87121. /**
  87122. * Serializes this ground mesh
  87123. * @param serializationObject object to write serialization to
  87124. */
  87125. serialize(serializationObject: any): void;
  87126. /**
  87127. * Parses a serialized ground mesh
  87128. * @param parsedMesh the serialized mesh
  87129. * @param scene the scene to create the ground mesh in
  87130. * @returns the created ground mesh
  87131. */
  87132. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  87133. }
  87134. }
  87135. declare module BABYLON {
  87136. /**
  87137. * Interface for Physics-Joint data
  87138. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87139. */
  87140. export interface PhysicsJointData {
  87141. /**
  87142. * The main pivot of the joint
  87143. */
  87144. mainPivot?: Vector3;
  87145. /**
  87146. * The connected pivot of the joint
  87147. */
  87148. connectedPivot?: Vector3;
  87149. /**
  87150. * The main axis of the joint
  87151. */
  87152. mainAxis?: Vector3;
  87153. /**
  87154. * The connected axis of the joint
  87155. */
  87156. connectedAxis?: Vector3;
  87157. /**
  87158. * The collision of the joint
  87159. */
  87160. collision?: boolean;
  87161. /**
  87162. * Native Oimo/Cannon/Energy data
  87163. */
  87164. nativeParams?: any;
  87165. }
  87166. /**
  87167. * This is a holder class for the physics joint created by the physics plugin
  87168. * It holds a set of functions to control the underlying joint
  87169. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87170. */
  87171. export class PhysicsJoint {
  87172. /**
  87173. * The type of the physics joint
  87174. */
  87175. type: number;
  87176. /**
  87177. * The data for the physics joint
  87178. */
  87179. jointData: PhysicsJointData;
  87180. private _physicsJoint;
  87181. protected _physicsPlugin: IPhysicsEnginePlugin;
  87182. /**
  87183. * Initializes the physics joint
  87184. * @param type The type of the physics joint
  87185. * @param jointData The data for the physics joint
  87186. */
  87187. constructor(
  87188. /**
  87189. * The type of the physics joint
  87190. */
  87191. type: number,
  87192. /**
  87193. * The data for the physics joint
  87194. */
  87195. jointData: PhysicsJointData);
  87196. /**
  87197. * Gets the physics joint
  87198. */
  87199. /**
  87200. * Sets the physics joint
  87201. */
  87202. physicsJoint: any;
  87203. /**
  87204. * Sets the physics plugin
  87205. */
  87206. physicsPlugin: IPhysicsEnginePlugin;
  87207. /**
  87208. * Execute a function that is physics-plugin specific.
  87209. * @param {Function} func the function that will be executed.
  87210. * It accepts two parameters: the physics world and the physics joint
  87211. */
  87212. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  87213. /**
  87214. * Distance-Joint type
  87215. */
  87216. static DistanceJoint: number;
  87217. /**
  87218. * Hinge-Joint type
  87219. */
  87220. static HingeJoint: number;
  87221. /**
  87222. * Ball-and-Socket joint type
  87223. */
  87224. static BallAndSocketJoint: number;
  87225. /**
  87226. * Wheel-Joint type
  87227. */
  87228. static WheelJoint: number;
  87229. /**
  87230. * Slider-Joint type
  87231. */
  87232. static SliderJoint: number;
  87233. /**
  87234. * Prismatic-Joint type
  87235. */
  87236. static PrismaticJoint: number;
  87237. /**
  87238. * Universal-Joint type
  87239. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  87240. */
  87241. static UniversalJoint: number;
  87242. /**
  87243. * Hinge-Joint 2 type
  87244. */
  87245. static Hinge2Joint: number;
  87246. /**
  87247. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  87248. */
  87249. static PointToPointJoint: number;
  87250. /**
  87251. * Spring-Joint type
  87252. */
  87253. static SpringJoint: number;
  87254. /**
  87255. * Lock-Joint type
  87256. */
  87257. static LockJoint: number;
  87258. }
  87259. /**
  87260. * A class representing a physics distance joint
  87261. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87262. */
  87263. export class DistanceJoint extends PhysicsJoint {
  87264. /**
  87265. *
  87266. * @param jointData The data for the Distance-Joint
  87267. */
  87268. constructor(jointData: DistanceJointData);
  87269. /**
  87270. * Update the predefined distance.
  87271. * @param maxDistance The maximum preferred distance
  87272. * @param minDistance The minimum preferred distance
  87273. */
  87274. updateDistance(maxDistance: number, minDistance?: number): void;
  87275. }
  87276. /**
  87277. * Represents a Motor-Enabled Joint
  87278. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87279. */
  87280. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  87281. /**
  87282. * Initializes the Motor-Enabled Joint
  87283. * @param type The type of the joint
  87284. * @param jointData The physica joint data for the joint
  87285. */
  87286. constructor(type: number, jointData: PhysicsJointData);
  87287. /**
  87288. * Set the motor values.
  87289. * Attention, this function is plugin specific. Engines won't react 100% the same.
  87290. * @param force the force to apply
  87291. * @param maxForce max force for this motor.
  87292. */
  87293. setMotor(force?: number, maxForce?: number): void;
  87294. /**
  87295. * Set the motor's limits.
  87296. * Attention, this function is plugin specific. Engines won't react 100% the same.
  87297. * @param upperLimit The upper limit of the motor
  87298. * @param lowerLimit The lower limit of the motor
  87299. */
  87300. setLimit(upperLimit: number, lowerLimit?: number): void;
  87301. }
  87302. /**
  87303. * This class represents a single physics Hinge-Joint
  87304. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87305. */
  87306. export class HingeJoint extends MotorEnabledJoint {
  87307. /**
  87308. * Initializes the Hinge-Joint
  87309. * @param jointData The joint data for the Hinge-Joint
  87310. */
  87311. constructor(jointData: PhysicsJointData);
  87312. /**
  87313. * Set the motor values.
  87314. * Attention, this function is plugin specific. Engines won't react 100% the same.
  87315. * @param {number} force the force to apply
  87316. * @param {number} maxForce max force for this motor.
  87317. */
  87318. setMotor(force?: number, maxForce?: number): void;
  87319. /**
  87320. * Set the motor's limits.
  87321. * Attention, this function is plugin specific. Engines won't react 100% the same.
  87322. * @param upperLimit The upper limit of the motor
  87323. * @param lowerLimit The lower limit of the motor
  87324. */
  87325. setLimit(upperLimit: number, lowerLimit?: number): void;
  87326. }
  87327. /**
  87328. * This class represents a dual hinge physics joint (same as wheel joint)
  87329. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87330. */
  87331. export class Hinge2Joint extends MotorEnabledJoint {
  87332. /**
  87333. * Initializes the Hinge2-Joint
  87334. * @param jointData The joint data for the Hinge2-Joint
  87335. */
  87336. constructor(jointData: PhysicsJointData);
  87337. /**
  87338. * Set the motor values.
  87339. * Attention, this function is plugin specific. Engines won't react 100% the same.
  87340. * @param {number} targetSpeed the speed the motor is to reach
  87341. * @param {number} maxForce max force for this motor.
  87342. * @param {motorIndex} the motor's index, 0 or 1.
  87343. */
  87344. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  87345. /**
  87346. * Set the motor limits.
  87347. * Attention, this function is plugin specific. Engines won't react 100% the same.
  87348. * @param {number} upperLimit the upper limit
  87349. * @param {number} lowerLimit lower limit
  87350. * @param {motorIndex} the motor's index, 0 or 1.
  87351. */
  87352. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  87353. }
  87354. /**
  87355. * Interface for a motor enabled joint
  87356. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87357. */
  87358. export interface IMotorEnabledJoint {
  87359. /**
  87360. * Physics joint
  87361. */
  87362. physicsJoint: any;
  87363. /**
  87364. * Sets the motor of the motor-enabled joint
  87365. * @param force The force of the motor
  87366. * @param maxForce The maximum force of the motor
  87367. * @param motorIndex The index of the motor
  87368. */
  87369. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  87370. /**
  87371. * Sets the limit of the motor
  87372. * @param upperLimit The upper limit of the motor
  87373. * @param lowerLimit The lower limit of the motor
  87374. * @param motorIndex The index of the motor
  87375. */
  87376. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  87377. }
  87378. /**
  87379. * Joint data for a Distance-Joint
  87380. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87381. */
  87382. export interface DistanceJointData extends PhysicsJointData {
  87383. /**
  87384. * Max distance the 2 joint objects can be apart
  87385. */
  87386. maxDistance: number;
  87387. }
  87388. /**
  87389. * Joint data from a spring joint
  87390. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87391. */
  87392. export interface SpringJointData extends PhysicsJointData {
  87393. /**
  87394. * Length of the spring
  87395. */
  87396. length: number;
  87397. /**
  87398. * Stiffness of the spring
  87399. */
  87400. stiffness: number;
  87401. /**
  87402. * Damping of the spring
  87403. */
  87404. damping: number;
  87405. /** this callback will be called when applying the force to the impostors. */
  87406. forceApplicationCallback: () => void;
  87407. }
  87408. }
  87409. declare module BABYLON {
  87410. /**
  87411. * Holds the data for the raycast result
  87412. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87413. */
  87414. export class PhysicsRaycastResult {
  87415. private _hasHit;
  87416. private _hitDistance;
  87417. private _hitNormalWorld;
  87418. private _hitPointWorld;
  87419. private _rayFromWorld;
  87420. private _rayToWorld;
  87421. /**
  87422. * Gets if there was a hit
  87423. */
  87424. readonly hasHit: boolean;
  87425. /**
  87426. * Gets the distance from the hit
  87427. */
  87428. readonly hitDistance: number;
  87429. /**
  87430. * Gets the hit normal/direction in the world
  87431. */
  87432. readonly hitNormalWorld: Vector3;
  87433. /**
  87434. * Gets the hit point in the world
  87435. */
  87436. readonly hitPointWorld: Vector3;
  87437. /**
  87438. * Gets the ray "start point" of the ray in the world
  87439. */
  87440. readonly rayFromWorld: Vector3;
  87441. /**
  87442. * Gets the ray "end point" of the ray in the world
  87443. */
  87444. readonly rayToWorld: Vector3;
  87445. /**
  87446. * Sets the hit data (normal & point in world space)
  87447. * @param hitNormalWorld defines the normal in world space
  87448. * @param hitPointWorld defines the point in world space
  87449. */
  87450. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  87451. /**
  87452. * Sets the distance from the start point to the hit point
  87453. * @param distance
  87454. */
  87455. setHitDistance(distance: number): void;
  87456. /**
  87457. * Calculates the distance manually
  87458. */
  87459. calculateHitDistance(): void;
  87460. /**
  87461. * Resets all the values to default
  87462. * @param from The from point on world space
  87463. * @param to The to point on world space
  87464. */
  87465. reset(from?: Vector3, to?: Vector3): void;
  87466. }
  87467. /**
  87468. * Interface for the size containing width and height
  87469. */
  87470. interface IXYZ {
  87471. /**
  87472. * X
  87473. */
  87474. x: number;
  87475. /**
  87476. * Y
  87477. */
  87478. y: number;
  87479. /**
  87480. * Z
  87481. */
  87482. z: number;
  87483. }
  87484. }
  87485. declare module BABYLON {
  87486. /**
  87487. * Interface used to describe a physics joint
  87488. */
  87489. export interface PhysicsImpostorJoint {
  87490. /** Defines the main impostor to which the joint is linked */
  87491. mainImpostor: PhysicsImpostor;
  87492. /** Defines the impostor that is connected to the main impostor using this joint */
  87493. connectedImpostor: PhysicsImpostor;
  87494. /** Defines the joint itself */
  87495. joint: PhysicsJoint;
  87496. }
  87497. /** @hidden */
  87498. export interface IPhysicsEnginePlugin {
  87499. world: any;
  87500. name: string;
  87501. setGravity(gravity: Vector3): void;
  87502. setTimeStep(timeStep: number): void;
  87503. getTimeStep(): number;
  87504. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  87505. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  87506. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  87507. generatePhysicsBody(impostor: PhysicsImpostor): void;
  87508. removePhysicsBody(impostor: PhysicsImpostor): void;
  87509. generateJoint(joint: PhysicsImpostorJoint): void;
  87510. removeJoint(joint: PhysicsImpostorJoint): void;
  87511. isSupported(): boolean;
  87512. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  87513. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  87514. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  87515. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  87516. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  87517. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  87518. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  87519. getBodyMass(impostor: PhysicsImpostor): number;
  87520. getBodyFriction(impostor: PhysicsImpostor): number;
  87521. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  87522. getBodyRestitution(impostor: PhysicsImpostor): number;
  87523. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  87524. getBodyPressure?(impostor: PhysicsImpostor): number;
  87525. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  87526. getBodyStiffness?(impostor: PhysicsImpostor): number;
  87527. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  87528. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  87529. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  87530. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  87531. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  87532. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  87533. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  87534. sleepBody(impostor: PhysicsImpostor): void;
  87535. wakeUpBody(impostor: PhysicsImpostor): void;
  87536. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  87537. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  87538. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  87539. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  87540. getRadius(impostor: PhysicsImpostor): number;
  87541. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  87542. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  87543. dispose(): void;
  87544. }
  87545. /**
  87546. * Interface used to define a physics engine
  87547. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  87548. */
  87549. export interface IPhysicsEngine {
  87550. /**
  87551. * Gets the gravity vector used by the simulation
  87552. */
  87553. gravity: Vector3;
  87554. /**
  87555. * Sets the gravity vector used by the simulation
  87556. * @param gravity defines the gravity vector to use
  87557. */
  87558. setGravity(gravity: Vector3): void;
  87559. /**
  87560. * Set the time step of the physics engine.
  87561. * Default is 1/60.
  87562. * To slow it down, enter 1/600 for example.
  87563. * To speed it up, 1/30
  87564. * @param newTimeStep the new timestep to apply to this world.
  87565. */
  87566. setTimeStep(newTimeStep: number): void;
  87567. /**
  87568. * Get the time step of the physics engine.
  87569. * @returns the current time step
  87570. */
  87571. getTimeStep(): number;
  87572. /**
  87573. * Release all resources
  87574. */
  87575. dispose(): void;
  87576. /**
  87577. * Gets the name of the current physics plugin
  87578. * @returns the name of the plugin
  87579. */
  87580. getPhysicsPluginName(): string;
  87581. /**
  87582. * Adding a new impostor for the impostor tracking.
  87583. * This will be done by the impostor itself.
  87584. * @param impostor the impostor to add
  87585. */
  87586. addImpostor(impostor: PhysicsImpostor): void;
  87587. /**
  87588. * Remove an impostor from the engine.
  87589. * This impostor and its mesh will not longer be updated by the physics engine.
  87590. * @param impostor the impostor to remove
  87591. */
  87592. removeImpostor(impostor: PhysicsImpostor): void;
  87593. /**
  87594. * Add a joint to the physics engine
  87595. * @param mainImpostor defines the main impostor to which the joint is added.
  87596. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  87597. * @param joint defines the joint that will connect both impostors.
  87598. */
  87599. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  87600. /**
  87601. * Removes a joint from the simulation
  87602. * @param mainImpostor defines the impostor used with the joint
  87603. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  87604. * @param joint defines the joint to remove
  87605. */
  87606. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  87607. /**
  87608. * Gets the current plugin used to run the simulation
  87609. * @returns current plugin
  87610. */
  87611. getPhysicsPlugin(): IPhysicsEnginePlugin;
  87612. /**
  87613. * Gets the list of physic impostors
  87614. * @returns an array of PhysicsImpostor
  87615. */
  87616. getImpostors(): Array<PhysicsImpostor>;
  87617. /**
  87618. * Gets the impostor for a physics enabled object
  87619. * @param object defines the object impersonated by the impostor
  87620. * @returns the PhysicsImpostor or null if not found
  87621. */
  87622. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  87623. /**
  87624. * Gets the impostor for a physics body object
  87625. * @param body defines physics body used by the impostor
  87626. * @returns the PhysicsImpostor or null if not found
  87627. */
  87628. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  87629. /**
  87630. * Does a raycast in the physics world
  87631. * @param from when should the ray start?
  87632. * @param to when should the ray end?
  87633. * @returns PhysicsRaycastResult
  87634. */
  87635. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  87636. /**
  87637. * Called by the scene. No need to call it.
  87638. * @param delta defines the timespam between frames
  87639. */
  87640. _step(delta: number): void;
  87641. }
  87642. }
  87643. declare module BABYLON {
  87644. /**
  87645. * The interface for the physics imposter parameters
  87646. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87647. */
  87648. export interface PhysicsImpostorParameters {
  87649. /**
  87650. * The mass of the physics imposter
  87651. */
  87652. mass: number;
  87653. /**
  87654. * The friction of the physics imposter
  87655. */
  87656. friction?: number;
  87657. /**
  87658. * The coefficient of restitution of the physics imposter
  87659. */
  87660. restitution?: number;
  87661. /**
  87662. * The native options of the physics imposter
  87663. */
  87664. nativeOptions?: any;
  87665. /**
  87666. * Specifies if the parent should be ignored
  87667. */
  87668. ignoreParent?: boolean;
  87669. /**
  87670. * Specifies if bi-directional transformations should be disabled
  87671. */
  87672. disableBidirectionalTransformation?: boolean;
  87673. /**
  87674. * The pressure inside the physics imposter, soft object only
  87675. */
  87676. pressure?: number;
  87677. /**
  87678. * The stiffness the physics imposter, soft object only
  87679. */
  87680. stiffness?: number;
  87681. /**
  87682. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  87683. */
  87684. velocityIterations?: number;
  87685. /**
  87686. * The number of iterations used in maintaining consistent vertex positions, soft object only
  87687. */
  87688. positionIterations?: number;
  87689. /**
  87690. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  87691. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  87692. * Add to fix multiple points
  87693. */
  87694. fixedPoints?: number;
  87695. /**
  87696. * The collision margin around a soft object
  87697. */
  87698. margin?: number;
  87699. /**
  87700. * The collision margin around a soft object
  87701. */
  87702. damping?: number;
  87703. /**
  87704. * The path for a rope based on an extrusion
  87705. */
  87706. path?: any;
  87707. /**
  87708. * The shape of an extrusion used for a rope based on an extrusion
  87709. */
  87710. shape?: any;
  87711. }
  87712. /**
  87713. * Interface for a physics-enabled object
  87714. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87715. */
  87716. export interface IPhysicsEnabledObject {
  87717. /**
  87718. * The position of the physics-enabled object
  87719. */
  87720. position: Vector3;
  87721. /**
  87722. * The rotation of the physics-enabled object
  87723. */
  87724. rotationQuaternion: Nullable<Quaternion>;
  87725. /**
  87726. * The scale of the physics-enabled object
  87727. */
  87728. scaling: Vector3;
  87729. /**
  87730. * The rotation of the physics-enabled object
  87731. */
  87732. rotation?: Vector3;
  87733. /**
  87734. * The parent of the physics-enabled object
  87735. */
  87736. parent?: any;
  87737. /**
  87738. * The bounding info of the physics-enabled object
  87739. * @returns The bounding info of the physics-enabled object
  87740. */
  87741. getBoundingInfo(): BoundingInfo;
  87742. /**
  87743. * Computes the world matrix
  87744. * @param force Specifies if the world matrix should be computed by force
  87745. * @returns A world matrix
  87746. */
  87747. computeWorldMatrix(force: boolean): Matrix;
  87748. /**
  87749. * Gets the world matrix
  87750. * @returns A world matrix
  87751. */
  87752. getWorldMatrix?(): Matrix;
  87753. /**
  87754. * Gets the child meshes
  87755. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  87756. * @returns An array of abstract meshes
  87757. */
  87758. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  87759. /**
  87760. * Gets the vertex data
  87761. * @param kind The type of vertex data
  87762. * @returns A nullable array of numbers, or a float32 array
  87763. */
  87764. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  87765. /**
  87766. * Gets the indices from the mesh
  87767. * @returns A nullable array of index arrays
  87768. */
  87769. getIndices?(): Nullable<IndicesArray>;
  87770. /**
  87771. * Gets the scene from the mesh
  87772. * @returns the indices array or null
  87773. */
  87774. getScene?(): Scene;
  87775. /**
  87776. * Gets the absolute position from the mesh
  87777. * @returns the absolute position
  87778. */
  87779. getAbsolutePosition(): Vector3;
  87780. /**
  87781. * Gets the absolute pivot point from the mesh
  87782. * @returns the absolute pivot point
  87783. */
  87784. getAbsolutePivotPoint(): Vector3;
  87785. /**
  87786. * Rotates the mesh
  87787. * @param axis The axis of rotation
  87788. * @param amount The amount of rotation
  87789. * @param space The space of the rotation
  87790. * @returns The rotation transform node
  87791. */
  87792. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  87793. /**
  87794. * Translates the mesh
  87795. * @param axis The axis of translation
  87796. * @param distance The distance of translation
  87797. * @param space The space of the translation
  87798. * @returns The transform node
  87799. */
  87800. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  87801. /**
  87802. * Sets the absolute position of the mesh
  87803. * @param absolutePosition The absolute position of the mesh
  87804. * @returns The transform node
  87805. */
  87806. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  87807. /**
  87808. * Gets the class name of the mesh
  87809. * @returns The class name
  87810. */
  87811. getClassName(): string;
  87812. }
  87813. /**
  87814. * Represents a physics imposter
  87815. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87816. */
  87817. export class PhysicsImpostor {
  87818. /**
  87819. * The physics-enabled object used as the physics imposter
  87820. */
  87821. object: IPhysicsEnabledObject;
  87822. /**
  87823. * The type of the physics imposter
  87824. */
  87825. type: number;
  87826. private _options;
  87827. private _scene?;
  87828. /**
  87829. * The default object size of the imposter
  87830. */
  87831. static DEFAULT_OBJECT_SIZE: Vector3;
  87832. /**
  87833. * The identity quaternion of the imposter
  87834. */
  87835. static IDENTITY_QUATERNION: Quaternion;
  87836. /** @hidden */
  87837. _pluginData: any;
  87838. private _physicsEngine;
  87839. private _physicsBody;
  87840. private _bodyUpdateRequired;
  87841. private _onBeforePhysicsStepCallbacks;
  87842. private _onAfterPhysicsStepCallbacks;
  87843. /** @hidden */
  87844. _onPhysicsCollideCallbacks: Array<{
  87845. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  87846. otherImpostors: Array<PhysicsImpostor>;
  87847. }>;
  87848. private _deltaPosition;
  87849. private _deltaRotation;
  87850. private _deltaRotationConjugated;
  87851. /** @hidden */
  87852. _isFromLine: boolean;
  87853. private _parent;
  87854. private _isDisposed;
  87855. private static _tmpVecs;
  87856. private static _tmpQuat;
  87857. /**
  87858. * Specifies if the physics imposter is disposed
  87859. */
  87860. readonly isDisposed: boolean;
  87861. /**
  87862. * Gets the mass of the physics imposter
  87863. */
  87864. mass: number;
  87865. /**
  87866. * Gets the coefficient of friction
  87867. */
  87868. /**
  87869. * Sets the coefficient of friction
  87870. */
  87871. friction: number;
  87872. /**
  87873. * Gets the coefficient of restitution
  87874. */
  87875. /**
  87876. * Sets the coefficient of restitution
  87877. */
  87878. restitution: number;
  87879. /**
  87880. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  87881. */
  87882. /**
  87883. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  87884. */
  87885. pressure: number;
  87886. /**
  87887. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  87888. */
  87889. /**
  87890. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  87891. */
  87892. stiffness: number;
  87893. /**
  87894. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  87895. */
  87896. /**
  87897. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  87898. */
  87899. velocityIterations: number;
  87900. /**
  87901. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  87902. */
  87903. /**
  87904. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  87905. */
  87906. positionIterations: number;
  87907. /**
  87908. * The unique id of the physics imposter
  87909. * set by the physics engine when adding this impostor to the array
  87910. */
  87911. uniqueId: number;
  87912. /**
  87913. * @hidden
  87914. */
  87915. soft: boolean;
  87916. /**
  87917. * @hidden
  87918. */
  87919. segments: number;
  87920. private _joints;
  87921. /**
  87922. * Initializes the physics imposter
  87923. * @param object The physics-enabled object used as the physics imposter
  87924. * @param type The type of the physics imposter
  87925. * @param _options The options for the physics imposter
  87926. * @param _scene The Babylon scene
  87927. */
  87928. constructor(
  87929. /**
  87930. * The physics-enabled object used as the physics imposter
  87931. */
  87932. object: IPhysicsEnabledObject,
  87933. /**
  87934. * The type of the physics imposter
  87935. */
  87936. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  87937. /**
  87938. * This function will completly initialize this impostor.
  87939. * It will create a new body - but only if this mesh has no parent.
  87940. * If it has, this impostor will not be used other than to define the impostor
  87941. * of the child mesh.
  87942. * @hidden
  87943. */
  87944. _init(): void;
  87945. private _getPhysicsParent;
  87946. /**
  87947. * Should a new body be generated.
  87948. * @returns boolean specifying if body initialization is required
  87949. */
  87950. isBodyInitRequired(): boolean;
  87951. /**
  87952. * Sets the updated scaling
  87953. * @param updated Specifies if the scaling is updated
  87954. */
  87955. setScalingUpdated(): void;
  87956. /**
  87957. * Force a regeneration of this or the parent's impostor's body.
  87958. * Use under cautious - This will remove all joints already implemented.
  87959. */
  87960. forceUpdate(): void;
  87961. /**
  87962. * Gets the body that holds this impostor. Either its own, or its parent.
  87963. */
  87964. /**
  87965. * Set the physics body. Used mainly by the physics engine/plugin
  87966. */
  87967. physicsBody: any;
  87968. /**
  87969. * Get the parent of the physics imposter
  87970. * @returns Physics imposter or null
  87971. */
  87972. /**
  87973. * Sets the parent of the physics imposter
  87974. */
  87975. parent: Nullable<PhysicsImpostor>;
  87976. /**
  87977. * Resets the update flags
  87978. */
  87979. resetUpdateFlags(): void;
  87980. /**
  87981. * Gets the object extend size
  87982. * @returns the object extend size
  87983. */
  87984. getObjectExtendSize(): Vector3;
  87985. /**
  87986. * Gets the object center
  87987. * @returns The object center
  87988. */
  87989. getObjectCenter(): Vector3;
  87990. /**
  87991. * Get a specific parametes from the options parameter
  87992. * @param paramName The object parameter name
  87993. * @returns The object parameter
  87994. */
  87995. getParam(paramName: string): any;
  87996. /**
  87997. * Sets a specific parameter in the options given to the physics plugin
  87998. * @param paramName The parameter name
  87999. * @param value The value of the parameter
  88000. */
  88001. setParam(paramName: string, value: number): void;
  88002. /**
  88003. * Specifically change the body's mass option. Won't recreate the physics body object
  88004. * @param mass The mass of the physics imposter
  88005. */
  88006. setMass(mass: number): void;
  88007. /**
  88008. * Gets the linear velocity
  88009. * @returns linear velocity or null
  88010. */
  88011. getLinearVelocity(): Nullable<Vector3>;
  88012. /**
  88013. * Sets the linear velocity
  88014. * @param velocity linear velocity or null
  88015. */
  88016. setLinearVelocity(velocity: Nullable<Vector3>): void;
  88017. /**
  88018. * Gets the angular velocity
  88019. * @returns angular velocity or null
  88020. */
  88021. getAngularVelocity(): Nullable<Vector3>;
  88022. /**
  88023. * Sets the angular velocity
  88024. * @param velocity The velocity or null
  88025. */
  88026. setAngularVelocity(velocity: Nullable<Vector3>): void;
  88027. /**
  88028. * Execute a function with the physics plugin native code
  88029. * Provide a function the will have two variables - the world object and the physics body object
  88030. * @param func The function to execute with the physics plugin native code
  88031. */
  88032. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  88033. /**
  88034. * Register a function that will be executed before the physics world is stepping forward
  88035. * @param func The function to execute before the physics world is stepped forward
  88036. */
  88037. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  88038. /**
  88039. * Unregister a function that will be executed before the physics world is stepping forward
  88040. * @param func The function to execute before the physics world is stepped forward
  88041. */
  88042. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  88043. /**
  88044. * Register a function that will be executed after the physics step
  88045. * @param func The function to execute after physics step
  88046. */
  88047. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  88048. /**
  88049. * Unregisters a function that will be executed after the physics step
  88050. * @param func The function to execute after physics step
  88051. */
  88052. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  88053. /**
  88054. * register a function that will be executed when this impostor collides against a different body
  88055. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  88056. * @param func Callback that is executed on collision
  88057. */
  88058. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  88059. /**
  88060. * Unregisters the physics imposter on contact
  88061. * @param collideAgainst The physics object to collide against
  88062. * @param func Callback to execute on collision
  88063. */
  88064. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  88065. private _tmpQuat;
  88066. private _tmpQuat2;
  88067. /**
  88068. * Get the parent rotation
  88069. * @returns The parent rotation
  88070. */
  88071. getParentsRotation(): Quaternion;
  88072. /**
  88073. * this function is executed by the physics engine.
  88074. */
  88075. beforeStep: () => void;
  88076. /**
  88077. * this function is executed by the physics engine
  88078. */
  88079. afterStep: () => void;
  88080. /**
  88081. * Legacy collision detection event support
  88082. */
  88083. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  88084. /**
  88085. * event and body object due to cannon's event-based architecture.
  88086. */
  88087. onCollide: (e: {
  88088. body: any;
  88089. }) => void;
  88090. /**
  88091. * Apply a force
  88092. * @param force The force to apply
  88093. * @param contactPoint The contact point for the force
  88094. * @returns The physics imposter
  88095. */
  88096. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  88097. /**
  88098. * Apply an impulse
  88099. * @param force The impulse force
  88100. * @param contactPoint The contact point for the impulse force
  88101. * @returns The physics imposter
  88102. */
  88103. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  88104. /**
  88105. * A help function to create a joint
  88106. * @param otherImpostor A physics imposter used to create a joint
  88107. * @param jointType The type of joint
  88108. * @param jointData The data for the joint
  88109. * @returns The physics imposter
  88110. */
  88111. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  88112. /**
  88113. * Add a joint to this impostor with a different impostor
  88114. * @param otherImpostor A physics imposter used to add a joint
  88115. * @param joint The joint to add
  88116. * @returns The physics imposter
  88117. */
  88118. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  88119. /**
  88120. * Add an anchor to a cloth impostor
  88121. * @param otherImpostor rigid impostor to anchor to
  88122. * @param width ratio across width from 0 to 1
  88123. * @param height ratio up height from 0 to 1
  88124. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  88125. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  88126. * @returns impostor the soft imposter
  88127. */
  88128. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  88129. /**
  88130. * Add a hook to a rope impostor
  88131. * @param otherImpostor rigid impostor to anchor to
  88132. * @param length ratio across rope from 0 to 1
  88133. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  88134. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  88135. * @returns impostor the rope imposter
  88136. */
  88137. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  88138. /**
  88139. * Will keep this body still, in a sleep mode.
  88140. * @returns the physics imposter
  88141. */
  88142. sleep(): PhysicsImpostor;
  88143. /**
  88144. * Wake the body up.
  88145. * @returns The physics imposter
  88146. */
  88147. wakeUp(): PhysicsImpostor;
  88148. /**
  88149. * Clones the physics imposter
  88150. * @param newObject The physics imposter clones to this physics-enabled object
  88151. * @returns A nullable physics imposter
  88152. */
  88153. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  88154. /**
  88155. * Disposes the physics imposter
  88156. */
  88157. dispose(): void;
  88158. /**
  88159. * Sets the delta position
  88160. * @param position The delta position amount
  88161. */
  88162. setDeltaPosition(position: Vector3): void;
  88163. /**
  88164. * Sets the delta rotation
  88165. * @param rotation The delta rotation amount
  88166. */
  88167. setDeltaRotation(rotation: Quaternion): void;
  88168. /**
  88169. * Gets the box size of the physics imposter and stores the result in the input parameter
  88170. * @param result Stores the box size
  88171. * @returns The physics imposter
  88172. */
  88173. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  88174. /**
  88175. * Gets the radius of the physics imposter
  88176. * @returns Radius of the physics imposter
  88177. */
  88178. getRadius(): number;
  88179. /**
  88180. * Sync a bone with this impostor
  88181. * @param bone The bone to sync to the impostor.
  88182. * @param boneMesh The mesh that the bone is influencing.
  88183. * @param jointPivot The pivot of the joint / bone in local space.
  88184. * @param distToJoint Optional distance from the impostor to the joint.
  88185. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  88186. */
  88187. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  88188. /**
  88189. * Sync impostor to a bone
  88190. * @param bone The bone that the impostor will be synced to.
  88191. * @param boneMesh The mesh that the bone is influencing.
  88192. * @param jointPivot The pivot of the joint / bone in local space.
  88193. * @param distToJoint Optional distance from the impostor to the joint.
  88194. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  88195. * @param boneAxis Optional vector3 axis the bone is aligned with
  88196. */
  88197. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  88198. /**
  88199. * No-Imposter type
  88200. */
  88201. static NoImpostor: number;
  88202. /**
  88203. * Sphere-Imposter type
  88204. */
  88205. static SphereImpostor: number;
  88206. /**
  88207. * Box-Imposter type
  88208. */
  88209. static BoxImpostor: number;
  88210. /**
  88211. * Plane-Imposter type
  88212. */
  88213. static PlaneImpostor: number;
  88214. /**
  88215. * Mesh-imposter type
  88216. */
  88217. static MeshImpostor: number;
  88218. /**
  88219. * Capsule-Impostor type (Ammo.js plugin only)
  88220. */
  88221. static CapsuleImpostor: number;
  88222. /**
  88223. * Cylinder-Imposter type
  88224. */
  88225. static CylinderImpostor: number;
  88226. /**
  88227. * Particle-Imposter type
  88228. */
  88229. static ParticleImpostor: number;
  88230. /**
  88231. * Heightmap-Imposter type
  88232. */
  88233. static HeightmapImpostor: number;
  88234. /**
  88235. * ConvexHull-Impostor type (Ammo.js plugin only)
  88236. */
  88237. static ConvexHullImpostor: number;
  88238. /**
  88239. * Rope-Imposter type
  88240. */
  88241. static RopeImpostor: number;
  88242. /**
  88243. * Cloth-Imposter type
  88244. */
  88245. static ClothImpostor: number;
  88246. /**
  88247. * Softbody-Imposter type
  88248. */
  88249. static SoftbodyImpostor: number;
  88250. }
  88251. }
  88252. declare module BABYLON {
  88253. /**
  88254. * @hidden
  88255. **/
  88256. export class _CreationDataStorage {
  88257. closePath?: boolean;
  88258. closeArray?: boolean;
  88259. idx: number[];
  88260. dashSize: number;
  88261. gapSize: number;
  88262. path3D: Path3D;
  88263. pathArray: Vector3[][];
  88264. arc: number;
  88265. radius: number;
  88266. cap: number;
  88267. tessellation: number;
  88268. }
  88269. /**
  88270. * @hidden
  88271. **/
  88272. class _InstanceDataStorage {
  88273. visibleInstances: any;
  88274. batchCache: _InstancesBatch;
  88275. instancesBufferSize: number;
  88276. instancesBuffer: Nullable<Buffer>;
  88277. instancesData: Float32Array;
  88278. overridenInstanceCount: number;
  88279. isFrozen: boolean;
  88280. previousBatch: Nullable<_InstancesBatch>;
  88281. hardwareInstancedRendering: boolean;
  88282. sideOrientation: number;
  88283. }
  88284. /**
  88285. * @hidden
  88286. **/
  88287. export class _InstancesBatch {
  88288. mustReturn: boolean;
  88289. visibleInstances: Nullable<InstancedMesh[]>[];
  88290. renderSelf: boolean[];
  88291. hardwareInstancedRendering: boolean[];
  88292. }
  88293. /**
  88294. * Class used to represent renderable models
  88295. */
  88296. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  88297. /**
  88298. * Mesh side orientation : usually the external or front surface
  88299. */
  88300. static readonly FRONTSIDE: number;
  88301. /**
  88302. * Mesh side orientation : usually the internal or back surface
  88303. */
  88304. static readonly BACKSIDE: number;
  88305. /**
  88306. * Mesh side orientation : both internal and external or front and back surfaces
  88307. */
  88308. static readonly DOUBLESIDE: number;
  88309. /**
  88310. * Mesh side orientation : by default, `FRONTSIDE`
  88311. */
  88312. static readonly DEFAULTSIDE: number;
  88313. /**
  88314. * Mesh cap setting : no cap
  88315. */
  88316. static readonly NO_CAP: number;
  88317. /**
  88318. * Mesh cap setting : one cap at the beginning of the mesh
  88319. */
  88320. static readonly CAP_START: number;
  88321. /**
  88322. * Mesh cap setting : one cap at the end of the mesh
  88323. */
  88324. static readonly CAP_END: number;
  88325. /**
  88326. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  88327. */
  88328. static readonly CAP_ALL: number;
  88329. /**
  88330. * Mesh pattern setting : no flip or rotate
  88331. */
  88332. static readonly NO_FLIP: number;
  88333. /**
  88334. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  88335. */
  88336. static readonly FLIP_TILE: number;
  88337. /**
  88338. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  88339. */
  88340. static readonly ROTATE_TILE: number;
  88341. /**
  88342. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  88343. */
  88344. static readonly FLIP_ROW: number;
  88345. /**
  88346. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  88347. */
  88348. static readonly ROTATE_ROW: number;
  88349. /**
  88350. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  88351. */
  88352. static readonly FLIP_N_ROTATE_TILE: number;
  88353. /**
  88354. * Mesh pattern setting : rotate pattern and rotate
  88355. */
  88356. static readonly FLIP_N_ROTATE_ROW: number;
  88357. /**
  88358. * Mesh tile positioning : part tiles same on left/right or top/bottom
  88359. */
  88360. static readonly CENTER: number;
  88361. /**
  88362. * Mesh tile positioning : part tiles on left
  88363. */
  88364. static readonly LEFT: number;
  88365. /**
  88366. * Mesh tile positioning : part tiles on right
  88367. */
  88368. static readonly RIGHT: number;
  88369. /**
  88370. * Mesh tile positioning : part tiles on top
  88371. */
  88372. static readonly TOP: number;
  88373. /**
  88374. * Mesh tile positioning : part tiles on bottom
  88375. */
  88376. static readonly BOTTOM: number;
  88377. /**
  88378. * Gets the default side orientation.
  88379. * @param orientation the orientation to value to attempt to get
  88380. * @returns the default orientation
  88381. * @hidden
  88382. */
  88383. static _GetDefaultSideOrientation(orientation?: number): number;
  88384. private _internalMeshDataInfo;
  88385. /**
  88386. * An event triggered before rendering the mesh
  88387. */
  88388. readonly onBeforeRenderObservable: Observable<Mesh>;
  88389. /**
  88390. * An event triggered before binding the mesh
  88391. */
  88392. readonly onBeforeBindObservable: Observable<Mesh>;
  88393. /**
  88394. * An event triggered after rendering the mesh
  88395. */
  88396. readonly onAfterRenderObservable: Observable<Mesh>;
  88397. /**
  88398. * An event triggered before drawing the mesh
  88399. */
  88400. readonly onBeforeDrawObservable: Observable<Mesh>;
  88401. private _onBeforeDrawObserver;
  88402. /**
  88403. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  88404. */
  88405. onBeforeDraw: () => void;
  88406. readonly hasInstances: boolean;
  88407. /**
  88408. * Gets the delay loading state of the mesh (when delay loading is turned on)
  88409. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  88410. */
  88411. delayLoadState: number;
  88412. /**
  88413. * Gets the list of instances created from this mesh
  88414. * it is not supposed to be modified manually.
  88415. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  88416. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  88417. */
  88418. instances: InstancedMesh[];
  88419. /**
  88420. * Gets the file containing delay loading data for this mesh
  88421. */
  88422. delayLoadingFile: string;
  88423. /** @hidden */
  88424. _binaryInfo: any;
  88425. /**
  88426. * User defined function used to change how LOD level selection is done
  88427. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  88428. */
  88429. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  88430. /**
  88431. * Gets or sets the morph target manager
  88432. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  88433. */
  88434. morphTargetManager: Nullable<MorphTargetManager>;
  88435. /** @hidden */
  88436. _creationDataStorage: Nullable<_CreationDataStorage>;
  88437. /** @hidden */
  88438. _geometry: Nullable<Geometry>;
  88439. /** @hidden */
  88440. _delayInfo: Array<string>;
  88441. /** @hidden */
  88442. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  88443. /** @hidden */
  88444. _instanceDataStorage: _InstanceDataStorage;
  88445. private _effectiveMaterial;
  88446. /** @hidden */
  88447. _shouldGenerateFlatShading: boolean;
  88448. /** @hidden */
  88449. _originalBuilderSideOrientation: number;
  88450. /**
  88451. * Use this property to change the original side orientation defined at construction time
  88452. */
  88453. overrideMaterialSideOrientation: Nullable<number>;
  88454. /**
  88455. * Gets the source mesh (the one used to clone this one from)
  88456. */
  88457. readonly source: Nullable<Mesh>;
  88458. /**
  88459. * Gets or sets a boolean indicating that this mesh does not use index buffer
  88460. */
  88461. isUnIndexed: boolean;
  88462. /**
  88463. * @constructor
  88464. * @param name The value used by scene.getMeshByName() to do a lookup.
  88465. * @param scene The scene to add this mesh to.
  88466. * @param parent The parent of this mesh, if it has one
  88467. * @param source An optional Mesh from which geometry is shared, cloned.
  88468. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  88469. * When false, achieved by calling a clone(), also passing False.
  88470. * This will make creation of children, recursive.
  88471. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  88472. */
  88473. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  88474. instantiateHierarychy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  88475. /**
  88476. * Gets the class name
  88477. * @returns the string "Mesh".
  88478. */
  88479. getClassName(): string;
  88480. /** @hidden */
  88481. readonly _isMesh: boolean;
  88482. /**
  88483. * Returns a description of this mesh
  88484. * @param fullDetails define if full details about this mesh must be used
  88485. * @returns a descriptive string representing this mesh
  88486. */
  88487. toString(fullDetails?: boolean): string;
  88488. /** @hidden */
  88489. _unBindEffect(): void;
  88490. /**
  88491. * Gets a boolean indicating if this mesh has LOD
  88492. */
  88493. readonly hasLODLevels: boolean;
  88494. /**
  88495. * Gets the list of MeshLODLevel associated with the current mesh
  88496. * @returns an array of MeshLODLevel
  88497. */
  88498. getLODLevels(): MeshLODLevel[];
  88499. private _sortLODLevels;
  88500. /**
  88501. * Add a mesh as LOD level triggered at the given distance.
  88502. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  88503. * @param distance The distance from the center of the object to show this level
  88504. * @param mesh The mesh to be added as LOD level (can be null)
  88505. * @return This mesh (for chaining)
  88506. */
  88507. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  88508. /**
  88509. * Returns the LOD level mesh at the passed distance or null if not found.
  88510. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  88511. * @param distance The distance from the center of the object to show this level
  88512. * @returns a Mesh or `null`
  88513. */
  88514. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  88515. /**
  88516. * Remove a mesh from the LOD array
  88517. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  88518. * @param mesh defines the mesh to be removed
  88519. * @return This mesh (for chaining)
  88520. */
  88521. removeLODLevel(mesh: Mesh): Mesh;
  88522. /**
  88523. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  88524. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  88525. * @param camera defines the camera to use to compute distance
  88526. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  88527. * @return This mesh (for chaining)
  88528. */
  88529. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  88530. /**
  88531. * Gets the mesh internal Geometry object
  88532. */
  88533. readonly geometry: Nullable<Geometry>;
  88534. /**
  88535. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  88536. * @returns the total number of vertices
  88537. */
  88538. getTotalVertices(): number;
  88539. /**
  88540. * Returns the content of an associated vertex buffer
  88541. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  88542. * - VertexBuffer.PositionKind
  88543. * - VertexBuffer.UVKind
  88544. * - VertexBuffer.UV2Kind
  88545. * - VertexBuffer.UV3Kind
  88546. * - VertexBuffer.UV4Kind
  88547. * - VertexBuffer.UV5Kind
  88548. * - VertexBuffer.UV6Kind
  88549. * - VertexBuffer.ColorKind
  88550. * - VertexBuffer.MatricesIndicesKind
  88551. * - VertexBuffer.MatricesIndicesExtraKind
  88552. * - VertexBuffer.MatricesWeightsKind
  88553. * - VertexBuffer.MatricesWeightsExtraKind
  88554. * @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
  88555. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  88556. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  88557. */
  88558. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  88559. /**
  88560. * Returns the mesh VertexBuffer object from the requested `kind`
  88561. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  88562. * - VertexBuffer.PositionKind
  88563. * - VertexBuffer.NormalKind
  88564. * - VertexBuffer.UVKind
  88565. * - VertexBuffer.UV2Kind
  88566. * - VertexBuffer.UV3Kind
  88567. * - VertexBuffer.UV4Kind
  88568. * - VertexBuffer.UV5Kind
  88569. * - VertexBuffer.UV6Kind
  88570. * - VertexBuffer.ColorKind
  88571. * - VertexBuffer.MatricesIndicesKind
  88572. * - VertexBuffer.MatricesIndicesExtraKind
  88573. * - VertexBuffer.MatricesWeightsKind
  88574. * - VertexBuffer.MatricesWeightsExtraKind
  88575. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  88576. */
  88577. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  88578. /**
  88579. * Tests if a specific vertex buffer is associated with this mesh
  88580. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  88581. * - VertexBuffer.PositionKind
  88582. * - VertexBuffer.NormalKind
  88583. * - VertexBuffer.UVKind
  88584. * - VertexBuffer.UV2Kind
  88585. * - VertexBuffer.UV3Kind
  88586. * - VertexBuffer.UV4Kind
  88587. * - VertexBuffer.UV5Kind
  88588. * - VertexBuffer.UV6Kind
  88589. * - VertexBuffer.ColorKind
  88590. * - VertexBuffer.MatricesIndicesKind
  88591. * - VertexBuffer.MatricesIndicesExtraKind
  88592. * - VertexBuffer.MatricesWeightsKind
  88593. * - VertexBuffer.MatricesWeightsExtraKind
  88594. * @returns a boolean
  88595. */
  88596. isVerticesDataPresent(kind: string): boolean;
  88597. /**
  88598. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  88599. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  88600. * - VertexBuffer.PositionKind
  88601. * - VertexBuffer.UVKind
  88602. * - VertexBuffer.UV2Kind
  88603. * - VertexBuffer.UV3Kind
  88604. * - VertexBuffer.UV4Kind
  88605. * - VertexBuffer.UV5Kind
  88606. * - VertexBuffer.UV6Kind
  88607. * - VertexBuffer.ColorKind
  88608. * - VertexBuffer.MatricesIndicesKind
  88609. * - VertexBuffer.MatricesIndicesExtraKind
  88610. * - VertexBuffer.MatricesWeightsKind
  88611. * - VertexBuffer.MatricesWeightsExtraKind
  88612. * @returns a boolean
  88613. */
  88614. isVertexBufferUpdatable(kind: string): boolean;
  88615. /**
  88616. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  88617. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  88618. * - VertexBuffer.PositionKind
  88619. * - VertexBuffer.NormalKind
  88620. * - VertexBuffer.UVKind
  88621. * - VertexBuffer.UV2Kind
  88622. * - VertexBuffer.UV3Kind
  88623. * - VertexBuffer.UV4Kind
  88624. * - VertexBuffer.UV5Kind
  88625. * - VertexBuffer.UV6Kind
  88626. * - VertexBuffer.ColorKind
  88627. * - VertexBuffer.MatricesIndicesKind
  88628. * - VertexBuffer.MatricesIndicesExtraKind
  88629. * - VertexBuffer.MatricesWeightsKind
  88630. * - VertexBuffer.MatricesWeightsExtraKind
  88631. * @returns an array of strings
  88632. */
  88633. getVerticesDataKinds(): string[];
  88634. /**
  88635. * Returns a positive integer : the total number of indices in this mesh geometry.
  88636. * @returns the numner of indices or zero if the mesh has no geometry.
  88637. */
  88638. getTotalIndices(): number;
  88639. /**
  88640. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  88641. * @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.
  88642. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88643. * @returns the indices array or an empty array if the mesh has no geometry
  88644. */
  88645. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  88646. readonly isBlocked: boolean;
  88647. /**
  88648. * Determine if the current mesh is ready to be rendered
  88649. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  88650. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  88651. * @returns true if all associated assets are ready (material, textures, shaders)
  88652. */
  88653. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  88654. /**
  88655. * 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.
  88656. */
  88657. readonly areNormalsFrozen: boolean;
  88658. /**
  88659. * 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.
  88660. * @returns the current mesh
  88661. */
  88662. freezeNormals(): Mesh;
  88663. /**
  88664. * 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
  88665. * @returns the current mesh
  88666. */
  88667. unfreezeNormals(): Mesh;
  88668. /**
  88669. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  88670. */
  88671. overridenInstanceCount: number;
  88672. /** @hidden */
  88673. _preActivate(): Mesh;
  88674. /** @hidden */
  88675. _preActivateForIntermediateRendering(renderId: number): Mesh;
  88676. /** @hidden */
  88677. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  88678. /**
  88679. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  88680. * This means the mesh underlying bounding box and sphere are recomputed.
  88681. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  88682. * @returns the current mesh
  88683. */
  88684. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  88685. /** @hidden */
  88686. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  88687. /**
  88688. * This function will subdivide the mesh into multiple submeshes
  88689. * @param count defines the expected number of submeshes
  88690. */
  88691. subdivide(count: number): void;
  88692. /**
  88693. * Copy a FloatArray into a specific associated vertex buffer
  88694. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  88695. * - VertexBuffer.PositionKind
  88696. * - VertexBuffer.UVKind
  88697. * - VertexBuffer.UV2Kind
  88698. * - VertexBuffer.UV3Kind
  88699. * - VertexBuffer.UV4Kind
  88700. * - VertexBuffer.UV5Kind
  88701. * - VertexBuffer.UV6Kind
  88702. * - VertexBuffer.ColorKind
  88703. * - VertexBuffer.MatricesIndicesKind
  88704. * - VertexBuffer.MatricesIndicesExtraKind
  88705. * - VertexBuffer.MatricesWeightsKind
  88706. * - VertexBuffer.MatricesWeightsExtraKind
  88707. * @param data defines the data source
  88708. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  88709. * @param stride defines the data stride size (can be null)
  88710. * @returns the current mesh
  88711. */
  88712. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  88713. /**
  88714. * Flags an associated vertex buffer as updatable
  88715. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  88716. * - VertexBuffer.PositionKind
  88717. * - VertexBuffer.UVKind
  88718. * - VertexBuffer.UV2Kind
  88719. * - VertexBuffer.UV3Kind
  88720. * - VertexBuffer.UV4Kind
  88721. * - VertexBuffer.UV5Kind
  88722. * - VertexBuffer.UV6Kind
  88723. * - VertexBuffer.ColorKind
  88724. * - VertexBuffer.MatricesIndicesKind
  88725. * - VertexBuffer.MatricesIndicesExtraKind
  88726. * - VertexBuffer.MatricesWeightsKind
  88727. * - VertexBuffer.MatricesWeightsExtraKind
  88728. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  88729. */
  88730. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  88731. /**
  88732. * Sets the mesh global Vertex Buffer
  88733. * @param buffer defines the buffer to use
  88734. * @returns the current mesh
  88735. */
  88736. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  88737. /**
  88738. * Update a specific associated vertex buffer
  88739. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  88740. * - VertexBuffer.PositionKind
  88741. * - VertexBuffer.UVKind
  88742. * - VertexBuffer.UV2Kind
  88743. * - VertexBuffer.UV3Kind
  88744. * - VertexBuffer.UV4Kind
  88745. * - VertexBuffer.UV5Kind
  88746. * - VertexBuffer.UV6Kind
  88747. * - VertexBuffer.ColorKind
  88748. * - VertexBuffer.MatricesIndicesKind
  88749. * - VertexBuffer.MatricesIndicesExtraKind
  88750. * - VertexBuffer.MatricesWeightsKind
  88751. * - VertexBuffer.MatricesWeightsExtraKind
  88752. * @param data defines the data source
  88753. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  88754. * @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)
  88755. * @returns the current mesh
  88756. */
  88757. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  88758. /**
  88759. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  88760. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  88761. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  88762. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  88763. * @returns the current mesh
  88764. */
  88765. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  88766. /**
  88767. * Creates a un-shared specific occurence of the geometry for the mesh.
  88768. * @returns the current mesh
  88769. */
  88770. makeGeometryUnique(): Mesh;
  88771. /**
  88772. * Set the index buffer of this mesh
  88773. * @param indices defines the source data
  88774. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  88775. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  88776. * @returns the current mesh
  88777. */
  88778. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  88779. /**
  88780. * Update the current index buffer
  88781. * @param indices defines the source data
  88782. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  88783. * @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)
  88784. * @returns the current mesh
  88785. */
  88786. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  88787. /**
  88788. * Invert the geometry to move from a right handed system to a left handed one.
  88789. * @returns the current mesh
  88790. */
  88791. toLeftHanded(): Mesh;
  88792. /** @hidden */
  88793. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  88794. /** @hidden */
  88795. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  88796. /**
  88797. * Registers for this mesh a javascript function called just before the rendering process
  88798. * @param func defines the function to call before rendering this mesh
  88799. * @returns the current mesh
  88800. */
  88801. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  88802. /**
  88803. * Disposes a previously registered javascript function called before the rendering
  88804. * @param func defines the function to remove
  88805. * @returns the current mesh
  88806. */
  88807. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  88808. /**
  88809. * Registers for this mesh a javascript function called just after the rendering is complete
  88810. * @param func defines the function to call after rendering this mesh
  88811. * @returns the current mesh
  88812. */
  88813. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  88814. /**
  88815. * Disposes a previously registered javascript function called after the rendering.
  88816. * @param func defines the function to remove
  88817. * @returns the current mesh
  88818. */
  88819. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  88820. /** @hidden */
  88821. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  88822. /** @hidden */
  88823. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  88824. /** @hidden */
  88825. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  88826. /** @hidden */
  88827. _rebuild(): void;
  88828. /** @hidden */
  88829. _freeze(): void;
  88830. /** @hidden */
  88831. _unFreeze(): void;
  88832. /**
  88833. * 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
  88834. * @param subMesh defines the subMesh to render
  88835. * @param enableAlphaMode defines if alpha mode can be changed
  88836. * @returns the current mesh
  88837. */
  88838. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  88839. private _onBeforeDraw;
  88840. /**
  88841. * Renormalize the mesh and patch it up if there are no weights
  88842. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  88843. * However in the case of zero weights then we set just a single influence to 1.
  88844. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  88845. */
  88846. cleanMatrixWeights(): void;
  88847. private normalizeSkinFourWeights;
  88848. private normalizeSkinWeightsAndExtra;
  88849. /**
  88850. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  88851. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  88852. * the user know there was an issue with importing the mesh
  88853. * @returns a validation object with skinned, valid and report string
  88854. */
  88855. validateSkinning(): {
  88856. skinned: boolean;
  88857. valid: boolean;
  88858. report: string;
  88859. };
  88860. /** @hidden */
  88861. _checkDelayState(): Mesh;
  88862. private _queueLoad;
  88863. /**
  88864. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  88865. * A mesh is in the frustum if its bounding box intersects the frustum
  88866. * @param frustumPlanes defines the frustum to test
  88867. * @returns true if the mesh is in the frustum planes
  88868. */
  88869. isInFrustum(frustumPlanes: Plane[]): boolean;
  88870. /**
  88871. * Sets the mesh material by the material or multiMaterial `id` property
  88872. * @param id is a string identifying the material or the multiMaterial
  88873. * @returns the current mesh
  88874. */
  88875. setMaterialByID(id: string): Mesh;
  88876. /**
  88877. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  88878. * @returns an array of IAnimatable
  88879. */
  88880. getAnimatables(): IAnimatable[];
  88881. /**
  88882. * Modifies the mesh geometry according to the passed transformation matrix.
  88883. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  88884. * The mesh normals are modified using the same transformation.
  88885. * Note that, under the hood, this method sets a new VertexBuffer each call.
  88886. * @param transform defines the transform matrix to use
  88887. * @see http://doc.babylonjs.com/resources/baking_transformations
  88888. * @returns the current mesh
  88889. */
  88890. bakeTransformIntoVertices(transform: Matrix): Mesh;
  88891. /**
  88892. * Modifies the mesh geometry according to its own current World Matrix.
  88893. * The mesh World Matrix is then reset.
  88894. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  88895. * Note that, under the hood, this method sets a new VertexBuffer each call.
  88896. * @see http://doc.babylonjs.com/resources/baking_transformations
  88897. * @returns the current mesh
  88898. */
  88899. bakeCurrentTransformIntoVertices(): Mesh;
  88900. /** @hidden */
  88901. readonly _positions: Nullable<Vector3[]>;
  88902. /** @hidden */
  88903. _resetPointsArrayCache(): Mesh;
  88904. /** @hidden */
  88905. _generatePointsArray(): boolean;
  88906. /**
  88907. * Returns a new Mesh object generated from the current mesh properties.
  88908. * This method must not get confused with createInstance()
  88909. * @param name is a string, the name given to the new mesh
  88910. * @param newParent can be any Node object (default `null`)
  88911. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  88912. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  88913. * @returns a new mesh
  88914. */
  88915. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  88916. /**
  88917. * Releases resources associated with this mesh.
  88918. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  88919. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  88920. */
  88921. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88922. /**
  88923. * Modifies the mesh geometry according to a displacement map.
  88924. * 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.
  88925. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  88926. * @param url is a string, the URL from the image file is to be downloaded.
  88927. * @param minHeight is the lower limit of the displacement.
  88928. * @param maxHeight is the upper limit of the displacement.
  88929. * @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.
  88930. * @param uvOffset is an optional vector2 used to offset UV.
  88931. * @param uvScale is an optional vector2 used to scale UV.
  88932. * @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.
  88933. * @returns the Mesh.
  88934. */
  88935. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  88936. /**
  88937. * Modifies the mesh geometry according to a displacementMap buffer.
  88938. * 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.
  88939. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  88940. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  88941. * @param heightMapWidth is the width of the buffer image.
  88942. * @param heightMapHeight is the height of the buffer image.
  88943. * @param minHeight is the lower limit of the displacement.
  88944. * @param maxHeight is the upper limit of the displacement.
  88945. * @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.
  88946. * @param uvOffset is an optional vector2 used to offset UV.
  88947. * @param uvScale is an optional vector2 used to scale UV.
  88948. * @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.
  88949. * @returns the Mesh.
  88950. */
  88951. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  88952. /**
  88953. * Modify the mesh to get a flat shading rendering.
  88954. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  88955. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  88956. * @returns current mesh
  88957. */
  88958. convertToFlatShadedMesh(): Mesh;
  88959. /**
  88960. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  88961. * In other words, more vertices, no more indices and a single bigger VBO.
  88962. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  88963. * @returns current mesh
  88964. */
  88965. convertToUnIndexedMesh(): Mesh;
  88966. /**
  88967. * Inverses facet orientations.
  88968. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  88969. * @param flipNormals will also inverts the normals
  88970. * @returns current mesh
  88971. */
  88972. flipFaces(flipNormals?: boolean): Mesh;
  88973. /**
  88974. * Increase the number of facets and hence vertices in a mesh
  88975. * Vertex normals are interpolated from existing vertex normals
  88976. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  88977. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  88978. */
  88979. increaseVertices(numberPerEdge: number): void;
  88980. /**
  88981. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  88982. * This will undo any application of covertToFlatShadedMesh
  88983. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  88984. */
  88985. forceSharedVertices(): void;
  88986. /** @hidden */
  88987. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  88988. /** @hidden */
  88989. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  88990. /**
  88991. * Creates a new InstancedMesh object from the mesh model.
  88992. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  88993. * @param name defines the name of the new instance
  88994. * @returns a new InstancedMesh
  88995. */
  88996. createInstance(name: string): InstancedMesh;
  88997. /**
  88998. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  88999. * After this call, all the mesh instances have the same submeshes than the current mesh.
  89000. * @returns the current mesh
  89001. */
  89002. synchronizeInstances(): Mesh;
  89003. /**
  89004. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  89005. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  89006. * This should be used together with the simplification to avoid disappearing triangles.
  89007. * @param successCallback an optional success callback to be called after the optimization finished.
  89008. * @returns the current mesh
  89009. */
  89010. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  89011. /**
  89012. * Serialize current mesh
  89013. * @param serializationObject defines the object which will receive the serialization data
  89014. */
  89015. serialize(serializationObject: any): void;
  89016. /** @hidden */
  89017. _syncGeometryWithMorphTargetManager(): void;
  89018. /** @hidden */
  89019. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  89020. /**
  89021. * Returns a new Mesh object parsed from the source provided.
  89022. * @param parsedMesh is the source
  89023. * @param scene defines the hosting scene
  89024. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  89025. * @returns a new Mesh
  89026. */
  89027. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  89028. /**
  89029. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  89030. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  89031. * @param name defines the name of the mesh to create
  89032. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  89033. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  89034. * @param closePath creates a seam between the first and the last points of each path of the path array
  89035. * @param offset is taken in account only if the `pathArray` is containing a single path
  89036. * @param scene defines the hosting scene
  89037. * @param updatable defines if the mesh must be flagged as updatable
  89038. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89039. * @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)
  89040. * @returns a new Mesh
  89041. */
  89042. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  89043. /**
  89044. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  89045. * @param name defines the name of the mesh to create
  89046. * @param radius sets the radius size (float) of the polygon (default 0.5)
  89047. * @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
  89048. * @param scene defines the hosting scene
  89049. * @param updatable defines if the mesh must be flagged as updatable
  89050. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89051. * @returns a new Mesh
  89052. */
  89053. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  89054. /**
  89055. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  89056. * @param name defines the name of the mesh to create
  89057. * @param size sets the size (float) of each box side (default 1)
  89058. * @param scene defines the hosting scene
  89059. * @param updatable defines if the mesh must be flagged as updatable
  89060. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89061. * @returns a new Mesh
  89062. */
  89063. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  89064. /**
  89065. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  89066. * @param name defines the name of the mesh to create
  89067. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  89068. * @param diameter sets the diameter size (float) of the sphere (default 1)
  89069. * @param scene defines the hosting scene
  89070. * @param updatable defines if the mesh must be flagged as updatable
  89071. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89072. * @returns a new Mesh
  89073. */
  89074. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  89075. /**
  89076. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  89077. * @param name defines the name of the mesh to create
  89078. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  89079. * @param diameter sets the diameter size (float) of the sphere (default 1)
  89080. * @param scene defines the hosting scene
  89081. * @returns a new Mesh
  89082. */
  89083. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  89084. /**
  89085. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  89086. * @param name defines the name of the mesh to create
  89087. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  89088. * @param diameterTop set the top cap diameter (floats, default 1)
  89089. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  89090. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  89091. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  89092. * @param scene defines the hosting scene
  89093. * @param updatable defines if the mesh must be flagged as updatable
  89094. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89095. * @returns a new Mesh
  89096. */
  89097. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  89098. /**
  89099. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  89100. * @param name defines the name of the mesh to create
  89101. * @param diameter sets the diameter size (float) of the torus (default 1)
  89102. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  89103. * @param tessellation sets the number of torus sides (postive integer, default 16)
  89104. * @param scene defines the hosting scene
  89105. * @param updatable defines if the mesh must be flagged as updatable
  89106. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89107. * @returns a new Mesh
  89108. */
  89109. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  89110. /**
  89111. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  89112. * @param name defines the name of the mesh to create
  89113. * @param radius sets the global radius size (float) of the torus knot (default 2)
  89114. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  89115. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  89116. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  89117. * @param p the number of windings on X axis (positive integers, default 2)
  89118. * @param q the number of windings on Y axis (positive integers, default 3)
  89119. * @param scene defines the hosting scene
  89120. * @param updatable defines if the mesh must be flagged as updatable
  89121. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89122. * @returns a new Mesh
  89123. */
  89124. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  89125. /**
  89126. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  89127. * @param name defines the name of the mesh to create
  89128. * @param points is an array successive Vector3
  89129. * @param scene defines the hosting scene
  89130. * @param updatable defines if the mesh must be flagged as updatable
  89131. * @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).
  89132. * @returns a new Mesh
  89133. */
  89134. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  89135. /**
  89136. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  89137. * @param name defines the name of the mesh to create
  89138. * @param points is an array successive Vector3
  89139. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  89140. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  89141. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  89142. * @param scene defines the hosting scene
  89143. * @param updatable defines if the mesh must be flagged as updatable
  89144. * @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)
  89145. * @returns a new Mesh
  89146. */
  89147. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  89148. /**
  89149. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  89150. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  89151. * 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.
  89152. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89153. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  89154. * Remember you can only change the shape positions, not their number when updating a polygon.
  89155. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  89156. * @param name defines the name of the mesh to create
  89157. * @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
  89158. * @param scene defines the hosting scene
  89159. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  89160. * @param updatable defines if the mesh must be flagged as updatable
  89161. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89162. * @param earcutInjection can be used to inject your own earcut reference
  89163. * @returns a new Mesh
  89164. */
  89165. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  89166. /**
  89167. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  89168. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  89169. * @param name defines the name of the mesh to create
  89170. * @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
  89171. * @param depth defines the height of extrusion
  89172. * @param scene defines the hosting scene
  89173. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  89174. * @param updatable defines if the mesh must be flagged as updatable
  89175. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89176. * @param earcutInjection can be used to inject your own earcut reference
  89177. * @returns a new Mesh
  89178. */
  89179. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  89180. /**
  89181. * Creates an extruded shape mesh.
  89182. * 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
  89183. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  89184. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  89185. * @param name defines the name of the mesh to create
  89186. * @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
  89187. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  89188. * @param scale is the value to scale the shape
  89189. * @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
  89190. * @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
  89191. * @param scene defines the hosting scene
  89192. * @param updatable defines if the mesh must be flagged as updatable
  89193. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89194. * @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)
  89195. * @returns a new Mesh
  89196. */
  89197. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  89198. /**
  89199. * Creates an custom extruded shape mesh.
  89200. * The custom extrusion is a parametric shape.
  89201. * It has no predefined shape. Its final shape will depend on the input parameters.
  89202. * Please consider using the same method from the MeshBuilder class instead
  89203. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  89204. * @param name defines the name of the mesh to create
  89205. * @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
  89206. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  89207. * @param scaleFunction is a custom Javascript function called on each path point
  89208. * @param rotationFunction is a custom Javascript function called on each path point
  89209. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  89210. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  89211. * @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
  89212. * @param scene defines the hosting scene
  89213. * @param updatable defines if the mesh must be flagged as updatable
  89214. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89215. * @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)
  89216. * @returns a new Mesh
  89217. */
  89218. 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;
  89219. /**
  89220. * Creates lathe mesh.
  89221. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  89222. * Please consider using the same method from the MeshBuilder class instead
  89223. * @param name defines the name of the mesh to create
  89224. * @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
  89225. * @param radius is the radius value of the lathe
  89226. * @param tessellation is the side number of the lathe.
  89227. * @param scene defines the hosting scene
  89228. * @param updatable defines if the mesh must be flagged as updatable
  89229. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89230. * @returns a new Mesh
  89231. */
  89232. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  89233. /**
  89234. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  89235. * @param name defines the name of the mesh to create
  89236. * @param size sets the size (float) of both sides of the plane at once (default 1)
  89237. * @param scene defines the hosting scene
  89238. * @param updatable defines if the mesh must be flagged as updatable
  89239. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89240. * @returns a new Mesh
  89241. */
  89242. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  89243. /**
  89244. * Creates a ground mesh.
  89245. * Please consider using the same method from the MeshBuilder class instead
  89246. * @param name defines the name of the mesh to create
  89247. * @param width set the width of the ground
  89248. * @param height set the height of the ground
  89249. * @param subdivisions sets the number of subdivisions per side
  89250. * @param scene defines the hosting scene
  89251. * @param updatable defines if the mesh must be flagged as updatable
  89252. * @returns a new Mesh
  89253. */
  89254. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  89255. /**
  89256. * Creates a tiled ground mesh.
  89257. * Please consider using the same method from the MeshBuilder class instead
  89258. * @param name defines the name of the mesh to create
  89259. * @param xmin set the ground minimum X coordinate
  89260. * @param zmin set the ground minimum Y coordinate
  89261. * @param xmax set the ground maximum X coordinate
  89262. * @param zmax set the ground maximum Z coordinate
  89263. * @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
  89264. * @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
  89265. * @param scene defines the hosting scene
  89266. * @param updatable defines if the mesh must be flagged as updatable
  89267. * @returns a new Mesh
  89268. */
  89269. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  89270. w: number;
  89271. h: number;
  89272. }, precision: {
  89273. w: number;
  89274. h: number;
  89275. }, scene: Scene, updatable?: boolean): Mesh;
  89276. /**
  89277. * Creates a ground mesh from a height map.
  89278. * Please consider using the same method from the MeshBuilder class instead
  89279. * @see http://doc.babylonjs.com/babylon101/height_map
  89280. * @param name defines the name of the mesh to create
  89281. * @param url sets the URL of the height map image resource
  89282. * @param width set the ground width size
  89283. * @param height set the ground height size
  89284. * @param subdivisions sets the number of subdivision per side
  89285. * @param minHeight is the minimum altitude on the ground
  89286. * @param maxHeight is the maximum altitude on the ground
  89287. * @param scene defines the hosting scene
  89288. * @param updatable defines if the mesh must be flagged as updatable
  89289. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  89290. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  89291. * @returns a new Mesh
  89292. */
  89293. 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;
  89294. /**
  89295. * Creates a tube mesh.
  89296. * The tube is a parametric shape.
  89297. * It has no predefined shape. Its final shape will depend on the input parameters.
  89298. * Please consider using the same method from the MeshBuilder class instead
  89299. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  89300. * @param name defines the name of the mesh to create
  89301. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  89302. * @param radius sets the tube radius size
  89303. * @param tessellation is the number of sides on the tubular surface
  89304. * @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
  89305. * @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
  89306. * @param scene defines the hosting scene
  89307. * @param updatable defines if the mesh must be flagged as updatable
  89308. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89309. * @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)
  89310. * @returns a new Mesh
  89311. */
  89312. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  89313. (i: number, distance: number): number;
  89314. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  89315. /**
  89316. * Creates a polyhedron mesh.
  89317. * Please consider using the same method from the MeshBuilder class instead.
  89318. * * 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
  89319. * * The parameter `size` (positive float, default 1) sets the polygon size
  89320. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  89321. * * 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`
  89322. * * 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
  89323. * * 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)`)
  89324. * * 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
  89325. * * 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
  89326. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89327. * * If you create a double-sided mesh, you can choose what parts of 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
  89328. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  89329. * @param name defines the name of the mesh to create
  89330. * @param options defines the options used to create the mesh
  89331. * @param scene defines the hosting scene
  89332. * @returns a new Mesh
  89333. */
  89334. static CreatePolyhedron(name: string, options: {
  89335. type?: number;
  89336. size?: number;
  89337. sizeX?: number;
  89338. sizeY?: number;
  89339. sizeZ?: number;
  89340. custom?: any;
  89341. faceUV?: Vector4[];
  89342. faceColors?: Color4[];
  89343. updatable?: boolean;
  89344. sideOrientation?: number;
  89345. }, scene: Scene): Mesh;
  89346. /**
  89347. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  89348. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  89349. * * 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`)
  89350. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  89351. * * 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
  89352. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89353. * * If you create a double-sided mesh, you can choose what parts of 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
  89354. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  89355. * @param name defines the name of the mesh
  89356. * @param options defines the options used to create the mesh
  89357. * @param scene defines the hosting scene
  89358. * @returns a new Mesh
  89359. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  89360. */
  89361. static CreateIcoSphere(name: string, options: {
  89362. radius?: number;
  89363. flat?: boolean;
  89364. subdivisions?: number;
  89365. sideOrientation?: number;
  89366. updatable?: boolean;
  89367. }, scene: Scene): Mesh;
  89368. /**
  89369. * Creates a decal mesh.
  89370. * Please consider using the same method from the MeshBuilder class instead.
  89371. * A decal is a mesh usually applied as a model onto the surface of another mesh
  89372. * @param name defines the name of the mesh
  89373. * @param sourceMesh defines the mesh receiving the decal
  89374. * @param position sets the position of the decal in world coordinates
  89375. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  89376. * @param size sets the decal scaling
  89377. * @param angle sets the angle to rotate the decal
  89378. * @returns a new Mesh
  89379. */
  89380. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  89381. /**
  89382. * Prepare internal position array for software CPU skinning
  89383. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  89384. */
  89385. setPositionsForCPUSkinning(): Float32Array;
  89386. /**
  89387. * Prepare internal normal array for software CPU skinning
  89388. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  89389. */
  89390. setNormalsForCPUSkinning(): Float32Array;
  89391. /**
  89392. * Updates the vertex buffer by applying transformation from the bones
  89393. * @param skeleton defines the skeleton to apply to current mesh
  89394. * @returns the current mesh
  89395. */
  89396. applySkeleton(skeleton: Skeleton): Mesh;
  89397. /**
  89398. * 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
  89399. * @param meshes defines the list of meshes to scan
  89400. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  89401. */
  89402. static MinMax(meshes: AbstractMesh[]): {
  89403. min: Vector3;
  89404. max: Vector3;
  89405. };
  89406. /**
  89407. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  89408. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  89409. * @returns a vector3
  89410. */
  89411. static Center(meshesOrMinMaxVector: {
  89412. min: Vector3;
  89413. max: Vector3;
  89414. } | AbstractMesh[]): Vector3;
  89415. /**
  89416. * Merge the array of meshes into a single mesh for performance reasons.
  89417. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  89418. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  89419. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  89420. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  89421. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  89422. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  89423. * @returns a new mesh
  89424. */
  89425. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  89426. /** @hidden */
  89427. addInstance(instance: InstancedMesh): void;
  89428. /** @hidden */
  89429. removeInstance(instance: InstancedMesh): void;
  89430. }
  89431. }
  89432. declare module BABYLON {
  89433. /**
  89434. * This is the base class of all the camera used in the application.
  89435. * @see http://doc.babylonjs.com/features/cameras
  89436. */
  89437. export class Camera extends Node {
  89438. /** @hidden */
  89439. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  89440. /**
  89441. * This is the default projection mode used by the cameras.
  89442. * It helps recreating a feeling of perspective and better appreciate depth.
  89443. * This is the best way to simulate real life cameras.
  89444. */
  89445. static readonly PERSPECTIVE_CAMERA: number;
  89446. /**
  89447. * This helps creating camera with an orthographic mode.
  89448. * 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.
  89449. */
  89450. static readonly ORTHOGRAPHIC_CAMERA: number;
  89451. /**
  89452. * This is the default FOV mode for perspective cameras.
  89453. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  89454. */
  89455. static readonly FOVMODE_VERTICAL_FIXED: number;
  89456. /**
  89457. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  89458. */
  89459. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  89460. /**
  89461. * This specifies ther is no need for a camera rig.
  89462. * Basically only one eye is rendered corresponding to the camera.
  89463. */
  89464. static readonly RIG_MODE_NONE: number;
  89465. /**
  89466. * Simulates a camera Rig with one blue eye and one red eye.
  89467. * This can be use with 3d blue and red glasses.
  89468. */
  89469. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  89470. /**
  89471. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  89472. */
  89473. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  89474. /**
  89475. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  89476. */
  89477. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  89478. /**
  89479. * Defines that both eyes of the camera will be rendered over under each other.
  89480. */
  89481. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  89482. /**
  89483. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  89484. */
  89485. static readonly RIG_MODE_VR: number;
  89486. /**
  89487. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  89488. */
  89489. static readonly RIG_MODE_WEBVR: number;
  89490. /**
  89491. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  89492. */
  89493. static readonly RIG_MODE_CUSTOM: number;
  89494. /**
  89495. * Defines if by default attaching controls should prevent the default javascript event to continue.
  89496. */
  89497. static ForceAttachControlToAlwaysPreventDefault: boolean;
  89498. /**
  89499. * Define the input manager associated with the camera.
  89500. */
  89501. inputs: CameraInputsManager<Camera>;
  89502. /** @hidden */
  89503. _position: Vector3;
  89504. /**
  89505. * Define the current local position of the camera in the scene
  89506. */
  89507. position: Vector3;
  89508. /**
  89509. * The vector the camera should consider as up.
  89510. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  89511. */
  89512. upVector: Vector3;
  89513. /**
  89514. * Define the current limit on the left side for an orthographic camera
  89515. * In scene unit
  89516. */
  89517. orthoLeft: Nullable<number>;
  89518. /**
  89519. * Define the current limit on the right side for an orthographic camera
  89520. * In scene unit
  89521. */
  89522. orthoRight: Nullable<number>;
  89523. /**
  89524. * Define the current limit on the bottom side for an orthographic camera
  89525. * In scene unit
  89526. */
  89527. orthoBottom: Nullable<number>;
  89528. /**
  89529. * Define the current limit on the top side for an orthographic camera
  89530. * In scene unit
  89531. */
  89532. orthoTop: Nullable<number>;
  89533. /**
  89534. * Field Of View is set in Radians. (default is 0.8)
  89535. */
  89536. fov: number;
  89537. /**
  89538. * Define the minimum distance the camera can see from.
  89539. * This is important to note that the depth buffer are not infinite and the closer it starts
  89540. * the more your scene might encounter depth fighting issue.
  89541. */
  89542. minZ: number;
  89543. /**
  89544. * Define the maximum distance the camera can see to.
  89545. * This is important to note that the depth buffer are not infinite and the further it end
  89546. * the more your scene might encounter depth fighting issue.
  89547. */
  89548. maxZ: number;
  89549. /**
  89550. * Define the default inertia of the camera.
  89551. * This helps giving a smooth feeling to the camera movement.
  89552. */
  89553. inertia: number;
  89554. /**
  89555. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  89556. */
  89557. mode: number;
  89558. /**
  89559. * Define wether the camera is intermediate.
  89560. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  89561. */
  89562. isIntermediate: boolean;
  89563. /**
  89564. * Define the viewport of the camera.
  89565. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  89566. */
  89567. viewport: Viewport;
  89568. /**
  89569. * Restricts the camera to viewing objects with the same layerMask.
  89570. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  89571. */
  89572. layerMask: number;
  89573. /**
  89574. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  89575. */
  89576. fovMode: number;
  89577. /**
  89578. * Rig mode of the camera.
  89579. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  89580. * This is normally controlled byt the camera themselves as internal use.
  89581. */
  89582. cameraRigMode: number;
  89583. /**
  89584. * Defines the distance between both "eyes" in case of a RIG
  89585. */
  89586. interaxialDistance: number;
  89587. /**
  89588. * Defines if stereoscopic rendering is done side by side or over under.
  89589. */
  89590. isStereoscopicSideBySide: boolean;
  89591. /**
  89592. * 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
  89593. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  89594. * else in the scene. (Eg. security camera)
  89595. *
  89596. * 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)
  89597. */
  89598. customRenderTargets: RenderTargetTexture[];
  89599. /**
  89600. * When set, the camera will render to this render target instead of the default canvas
  89601. *
  89602. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  89603. */
  89604. outputRenderTarget: Nullable<RenderTargetTexture>;
  89605. /**
  89606. * Observable triggered when the camera view matrix has changed.
  89607. */
  89608. onViewMatrixChangedObservable: Observable<Camera>;
  89609. /**
  89610. * Observable triggered when the camera Projection matrix has changed.
  89611. */
  89612. onProjectionMatrixChangedObservable: Observable<Camera>;
  89613. /**
  89614. * Observable triggered when the inputs have been processed.
  89615. */
  89616. onAfterCheckInputsObservable: Observable<Camera>;
  89617. /**
  89618. * Observable triggered when reset has been called and applied to the camera.
  89619. */
  89620. onRestoreStateObservable: Observable<Camera>;
  89621. /** @hidden */
  89622. _cameraRigParams: any;
  89623. /** @hidden */
  89624. _rigCameras: Camera[];
  89625. /** @hidden */
  89626. _rigPostProcess: Nullable<PostProcess>;
  89627. protected _webvrViewMatrix: Matrix;
  89628. /** @hidden */
  89629. _skipRendering: boolean;
  89630. /** @hidden */
  89631. _projectionMatrix: Matrix;
  89632. /** @hidden */
  89633. _postProcesses: Nullable<PostProcess>[];
  89634. /** @hidden */
  89635. _activeMeshes: SmartArray<AbstractMesh>;
  89636. protected _globalPosition: Vector3;
  89637. /** @hidden */
  89638. _computedViewMatrix: Matrix;
  89639. private _doNotComputeProjectionMatrix;
  89640. private _transformMatrix;
  89641. private _frustumPlanes;
  89642. private _refreshFrustumPlanes;
  89643. private _storedFov;
  89644. private _stateStored;
  89645. /**
  89646. * Instantiates a new camera object.
  89647. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  89648. * @see http://doc.babylonjs.com/features/cameras
  89649. * @param name Defines the name of the camera in the scene
  89650. * @param position Defines the position of the camera
  89651. * @param scene Defines the scene the camera belongs too
  89652. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  89653. */
  89654. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  89655. /**
  89656. * Store current camera state (fov, position, etc..)
  89657. * @returns the camera
  89658. */
  89659. storeState(): Camera;
  89660. /**
  89661. * Restores the camera state values if it has been stored. You must call storeState() first
  89662. */
  89663. protected _restoreStateValues(): boolean;
  89664. /**
  89665. * Restored camera state. You must call storeState() first.
  89666. * @returns true if restored and false otherwise
  89667. */
  89668. restoreState(): boolean;
  89669. /**
  89670. * Gets the class name of the camera.
  89671. * @returns the class name
  89672. */
  89673. getClassName(): string;
  89674. /** @hidden */
  89675. readonly _isCamera: boolean;
  89676. /**
  89677. * Gets a string representation of the camera useful for debug purpose.
  89678. * @param fullDetails Defines that a more verboe level of logging is required
  89679. * @returns the string representation
  89680. */
  89681. toString(fullDetails?: boolean): string;
  89682. /**
  89683. * Gets the current world space position of the camera.
  89684. */
  89685. readonly globalPosition: Vector3;
  89686. /**
  89687. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  89688. * @returns the active meshe list
  89689. */
  89690. getActiveMeshes(): SmartArray<AbstractMesh>;
  89691. /**
  89692. * Check wether a mesh is part of the current active mesh list of the camera
  89693. * @param mesh Defines the mesh to check
  89694. * @returns true if active, false otherwise
  89695. */
  89696. isActiveMesh(mesh: Mesh): boolean;
  89697. /**
  89698. * Is this camera ready to be used/rendered
  89699. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  89700. * @return true if the camera is ready
  89701. */
  89702. isReady(completeCheck?: boolean): boolean;
  89703. /** @hidden */
  89704. _initCache(): void;
  89705. /** @hidden */
  89706. _updateCache(ignoreParentClass?: boolean): void;
  89707. /** @hidden */
  89708. _isSynchronized(): boolean;
  89709. /** @hidden */
  89710. _isSynchronizedViewMatrix(): boolean;
  89711. /** @hidden */
  89712. _isSynchronizedProjectionMatrix(): boolean;
  89713. /**
  89714. * Attach the input controls to a specific dom element to get the input from.
  89715. * @param element Defines the element the controls should be listened from
  89716. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  89717. */
  89718. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  89719. /**
  89720. * Detach the current controls from the specified dom element.
  89721. * @param element Defines the element to stop listening the inputs from
  89722. */
  89723. detachControl(element: HTMLElement): void;
  89724. /**
  89725. * Update the camera state according to the different inputs gathered during the frame.
  89726. */
  89727. update(): void;
  89728. /** @hidden */
  89729. _checkInputs(): void;
  89730. /** @hidden */
  89731. readonly rigCameras: Camera[];
  89732. /**
  89733. * Gets the post process used by the rig cameras
  89734. */
  89735. readonly rigPostProcess: Nullable<PostProcess>;
  89736. /**
  89737. * Internal, gets the first post proces.
  89738. * @returns the first post process to be run on this camera.
  89739. */
  89740. _getFirstPostProcess(): Nullable<PostProcess>;
  89741. private _cascadePostProcessesToRigCams;
  89742. /**
  89743. * Attach a post process to the camera.
  89744. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  89745. * @param postProcess The post process to attach to the camera
  89746. * @param insertAt The position of the post process in case several of them are in use in the scene
  89747. * @returns the position the post process has been inserted at
  89748. */
  89749. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  89750. /**
  89751. * Detach a post process to the camera.
  89752. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  89753. * @param postProcess The post process to detach from the camera
  89754. */
  89755. detachPostProcess(postProcess: PostProcess): void;
  89756. /**
  89757. * Gets the current world matrix of the camera
  89758. */
  89759. getWorldMatrix(): Matrix;
  89760. /** @hidden */
  89761. _getViewMatrix(): Matrix;
  89762. /**
  89763. * Gets the current view matrix of the camera.
  89764. * @param force forces the camera to recompute the matrix without looking at the cached state
  89765. * @returns the view matrix
  89766. */
  89767. getViewMatrix(force?: boolean): Matrix;
  89768. /**
  89769. * Freeze the projection matrix.
  89770. * It will prevent the cache check of the camera projection compute and can speed up perf
  89771. * if no parameter of the camera are meant to change
  89772. * @param projection Defines manually a projection if necessary
  89773. */
  89774. freezeProjectionMatrix(projection?: Matrix): void;
  89775. /**
  89776. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  89777. */
  89778. unfreezeProjectionMatrix(): void;
  89779. /**
  89780. * Gets the current projection matrix of the camera.
  89781. * @param force forces the camera to recompute the matrix without looking at the cached state
  89782. * @returns the projection matrix
  89783. */
  89784. getProjectionMatrix(force?: boolean): Matrix;
  89785. /**
  89786. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  89787. * @returns a Matrix
  89788. */
  89789. getTransformationMatrix(): Matrix;
  89790. private _updateFrustumPlanes;
  89791. /**
  89792. * Checks if a cullable object (mesh...) is in the camera frustum
  89793. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  89794. * @param target The object to check
  89795. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  89796. * @returns true if the object is in frustum otherwise false
  89797. */
  89798. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  89799. /**
  89800. * Checks if a cullable object (mesh...) is in the camera frustum
  89801. * Unlike isInFrustum this cheks the full bounding box
  89802. * @param target The object to check
  89803. * @returns true if the object is in frustum otherwise false
  89804. */
  89805. isCompletelyInFrustum(target: ICullable): boolean;
  89806. /**
  89807. * Gets a ray in the forward direction from the camera.
  89808. * @param length Defines the length of the ray to create
  89809. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  89810. * @param origin Defines the start point of the ray which defaults to the camera position
  89811. * @returns the forward ray
  89812. */
  89813. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  89814. /**
  89815. * Releases resources associated with this node.
  89816. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  89817. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  89818. */
  89819. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  89820. /** @hidden */
  89821. _isLeftCamera: boolean;
  89822. /**
  89823. * Gets the left camera of a rig setup in case of Rigged Camera
  89824. */
  89825. readonly isLeftCamera: boolean;
  89826. /** @hidden */
  89827. _isRightCamera: boolean;
  89828. /**
  89829. * Gets the right camera of a rig setup in case of Rigged Camera
  89830. */
  89831. readonly isRightCamera: boolean;
  89832. /**
  89833. * Gets the left camera of a rig setup in case of Rigged Camera
  89834. */
  89835. readonly leftCamera: Nullable<FreeCamera>;
  89836. /**
  89837. * Gets the right camera of a rig setup in case of Rigged Camera
  89838. */
  89839. readonly rightCamera: Nullable<FreeCamera>;
  89840. /**
  89841. * Gets the left camera target of a rig setup in case of Rigged Camera
  89842. * @returns the target position
  89843. */
  89844. getLeftTarget(): Nullable<Vector3>;
  89845. /**
  89846. * Gets the right camera target of a rig setup in case of Rigged Camera
  89847. * @returns the target position
  89848. */
  89849. getRightTarget(): Nullable<Vector3>;
  89850. /**
  89851. * @hidden
  89852. */
  89853. setCameraRigMode(mode: number, rigParams: any): void;
  89854. /** @hidden */
  89855. static _setStereoscopicRigMode(camera: Camera): void;
  89856. /** @hidden */
  89857. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  89858. /** @hidden */
  89859. static _setVRRigMode(camera: Camera, rigParams: any): void;
  89860. /** @hidden */
  89861. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  89862. /** @hidden */
  89863. _getVRProjectionMatrix(): Matrix;
  89864. protected _updateCameraRotationMatrix(): void;
  89865. protected _updateWebVRCameraRotationMatrix(): void;
  89866. /**
  89867. * This function MUST be overwritten by the different WebVR cameras available.
  89868. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  89869. * @hidden
  89870. */
  89871. _getWebVRProjectionMatrix(): Matrix;
  89872. /**
  89873. * This function MUST be overwritten by the different WebVR cameras available.
  89874. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  89875. * @hidden
  89876. */
  89877. _getWebVRViewMatrix(): Matrix;
  89878. /** @hidden */
  89879. setCameraRigParameter(name: string, value: any): void;
  89880. /**
  89881. * needs to be overridden by children so sub has required properties to be copied
  89882. * @hidden
  89883. */
  89884. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  89885. /**
  89886. * May need to be overridden by children
  89887. * @hidden
  89888. */
  89889. _updateRigCameras(): void;
  89890. /** @hidden */
  89891. _setupInputs(): void;
  89892. /**
  89893. * Serialiaze the camera setup to a json represention
  89894. * @returns the JSON representation
  89895. */
  89896. serialize(): any;
  89897. /**
  89898. * Clones the current camera.
  89899. * @param name The cloned camera name
  89900. * @returns the cloned camera
  89901. */
  89902. clone(name: string): Camera;
  89903. /**
  89904. * Gets the direction of the camera relative to a given local axis.
  89905. * @param localAxis Defines the reference axis to provide a relative direction.
  89906. * @return the direction
  89907. */
  89908. getDirection(localAxis: Vector3): Vector3;
  89909. /**
  89910. * Gets the direction of the camera relative to a given local axis into a passed vector.
  89911. * @param localAxis Defines the reference axis to provide a relative direction.
  89912. * @param result Defines the vector to store the result in
  89913. */
  89914. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  89915. /**
  89916. * Gets a camera constructor for a given camera type
  89917. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  89918. * @param name The name of the camera the result will be able to instantiate
  89919. * @param scene The scene the result will construct the camera in
  89920. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  89921. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  89922. * @returns a factory method to construc the camera
  89923. */
  89924. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  89925. /**
  89926. * Compute the world matrix of the camera.
  89927. * @returns the camera workd matrix
  89928. */
  89929. computeWorldMatrix(): Matrix;
  89930. /**
  89931. * Parse a JSON and creates the camera from the parsed information
  89932. * @param parsedCamera The JSON to parse
  89933. * @param scene The scene to instantiate the camera in
  89934. * @returns the newly constructed camera
  89935. */
  89936. static Parse(parsedCamera: any, scene: Scene): Camera;
  89937. }
  89938. }
  89939. declare module BABYLON {
  89940. /**
  89941. * Class containing static functions to help procedurally build meshes
  89942. */
  89943. export class DiscBuilder {
  89944. /**
  89945. * Creates a plane polygonal mesh. By default, this is a disc
  89946. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  89947. * * 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
  89948. * * 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
  89949. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  89950. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  89951. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  89952. * @param name defines the name of the mesh
  89953. * @param options defines the options used to create the mesh
  89954. * @param scene defines the hosting scene
  89955. * @returns the plane polygonal mesh
  89956. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  89957. */
  89958. static CreateDisc(name: string, options: {
  89959. radius?: number;
  89960. tessellation?: number;
  89961. arc?: number;
  89962. updatable?: boolean;
  89963. sideOrientation?: number;
  89964. frontUVs?: Vector4;
  89965. backUVs?: Vector4;
  89966. }, scene?: Nullable<Scene>): Mesh;
  89967. }
  89968. }
  89969. declare module BABYLON {
  89970. /**
  89971. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  89972. *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.
  89973. * The SPS is also a particle system. It provides some methods to manage the particles.
  89974. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  89975. *
  89976. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  89977. */
  89978. export class SolidParticleSystem implements IDisposable {
  89979. /**
  89980. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  89981. * Example : var p = SPS.particles[i];
  89982. */
  89983. particles: SolidParticle[];
  89984. /**
  89985. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  89986. */
  89987. nbParticles: number;
  89988. /**
  89989. * If the particles must ever face the camera (default false). Useful for planar particles.
  89990. */
  89991. billboard: boolean;
  89992. /**
  89993. * Recompute normals when adding a shape
  89994. */
  89995. recomputeNormals: boolean;
  89996. /**
  89997. * This a counter ofr your own usage. It's not set by any SPS functions.
  89998. */
  89999. counter: number;
  90000. /**
  90001. * The SPS name. This name is also given to the underlying mesh.
  90002. */
  90003. name: string;
  90004. /**
  90005. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  90006. */
  90007. mesh: Mesh;
  90008. /**
  90009. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  90010. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  90011. */
  90012. vars: any;
  90013. /**
  90014. * This array is populated when the SPS is set as 'pickable'.
  90015. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  90016. * Each element of this array is an object `{idx: int, faceId: int}`.
  90017. * `idx` is the picked particle index in the `SPS.particles` array
  90018. * `faceId` is the picked face index counted within this particle.
  90019. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  90020. */
  90021. pickedParticles: {
  90022. idx: number;
  90023. faceId: number;
  90024. }[];
  90025. /**
  90026. * This array is populated when `enableDepthSort` is set to true.
  90027. * Each element of this array is an instance of the class DepthSortedParticle.
  90028. */
  90029. depthSortedParticles: DepthSortedParticle[];
  90030. /**
  90031. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  90032. * @hidden
  90033. */
  90034. _bSphereOnly: boolean;
  90035. /**
  90036. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  90037. * @hidden
  90038. */
  90039. _bSphereRadiusFactor: number;
  90040. private _scene;
  90041. private _positions;
  90042. private _indices;
  90043. private _normals;
  90044. private _colors;
  90045. private _uvs;
  90046. private _indices32;
  90047. private _positions32;
  90048. private _normals32;
  90049. private _fixedNormal32;
  90050. private _colors32;
  90051. private _uvs32;
  90052. private _index;
  90053. private _updatable;
  90054. private _pickable;
  90055. private _isVisibilityBoxLocked;
  90056. private _alwaysVisible;
  90057. private _depthSort;
  90058. private _shapeCounter;
  90059. private _copy;
  90060. private _color;
  90061. private _computeParticleColor;
  90062. private _computeParticleTexture;
  90063. private _computeParticleRotation;
  90064. private _computeParticleVertex;
  90065. private _computeBoundingBox;
  90066. private _depthSortParticles;
  90067. private _camera;
  90068. private _mustUnrotateFixedNormals;
  90069. private _particlesIntersect;
  90070. private _needs32Bits;
  90071. /**
  90072. * Creates a SPS (Solid Particle System) object.
  90073. * @param name (String) is the SPS name, this will be the underlying mesh name.
  90074. * @param scene (Scene) is the scene in which the SPS is added.
  90075. * @param options defines the options of the sps e.g.
  90076. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  90077. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  90078. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  90079. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  90080. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  90081. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  90082. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  90083. */
  90084. constructor(name: string, scene: Scene, options?: {
  90085. updatable?: boolean;
  90086. isPickable?: boolean;
  90087. enableDepthSort?: boolean;
  90088. particleIntersection?: boolean;
  90089. boundingSphereOnly?: boolean;
  90090. bSphereRadiusFactor?: number;
  90091. });
  90092. /**
  90093. * Builds the SPS underlying mesh. Returns a standard Mesh.
  90094. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  90095. * @returns the created mesh
  90096. */
  90097. buildMesh(): Mesh;
  90098. /**
  90099. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  90100. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  90101. * Thus the particles generated from `digest()` have their property `position` set yet.
  90102. * @param mesh ( Mesh ) is the mesh to be digested
  90103. * @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
  90104. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  90105. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  90106. * @returns the current SPS
  90107. */
  90108. digest(mesh: Mesh, options?: {
  90109. facetNb?: number;
  90110. number?: number;
  90111. delta?: number;
  90112. }): SolidParticleSystem;
  90113. private _unrotateFixedNormals;
  90114. private _resetCopy;
  90115. private _meshBuilder;
  90116. private _posToShape;
  90117. private _uvsToShapeUV;
  90118. private _addParticle;
  90119. /**
  90120. * Adds some particles to the SPS from the model shape. Returns the shape id.
  90121. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  90122. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  90123. * @param nb (positive integer) the number of particles to be created from this model
  90124. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  90125. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  90126. * @returns the number of shapes in the system
  90127. */
  90128. addShape(mesh: Mesh, nb: number, options?: {
  90129. positionFunction?: any;
  90130. vertexFunction?: any;
  90131. }): number;
  90132. private _rebuildParticle;
  90133. /**
  90134. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  90135. * @returns the SPS.
  90136. */
  90137. rebuildMesh(): SolidParticleSystem;
  90138. /**
  90139. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  90140. * This method calls `updateParticle()` for each particle of the SPS.
  90141. * For an animated SPS, it is usually called within the render loop.
  90142. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  90143. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  90144. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  90145. * @returns the SPS.
  90146. */
  90147. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  90148. /**
  90149. * Disposes the SPS.
  90150. */
  90151. dispose(): void;
  90152. /**
  90153. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  90154. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  90155. * @returns the SPS.
  90156. */
  90157. refreshVisibleSize(): SolidParticleSystem;
  90158. /**
  90159. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  90160. * @param size the size (float) of the visibility box
  90161. * note : this doesn't lock the SPS mesh bounding box.
  90162. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  90163. */
  90164. setVisibilityBox(size: number): void;
  90165. /**
  90166. * Gets whether the SPS as always visible or not
  90167. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  90168. */
  90169. /**
  90170. * Sets the SPS as always visible or not
  90171. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  90172. */
  90173. isAlwaysVisible: boolean;
  90174. /**
  90175. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  90176. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  90177. */
  90178. /**
  90179. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  90180. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  90181. */
  90182. isVisibilityBoxLocked: boolean;
  90183. /**
  90184. * Tells to `setParticles()` to compute the particle rotations or not.
  90185. * Default value : true. The SPS is faster when it's set to false.
  90186. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  90187. */
  90188. /**
  90189. * Gets if `setParticles()` computes the particle rotations or not.
  90190. * Default value : true. The SPS is faster when it's set to false.
  90191. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  90192. */
  90193. computeParticleRotation: boolean;
  90194. /**
  90195. * Tells to `setParticles()` to compute the particle colors or not.
  90196. * Default value : true. The SPS is faster when it's set to false.
  90197. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  90198. */
  90199. /**
  90200. * Gets if `setParticles()` computes the particle colors or not.
  90201. * Default value : true. The SPS is faster when it's set to false.
  90202. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  90203. */
  90204. computeParticleColor: boolean;
  90205. /**
  90206. * Gets if `setParticles()` computes the particle textures or not.
  90207. * Default value : true. The SPS is faster when it's set to false.
  90208. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  90209. */
  90210. computeParticleTexture: boolean;
  90211. /**
  90212. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  90213. * Default value : false. The SPS is faster when it's set to false.
  90214. * Note : the particle custom vertex positions aren't stored values.
  90215. */
  90216. /**
  90217. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  90218. * Default value : false. The SPS is faster when it's set to false.
  90219. * Note : the particle custom vertex positions aren't stored values.
  90220. */
  90221. computeParticleVertex: boolean;
  90222. /**
  90223. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  90224. */
  90225. /**
  90226. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  90227. */
  90228. computeBoundingBox: boolean;
  90229. /**
  90230. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  90231. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  90232. * Default : `true`
  90233. */
  90234. /**
  90235. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  90236. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  90237. * Default : `true`
  90238. */
  90239. depthSortParticles: boolean;
  90240. /**
  90241. * This function does nothing. It may be overwritten to set all the particle first values.
  90242. * The SPS doesn't call this function, you may have to call it by your own.
  90243. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  90244. */
  90245. initParticles(): void;
  90246. /**
  90247. * This function does nothing. It may be overwritten to recycle a particle.
  90248. * The SPS doesn't call this function, you may have to call it by your own.
  90249. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  90250. * @param particle The particle to recycle
  90251. * @returns the recycled particle
  90252. */
  90253. recycleParticle(particle: SolidParticle): SolidParticle;
  90254. /**
  90255. * Updates a particle : this function should be overwritten by the user.
  90256. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  90257. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  90258. * @example : just set a particle position or velocity and recycle conditions
  90259. * @param particle The particle to update
  90260. * @returns the updated particle
  90261. */
  90262. updateParticle(particle: SolidParticle): SolidParticle;
  90263. /**
  90264. * Updates a vertex of a particle : it can be overwritten by the user.
  90265. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  90266. * @param particle the current particle
  90267. * @param vertex the current index of the current particle
  90268. * @param pt the index of the current vertex in the particle shape
  90269. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  90270. * @example : just set a vertex particle position
  90271. * @returns the updated vertex
  90272. */
  90273. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  90274. /**
  90275. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  90276. * This does nothing and may be overwritten by the user.
  90277. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  90278. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  90279. * @param update the boolean update value actually passed to setParticles()
  90280. */
  90281. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  90282. /**
  90283. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  90284. * This will be passed three parameters.
  90285. * This does nothing and may be overwritten by the user.
  90286. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  90287. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  90288. * @param update the boolean update value actually passed to setParticles()
  90289. */
  90290. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  90291. }
  90292. }
  90293. declare module BABYLON {
  90294. /**
  90295. * Represents one particle of a solid particle system.
  90296. */
  90297. export class SolidParticle {
  90298. /**
  90299. * particle global index
  90300. */
  90301. idx: number;
  90302. /**
  90303. * The color of the particle
  90304. */
  90305. color: Nullable<Color4>;
  90306. /**
  90307. * The world space position of the particle.
  90308. */
  90309. position: Vector3;
  90310. /**
  90311. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  90312. */
  90313. rotation: Vector3;
  90314. /**
  90315. * The world space rotation quaternion of the particle.
  90316. */
  90317. rotationQuaternion: Nullable<Quaternion>;
  90318. /**
  90319. * The scaling of the particle.
  90320. */
  90321. scaling: Vector3;
  90322. /**
  90323. * The uvs of the particle.
  90324. */
  90325. uvs: Vector4;
  90326. /**
  90327. * The current speed of the particle.
  90328. */
  90329. velocity: Vector3;
  90330. /**
  90331. * The pivot point in the particle local space.
  90332. */
  90333. pivot: Vector3;
  90334. /**
  90335. * Must the particle be translated from its pivot point in its local space ?
  90336. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  90337. * Default : false
  90338. */
  90339. translateFromPivot: boolean;
  90340. /**
  90341. * Is the particle active or not ?
  90342. */
  90343. alive: boolean;
  90344. /**
  90345. * Is the particle visible or not ?
  90346. */
  90347. isVisible: boolean;
  90348. /**
  90349. * Index of this particle in the global "positions" array (Internal use)
  90350. * @hidden
  90351. */
  90352. _pos: number;
  90353. /**
  90354. * @hidden Index of this particle in the global "indices" array (Internal use)
  90355. */
  90356. _ind: number;
  90357. /**
  90358. * @hidden ModelShape of this particle (Internal use)
  90359. */
  90360. _model: ModelShape;
  90361. /**
  90362. * ModelShape id of this particle
  90363. */
  90364. shapeId: number;
  90365. /**
  90366. * Index of the particle in its shape id
  90367. */
  90368. idxInShape: number;
  90369. /**
  90370. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  90371. */
  90372. _modelBoundingInfo: BoundingInfo;
  90373. /**
  90374. * @hidden Particle BoundingInfo object (Internal use)
  90375. */
  90376. _boundingInfo: BoundingInfo;
  90377. /**
  90378. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  90379. */
  90380. _sps: SolidParticleSystem;
  90381. /**
  90382. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  90383. */
  90384. _stillInvisible: boolean;
  90385. /**
  90386. * @hidden Last computed particle rotation matrix
  90387. */
  90388. _rotationMatrix: number[];
  90389. /**
  90390. * Parent particle Id, if any.
  90391. * Default null.
  90392. */
  90393. parentId: Nullable<number>;
  90394. /**
  90395. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  90396. * The possible values are :
  90397. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  90398. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  90399. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  90400. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  90401. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  90402. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  90403. * */
  90404. cullingStrategy: number;
  90405. /**
  90406. * @hidden Internal global position in the SPS.
  90407. */
  90408. _globalPosition: Vector3;
  90409. /**
  90410. * Creates a Solid Particle object.
  90411. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  90412. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  90413. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  90414. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  90415. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  90416. * @param shapeId (integer) is the model shape identifier in the SPS.
  90417. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  90418. * @param sps defines the sps it is associated to
  90419. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  90420. */
  90421. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  90422. /**
  90423. * Legacy support, changed scale to scaling
  90424. */
  90425. /**
  90426. * Legacy support, changed scale to scaling
  90427. */
  90428. scale: Vector3;
  90429. /**
  90430. * Legacy support, changed quaternion to rotationQuaternion
  90431. */
  90432. /**
  90433. * Legacy support, changed quaternion to rotationQuaternion
  90434. */
  90435. quaternion: Nullable<Quaternion>;
  90436. /**
  90437. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  90438. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  90439. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  90440. * @returns true if it intersects
  90441. */
  90442. intersectsMesh(target: Mesh | SolidParticle): boolean;
  90443. /**
  90444. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  90445. * A particle is in the frustum if its bounding box intersects the frustum
  90446. * @param frustumPlanes defines the frustum to test
  90447. * @returns true if the particle is in the frustum planes
  90448. */
  90449. isInFrustum(frustumPlanes: Plane[]): boolean;
  90450. /**
  90451. * get the rotation matrix of the particle
  90452. * @hidden
  90453. */
  90454. getRotationMatrix(m: Matrix): void;
  90455. }
  90456. /**
  90457. * Represents the shape of the model used by one particle of a solid particle system.
  90458. * SPS internal tool, don't use it manually.
  90459. */
  90460. export class ModelShape {
  90461. /**
  90462. * The shape id
  90463. * @hidden
  90464. */
  90465. shapeID: number;
  90466. /**
  90467. * flat array of model positions (internal use)
  90468. * @hidden
  90469. */
  90470. _shape: Vector3[];
  90471. /**
  90472. * flat array of model UVs (internal use)
  90473. * @hidden
  90474. */
  90475. _shapeUV: number[];
  90476. /**
  90477. * length of the shape in the model indices array (internal use)
  90478. * @hidden
  90479. */
  90480. _indicesLength: number;
  90481. /**
  90482. * Custom position function (internal use)
  90483. * @hidden
  90484. */
  90485. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  90486. /**
  90487. * Custom vertex function (internal use)
  90488. * @hidden
  90489. */
  90490. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  90491. /**
  90492. * 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.
  90493. * SPS internal tool, don't use it manually.
  90494. * @hidden
  90495. */
  90496. 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>);
  90497. }
  90498. /**
  90499. * Represents a Depth Sorted Particle in the solid particle system.
  90500. */
  90501. export class DepthSortedParticle {
  90502. /**
  90503. * Index of the particle in the "indices" array
  90504. */
  90505. ind: number;
  90506. /**
  90507. * Length of the particle shape in the "indices" array
  90508. */
  90509. indicesLength: number;
  90510. /**
  90511. * Squared distance from the particle to the camera
  90512. */
  90513. sqDistance: number;
  90514. }
  90515. }
  90516. declare module BABYLON {
  90517. /**
  90518. * @hidden
  90519. */
  90520. export class _MeshCollisionData {
  90521. _checkCollisions: boolean;
  90522. _collisionMask: number;
  90523. _collisionGroup: number;
  90524. _collider: Nullable<Collider>;
  90525. _oldPositionForCollisions: Vector3;
  90526. _diffPositionForCollisions: Vector3;
  90527. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  90528. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  90529. }
  90530. }
  90531. declare module BABYLON {
  90532. /** @hidden */
  90533. class _FacetDataStorage {
  90534. facetPositions: Vector3[];
  90535. facetNormals: Vector3[];
  90536. facetPartitioning: number[][];
  90537. facetNb: number;
  90538. partitioningSubdivisions: number;
  90539. partitioningBBoxRatio: number;
  90540. facetDataEnabled: boolean;
  90541. facetParameters: any;
  90542. bbSize: Vector3;
  90543. subDiv: {
  90544. max: number;
  90545. X: number;
  90546. Y: number;
  90547. Z: number;
  90548. };
  90549. facetDepthSort: boolean;
  90550. facetDepthSortEnabled: boolean;
  90551. depthSortedIndices: IndicesArray;
  90552. depthSortedFacets: {
  90553. ind: number;
  90554. sqDistance: number;
  90555. }[];
  90556. facetDepthSortFunction: (f1: {
  90557. ind: number;
  90558. sqDistance: number;
  90559. }, f2: {
  90560. ind: number;
  90561. sqDistance: number;
  90562. }) => number;
  90563. facetDepthSortFrom: Vector3;
  90564. facetDepthSortOrigin: Vector3;
  90565. invertedMatrix: Matrix;
  90566. }
  90567. /**
  90568. * @hidden
  90569. **/
  90570. class _InternalAbstractMeshDataInfo {
  90571. _hasVertexAlpha: boolean;
  90572. _useVertexColors: boolean;
  90573. _numBoneInfluencers: number;
  90574. _applyFog: boolean;
  90575. _receiveShadows: boolean;
  90576. _facetData: _FacetDataStorage;
  90577. _visibility: number;
  90578. _skeleton: Nullable<Skeleton>;
  90579. _layerMask: number;
  90580. _computeBonesUsingShaders: boolean;
  90581. _isActive: boolean;
  90582. _onlyForInstances: boolean;
  90583. _isActiveIntermediate: boolean;
  90584. _onlyForInstancesIntermediate: boolean;
  90585. }
  90586. /**
  90587. * Class used to store all common mesh properties
  90588. */
  90589. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  90590. /** No occlusion */
  90591. static OCCLUSION_TYPE_NONE: number;
  90592. /** Occlusion set to optimisitic */
  90593. static OCCLUSION_TYPE_OPTIMISTIC: number;
  90594. /** Occlusion set to strict */
  90595. static OCCLUSION_TYPE_STRICT: number;
  90596. /** Use an accurante occlusion algorithm */
  90597. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  90598. /** Use a conservative occlusion algorithm */
  90599. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  90600. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  90601. * Test order :
  90602. * Is the bounding sphere outside the frustum ?
  90603. * If not, are the bounding box vertices outside the frustum ?
  90604. * It not, then the cullable object is in the frustum.
  90605. */
  90606. static readonly CULLINGSTRATEGY_STANDARD: number;
  90607. /** Culling strategy : Bounding Sphere Only.
  90608. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  90609. * It's also less accurate than the standard because some not visible objects can still be selected.
  90610. * Test : is the bounding sphere outside the frustum ?
  90611. * If not, then the cullable object is in the frustum.
  90612. */
  90613. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  90614. /** Culling strategy : Optimistic Inclusion.
  90615. * This in an inclusion test first, then the standard exclusion test.
  90616. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  90617. * 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.
  90618. * Anyway, it's as accurate as the standard strategy.
  90619. * Test :
  90620. * Is the cullable object bounding sphere center in the frustum ?
  90621. * If not, apply the default culling strategy.
  90622. */
  90623. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  90624. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  90625. * This in an inclusion test first, then the bounding sphere only exclusion test.
  90626. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  90627. * 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.
  90628. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  90629. * Test :
  90630. * Is the cullable object bounding sphere center in the frustum ?
  90631. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  90632. */
  90633. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  90634. /**
  90635. * No billboard
  90636. */
  90637. static readonly BILLBOARDMODE_NONE: number;
  90638. /** Billboard on X axis */
  90639. static readonly BILLBOARDMODE_X: number;
  90640. /** Billboard on Y axis */
  90641. static readonly BILLBOARDMODE_Y: number;
  90642. /** Billboard on Z axis */
  90643. static readonly BILLBOARDMODE_Z: number;
  90644. /** Billboard on all axes */
  90645. static readonly BILLBOARDMODE_ALL: number;
  90646. /** Billboard on using position instead of orientation */
  90647. static readonly BILLBOARDMODE_USE_POSITION: number;
  90648. /** @hidden */
  90649. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  90650. /**
  90651. * The culling strategy to use to check whether the mesh must be rendered or not.
  90652. * This value can be changed at any time and will be used on the next render mesh selection.
  90653. * The possible values are :
  90654. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  90655. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  90656. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  90657. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  90658. * Please read each static variable documentation to get details about the culling process.
  90659. * */
  90660. cullingStrategy: number;
  90661. /**
  90662. * Gets the number of facets in the mesh
  90663. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  90664. */
  90665. readonly facetNb: number;
  90666. /**
  90667. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  90668. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  90669. */
  90670. partitioningSubdivisions: number;
  90671. /**
  90672. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  90673. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  90674. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  90675. */
  90676. partitioningBBoxRatio: number;
  90677. /**
  90678. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  90679. * Works only for updatable meshes.
  90680. * Doesn't work with multi-materials
  90681. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  90682. */
  90683. mustDepthSortFacets: boolean;
  90684. /**
  90685. * The location (Vector3) where the facet depth sort must be computed from.
  90686. * By default, the active camera position.
  90687. * Used only when facet depth sort is enabled
  90688. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  90689. */
  90690. facetDepthSortFrom: Vector3;
  90691. /**
  90692. * gets a boolean indicating if facetData is enabled
  90693. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  90694. */
  90695. readonly isFacetDataEnabled: boolean;
  90696. /** @hidden */
  90697. _updateNonUniformScalingState(value: boolean): boolean;
  90698. /**
  90699. * An event triggered when this mesh collides with another one
  90700. */
  90701. onCollideObservable: Observable<AbstractMesh>;
  90702. /** Set a function to call when this mesh collides with another one */
  90703. onCollide: () => void;
  90704. /**
  90705. * An event triggered when the collision's position changes
  90706. */
  90707. onCollisionPositionChangeObservable: Observable<Vector3>;
  90708. /** Set a function to call when the collision's position changes */
  90709. onCollisionPositionChange: () => void;
  90710. /**
  90711. * An event triggered when material is changed
  90712. */
  90713. onMaterialChangedObservable: Observable<AbstractMesh>;
  90714. /**
  90715. * Gets or sets the orientation for POV movement & rotation
  90716. */
  90717. definedFacingForward: boolean;
  90718. /** @hidden */
  90719. _occlusionQuery: Nullable<WebGLQuery>;
  90720. /** @hidden */
  90721. _renderingGroup: Nullable<RenderingGroup>;
  90722. /**
  90723. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  90724. */
  90725. /**
  90726. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  90727. */
  90728. visibility: number;
  90729. /** Gets or sets the alpha index used to sort transparent meshes
  90730. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  90731. */
  90732. alphaIndex: number;
  90733. /**
  90734. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  90735. */
  90736. isVisible: boolean;
  90737. /**
  90738. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  90739. */
  90740. isPickable: boolean;
  90741. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  90742. showSubMeshesBoundingBox: boolean;
  90743. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  90744. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  90745. */
  90746. isBlocker: boolean;
  90747. /**
  90748. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  90749. */
  90750. enablePointerMoveEvents: boolean;
  90751. /**
  90752. * Specifies the rendering group id for this mesh (0 by default)
  90753. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  90754. */
  90755. renderingGroupId: number;
  90756. private _material;
  90757. /** Gets or sets current material */
  90758. material: Nullable<Material>;
  90759. /**
  90760. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  90761. * @see http://doc.babylonjs.com/babylon101/shadows
  90762. */
  90763. receiveShadows: boolean;
  90764. /** Defines color to use when rendering outline */
  90765. outlineColor: Color3;
  90766. /** Define width to use when rendering outline */
  90767. outlineWidth: number;
  90768. /** Defines color to use when rendering overlay */
  90769. overlayColor: Color3;
  90770. /** Defines alpha to use when rendering overlay */
  90771. overlayAlpha: number;
  90772. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  90773. hasVertexAlpha: boolean;
  90774. /** 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) */
  90775. useVertexColors: boolean;
  90776. /**
  90777. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  90778. */
  90779. computeBonesUsingShaders: boolean;
  90780. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  90781. numBoneInfluencers: number;
  90782. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  90783. applyFog: boolean;
  90784. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  90785. useOctreeForRenderingSelection: boolean;
  90786. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  90787. useOctreeForPicking: boolean;
  90788. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  90789. useOctreeForCollisions: boolean;
  90790. /**
  90791. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  90792. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  90793. */
  90794. layerMask: number;
  90795. /**
  90796. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  90797. */
  90798. alwaysSelectAsActiveMesh: boolean;
  90799. /**
  90800. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  90801. */
  90802. doNotSyncBoundingInfo: boolean;
  90803. /**
  90804. * Gets or sets the current action manager
  90805. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90806. */
  90807. actionManager: Nullable<AbstractActionManager>;
  90808. private _meshCollisionData;
  90809. /**
  90810. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  90811. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  90812. */
  90813. ellipsoid: Vector3;
  90814. /**
  90815. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  90816. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  90817. */
  90818. ellipsoidOffset: Vector3;
  90819. /**
  90820. * Gets or sets a collision mask used to mask collisions (default is -1).
  90821. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  90822. */
  90823. collisionMask: number;
  90824. /**
  90825. * Gets or sets the current collision group mask (-1 by default).
  90826. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  90827. */
  90828. collisionGroup: number;
  90829. /**
  90830. * Defines edge width used when edgesRenderer is enabled
  90831. * @see https://www.babylonjs-playground.com/#10OJSG#13
  90832. */
  90833. edgesWidth: number;
  90834. /**
  90835. * Defines edge color used when edgesRenderer is enabled
  90836. * @see https://www.babylonjs-playground.com/#10OJSG#13
  90837. */
  90838. edgesColor: Color4;
  90839. /** @hidden */
  90840. _edgesRenderer: Nullable<IEdgesRenderer>;
  90841. /** @hidden */
  90842. _masterMesh: Nullable<AbstractMesh>;
  90843. /** @hidden */
  90844. _boundingInfo: Nullable<BoundingInfo>;
  90845. /** @hidden */
  90846. _renderId: number;
  90847. /**
  90848. * Gets or sets the list of subMeshes
  90849. * @see http://doc.babylonjs.com/how_to/multi_materials
  90850. */
  90851. subMeshes: SubMesh[];
  90852. /** @hidden */
  90853. _intersectionsInProgress: AbstractMesh[];
  90854. /** @hidden */
  90855. _unIndexed: boolean;
  90856. /** @hidden */
  90857. _lightSources: Light[];
  90858. /** Gets the list of lights affecting that mesh */
  90859. readonly lightSources: Light[];
  90860. /** @hidden */
  90861. readonly _positions: Nullable<Vector3[]>;
  90862. /** @hidden */
  90863. _waitingData: {
  90864. lods: Nullable<any>;
  90865. actions: Nullable<any>;
  90866. freezeWorldMatrix: Nullable<boolean>;
  90867. };
  90868. /** @hidden */
  90869. _bonesTransformMatrices: Nullable<Float32Array>;
  90870. /** @hidden */
  90871. _transformMatrixTexture: Nullable<RawTexture>;
  90872. /**
  90873. * Gets or sets a skeleton to apply skining transformations
  90874. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  90875. */
  90876. skeleton: Nullable<Skeleton>;
  90877. /**
  90878. * An event triggered when the mesh is rebuilt.
  90879. */
  90880. onRebuildObservable: Observable<AbstractMesh>;
  90881. /**
  90882. * Creates a new AbstractMesh
  90883. * @param name defines the name of the mesh
  90884. * @param scene defines the hosting scene
  90885. */
  90886. constructor(name: string, scene?: Nullable<Scene>);
  90887. /**
  90888. * Returns the string "AbstractMesh"
  90889. * @returns "AbstractMesh"
  90890. */
  90891. getClassName(): string;
  90892. /**
  90893. * Gets a string representation of the current mesh
  90894. * @param fullDetails defines a boolean indicating if full details must be included
  90895. * @returns a string representation of the current mesh
  90896. */
  90897. toString(fullDetails?: boolean): string;
  90898. /**
  90899. * @hidden
  90900. */
  90901. protected _getEffectiveParent(): Nullable<Node>;
  90902. /** @hidden */
  90903. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  90904. /** @hidden */
  90905. _rebuild(): void;
  90906. /** @hidden */
  90907. _resyncLightSources(): void;
  90908. /** @hidden */
  90909. _resyncLighSource(light: Light): void;
  90910. /** @hidden */
  90911. _unBindEffect(): void;
  90912. /** @hidden */
  90913. _removeLightSource(light: Light, dispose: boolean): void;
  90914. private _markSubMeshesAsDirty;
  90915. /** @hidden */
  90916. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  90917. /** @hidden */
  90918. _markSubMeshesAsAttributesDirty(): void;
  90919. /** @hidden */
  90920. _markSubMeshesAsMiscDirty(): void;
  90921. /**
  90922. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  90923. */
  90924. scaling: Vector3;
  90925. /**
  90926. * Returns true if the mesh is blocked. Implemented by child classes
  90927. */
  90928. readonly isBlocked: boolean;
  90929. /**
  90930. * Returns the mesh itself by default. Implemented by child classes
  90931. * @param camera defines the camera to use to pick the right LOD level
  90932. * @returns the currentAbstractMesh
  90933. */
  90934. getLOD(camera: Camera): Nullable<AbstractMesh>;
  90935. /**
  90936. * Returns 0 by default. Implemented by child classes
  90937. * @returns an integer
  90938. */
  90939. getTotalVertices(): number;
  90940. /**
  90941. * Returns a positive integer : the total number of indices in this mesh geometry.
  90942. * @returns the numner of indices or zero if the mesh has no geometry.
  90943. */
  90944. getTotalIndices(): number;
  90945. /**
  90946. * Returns null by default. Implemented by child classes
  90947. * @returns null
  90948. */
  90949. getIndices(): Nullable<IndicesArray>;
  90950. /**
  90951. * Returns the array of the requested vertex data kind. Implemented by child classes
  90952. * @param kind defines the vertex data kind to use
  90953. * @returns null
  90954. */
  90955. getVerticesData(kind: string): Nullable<FloatArray>;
  90956. /**
  90957. * Sets the vertex data of the mesh geometry for the requested `kind`.
  90958. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  90959. * Note that a new underlying VertexBuffer object is created each call.
  90960. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  90961. * @param kind defines vertex data kind:
  90962. * * VertexBuffer.PositionKind
  90963. * * VertexBuffer.UVKind
  90964. * * VertexBuffer.UV2Kind
  90965. * * VertexBuffer.UV3Kind
  90966. * * VertexBuffer.UV4Kind
  90967. * * VertexBuffer.UV5Kind
  90968. * * VertexBuffer.UV6Kind
  90969. * * VertexBuffer.ColorKind
  90970. * * VertexBuffer.MatricesIndicesKind
  90971. * * VertexBuffer.MatricesIndicesExtraKind
  90972. * * VertexBuffer.MatricesWeightsKind
  90973. * * VertexBuffer.MatricesWeightsExtraKind
  90974. * @param data defines the data source
  90975. * @param updatable defines if the data must be flagged as updatable (or static)
  90976. * @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
  90977. * @returns the current mesh
  90978. */
  90979. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  90980. /**
  90981. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  90982. * If the mesh has no geometry, it is simply returned as it is.
  90983. * @param kind defines vertex data kind:
  90984. * * VertexBuffer.PositionKind
  90985. * * VertexBuffer.UVKind
  90986. * * VertexBuffer.UV2Kind
  90987. * * VertexBuffer.UV3Kind
  90988. * * VertexBuffer.UV4Kind
  90989. * * VertexBuffer.UV5Kind
  90990. * * VertexBuffer.UV6Kind
  90991. * * VertexBuffer.ColorKind
  90992. * * VertexBuffer.MatricesIndicesKind
  90993. * * VertexBuffer.MatricesIndicesExtraKind
  90994. * * VertexBuffer.MatricesWeightsKind
  90995. * * VertexBuffer.MatricesWeightsExtraKind
  90996. * @param data defines the data source
  90997. * @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
  90998. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  90999. * @returns the current mesh
  91000. */
  91001. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  91002. /**
  91003. * Sets the mesh indices,
  91004. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  91005. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  91006. * @param totalVertices Defines the total number of vertices
  91007. * @returns the current mesh
  91008. */
  91009. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  91010. /**
  91011. * Gets a boolean indicating if specific vertex data is present
  91012. * @param kind defines the vertex data kind to use
  91013. * @returns true is data kind is present
  91014. */
  91015. isVerticesDataPresent(kind: string): boolean;
  91016. /**
  91017. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  91018. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  91019. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  91020. * @returns a BoundingInfo
  91021. */
  91022. getBoundingInfo(): BoundingInfo;
  91023. /**
  91024. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  91025. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  91026. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  91027. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  91028. * @returns the current mesh
  91029. */
  91030. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  91031. /**
  91032. * Overwrite the current bounding info
  91033. * @param boundingInfo defines the new bounding info
  91034. * @returns the current mesh
  91035. */
  91036. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  91037. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  91038. readonly useBones: boolean;
  91039. /** @hidden */
  91040. _preActivate(): void;
  91041. /** @hidden */
  91042. _preActivateForIntermediateRendering(renderId: number): void;
  91043. /** @hidden */
  91044. _activate(renderId: number, intermediateRendering: boolean): boolean;
  91045. /** @hidden */
  91046. _postActivate(): void;
  91047. /** @hidden */
  91048. _freeze(): void;
  91049. /** @hidden */
  91050. _unFreeze(): void;
  91051. /**
  91052. * Gets the current world matrix
  91053. * @returns a Matrix
  91054. */
  91055. getWorldMatrix(): Matrix;
  91056. /** @hidden */
  91057. _getWorldMatrixDeterminant(): number;
  91058. /**
  91059. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  91060. */
  91061. readonly isAnInstance: boolean;
  91062. /**
  91063. * Gets a boolean indicating if this mesh has instances
  91064. */
  91065. readonly hasInstances: boolean;
  91066. /**
  91067. * Perform relative position change from the point of view of behind the front of the mesh.
  91068. * This is performed taking into account the meshes current rotation, so you do not have to care.
  91069. * Supports definition of mesh facing forward or backward
  91070. * @param amountRight defines the distance on the right axis
  91071. * @param amountUp defines the distance on the up axis
  91072. * @param amountForward defines the distance on the forward axis
  91073. * @returns the current mesh
  91074. */
  91075. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  91076. /**
  91077. * Calculate relative position change from the point of view of behind the front of the mesh.
  91078. * This is performed taking into account the meshes current rotation, so you do not have to care.
  91079. * Supports definition of mesh facing forward or backward
  91080. * @param amountRight defines the distance on the right axis
  91081. * @param amountUp defines the distance on the up axis
  91082. * @param amountForward defines the distance on the forward axis
  91083. * @returns the new displacement vector
  91084. */
  91085. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  91086. /**
  91087. * Perform relative rotation change from the point of view of behind the front of the mesh.
  91088. * Supports definition of mesh facing forward or backward
  91089. * @param flipBack defines the flip
  91090. * @param twirlClockwise defines the twirl
  91091. * @param tiltRight defines the tilt
  91092. * @returns the current mesh
  91093. */
  91094. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  91095. /**
  91096. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  91097. * Supports definition of mesh facing forward or backward.
  91098. * @param flipBack defines the flip
  91099. * @param twirlClockwise defines the twirl
  91100. * @param tiltRight defines the tilt
  91101. * @returns the new rotation vector
  91102. */
  91103. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  91104. /**
  91105. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  91106. * This means the mesh underlying bounding box and sphere are recomputed.
  91107. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  91108. * @returns the current mesh
  91109. */
  91110. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  91111. /** @hidden */
  91112. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  91113. /** @hidden */
  91114. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  91115. /** @hidden */
  91116. _updateBoundingInfo(): AbstractMesh;
  91117. /** @hidden */
  91118. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  91119. /** @hidden */
  91120. protected _afterComputeWorldMatrix(): void;
  91121. /** @hidden */
  91122. readonly _effectiveMesh: AbstractMesh;
  91123. /**
  91124. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  91125. * A mesh is in the frustum if its bounding box intersects the frustum
  91126. * @param frustumPlanes defines the frustum to test
  91127. * @returns true if the mesh is in the frustum planes
  91128. */
  91129. isInFrustum(frustumPlanes: Plane[]): boolean;
  91130. /**
  91131. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  91132. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  91133. * @param frustumPlanes defines the frustum to test
  91134. * @returns true if the mesh is completely in the frustum planes
  91135. */
  91136. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  91137. /**
  91138. * True if the mesh intersects another mesh or a SolidParticle object
  91139. * @param mesh defines a target mesh or SolidParticle to test
  91140. * @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)
  91141. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  91142. * @returns true if there is an intersection
  91143. */
  91144. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  91145. /**
  91146. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  91147. * @param point defines the point to test
  91148. * @returns true if there is an intersection
  91149. */
  91150. intersectsPoint(point: Vector3): boolean;
  91151. /**
  91152. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  91153. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91154. */
  91155. checkCollisions: boolean;
  91156. /**
  91157. * Gets Collider object used to compute collisions (not physics)
  91158. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91159. */
  91160. readonly collider: Nullable<Collider>;
  91161. /**
  91162. * Move the mesh using collision engine
  91163. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91164. * @param displacement defines the requested displacement vector
  91165. * @returns the current mesh
  91166. */
  91167. moveWithCollisions(displacement: Vector3): AbstractMesh;
  91168. private _onCollisionPositionChange;
  91169. /** @hidden */
  91170. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  91171. /** @hidden */
  91172. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  91173. /** @hidden */
  91174. _checkCollision(collider: Collider): AbstractMesh;
  91175. /** @hidden */
  91176. _generatePointsArray(): boolean;
  91177. /**
  91178. * Checks if the passed Ray intersects with the mesh
  91179. * @param ray defines the ray to use
  91180. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  91181. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  91182. * @returns the picking info
  91183. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  91184. */
  91185. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  91186. /**
  91187. * Clones the current mesh
  91188. * @param name defines the mesh name
  91189. * @param newParent defines the new mesh parent
  91190. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  91191. * @returns the new mesh
  91192. */
  91193. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  91194. /**
  91195. * Disposes all the submeshes of the current meshnp
  91196. * @returns the current mesh
  91197. */
  91198. releaseSubMeshes(): AbstractMesh;
  91199. /**
  91200. * Releases resources associated with this abstract mesh.
  91201. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  91202. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  91203. */
  91204. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  91205. /**
  91206. * Adds the passed mesh as a child to the current mesh
  91207. * @param mesh defines the child mesh
  91208. * @returns the current mesh
  91209. */
  91210. addChild(mesh: AbstractMesh): AbstractMesh;
  91211. /**
  91212. * Removes the passed mesh from the current mesh children list
  91213. * @param mesh defines the child mesh
  91214. * @returns the current mesh
  91215. */
  91216. removeChild(mesh: AbstractMesh): AbstractMesh;
  91217. /** @hidden */
  91218. private _initFacetData;
  91219. /**
  91220. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  91221. * This method can be called within the render loop.
  91222. * 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
  91223. * @returns the current mesh
  91224. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91225. */
  91226. updateFacetData(): AbstractMesh;
  91227. /**
  91228. * Returns the facetLocalNormals array.
  91229. * The normals are expressed in the mesh local spac
  91230. * @returns an array of Vector3
  91231. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91232. */
  91233. getFacetLocalNormals(): Vector3[];
  91234. /**
  91235. * Returns the facetLocalPositions array.
  91236. * The facet positions are expressed in the mesh local space
  91237. * @returns an array of Vector3
  91238. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91239. */
  91240. getFacetLocalPositions(): Vector3[];
  91241. /**
  91242. * Returns the facetLocalPartioning array
  91243. * @returns an array of array of numbers
  91244. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91245. */
  91246. getFacetLocalPartitioning(): number[][];
  91247. /**
  91248. * Returns the i-th facet position in the world system.
  91249. * This method allocates a new Vector3 per call
  91250. * @param i defines the facet index
  91251. * @returns a new Vector3
  91252. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91253. */
  91254. getFacetPosition(i: number): Vector3;
  91255. /**
  91256. * Sets the reference Vector3 with the i-th facet position in the world system
  91257. * @param i defines the facet index
  91258. * @param ref defines the target vector
  91259. * @returns the current mesh
  91260. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91261. */
  91262. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  91263. /**
  91264. * Returns the i-th facet normal in the world system.
  91265. * This method allocates a new Vector3 per call
  91266. * @param i defines the facet index
  91267. * @returns a new Vector3
  91268. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91269. */
  91270. getFacetNormal(i: number): Vector3;
  91271. /**
  91272. * Sets the reference Vector3 with the i-th facet normal in the world system
  91273. * @param i defines the facet index
  91274. * @param ref defines the target vector
  91275. * @returns the current mesh
  91276. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91277. */
  91278. getFacetNormalToRef(i: number, ref: Vector3): this;
  91279. /**
  91280. * 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)
  91281. * @param x defines x coordinate
  91282. * @param y defines y coordinate
  91283. * @param z defines z coordinate
  91284. * @returns the array of facet indexes
  91285. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91286. */
  91287. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  91288. /**
  91289. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  91290. * @param projected sets as the (x,y,z) world projection on the facet
  91291. * @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
  91292. * @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
  91293. * @param x defines x coordinate
  91294. * @param y defines y coordinate
  91295. * @param z defines z coordinate
  91296. * @returns the face index if found (or null instead)
  91297. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91298. */
  91299. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  91300. /**
  91301. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  91302. * @param projected sets as the (x,y,z) local projection on the facet
  91303. * @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
  91304. * @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
  91305. * @param x defines x coordinate
  91306. * @param y defines y coordinate
  91307. * @param z defines z coordinate
  91308. * @returns the face index if found (or null instead)
  91309. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91310. */
  91311. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  91312. /**
  91313. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  91314. * @returns the parameters
  91315. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91316. */
  91317. getFacetDataParameters(): any;
  91318. /**
  91319. * Disables the feature FacetData and frees the related memory
  91320. * @returns the current mesh
  91321. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91322. */
  91323. disableFacetData(): AbstractMesh;
  91324. /**
  91325. * Updates the AbstractMesh indices array
  91326. * @param indices defines the data source
  91327. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  91328. * @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)
  91329. * @returns the current mesh
  91330. */
  91331. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  91332. /**
  91333. * Creates new normals data for the mesh
  91334. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  91335. * @returns the current mesh
  91336. */
  91337. createNormals(updatable: boolean): AbstractMesh;
  91338. /**
  91339. * Align the mesh with a normal
  91340. * @param normal defines the normal to use
  91341. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  91342. * @returns the current mesh
  91343. */
  91344. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  91345. /** @hidden */
  91346. _checkOcclusionQuery(): boolean;
  91347. /**
  91348. * Disables the mesh edge rendering mode
  91349. * @returns the currentAbstractMesh
  91350. */
  91351. disableEdgesRendering(): AbstractMesh;
  91352. /**
  91353. * Enables the edge rendering mode on the mesh.
  91354. * This mode makes the mesh edges visible
  91355. * @param epsilon defines the maximal distance between two angles to detect a face
  91356. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  91357. * @returns the currentAbstractMesh
  91358. * @see https://www.babylonjs-playground.com/#19O9TU#0
  91359. */
  91360. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  91361. }
  91362. }
  91363. declare module BABYLON {
  91364. /**
  91365. * Interface used to define ActionEvent
  91366. */
  91367. export interface IActionEvent {
  91368. /** The mesh or sprite that triggered the action */
  91369. source: any;
  91370. /** The X mouse cursor position at the time of the event */
  91371. pointerX: number;
  91372. /** The Y mouse cursor position at the time of the event */
  91373. pointerY: number;
  91374. /** The mesh that is currently pointed at (can be null) */
  91375. meshUnderPointer: Nullable<AbstractMesh>;
  91376. /** the original (browser) event that triggered the ActionEvent */
  91377. sourceEvent?: any;
  91378. /** additional data for the event */
  91379. additionalData?: any;
  91380. }
  91381. /**
  91382. * ActionEvent is the event being sent when an action is triggered.
  91383. */
  91384. export class ActionEvent implements IActionEvent {
  91385. /** The mesh or sprite that triggered the action */
  91386. source: any;
  91387. /** The X mouse cursor position at the time of the event */
  91388. pointerX: number;
  91389. /** The Y mouse cursor position at the time of the event */
  91390. pointerY: number;
  91391. /** The mesh that is currently pointed at (can be null) */
  91392. meshUnderPointer: Nullable<AbstractMesh>;
  91393. /** the original (browser) event that triggered the ActionEvent */
  91394. sourceEvent?: any;
  91395. /** additional data for the event */
  91396. additionalData?: any;
  91397. /**
  91398. * Creates a new ActionEvent
  91399. * @param source The mesh or sprite that triggered the action
  91400. * @param pointerX The X mouse cursor position at the time of the event
  91401. * @param pointerY The Y mouse cursor position at the time of the event
  91402. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  91403. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  91404. * @param additionalData additional data for the event
  91405. */
  91406. constructor(
  91407. /** The mesh or sprite that triggered the action */
  91408. source: any,
  91409. /** The X mouse cursor position at the time of the event */
  91410. pointerX: number,
  91411. /** The Y mouse cursor position at the time of the event */
  91412. pointerY: number,
  91413. /** The mesh that is currently pointed at (can be null) */
  91414. meshUnderPointer: Nullable<AbstractMesh>,
  91415. /** the original (browser) event that triggered the ActionEvent */
  91416. sourceEvent?: any,
  91417. /** additional data for the event */
  91418. additionalData?: any);
  91419. /**
  91420. * Helper function to auto-create an ActionEvent from a source mesh.
  91421. * @param source The source mesh that triggered the event
  91422. * @param evt The original (browser) event
  91423. * @param additionalData additional data for the event
  91424. * @returns the new ActionEvent
  91425. */
  91426. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  91427. /**
  91428. * Helper function to auto-create an ActionEvent from a source sprite
  91429. * @param source The source sprite that triggered the event
  91430. * @param scene Scene associated with the sprite
  91431. * @param evt The original (browser) event
  91432. * @param additionalData additional data for the event
  91433. * @returns the new ActionEvent
  91434. */
  91435. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  91436. /**
  91437. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  91438. * @param scene the scene where the event occurred
  91439. * @param evt The original (browser) event
  91440. * @returns the new ActionEvent
  91441. */
  91442. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  91443. /**
  91444. * Helper function to auto-create an ActionEvent from a primitive
  91445. * @param prim defines the target primitive
  91446. * @param pointerPos defines the pointer position
  91447. * @param evt The original (browser) event
  91448. * @param additionalData additional data for the event
  91449. * @returns the new ActionEvent
  91450. */
  91451. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  91452. }
  91453. }
  91454. declare module BABYLON {
  91455. /**
  91456. * Abstract class used to decouple action Manager from scene and meshes.
  91457. * Do not instantiate.
  91458. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91459. */
  91460. export abstract class AbstractActionManager implements IDisposable {
  91461. /** Gets the list of active triggers */
  91462. static Triggers: {
  91463. [key: string]: number;
  91464. };
  91465. /** Gets the cursor to use when hovering items */
  91466. hoverCursor: string;
  91467. /** Gets the list of actions */
  91468. actions: IAction[];
  91469. /**
  91470. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  91471. */
  91472. isRecursive: boolean;
  91473. /**
  91474. * Releases all associated resources
  91475. */
  91476. abstract dispose(): void;
  91477. /**
  91478. * Does this action manager has pointer triggers
  91479. */
  91480. abstract readonly hasPointerTriggers: boolean;
  91481. /**
  91482. * Does this action manager has pick triggers
  91483. */
  91484. abstract readonly hasPickTriggers: boolean;
  91485. /**
  91486. * Process a specific trigger
  91487. * @param trigger defines the trigger to process
  91488. * @param evt defines the event details to be processed
  91489. */
  91490. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  91491. /**
  91492. * Does this action manager handles actions of any of the given triggers
  91493. * @param triggers defines the triggers to be tested
  91494. * @return a boolean indicating whether one (or more) of the triggers is handled
  91495. */
  91496. abstract hasSpecificTriggers(triggers: number[]): boolean;
  91497. /**
  91498. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  91499. * speed.
  91500. * @param triggerA defines the trigger to be tested
  91501. * @param triggerB defines the trigger to be tested
  91502. * @return a boolean indicating whether one (or more) of the triggers is handled
  91503. */
  91504. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  91505. /**
  91506. * Does this action manager handles actions of a given trigger
  91507. * @param trigger defines the trigger to be tested
  91508. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  91509. * @return whether the trigger is handled
  91510. */
  91511. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  91512. /**
  91513. * Serialize this manager to a JSON object
  91514. * @param name defines the property name to store this manager
  91515. * @returns a JSON representation of this manager
  91516. */
  91517. abstract serialize(name: string): any;
  91518. /**
  91519. * Registers an action to this action manager
  91520. * @param action defines the action to be registered
  91521. * @return the action amended (prepared) after registration
  91522. */
  91523. abstract registerAction(action: IAction): Nullable<IAction>;
  91524. /**
  91525. * Unregisters an action to this action manager
  91526. * @param action defines the action to be unregistered
  91527. * @return a boolean indicating whether the action has been unregistered
  91528. */
  91529. abstract unregisterAction(action: IAction): Boolean;
  91530. /**
  91531. * Does exist one action manager with at least one trigger
  91532. **/
  91533. static readonly HasTriggers: boolean;
  91534. /**
  91535. * Does exist one action manager with at least one pick trigger
  91536. **/
  91537. static readonly HasPickTriggers: boolean;
  91538. /**
  91539. * Does exist one action manager that handles actions of a given trigger
  91540. * @param trigger defines the trigger to be tested
  91541. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  91542. **/
  91543. static HasSpecificTrigger(trigger: number): boolean;
  91544. }
  91545. }
  91546. declare module BABYLON {
  91547. /**
  91548. * Defines how a node can be built from a string name.
  91549. */
  91550. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  91551. /**
  91552. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  91553. */
  91554. export class Node implements IBehaviorAware<Node> {
  91555. /** @hidden */
  91556. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  91557. private static _NodeConstructors;
  91558. /**
  91559. * Add a new node constructor
  91560. * @param type defines the type name of the node to construct
  91561. * @param constructorFunc defines the constructor function
  91562. */
  91563. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  91564. /**
  91565. * Returns a node constructor based on type name
  91566. * @param type defines the type name
  91567. * @param name defines the new node name
  91568. * @param scene defines the hosting scene
  91569. * @param options defines optional options to transmit to constructors
  91570. * @returns the new constructor or null
  91571. */
  91572. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  91573. /**
  91574. * Gets or sets the name of the node
  91575. */
  91576. name: string;
  91577. /**
  91578. * Gets or sets the id of the node
  91579. */
  91580. id: string;
  91581. /**
  91582. * Gets or sets the unique id of the node
  91583. */
  91584. uniqueId: number;
  91585. /**
  91586. * Gets or sets a string used to store user defined state for the node
  91587. */
  91588. state: string;
  91589. /**
  91590. * Gets or sets an object used to store user defined information for the node
  91591. */
  91592. metadata: any;
  91593. /**
  91594. * For internal use only. Please do not use.
  91595. */
  91596. reservedDataStore: any;
  91597. /**
  91598. * List of inspectable custom properties (used by the Inspector)
  91599. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  91600. */
  91601. inspectableCustomProperties: IInspectable[];
  91602. /**
  91603. * Gets or sets a boolean used to define if the node must be serialized
  91604. */
  91605. doNotSerialize: boolean;
  91606. /** @hidden */
  91607. _isDisposed: boolean;
  91608. /**
  91609. * Gets a list of Animations associated with the node
  91610. */
  91611. animations: Animation[];
  91612. protected _ranges: {
  91613. [name: string]: Nullable<AnimationRange>;
  91614. };
  91615. /**
  91616. * Callback raised when the node is ready to be used
  91617. */
  91618. onReady: Nullable<(node: Node) => void>;
  91619. private _isEnabled;
  91620. private _isParentEnabled;
  91621. private _isReady;
  91622. /** @hidden */
  91623. _currentRenderId: number;
  91624. private _parentUpdateId;
  91625. /** @hidden */
  91626. _childUpdateId: number;
  91627. /** @hidden */
  91628. _waitingParentId: Nullable<string>;
  91629. /** @hidden */
  91630. _scene: Scene;
  91631. /** @hidden */
  91632. _cache: any;
  91633. private _parentNode;
  91634. private _children;
  91635. /** @hidden */
  91636. _worldMatrix: Matrix;
  91637. /** @hidden */
  91638. _worldMatrixDeterminant: number;
  91639. /** @hidden */
  91640. _worldMatrixDeterminantIsDirty: boolean;
  91641. /** @hidden */
  91642. private _sceneRootNodesIndex;
  91643. /**
  91644. * Gets a boolean indicating if the node has been disposed
  91645. * @returns true if the node was disposed
  91646. */
  91647. isDisposed(): boolean;
  91648. /**
  91649. * Gets or sets the parent of the node (without keeping the current position in the scene)
  91650. * @see https://doc.babylonjs.com/how_to/parenting
  91651. */
  91652. parent: Nullable<Node>;
  91653. private addToSceneRootNodes;
  91654. private removeFromSceneRootNodes;
  91655. private _animationPropertiesOverride;
  91656. /**
  91657. * Gets or sets the animation properties override
  91658. */
  91659. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  91660. /**
  91661. * Gets a string idenfifying the name of the class
  91662. * @returns "Node" string
  91663. */
  91664. getClassName(): string;
  91665. /** @hidden */
  91666. readonly _isNode: boolean;
  91667. /**
  91668. * An event triggered when the mesh is disposed
  91669. */
  91670. onDisposeObservable: Observable<Node>;
  91671. private _onDisposeObserver;
  91672. /**
  91673. * Sets a callback that will be raised when the node will be disposed
  91674. */
  91675. onDispose: () => void;
  91676. /**
  91677. * Creates a new Node
  91678. * @param name the name and id to be given to this node
  91679. * @param scene the scene this node will be added to
  91680. * @param addToRootNodes the node will be added to scene.rootNodes
  91681. */
  91682. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  91683. /**
  91684. * Gets the scene of the node
  91685. * @returns a scene
  91686. */
  91687. getScene(): Scene;
  91688. /**
  91689. * Gets the engine of the node
  91690. * @returns a Engine
  91691. */
  91692. getEngine(): Engine;
  91693. private _behaviors;
  91694. /**
  91695. * Attach a behavior to the node
  91696. * @see http://doc.babylonjs.com/features/behaviour
  91697. * @param behavior defines the behavior to attach
  91698. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  91699. * @returns the current Node
  91700. */
  91701. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  91702. /**
  91703. * Remove an attached behavior
  91704. * @see http://doc.babylonjs.com/features/behaviour
  91705. * @param behavior defines the behavior to attach
  91706. * @returns the current Node
  91707. */
  91708. removeBehavior(behavior: Behavior<Node>): Node;
  91709. /**
  91710. * Gets the list of attached behaviors
  91711. * @see http://doc.babylonjs.com/features/behaviour
  91712. */
  91713. readonly behaviors: Behavior<Node>[];
  91714. /**
  91715. * Gets an attached behavior by name
  91716. * @param name defines the name of the behavior to look for
  91717. * @see http://doc.babylonjs.com/features/behaviour
  91718. * @returns null if behavior was not found else the requested behavior
  91719. */
  91720. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  91721. /**
  91722. * Returns the latest update of the World matrix
  91723. * @returns a Matrix
  91724. */
  91725. getWorldMatrix(): Matrix;
  91726. /** @hidden */
  91727. _getWorldMatrixDeterminant(): number;
  91728. /**
  91729. * Returns directly the latest state of the mesh World matrix.
  91730. * A Matrix is returned.
  91731. */
  91732. readonly worldMatrixFromCache: Matrix;
  91733. /** @hidden */
  91734. _initCache(): void;
  91735. /** @hidden */
  91736. updateCache(force?: boolean): void;
  91737. /** @hidden */
  91738. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  91739. /** @hidden */
  91740. _updateCache(ignoreParentClass?: boolean): void;
  91741. /** @hidden */
  91742. _isSynchronized(): boolean;
  91743. /** @hidden */
  91744. _markSyncedWithParent(): void;
  91745. /** @hidden */
  91746. isSynchronizedWithParent(): boolean;
  91747. /** @hidden */
  91748. isSynchronized(): boolean;
  91749. /**
  91750. * Is this node ready to be used/rendered
  91751. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  91752. * @return true if the node is ready
  91753. */
  91754. isReady(completeCheck?: boolean): boolean;
  91755. /**
  91756. * Is this node enabled?
  91757. * 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
  91758. * @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
  91759. * @return whether this node (and its parent) is enabled
  91760. */
  91761. isEnabled(checkAncestors?: boolean): boolean;
  91762. /** @hidden */
  91763. protected _syncParentEnabledState(): void;
  91764. /**
  91765. * Set the enabled state of this node
  91766. * @param value defines the new enabled state
  91767. */
  91768. setEnabled(value: boolean): void;
  91769. /**
  91770. * Is this node a descendant of the given node?
  91771. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  91772. * @param ancestor defines the parent node to inspect
  91773. * @returns a boolean indicating if this node is a descendant of the given node
  91774. */
  91775. isDescendantOf(ancestor: Node): boolean;
  91776. /** @hidden */
  91777. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  91778. /**
  91779. * Will return all nodes that have this node as ascendant
  91780. * @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
  91781. * @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
  91782. * @return all children nodes of all types
  91783. */
  91784. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  91785. /**
  91786. * Get all child-meshes of this node
  91787. * @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)
  91788. * @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
  91789. * @returns an array of AbstractMesh
  91790. */
  91791. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  91792. /**
  91793. * Get all direct children of this node
  91794. * @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
  91795. * @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)
  91796. * @returns an array of Node
  91797. */
  91798. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  91799. /** @hidden */
  91800. _setReady(state: boolean): void;
  91801. /**
  91802. * Get an animation by name
  91803. * @param name defines the name of the animation to look for
  91804. * @returns null if not found else the requested animation
  91805. */
  91806. getAnimationByName(name: string): Nullable<Animation>;
  91807. /**
  91808. * Creates an animation range for this node
  91809. * @param name defines the name of the range
  91810. * @param from defines the starting key
  91811. * @param to defines the end key
  91812. */
  91813. createAnimationRange(name: string, from: number, to: number): void;
  91814. /**
  91815. * Delete a specific animation range
  91816. * @param name defines the name of the range to delete
  91817. * @param deleteFrames defines if animation frames from the range must be deleted as well
  91818. */
  91819. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  91820. /**
  91821. * Get an animation range by name
  91822. * @param name defines the name of the animation range to look for
  91823. * @returns null if not found else the requested animation range
  91824. */
  91825. getAnimationRange(name: string): Nullable<AnimationRange>;
  91826. /**
  91827. * Gets the list of all animation ranges defined on this node
  91828. * @returns an array
  91829. */
  91830. getAnimationRanges(): Nullable<AnimationRange>[];
  91831. /**
  91832. * Will start the animation sequence
  91833. * @param name defines the range frames for animation sequence
  91834. * @param loop defines if the animation should loop (false by default)
  91835. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  91836. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  91837. * @returns the object created for this animation. If range does not exist, it will return null
  91838. */
  91839. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  91840. /**
  91841. * Serialize animation ranges into a JSON compatible object
  91842. * @returns serialization object
  91843. */
  91844. serializeAnimationRanges(): any;
  91845. /**
  91846. * Computes the world matrix of the node
  91847. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  91848. * @returns the world matrix
  91849. */
  91850. computeWorldMatrix(force?: boolean): Matrix;
  91851. /**
  91852. * Releases resources associated with this node.
  91853. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  91854. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  91855. */
  91856. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  91857. /**
  91858. * Parse animation range data from a serialization object and store them into a given node
  91859. * @param node defines where to store the animation ranges
  91860. * @param parsedNode defines the serialization object to read data from
  91861. * @param scene defines the hosting scene
  91862. */
  91863. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  91864. /**
  91865. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  91866. * @param includeDescendants Include bounding info from descendants as well (true by default)
  91867. * @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
  91868. * @returns the new bounding vectors
  91869. */
  91870. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  91871. min: Vector3;
  91872. max: Vector3;
  91873. };
  91874. }
  91875. }
  91876. declare module BABYLON {
  91877. /**
  91878. * @hidden
  91879. */
  91880. export class _IAnimationState {
  91881. key: number;
  91882. repeatCount: number;
  91883. workValue?: any;
  91884. loopMode?: number;
  91885. offsetValue?: any;
  91886. highLimitValue?: any;
  91887. }
  91888. /**
  91889. * Class used to store any kind of animation
  91890. */
  91891. export class Animation {
  91892. /**Name of the animation */
  91893. name: string;
  91894. /**Property to animate */
  91895. targetProperty: string;
  91896. /**The frames per second of the animation */
  91897. framePerSecond: number;
  91898. /**The data type of the animation */
  91899. dataType: number;
  91900. /**The loop mode of the animation */
  91901. loopMode?: number | undefined;
  91902. /**Specifies if blending should be enabled */
  91903. enableBlending?: boolean | undefined;
  91904. /**
  91905. * Use matrix interpolation instead of using direct key value when animating matrices
  91906. */
  91907. static AllowMatricesInterpolation: boolean;
  91908. /**
  91909. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  91910. */
  91911. static AllowMatrixDecomposeForInterpolation: boolean;
  91912. /**
  91913. * Stores the key frames of the animation
  91914. */
  91915. private _keys;
  91916. /**
  91917. * Stores the easing function of the animation
  91918. */
  91919. private _easingFunction;
  91920. /**
  91921. * @hidden Internal use only
  91922. */
  91923. _runtimeAnimations: RuntimeAnimation[];
  91924. /**
  91925. * The set of event that will be linked to this animation
  91926. */
  91927. private _events;
  91928. /**
  91929. * Stores an array of target property paths
  91930. */
  91931. targetPropertyPath: string[];
  91932. /**
  91933. * Stores the blending speed of the animation
  91934. */
  91935. blendingSpeed: number;
  91936. /**
  91937. * Stores the animation ranges for the animation
  91938. */
  91939. private _ranges;
  91940. /**
  91941. * @hidden Internal use
  91942. */
  91943. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  91944. /**
  91945. * Sets up an animation
  91946. * @param property The property to animate
  91947. * @param animationType The animation type to apply
  91948. * @param framePerSecond The frames per second of the animation
  91949. * @param easingFunction The easing function used in the animation
  91950. * @returns The created animation
  91951. */
  91952. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  91953. /**
  91954. * Create and start an animation on a node
  91955. * @param name defines the name of the global animation that will be run on all nodes
  91956. * @param node defines the root node where the animation will take place
  91957. * @param targetProperty defines property to animate
  91958. * @param framePerSecond defines the number of frame per second yo use
  91959. * @param totalFrame defines the number of frames in total
  91960. * @param from defines the initial value
  91961. * @param to defines the final value
  91962. * @param loopMode defines which loop mode you want to use (off by default)
  91963. * @param easingFunction defines the easing function to use (linear by default)
  91964. * @param onAnimationEnd defines the callback to call when animation end
  91965. * @returns the animatable created for this animation
  91966. */
  91967. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  91968. /**
  91969. * Create and start an animation on a node and its descendants
  91970. * @param name defines the name of the global animation that will be run on all nodes
  91971. * @param node defines the root node where the animation will take place
  91972. * @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
  91973. * @param targetProperty defines property to animate
  91974. * @param framePerSecond defines the number of frame per second to use
  91975. * @param totalFrame defines the number of frames in total
  91976. * @param from defines the initial value
  91977. * @param to defines the final value
  91978. * @param loopMode defines which loop mode you want to use (off by default)
  91979. * @param easingFunction defines the easing function to use (linear by default)
  91980. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  91981. * @returns the list of animatables created for all nodes
  91982. * @example https://www.babylonjs-playground.com/#MH0VLI
  91983. */
  91984. 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[]>;
  91985. /**
  91986. * Creates a new animation, merges it with the existing animations and starts it
  91987. * @param name Name of the animation
  91988. * @param node Node which contains the scene that begins the animations
  91989. * @param targetProperty Specifies which property to animate
  91990. * @param framePerSecond The frames per second of the animation
  91991. * @param totalFrame The total number of frames
  91992. * @param from The frame at the beginning of the animation
  91993. * @param to The frame at the end of the animation
  91994. * @param loopMode Specifies the loop mode of the animation
  91995. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  91996. * @param onAnimationEnd Callback to run once the animation is complete
  91997. * @returns Nullable animation
  91998. */
  91999. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  92000. /**
  92001. * Transition property of an host to the target Value
  92002. * @param property The property to transition
  92003. * @param targetValue The target Value of the property
  92004. * @param host The object where the property to animate belongs
  92005. * @param scene Scene used to run the animation
  92006. * @param frameRate Framerate (in frame/s) to use
  92007. * @param transition The transition type we want to use
  92008. * @param duration The duration of the animation, in milliseconds
  92009. * @param onAnimationEnd Callback trigger at the end of the animation
  92010. * @returns Nullable animation
  92011. */
  92012. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  92013. /**
  92014. * Return the array of runtime animations currently using this animation
  92015. */
  92016. readonly runtimeAnimations: RuntimeAnimation[];
  92017. /**
  92018. * Specifies if any of the runtime animations are currently running
  92019. */
  92020. readonly hasRunningRuntimeAnimations: boolean;
  92021. /**
  92022. * Initializes the animation
  92023. * @param name Name of the animation
  92024. * @param targetProperty Property to animate
  92025. * @param framePerSecond The frames per second of the animation
  92026. * @param dataType The data type of the animation
  92027. * @param loopMode The loop mode of the animation
  92028. * @param enableBlending Specifies if blending should be enabled
  92029. */
  92030. constructor(
  92031. /**Name of the animation */
  92032. name: string,
  92033. /**Property to animate */
  92034. targetProperty: string,
  92035. /**The frames per second of the animation */
  92036. framePerSecond: number,
  92037. /**The data type of the animation */
  92038. dataType: number,
  92039. /**The loop mode of the animation */
  92040. loopMode?: number | undefined,
  92041. /**Specifies if blending should be enabled */
  92042. enableBlending?: boolean | undefined);
  92043. /**
  92044. * Converts the animation to a string
  92045. * @param fullDetails support for multiple levels of logging within scene loading
  92046. * @returns String form of the animation
  92047. */
  92048. toString(fullDetails?: boolean): string;
  92049. /**
  92050. * Add an event to this animation
  92051. * @param event Event to add
  92052. */
  92053. addEvent(event: AnimationEvent): void;
  92054. /**
  92055. * Remove all events found at the given frame
  92056. * @param frame The frame to remove events from
  92057. */
  92058. removeEvents(frame: number): void;
  92059. /**
  92060. * Retrieves all the events from the animation
  92061. * @returns Events from the animation
  92062. */
  92063. getEvents(): AnimationEvent[];
  92064. /**
  92065. * Creates an animation range
  92066. * @param name Name of the animation range
  92067. * @param from Starting frame of the animation range
  92068. * @param to Ending frame of the animation
  92069. */
  92070. createRange(name: string, from: number, to: number): void;
  92071. /**
  92072. * Deletes an animation range by name
  92073. * @param name Name of the animation range to delete
  92074. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  92075. */
  92076. deleteRange(name: string, deleteFrames?: boolean): void;
  92077. /**
  92078. * Gets the animation range by name, or null if not defined
  92079. * @param name Name of the animation range
  92080. * @returns Nullable animation range
  92081. */
  92082. getRange(name: string): Nullable<AnimationRange>;
  92083. /**
  92084. * Gets the key frames from the animation
  92085. * @returns The key frames of the animation
  92086. */
  92087. getKeys(): Array<IAnimationKey>;
  92088. /**
  92089. * Gets the highest frame rate of the animation
  92090. * @returns Highest frame rate of the animation
  92091. */
  92092. getHighestFrame(): number;
  92093. /**
  92094. * Gets the easing function of the animation
  92095. * @returns Easing function of the animation
  92096. */
  92097. getEasingFunction(): IEasingFunction;
  92098. /**
  92099. * Sets the easing function of the animation
  92100. * @param easingFunction A custom mathematical formula for animation
  92101. */
  92102. setEasingFunction(easingFunction: EasingFunction): void;
  92103. /**
  92104. * Interpolates a scalar linearly
  92105. * @param startValue Start value of the animation curve
  92106. * @param endValue End value of the animation curve
  92107. * @param gradient Scalar amount to interpolate
  92108. * @returns Interpolated scalar value
  92109. */
  92110. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  92111. /**
  92112. * Interpolates a scalar cubically
  92113. * @param startValue Start value of the animation curve
  92114. * @param outTangent End tangent of the animation
  92115. * @param endValue End value of the animation curve
  92116. * @param inTangent Start tangent of the animation curve
  92117. * @param gradient Scalar amount to interpolate
  92118. * @returns Interpolated scalar value
  92119. */
  92120. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  92121. /**
  92122. * Interpolates a quaternion using a spherical linear interpolation
  92123. * @param startValue Start value of the animation curve
  92124. * @param endValue End value of the animation curve
  92125. * @param gradient Scalar amount to interpolate
  92126. * @returns Interpolated quaternion value
  92127. */
  92128. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  92129. /**
  92130. * Interpolates a quaternion cubically
  92131. * @param startValue Start value of the animation curve
  92132. * @param outTangent End tangent of the animation curve
  92133. * @param endValue End value of the animation curve
  92134. * @param inTangent Start tangent of the animation curve
  92135. * @param gradient Scalar amount to interpolate
  92136. * @returns Interpolated quaternion value
  92137. */
  92138. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  92139. /**
  92140. * Interpolates a Vector3 linearl
  92141. * @param startValue Start value of the animation curve
  92142. * @param endValue End value of the animation curve
  92143. * @param gradient Scalar amount to interpolate
  92144. * @returns Interpolated scalar value
  92145. */
  92146. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  92147. /**
  92148. * Interpolates a Vector3 cubically
  92149. * @param startValue Start value of the animation curve
  92150. * @param outTangent End tangent of the animation
  92151. * @param endValue End value of the animation curve
  92152. * @param inTangent Start tangent of the animation curve
  92153. * @param gradient Scalar amount to interpolate
  92154. * @returns InterpolatedVector3 value
  92155. */
  92156. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  92157. /**
  92158. * Interpolates a Vector2 linearly
  92159. * @param startValue Start value of the animation curve
  92160. * @param endValue End value of the animation curve
  92161. * @param gradient Scalar amount to interpolate
  92162. * @returns Interpolated Vector2 value
  92163. */
  92164. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  92165. /**
  92166. * Interpolates a Vector2 cubically
  92167. * @param startValue Start value of the animation curve
  92168. * @param outTangent End tangent of the animation
  92169. * @param endValue End value of the animation curve
  92170. * @param inTangent Start tangent of the animation curve
  92171. * @param gradient Scalar amount to interpolate
  92172. * @returns Interpolated Vector2 value
  92173. */
  92174. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  92175. /**
  92176. * Interpolates a size linearly
  92177. * @param startValue Start value of the animation curve
  92178. * @param endValue End value of the animation curve
  92179. * @param gradient Scalar amount to interpolate
  92180. * @returns Interpolated Size value
  92181. */
  92182. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  92183. /**
  92184. * Interpolates a Color3 linearly
  92185. * @param startValue Start value of the animation curve
  92186. * @param endValue End value of the animation curve
  92187. * @param gradient Scalar amount to interpolate
  92188. * @returns Interpolated Color3 value
  92189. */
  92190. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  92191. /**
  92192. * @hidden Internal use only
  92193. */
  92194. _getKeyValue(value: any): any;
  92195. /**
  92196. * @hidden Internal use only
  92197. */
  92198. _interpolate(currentFrame: number, state: _IAnimationState): any;
  92199. /**
  92200. * Defines the function to use to interpolate matrices
  92201. * @param startValue defines the start matrix
  92202. * @param endValue defines the end matrix
  92203. * @param gradient defines the gradient between both matrices
  92204. * @param result defines an optional target matrix where to store the interpolation
  92205. * @returns the interpolated matrix
  92206. */
  92207. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  92208. /**
  92209. * Makes a copy of the animation
  92210. * @returns Cloned animation
  92211. */
  92212. clone(): Animation;
  92213. /**
  92214. * Sets the key frames of the animation
  92215. * @param values The animation key frames to set
  92216. */
  92217. setKeys(values: Array<IAnimationKey>): void;
  92218. /**
  92219. * Serializes the animation to an object
  92220. * @returns Serialized object
  92221. */
  92222. serialize(): any;
  92223. /**
  92224. * Float animation type
  92225. */
  92226. private static _ANIMATIONTYPE_FLOAT;
  92227. /**
  92228. * Vector3 animation type
  92229. */
  92230. private static _ANIMATIONTYPE_VECTOR3;
  92231. /**
  92232. * Quaternion animation type
  92233. */
  92234. private static _ANIMATIONTYPE_QUATERNION;
  92235. /**
  92236. * Matrix animation type
  92237. */
  92238. private static _ANIMATIONTYPE_MATRIX;
  92239. /**
  92240. * Color3 animation type
  92241. */
  92242. private static _ANIMATIONTYPE_COLOR3;
  92243. /**
  92244. * Vector2 animation type
  92245. */
  92246. private static _ANIMATIONTYPE_VECTOR2;
  92247. /**
  92248. * Size animation type
  92249. */
  92250. private static _ANIMATIONTYPE_SIZE;
  92251. /**
  92252. * Relative Loop Mode
  92253. */
  92254. private static _ANIMATIONLOOPMODE_RELATIVE;
  92255. /**
  92256. * Cycle Loop Mode
  92257. */
  92258. private static _ANIMATIONLOOPMODE_CYCLE;
  92259. /**
  92260. * Constant Loop Mode
  92261. */
  92262. private static _ANIMATIONLOOPMODE_CONSTANT;
  92263. /**
  92264. * Get the float animation type
  92265. */
  92266. static readonly ANIMATIONTYPE_FLOAT: number;
  92267. /**
  92268. * Get the Vector3 animation type
  92269. */
  92270. static readonly ANIMATIONTYPE_VECTOR3: number;
  92271. /**
  92272. * Get the Vector2 animation type
  92273. */
  92274. static readonly ANIMATIONTYPE_VECTOR2: number;
  92275. /**
  92276. * Get the Size animation type
  92277. */
  92278. static readonly ANIMATIONTYPE_SIZE: number;
  92279. /**
  92280. * Get the Quaternion animation type
  92281. */
  92282. static readonly ANIMATIONTYPE_QUATERNION: number;
  92283. /**
  92284. * Get the Matrix animation type
  92285. */
  92286. static readonly ANIMATIONTYPE_MATRIX: number;
  92287. /**
  92288. * Get the Color3 animation type
  92289. */
  92290. static readonly ANIMATIONTYPE_COLOR3: number;
  92291. /**
  92292. * Get the Relative Loop Mode
  92293. */
  92294. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  92295. /**
  92296. * Get the Cycle Loop Mode
  92297. */
  92298. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  92299. /**
  92300. * Get the Constant Loop Mode
  92301. */
  92302. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  92303. /** @hidden */
  92304. static _UniversalLerp(left: any, right: any, amount: number): any;
  92305. /**
  92306. * Parses an animation object and creates an animation
  92307. * @param parsedAnimation Parsed animation object
  92308. * @returns Animation object
  92309. */
  92310. static Parse(parsedAnimation: any): Animation;
  92311. /**
  92312. * Appends the serialized animations from the source animations
  92313. * @param source Source containing the animations
  92314. * @param destination Target to store the animations
  92315. */
  92316. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  92317. }
  92318. }
  92319. declare module BABYLON {
  92320. /**
  92321. * Interface containing an array of animations
  92322. */
  92323. export interface IAnimatable {
  92324. /**
  92325. * Array of animations
  92326. */
  92327. animations: Nullable<Array<Animation>>;
  92328. }
  92329. }
  92330. declare module BABYLON {
  92331. /**
  92332. * This represents all the required information to add a fresnel effect on a material:
  92333. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  92334. */
  92335. export class FresnelParameters {
  92336. private _isEnabled;
  92337. /**
  92338. * Define if the fresnel effect is enable or not.
  92339. */
  92340. isEnabled: boolean;
  92341. /**
  92342. * Define the color used on edges (grazing angle)
  92343. */
  92344. leftColor: Color3;
  92345. /**
  92346. * Define the color used on center
  92347. */
  92348. rightColor: Color3;
  92349. /**
  92350. * Define bias applied to computed fresnel term
  92351. */
  92352. bias: number;
  92353. /**
  92354. * Defined the power exponent applied to fresnel term
  92355. */
  92356. power: number;
  92357. /**
  92358. * Clones the current fresnel and its valuues
  92359. * @returns a clone fresnel configuration
  92360. */
  92361. clone(): FresnelParameters;
  92362. /**
  92363. * Serializes the current fresnel parameters to a JSON representation.
  92364. * @return the JSON serialization
  92365. */
  92366. serialize(): any;
  92367. /**
  92368. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  92369. * @param parsedFresnelParameters Define the JSON representation
  92370. * @returns the parsed parameters
  92371. */
  92372. static Parse(parsedFresnelParameters: any): FresnelParameters;
  92373. }
  92374. }
  92375. declare module BABYLON {
  92376. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  92377. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92378. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92379. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92380. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92381. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92382. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92383. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92384. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92385. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92386. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92387. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92388. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92389. /**
  92390. * Decorator used to define property that can be serialized as reference to a camera
  92391. * @param sourceName defines the name of the property to decorate
  92392. */
  92393. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92394. /**
  92395. * Class used to help serialization objects
  92396. */
  92397. export class SerializationHelper {
  92398. /** @hidden */
  92399. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  92400. /** @hidden */
  92401. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  92402. /** @hidden */
  92403. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  92404. /** @hidden */
  92405. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  92406. /**
  92407. * Appends the serialized animations from the source animations
  92408. * @param source Source containing the animations
  92409. * @param destination Target to store the animations
  92410. */
  92411. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  92412. /**
  92413. * Static function used to serialized a specific entity
  92414. * @param entity defines the entity to serialize
  92415. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  92416. * @returns a JSON compatible object representing the serialization of the entity
  92417. */
  92418. static Serialize<T>(entity: T, serializationObject?: any): any;
  92419. /**
  92420. * Creates a new entity from a serialization data object
  92421. * @param creationFunction defines a function used to instanciated the new entity
  92422. * @param source defines the source serialization data
  92423. * @param scene defines the hosting scene
  92424. * @param rootUrl defines the root url for resources
  92425. * @returns a new entity
  92426. */
  92427. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  92428. /**
  92429. * Clones an object
  92430. * @param creationFunction defines the function used to instanciate the new object
  92431. * @param source defines the source object
  92432. * @returns the cloned object
  92433. */
  92434. static Clone<T>(creationFunction: () => T, source: T): T;
  92435. /**
  92436. * Instanciates a new object based on a source one (some data will be shared between both object)
  92437. * @param creationFunction defines the function used to instanciate the new object
  92438. * @param source defines the source object
  92439. * @returns the new object
  92440. */
  92441. static Instanciate<T>(creationFunction: () => T, source: T): T;
  92442. }
  92443. }
  92444. declare module BABYLON {
  92445. /**
  92446. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  92447. */
  92448. export interface CubeMapInfo {
  92449. /**
  92450. * The pixel array for the front face.
  92451. * This is stored in format, left to right, up to down format.
  92452. */
  92453. front: Nullable<ArrayBufferView>;
  92454. /**
  92455. * The pixel array for the back face.
  92456. * This is stored in format, left to right, up to down format.
  92457. */
  92458. back: Nullable<ArrayBufferView>;
  92459. /**
  92460. * The pixel array for the left face.
  92461. * This is stored in format, left to right, up to down format.
  92462. */
  92463. left: Nullable<ArrayBufferView>;
  92464. /**
  92465. * The pixel array for the right face.
  92466. * This is stored in format, left to right, up to down format.
  92467. */
  92468. right: Nullable<ArrayBufferView>;
  92469. /**
  92470. * The pixel array for the up face.
  92471. * This is stored in format, left to right, up to down format.
  92472. */
  92473. up: Nullable<ArrayBufferView>;
  92474. /**
  92475. * The pixel array for the down face.
  92476. * This is stored in format, left to right, up to down format.
  92477. */
  92478. down: Nullable<ArrayBufferView>;
  92479. /**
  92480. * The size of the cubemap stored.
  92481. *
  92482. * Each faces will be size * size pixels.
  92483. */
  92484. size: number;
  92485. /**
  92486. * The format of the texture.
  92487. *
  92488. * RGBA, RGB.
  92489. */
  92490. format: number;
  92491. /**
  92492. * The type of the texture data.
  92493. *
  92494. * UNSIGNED_INT, FLOAT.
  92495. */
  92496. type: number;
  92497. /**
  92498. * Specifies whether the texture is in gamma space.
  92499. */
  92500. gammaSpace: boolean;
  92501. }
  92502. /**
  92503. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  92504. */
  92505. export class PanoramaToCubeMapTools {
  92506. private static FACE_FRONT;
  92507. private static FACE_BACK;
  92508. private static FACE_RIGHT;
  92509. private static FACE_LEFT;
  92510. private static FACE_DOWN;
  92511. private static FACE_UP;
  92512. /**
  92513. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  92514. *
  92515. * @param float32Array The source data.
  92516. * @param inputWidth The width of the input panorama.
  92517. * @param inputHeight The height of the input panorama.
  92518. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  92519. * @return The cubemap data
  92520. */
  92521. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  92522. private static CreateCubemapTexture;
  92523. private static CalcProjectionSpherical;
  92524. }
  92525. }
  92526. declare module BABYLON {
  92527. /**
  92528. * Helper class dealing with the extraction of spherical polynomial dataArray
  92529. * from a cube map.
  92530. */
  92531. export class CubeMapToSphericalPolynomialTools {
  92532. private static FileFaces;
  92533. /**
  92534. * Converts a texture to the according Spherical Polynomial data.
  92535. * This extracts the first 3 orders only as they are the only one used in the lighting.
  92536. *
  92537. * @param texture The texture to extract the information from.
  92538. * @return The Spherical Polynomial data.
  92539. */
  92540. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  92541. /**
  92542. * Converts a cubemap to the according Spherical Polynomial data.
  92543. * This extracts the first 3 orders only as they are the only one used in the lighting.
  92544. *
  92545. * @param cubeInfo The Cube map to extract the information from.
  92546. * @return The Spherical Polynomial data.
  92547. */
  92548. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  92549. }
  92550. }
  92551. declare module BABYLON {
  92552. /**
  92553. * Class used to manipulate GUIDs
  92554. */
  92555. export class GUID {
  92556. /**
  92557. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  92558. * Be aware Math.random() could cause collisions, but:
  92559. * "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"
  92560. * @returns a pseudo random id
  92561. */
  92562. static RandomId(): string;
  92563. }
  92564. }
  92565. declare module BABYLON {
  92566. /**
  92567. * Base class of all the textures in babylon.
  92568. * It groups all the common properties the materials, post process, lights... might need
  92569. * in order to make a correct use of the texture.
  92570. */
  92571. export class BaseTexture implements IAnimatable {
  92572. /**
  92573. * Default anisotropic filtering level for the application.
  92574. * It is set to 4 as a good tradeoff between perf and quality.
  92575. */
  92576. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  92577. /**
  92578. * Gets or sets the unique id of the texture
  92579. */
  92580. uniqueId: number;
  92581. /**
  92582. * Define the name of the texture.
  92583. */
  92584. name: string;
  92585. /**
  92586. * Gets or sets an object used to store user defined information.
  92587. */
  92588. metadata: any;
  92589. /**
  92590. * For internal use only. Please do not use.
  92591. */
  92592. reservedDataStore: any;
  92593. private _hasAlpha;
  92594. /**
  92595. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  92596. */
  92597. hasAlpha: boolean;
  92598. /**
  92599. * Defines if the alpha value should be determined via the rgb values.
  92600. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  92601. */
  92602. getAlphaFromRGB: boolean;
  92603. /**
  92604. * Intensity or strength of the texture.
  92605. * It is commonly used by materials to fine tune the intensity of the texture
  92606. */
  92607. level: number;
  92608. /**
  92609. * Define the UV chanel to use starting from 0 and defaulting to 0.
  92610. * This is part of the texture as textures usually maps to one uv set.
  92611. */
  92612. coordinatesIndex: number;
  92613. private _coordinatesMode;
  92614. /**
  92615. * How a texture is mapped.
  92616. *
  92617. * | Value | Type | Description |
  92618. * | ----- | ----------------------------------- | ----------- |
  92619. * | 0 | EXPLICIT_MODE | |
  92620. * | 1 | SPHERICAL_MODE | |
  92621. * | 2 | PLANAR_MODE | |
  92622. * | 3 | CUBIC_MODE | |
  92623. * | 4 | PROJECTION_MODE | |
  92624. * | 5 | SKYBOX_MODE | |
  92625. * | 6 | INVCUBIC_MODE | |
  92626. * | 7 | EQUIRECTANGULAR_MODE | |
  92627. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  92628. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  92629. */
  92630. coordinatesMode: number;
  92631. /**
  92632. * | Value | Type | Description |
  92633. * | ----- | ------------------ | ----------- |
  92634. * | 0 | CLAMP_ADDRESSMODE | |
  92635. * | 1 | WRAP_ADDRESSMODE | |
  92636. * | 2 | MIRROR_ADDRESSMODE | |
  92637. */
  92638. wrapU: number;
  92639. /**
  92640. * | Value | Type | Description |
  92641. * | ----- | ------------------ | ----------- |
  92642. * | 0 | CLAMP_ADDRESSMODE | |
  92643. * | 1 | WRAP_ADDRESSMODE | |
  92644. * | 2 | MIRROR_ADDRESSMODE | |
  92645. */
  92646. wrapV: number;
  92647. /**
  92648. * | Value | Type | Description |
  92649. * | ----- | ------------------ | ----------- |
  92650. * | 0 | CLAMP_ADDRESSMODE | |
  92651. * | 1 | WRAP_ADDRESSMODE | |
  92652. * | 2 | MIRROR_ADDRESSMODE | |
  92653. */
  92654. wrapR: number;
  92655. /**
  92656. * With compliant hardware and browser (supporting anisotropic filtering)
  92657. * this defines the level of anisotropic filtering in the texture.
  92658. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  92659. */
  92660. anisotropicFilteringLevel: number;
  92661. /**
  92662. * Define if the texture is a cube texture or if false a 2d texture.
  92663. */
  92664. isCube: boolean;
  92665. /**
  92666. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  92667. */
  92668. is3D: boolean;
  92669. /**
  92670. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  92671. * HDR texture are usually stored in linear space.
  92672. * This only impacts the PBR and Background materials
  92673. */
  92674. gammaSpace: boolean;
  92675. /**
  92676. * Gets whether or not the texture contains RGBD data.
  92677. */
  92678. readonly isRGBD: boolean;
  92679. /**
  92680. * Is Z inverted in the texture (useful in a cube texture).
  92681. */
  92682. invertZ: boolean;
  92683. /**
  92684. * Are mip maps generated for this texture or not.
  92685. */
  92686. readonly noMipmap: boolean;
  92687. /**
  92688. * @hidden
  92689. */
  92690. lodLevelInAlpha: boolean;
  92691. /**
  92692. * With prefiltered texture, defined the offset used during the prefiltering steps.
  92693. */
  92694. lodGenerationOffset: number;
  92695. /**
  92696. * With prefiltered texture, defined the scale used during the prefiltering steps.
  92697. */
  92698. lodGenerationScale: number;
  92699. /**
  92700. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  92701. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  92702. * average roughness values.
  92703. */
  92704. linearSpecularLOD: boolean;
  92705. /**
  92706. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  92707. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  92708. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  92709. */
  92710. irradianceTexture: Nullable<BaseTexture>;
  92711. /**
  92712. * Define if the texture is a render target.
  92713. */
  92714. isRenderTarget: boolean;
  92715. /**
  92716. * Define the unique id of the texture in the scene.
  92717. */
  92718. readonly uid: string;
  92719. /**
  92720. * Return a string representation of the texture.
  92721. * @returns the texture as a string
  92722. */
  92723. toString(): string;
  92724. /**
  92725. * Get the class name of the texture.
  92726. * @returns "BaseTexture"
  92727. */
  92728. getClassName(): string;
  92729. /**
  92730. * Define the list of animation attached to the texture.
  92731. */
  92732. animations: Animation[];
  92733. /**
  92734. * An event triggered when the texture is disposed.
  92735. */
  92736. onDisposeObservable: Observable<BaseTexture>;
  92737. private _onDisposeObserver;
  92738. /**
  92739. * Callback triggered when the texture has been disposed.
  92740. * Kept for back compatibility, you can use the onDisposeObservable instead.
  92741. */
  92742. onDispose: () => void;
  92743. /**
  92744. * Define the current state of the loading sequence when in delayed load mode.
  92745. */
  92746. delayLoadState: number;
  92747. private _scene;
  92748. /** @hidden */
  92749. _texture: Nullable<InternalTexture>;
  92750. private _uid;
  92751. /**
  92752. * Define if the texture is preventinga material to render or not.
  92753. * If not and the texture is not ready, the engine will use a default black texture instead.
  92754. */
  92755. readonly isBlocking: boolean;
  92756. /**
  92757. * Instantiates a new BaseTexture.
  92758. * Base class of all the textures in babylon.
  92759. * It groups all the common properties the materials, post process, lights... might need
  92760. * in order to make a correct use of the texture.
  92761. * @param scene Define the scene the texture blongs to
  92762. */
  92763. constructor(scene: Nullable<Scene>);
  92764. /**
  92765. * Get the scene the texture belongs to.
  92766. * @returns the scene or null if undefined
  92767. */
  92768. getScene(): Nullable<Scene>;
  92769. /**
  92770. * Get the texture transform matrix used to offset tile the texture for istance.
  92771. * @returns the transformation matrix
  92772. */
  92773. getTextureMatrix(): Matrix;
  92774. /**
  92775. * Get the texture reflection matrix used to rotate/transform the reflection.
  92776. * @returns the reflection matrix
  92777. */
  92778. getReflectionTextureMatrix(): Matrix;
  92779. /**
  92780. * Get the underlying lower level texture from Babylon.
  92781. * @returns the insternal texture
  92782. */
  92783. getInternalTexture(): Nullable<InternalTexture>;
  92784. /**
  92785. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  92786. * @returns true if ready or not blocking
  92787. */
  92788. isReadyOrNotBlocking(): boolean;
  92789. /**
  92790. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  92791. * @returns true if fully ready
  92792. */
  92793. isReady(): boolean;
  92794. private _cachedSize;
  92795. /**
  92796. * Get the size of the texture.
  92797. * @returns the texture size.
  92798. */
  92799. getSize(): ISize;
  92800. /**
  92801. * Get the base size of the texture.
  92802. * It can be different from the size if the texture has been resized for POT for instance
  92803. * @returns the base size
  92804. */
  92805. getBaseSize(): ISize;
  92806. /**
  92807. * Update the sampling mode of the texture.
  92808. * Default is Trilinear mode.
  92809. *
  92810. * | Value | Type | Description |
  92811. * | ----- | ------------------ | ----------- |
  92812. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  92813. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  92814. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  92815. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  92816. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  92817. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  92818. * | 7 | NEAREST_LINEAR | |
  92819. * | 8 | NEAREST_NEAREST | |
  92820. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  92821. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  92822. * | 11 | LINEAR_LINEAR | |
  92823. * | 12 | LINEAR_NEAREST | |
  92824. *
  92825. * > _mag_: magnification filter (close to the viewer)
  92826. * > _min_: minification filter (far from the viewer)
  92827. * > _mip_: filter used between mip map levels
  92828. *@param samplingMode Define the new sampling mode of the texture
  92829. */
  92830. updateSamplingMode(samplingMode: number): void;
  92831. /**
  92832. * Scales the texture if is `canRescale()`
  92833. * @param ratio the resize factor we want to use to rescale
  92834. */
  92835. scale(ratio: number): void;
  92836. /**
  92837. * Get if the texture can rescale.
  92838. */
  92839. readonly canRescale: boolean;
  92840. /** @hidden */
  92841. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  92842. /** @hidden */
  92843. _rebuild(): void;
  92844. /**
  92845. * Triggers the load sequence in delayed load mode.
  92846. */
  92847. delayLoad(): void;
  92848. /**
  92849. * Clones the texture.
  92850. * @returns the cloned texture
  92851. */
  92852. clone(): Nullable<BaseTexture>;
  92853. /**
  92854. * Get the texture underlying type (INT, FLOAT...)
  92855. */
  92856. readonly textureType: number;
  92857. /**
  92858. * Get the texture underlying format (RGB, RGBA...)
  92859. */
  92860. readonly textureFormat: number;
  92861. /**
  92862. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  92863. * This will returns an RGBA array buffer containing either in values (0-255) or
  92864. * float values (0-1) depending of the underlying buffer type.
  92865. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  92866. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  92867. * @param buffer defines a user defined buffer to fill with data (can be null)
  92868. * @returns The Array buffer containing the pixels data.
  92869. */
  92870. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  92871. /**
  92872. * Release and destroy the underlying lower level texture aka internalTexture.
  92873. */
  92874. releaseInternalTexture(): void;
  92875. /**
  92876. * Get the polynomial representation of the texture data.
  92877. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  92878. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  92879. */
  92880. sphericalPolynomial: Nullable<SphericalPolynomial>;
  92881. /** @hidden */
  92882. readonly _lodTextureHigh: Nullable<BaseTexture>;
  92883. /** @hidden */
  92884. readonly _lodTextureMid: Nullable<BaseTexture>;
  92885. /** @hidden */
  92886. readonly _lodTextureLow: Nullable<BaseTexture>;
  92887. /**
  92888. * Dispose the texture and release its associated resources.
  92889. */
  92890. dispose(): void;
  92891. /**
  92892. * Serialize the texture into a JSON representation that can be parsed later on.
  92893. * @returns the JSON representation of the texture
  92894. */
  92895. serialize(): any;
  92896. /**
  92897. * Helper function to be called back once a list of texture contains only ready textures.
  92898. * @param textures Define the list of textures to wait for
  92899. * @param callback Define the callback triggered once the entire list will be ready
  92900. */
  92901. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  92902. }
  92903. }
  92904. declare module BABYLON {
  92905. /**
  92906. * Class used to store data associated with WebGL texture data for the engine
  92907. * This class should not be used directly
  92908. */
  92909. export class InternalTexture {
  92910. /** @hidden */
  92911. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  92912. /**
  92913. * The source of the texture data is unknown
  92914. */
  92915. static DATASOURCE_UNKNOWN: number;
  92916. /**
  92917. * Texture data comes from an URL
  92918. */
  92919. static DATASOURCE_URL: number;
  92920. /**
  92921. * Texture data is only used for temporary storage
  92922. */
  92923. static DATASOURCE_TEMP: number;
  92924. /**
  92925. * Texture data comes from raw data (ArrayBuffer)
  92926. */
  92927. static DATASOURCE_RAW: number;
  92928. /**
  92929. * Texture content is dynamic (video or dynamic texture)
  92930. */
  92931. static DATASOURCE_DYNAMIC: number;
  92932. /**
  92933. * Texture content is generated by rendering to it
  92934. */
  92935. static DATASOURCE_RENDERTARGET: number;
  92936. /**
  92937. * Texture content is part of a multi render target process
  92938. */
  92939. static DATASOURCE_MULTIRENDERTARGET: number;
  92940. /**
  92941. * Texture data comes from a cube data file
  92942. */
  92943. static DATASOURCE_CUBE: number;
  92944. /**
  92945. * Texture data comes from a raw cube data
  92946. */
  92947. static DATASOURCE_CUBERAW: number;
  92948. /**
  92949. * Texture data come from a prefiltered cube data file
  92950. */
  92951. static DATASOURCE_CUBEPREFILTERED: number;
  92952. /**
  92953. * Texture content is raw 3D data
  92954. */
  92955. static DATASOURCE_RAW3D: number;
  92956. /**
  92957. * Texture content is a depth texture
  92958. */
  92959. static DATASOURCE_DEPTHTEXTURE: number;
  92960. /**
  92961. * Texture data comes from a raw cube data encoded with RGBD
  92962. */
  92963. static DATASOURCE_CUBERAW_RGBD: number;
  92964. /**
  92965. * Defines if the texture is ready
  92966. */
  92967. isReady: boolean;
  92968. /**
  92969. * Defines if the texture is a cube texture
  92970. */
  92971. isCube: boolean;
  92972. /**
  92973. * Defines if the texture contains 3D data
  92974. */
  92975. is3D: boolean;
  92976. /**
  92977. * Defines if the texture contains multiview data
  92978. */
  92979. isMultiview: boolean;
  92980. /**
  92981. * Gets the URL used to load this texture
  92982. */
  92983. url: string;
  92984. /**
  92985. * Gets the sampling mode of the texture
  92986. */
  92987. samplingMode: number;
  92988. /**
  92989. * Gets a boolean indicating if the texture needs mipmaps generation
  92990. */
  92991. generateMipMaps: boolean;
  92992. /**
  92993. * Gets the number of samples used by the texture (WebGL2+ only)
  92994. */
  92995. samples: number;
  92996. /**
  92997. * Gets the type of the texture (int, float...)
  92998. */
  92999. type: number;
  93000. /**
  93001. * Gets the format of the texture (RGB, RGBA...)
  93002. */
  93003. format: number;
  93004. /**
  93005. * Observable called when the texture is loaded
  93006. */
  93007. onLoadedObservable: Observable<InternalTexture>;
  93008. /**
  93009. * Gets the width of the texture
  93010. */
  93011. width: number;
  93012. /**
  93013. * Gets the height of the texture
  93014. */
  93015. height: number;
  93016. /**
  93017. * Gets the depth of the texture
  93018. */
  93019. depth: number;
  93020. /**
  93021. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  93022. */
  93023. baseWidth: number;
  93024. /**
  93025. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  93026. */
  93027. baseHeight: number;
  93028. /**
  93029. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  93030. */
  93031. baseDepth: number;
  93032. /**
  93033. * Gets a boolean indicating if the texture is inverted on Y axis
  93034. */
  93035. invertY: boolean;
  93036. /** @hidden */
  93037. _invertVScale: boolean;
  93038. /** @hidden */
  93039. _associatedChannel: number;
  93040. /** @hidden */
  93041. _dataSource: number;
  93042. /** @hidden */
  93043. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  93044. /** @hidden */
  93045. _bufferView: Nullable<ArrayBufferView>;
  93046. /** @hidden */
  93047. _bufferViewArray: Nullable<ArrayBufferView[]>;
  93048. /** @hidden */
  93049. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  93050. /** @hidden */
  93051. _size: number;
  93052. /** @hidden */
  93053. _extension: string;
  93054. /** @hidden */
  93055. _files: Nullable<string[]>;
  93056. /** @hidden */
  93057. _workingCanvas: Nullable<HTMLCanvasElement>;
  93058. /** @hidden */
  93059. _workingContext: Nullable<CanvasRenderingContext2D>;
  93060. /** @hidden */
  93061. _framebuffer: Nullable<WebGLFramebuffer>;
  93062. /** @hidden */
  93063. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  93064. /** @hidden */
  93065. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  93066. /** @hidden */
  93067. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  93068. /** @hidden */
  93069. _attachments: Nullable<number[]>;
  93070. /** @hidden */
  93071. _cachedCoordinatesMode: Nullable<number>;
  93072. /** @hidden */
  93073. _cachedWrapU: Nullable<number>;
  93074. /** @hidden */
  93075. _cachedWrapV: Nullable<number>;
  93076. /** @hidden */
  93077. _cachedWrapR: Nullable<number>;
  93078. /** @hidden */
  93079. _cachedAnisotropicFilteringLevel: Nullable<number>;
  93080. /** @hidden */
  93081. _isDisabled: boolean;
  93082. /** @hidden */
  93083. _compression: Nullable<string>;
  93084. /** @hidden */
  93085. _generateStencilBuffer: boolean;
  93086. /** @hidden */
  93087. _generateDepthBuffer: boolean;
  93088. /** @hidden */
  93089. _comparisonFunction: number;
  93090. /** @hidden */
  93091. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  93092. /** @hidden */
  93093. _lodGenerationScale: number;
  93094. /** @hidden */
  93095. _lodGenerationOffset: number;
  93096. /** @hidden */
  93097. _colorTextureArray: Nullable<WebGLTexture>;
  93098. /** @hidden */
  93099. _depthStencilTextureArray: Nullable<WebGLTexture>;
  93100. /** @hidden */
  93101. _lodTextureHigh: Nullable<BaseTexture>;
  93102. /** @hidden */
  93103. _lodTextureMid: Nullable<BaseTexture>;
  93104. /** @hidden */
  93105. _lodTextureLow: Nullable<BaseTexture>;
  93106. /** @hidden */
  93107. _isRGBD: boolean;
  93108. /** @hidden */
  93109. _linearSpecularLOD: boolean;
  93110. /** @hidden */
  93111. _irradianceTexture: Nullable<BaseTexture>;
  93112. /** @hidden */
  93113. _webGLTexture: Nullable<WebGLTexture>;
  93114. /** @hidden */
  93115. _references: number;
  93116. private _engine;
  93117. /**
  93118. * Gets the Engine the texture belongs to.
  93119. * @returns The babylon engine
  93120. */
  93121. getEngine(): Engine;
  93122. /**
  93123. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  93124. */
  93125. readonly dataSource: number;
  93126. /**
  93127. * Creates a new InternalTexture
  93128. * @param engine defines the engine to use
  93129. * @param dataSource defines the type of data that will be used
  93130. * @param delayAllocation if the texture allocation should be delayed (default: false)
  93131. */
  93132. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  93133. /**
  93134. * Increments the number of references (ie. the number of Texture that point to it)
  93135. */
  93136. incrementReferences(): void;
  93137. /**
  93138. * Change the size of the texture (not the size of the content)
  93139. * @param width defines the new width
  93140. * @param height defines the new height
  93141. * @param depth defines the new depth (1 by default)
  93142. */
  93143. updateSize(width: int, height: int, depth?: int): void;
  93144. /** @hidden */
  93145. _rebuild(): void;
  93146. /** @hidden */
  93147. _swapAndDie(target: InternalTexture): void;
  93148. /**
  93149. * Dispose the current allocated resources
  93150. */
  93151. dispose(): void;
  93152. }
  93153. }
  93154. declare module BABYLON {
  93155. /**
  93156. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  93157. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  93158. */
  93159. export class EffectFallbacks {
  93160. private _defines;
  93161. private _currentRank;
  93162. private _maxRank;
  93163. private _mesh;
  93164. /**
  93165. * Removes the fallback from the bound mesh.
  93166. */
  93167. unBindMesh(): void;
  93168. /**
  93169. * Adds a fallback on the specified property.
  93170. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  93171. * @param define The name of the define in the shader
  93172. */
  93173. addFallback(rank: number, define: string): void;
  93174. /**
  93175. * Sets the mesh to use CPU skinning when needing to fallback.
  93176. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  93177. * @param mesh The mesh to use the fallbacks.
  93178. */
  93179. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  93180. /**
  93181. * Checks to see if more fallbacks are still availible.
  93182. */
  93183. readonly hasMoreFallbacks: boolean;
  93184. /**
  93185. * Removes the defines that should be removed when falling back.
  93186. * @param currentDefines defines the current define statements for the shader.
  93187. * @param effect defines the current effect we try to compile
  93188. * @returns The resulting defines with defines of the current rank removed.
  93189. */
  93190. reduce(currentDefines: string, effect: Effect): string;
  93191. }
  93192. /**
  93193. * Options to be used when creating an effect.
  93194. */
  93195. export class EffectCreationOptions {
  93196. /**
  93197. * Atrributes that will be used in the shader.
  93198. */
  93199. attributes: string[];
  93200. /**
  93201. * Uniform varible names that will be set in the shader.
  93202. */
  93203. uniformsNames: string[];
  93204. /**
  93205. * Uniform buffer varible names that will be set in the shader.
  93206. */
  93207. uniformBuffersNames: string[];
  93208. /**
  93209. * Sampler texture variable names that will be set in the shader.
  93210. */
  93211. samplers: string[];
  93212. /**
  93213. * Define statements that will be set in the shader.
  93214. */
  93215. defines: any;
  93216. /**
  93217. * Possible fallbacks for this effect to improve performance when needed.
  93218. */
  93219. fallbacks: Nullable<EffectFallbacks>;
  93220. /**
  93221. * Callback that will be called when the shader is compiled.
  93222. */
  93223. onCompiled: Nullable<(effect: Effect) => void>;
  93224. /**
  93225. * Callback that will be called if an error occurs during shader compilation.
  93226. */
  93227. onError: Nullable<(effect: Effect, errors: string) => void>;
  93228. /**
  93229. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  93230. */
  93231. indexParameters: any;
  93232. /**
  93233. * Max number of lights that can be used in the shader.
  93234. */
  93235. maxSimultaneousLights: number;
  93236. /**
  93237. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  93238. */
  93239. transformFeedbackVaryings: Nullable<string[]>;
  93240. }
  93241. /**
  93242. * Effect containing vertex and fragment shader that can be executed on an object.
  93243. */
  93244. export class Effect implements IDisposable {
  93245. /**
  93246. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  93247. */
  93248. static ShadersRepository: string;
  93249. /**
  93250. * Name of the effect.
  93251. */
  93252. name: any;
  93253. /**
  93254. * String container all the define statements that should be set on the shader.
  93255. */
  93256. defines: string;
  93257. /**
  93258. * Callback that will be called when the shader is compiled.
  93259. */
  93260. onCompiled: Nullable<(effect: Effect) => void>;
  93261. /**
  93262. * Callback that will be called if an error occurs during shader compilation.
  93263. */
  93264. onError: Nullable<(effect: Effect, errors: string) => void>;
  93265. /**
  93266. * Callback that will be called when effect is bound.
  93267. */
  93268. onBind: Nullable<(effect: Effect) => void>;
  93269. /**
  93270. * Unique ID of the effect.
  93271. */
  93272. uniqueId: number;
  93273. /**
  93274. * Observable that will be called when the shader is compiled.
  93275. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  93276. */
  93277. onCompileObservable: Observable<Effect>;
  93278. /**
  93279. * Observable that will be called if an error occurs during shader compilation.
  93280. */
  93281. onErrorObservable: Observable<Effect>;
  93282. /** @hidden */
  93283. _onBindObservable: Nullable<Observable<Effect>>;
  93284. /**
  93285. * Observable that will be called when effect is bound.
  93286. */
  93287. readonly onBindObservable: Observable<Effect>;
  93288. /** @hidden */
  93289. _bonesComputationForcedToCPU: boolean;
  93290. private static _uniqueIdSeed;
  93291. private _engine;
  93292. private _uniformBuffersNames;
  93293. private _uniformsNames;
  93294. private _samplerList;
  93295. private _samplers;
  93296. private _isReady;
  93297. private _compilationError;
  93298. private _attributesNames;
  93299. private _attributes;
  93300. private _uniforms;
  93301. /**
  93302. * Key for the effect.
  93303. * @hidden
  93304. */
  93305. _key: string;
  93306. private _indexParameters;
  93307. private _fallbacks;
  93308. private _vertexSourceCode;
  93309. private _fragmentSourceCode;
  93310. private _vertexSourceCodeOverride;
  93311. private _fragmentSourceCodeOverride;
  93312. private _transformFeedbackVaryings;
  93313. /**
  93314. * Compiled shader to webGL program.
  93315. * @hidden
  93316. */
  93317. _pipelineContext: Nullable<IPipelineContext>;
  93318. private _valueCache;
  93319. private static _baseCache;
  93320. /**
  93321. * Instantiates an effect.
  93322. * An effect can be used to create/manage/execute vertex and fragment shaders.
  93323. * @param baseName Name of the effect.
  93324. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  93325. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  93326. * @param samplers List of sampler variables that will be passed to the shader.
  93327. * @param engine Engine to be used to render the effect
  93328. * @param defines Define statements to be added to the shader.
  93329. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  93330. * @param onCompiled Callback that will be called when the shader is compiled.
  93331. * @param onError Callback that will be called if an error occurs during shader compilation.
  93332. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  93333. */
  93334. 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);
  93335. private _useFinalCode;
  93336. /**
  93337. * Unique key for this effect
  93338. */
  93339. readonly key: string;
  93340. /**
  93341. * If the effect has been compiled and prepared.
  93342. * @returns if the effect is compiled and prepared.
  93343. */
  93344. isReady(): boolean;
  93345. private _isReadyInternal;
  93346. /**
  93347. * The engine the effect was initialized with.
  93348. * @returns the engine.
  93349. */
  93350. getEngine(): Engine;
  93351. /**
  93352. * The pipeline context for this effect
  93353. * @returns the associated pipeline context
  93354. */
  93355. getPipelineContext(): Nullable<IPipelineContext>;
  93356. /**
  93357. * The set of names of attribute variables for the shader.
  93358. * @returns An array of attribute names.
  93359. */
  93360. getAttributesNames(): string[];
  93361. /**
  93362. * Returns the attribute at the given index.
  93363. * @param index The index of the attribute.
  93364. * @returns The location of the attribute.
  93365. */
  93366. getAttributeLocation(index: number): number;
  93367. /**
  93368. * Returns the attribute based on the name of the variable.
  93369. * @param name of the attribute to look up.
  93370. * @returns the attribute location.
  93371. */
  93372. getAttributeLocationByName(name: string): number;
  93373. /**
  93374. * The number of attributes.
  93375. * @returns the numnber of attributes.
  93376. */
  93377. getAttributesCount(): number;
  93378. /**
  93379. * Gets the index of a uniform variable.
  93380. * @param uniformName of the uniform to look up.
  93381. * @returns the index.
  93382. */
  93383. getUniformIndex(uniformName: string): number;
  93384. /**
  93385. * Returns the attribute based on the name of the variable.
  93386. * @param uniformName of the uniform to look up.
  93387. * @returns the location of the uniform.
  93388. */
  93389. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  93390. /**
  93391. * Returns an array of sampler variable names
  93392. * @returns The array of sampler variable neames.
  93393. */
  93394. getSamplers(): string[];
  93395. /**
  93396. * The error from the last compilation.
  93397. * @returns the error string.
  93398. */
  93399. getCompilationError(): string;
  93400. /**
  93401. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  93402. * @param func The callback to be used.
  93403. */
  93404. executeWhenCompiled(func: (effect: Effect) => void): void;
  93405. private _checkIsReady;
  93406. /** @hidden */
  93407. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  93408. /** @hidden */
  93409. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  93410. /** @hidden */
  93411. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  93412. /**
  93413. * Recompiles the webGL program
  93414. * @param vertexSourceCode The source code for the vertex shader.
  93415. * @param fragmentSourceCode The source code for the fragment shader.
  93416. * @param onCompiled Callback called when completed.
  93417. * @param onError Callback called on error.
  93418. * @hidden
  93419. */
  93420. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  93421. /**
  93422. * Prepares the effect
  93423. * @hidden
  93424. */
  93425. _prepareEffect(): void;
  93426. private _processCompilationErrors;
  93427. /**
  93428. * Checks if the effect is supported. (Must be called after compilation)
  93429. */
  93430. readonly isSupported: boolean;
  93431. /**
  93432. * Binds a texture to the engine to be used as output of the shader.
  93433. * @param channel Name of the output variable.
  93434. * @param texture Texture to bind.
  93435. * @hidden
  93436. */
  93437. _bindTexture(channel: string, texture: InternalTexture): void;
  93438. /**
  93439. * Sets a texture on the engine to be used in the shader.
  93440. * @param channel Name of the sampler variable.
  93441. * @param texture Texture to set.
  93442. */
  93443. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  93444. /**
  93445. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  93446. * @param channel Name of the sampler variable.
  93447. * @param texture Texture to set.
  93448. */
  93449. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  93450. /**
  93451. * Sets an array of textures on the engine to be used in the shader.
  93452. * @param channel Name of the variable.
  93453. * @param textures Textures to set.
  93454. */
  93455. setTextureArray(channel: string, textures: BaseTexture[]): void;
  93456. /**
  93457. * 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)
  93458. * @param channel Name of the sampler variable.
  93459. * @param postProcess Post process to get the input texture from.
  93460. */
  93461. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  93462. /**
  93463. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  93464. * 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)
  93465. * @param channel Name of the sampler variable.
  93466. * @param postProcess Post process to get the output texture from.
  93467. */
  93468. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  93469. /** @hidden */
  93470. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  93471. /** @hidden */
  93472. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  93473. /** @hidden */
  93474. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  93475. /** @hidden */
  93476. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  93477. /**
  93478. * Binds a buffer to a uniform.
  93479. * @param buffer Buffer to bind.
  93480. * @param name Name of the uniform variable to bind to.
  93481. */
  93482. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  93483. /**
  93484. * Binds block to a uniform.
  93485. * @param blockName Name of the block to bind.
  93486. * @param index Index to bind.
  93487. */
  93488. bindUniformBlock(blockName: string, index: number): void;
  93489. /**
  93490. * Sets an interger value on a uniform variable.
  93491. * @param uniformName Name of the variable.
  93492. * @param value Value to be set.
  93493. * @returns this effect.
  93494. */
  93495. setInt(uniformName: string, value: number): Effect;
  93496. /**
  93497. * Sets an int array on a uniform variable.
  93498. * @param uniformName Name of the variable.
  93499. * @param array array to be set.
  93500. * @returns this effect.
  93501. */
  93502. setIntArray(uniformName: string, array: Int32Array): Effect;
  93503. /**
  93504. * 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)
  93505. * @param uniformName Name of the variable.
  93506. * @param array array to be set.
  93507. * @returns this effect.
  93508. */
  93509. setIntArray2(uniformName: string, array: Int32Array): Effect;
  93510. /**
  93511. * 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)
  93512. * @param uniformName Name of the variable.
  93513. * @param array array to be set.
  93514. * @returns this effect.
  93515. */
  93516. setIntArray3(uniformName: string, array: Int32Array): Effect;
  93517. /**
  93518. * 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)
  93519. * @param uniformName Name of the variable.
  93520. * @param array array to be set.
  93521. * @returns this effect.
  93522. */
  93523. setIntArray4(uniformName: string, array: Int32Array): Effect;
  93524. /**
  93525. * Sets an float array on a uniform variable.
  93526. * @param uniformName Name of the variable.
  93527. * @param array array to be set.
  93528. * @returns this effect.
  93529. */
  93530. setFloatArray(uniformName: string, array: Float32Array): Effect;
  93531. /**
  93532. * 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)
  93533. * @param uniformName Name of the variable.
  93534. * @param array array to be set.
  93535. * @returns this effect.
  93536. */
  93537. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  93538. /**
  93539. * 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)
  93540. * @param uniformName Name of the variable.
  93541. * @param array array to be set.
  93542. * @returns this effect.
  93543. */
  93544. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  93545. /**
  93546. * 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)
  93547. * @param uniformName Name of the variable.
  93548. * @param array array to be set.
  93549. * @returns this effect.
  93550. */
  93551. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  93552. /**
  93553. * Sets an array on a uniform variable.
  93554. * @param uniformName Name of the variable.
  93555. * @param array array to be set.
  93556. * @returns this effect.
  93557. */
  93558. setArray(uniformName: string, array: number[]): Effect;
  93559. /**
  93560. * 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)
  93561. * @param uniformName Name of the variable.
  93562. * @param array array to be set.
  93563. * @returns this effect.
  93564. */
  93565. setArray2(uniformName: string, array: number[]): Effect;
  93566. /**
  93567. * 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)
  93568. * @param uniformName Name of the variable.
  93569. * @param array array to be set.
  93570. * @returns this effect.
  93571. */
  93572. setArray3(uniformName: string, array: number[]): Effect;
  93573. /**
  93574. * 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)
  93575. * @param uniformName Name of the variable.
  93576. * @param array array to be set.
  93577. * @returns this effect.
  93578. */
  93579. setArray4(uniformName: string, array: number[]): Effect;
  93580. /**
  93581. * Sets matrices on a uniform variable.
  93582. * @param uniformName Name of the variable.
  93583. * @param matrices matrices to be set.
  93584. * @returns this effect.
  93585. */
  93586. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  93587. /**
  93588. * Sets matrix on a uniform variable.
  93589. * @param uniformName Name of the variable.
  93590. * @param matrix matrix to be set.
  93591. * @returns this effect.
  93592. */
  93593. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  93594. /**
  93595. * 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)
  93596. * @param uniformName Name of the variable.
  93597. * @param matrix matrix to be set.
  93598. * @returns this effect.
  93599. */
  93600. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  93601. /**
  93602. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  93603. * @param uniformName Name of the variable.
  93604. * @param matrix matrix to be set.
  93605. * @returns this effect.
  93606. */
  93607. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  93608. /**
  93609. * Sets a float on a uniform variable.
  93610. * @param uniformName Name of the variable.
  93611. * @param value value to be set.
  93612. * @returns this effect.
  93613. */
  93614. setFloat(uniformName: string, value: number): Effect;
  93615. /**
  93616. * Sets a boolean on a uniform variable.
  93617. * @param uniformName Name of the variable.
  93618. * @param bool value to be set.
  93619. * @returns this effect.
  93620. */
  93621. setBool(uniformName: string, bool: boolean): Effect;
  93622. /**
  93623. * Sets a Vector2 on a uniform variable.
  93624. * @param uniformName Name of the variable.
  93625. * @param vector2 vector2 to be set.
  93626. * @returns this effect.
  93627. */
  93628. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  93629. /**
  93630. * Sets a float2 on a uniform variable.
  93631. * @param uniformName Name of the variable.
  93632. * @param x First float in float2.
  93633. * @param y Second float in float2.
  93634. * @returns this effect.
  93635. */
  93636. setFloat2(uniformName: string, x: number, y: number): Effect;
  93637. /**
  93638. * Sets a Vector3 on a uniform variable.
  93639. * @param uniformName Name of the variable.
  93640. * @param vector3 Value to be set.
  93641. * @returns this effect.
  93642. */
  93643. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  93644. /**
  93645. * Sets a float3 on a uniform variable.
  93646. * @param uniformName Name of the variable.
  93647. * @param x First float in float3.
  93648. * @param y Second float in float3.
  93649. * @param z Third float in float3.
  93650. * @returns this effect.
  93651. */
  93652. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  93653. /**
  93654. * Sets a Vector4 on a uniform variable.
  93655. * @param uniformName Name of the variable.
  93656. * @param vector4 Value to be set.
  93657. * @returns this effect.
  93658. */
  93659. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  93660. /**
  93661. * Sets a float4 on a uniform variable.
  93662. * @param uniformName Name of the variable.
  93663. * @param x First float in float4.
  93664. * @param y Second float in float4.
  93665. * @param z Third float in float4.
  93666. * @param w Fourth float in float4.
  93667. * @returns this effect.
  93668. */
  93669. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  93670. /**
  93671. * Sets a Color3 on a uniform variable.
  93672. * @param uniformName Name of the variable.
  93673. * @param color3 Value to be set.
  93674. * @returns this effect.
  93675. */
  93676. setColor3(uniformName: string, color3: IColor3Like): Effect;
  93677. /**
  93678. * Sets a Color4 on a uniform variable.
  93679. * @param uniformName Name of the variable.
  93680. * @param color3 Value to be set.
  93681. * @param alpha Alpha value to be set.
  93682. * @returns this effect.
  93683. */
  93684. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  93685. /**
  93686. * Sets a Color4 on a uniform variable
  93687. * @param uniformName defines the name of the variable
  93688. * @param color4 defines the value to be set
  93689. * @returns this effect.
  93690. */
  93691. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  93692. /** Release all associated resources */
  93693. dispose(): void;
  93694. /**
  93695. * This function will add a new shader to the shader store
  93696. * @param name the name of the shader
  93697. * @param pixelShader optional pixel shader content
  93698. * @param vertexShader optional vertex shader content
  93699. */
  93700. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  93701. /**
  93702. * Store of each shader (The can be looked up using effect.key)
  93703. */
  93704. static ShadersStore: {
  93705. [key: string]: string;
  93706. };
  93707. /**
  93708. * Store of each included file for a shader (The can be looked up using effect.key)
  93709. */
  93710. static IncludesShadersStore: {
  93711. [key: string]: string;
  93712. };
  93713. /**
  93714. * Resets the cache of effects.
  93715. */
  93716. static ResetCache(): void;
  93717. }
  93718. }
  93719. declare module BABYLON {
  93720. /**
  93721. * Uniform buffer objects.
  93722. *
  93723. * Handles blocks of uniform on the GPU.
  93724. *
  93725. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  93726. *
  93727. * For more information, please refer to :
  93728. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  93729. */
  93730. export class UniformBuffer {
  93731. private _engine;
  93732. private _buffer;
  93733. private _data;
  93734. private _bufferData;
  93735. private _dynamic?;
  93736. private _uniformLocations;
  93737. private _uniformSizes;
  93738. private _uniformLocationPointer;
  93739. private _needSync;
  93740. private _noUBO;
  93741. private _currentEffect;
  93742. private static _MAX_UNIFORM_SIZE;
  93743. private static _tempBuffer;
  93744. /**
  93745. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  93746. * This is dynamic to allow compat with webgl 1 and 2.
  93747. * You will need to pass the name of the uniform as well as the value.
  93748. */
  93749. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  93750. /**
  93751. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  93752. * This is dynamic to allow compat with webgl 1 and 2.
  93753. * You will need to pass the name of the uniform as well as the value.
  93754. */
  93755. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  93756. /**
  93757. * Lambda to Update a single float in a uniform buffer.
  93758. * This is dynamic to allow compat with webgl 1 and 2.
  93759. * You will need to pass the name of the uniform as well as the value.
  93760. */
  93761. updateFloat: (name: string, x: number) => void;
  93762. /**
  93763. * Lambda to Update a vec2 of float in a uniform buffer.
  93764. * This is dynamic to allow compat with webgl 1 and 2.
  93765. * You will need to pass the name of the uniform as well as the value.
  93766. */
  93767. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  93768. /**
  93769. * Lambda to Update a vec3 of float in a uniform buffer.
  93770. * This is dynamic to allow compat with webgl 1 and 2.
  93771. * You will need to pass the name of the uniform as well as the value.
  93772. */
  93773. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  93774. /**
  93775. * Lambda to Update a vec4 of float in a uniform buffer.
  93776. * This is dynamic to allow compat with webgl 1 and 2.
  93777. * You will need to pass the name of the uniform as well as the value.
  93778. */
  93779. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  93780. /**
  93781. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  93782. * This is dynamic to allow compat with webgl 1 and 2.
  93783. * You will need to pass the name of the uniform as well as the value.
  93784. */
  93785. updateMatrix: (name: string, mat: Matrix) => void;
  93786. /**
  93787. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  93788. * This is dynamic to allow compat with webgl 1 and 2.
  93789. * You will need to pass the name of the uniform as well as the value.
  93790. */
  93791. updateVector3: (name: string, vector: Vector3) => void;
  93792. /**
  93793. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  93794. * This is dynamic to allow compat with webgl 1 and 2.
  93795. * You will need to pass the name of the uniform as well as the value.
  93796. */
  93797. updateVector4: (name: string, vector: Vector4) => void;
  93798. /**
  93799. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  93800. * This is dynamic to allow compat with webgl 1 and 2.
  93801. * You will need to pass the name of the uniform as well as the value.
  93802. */
  93803. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  93804. /**
  93805. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  93806. * This is dynamic to allow compat with webgl 1 and 2.
  93807. * You will need to pass the name of the uniform as well as the value.
  93808. */
  93809. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  93810. /**
  93811. * Instantiates a new Uniform buffer objects.
  93812. *
  93813. * Handles blocks of uniform on the GPU.
  93814. *
  93815. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  93816. *
  93817. * For more information, please refer to :
  93818. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  93819. * @param engine Define the engine the buffer is associated with
  93820. * @param data Define the data contained in the buffer
  93821. * @param dynamic Define if the buffer is updatable
  93822. */
  93823. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  93824. /**
  93825. * Indicates if the buffer is using the WebGL2 UBO implementation,
  93826. * or just falling back on setUniformXXX calls.
  93827. */
  93828. readonly useUbo: boolean;
  93829. /**
  93830. * Indicates if the WebGL underlying uniform buffer is in sync
  93831. * with the javascript cache data.
  93832. */
  93833. readonly isSync: boolean;
  93834. /**
  93835. * Indicates if the WebGL underlying uniform buffer is dynamic.
  93836. * Also, a dynamic UniformBuffer will disable cache verification and always
  93837. * update the underlying WebGL uniform buffer to the GPU.
  93838. * @returns if Dynamic, otherwise false
  93839. */
  93840. isDynamic(): boolean;
  93841. /**
  93842. * The data cache on JS side.
  93843. * @returns the underlying data as a float array
  93844. */
  93845. getData(): Float32Array;
  93846. /**
  93847. * The underlying WebGL Uniform buffer.
  93848. * @returns the webgl buffer
  93849. */
  93850. getBuffer(): Nullable<DataBuffer>;
  93851. /**
  93852. * std140 layout specifies how to align data within an UBO structure.
  93853. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  93854. * for specs.
  93855. */
  93856. private _fillAlignment;
  93857. /**
  93858. * Adds an uniform in the buffer.
  93859. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  93860. * for the layout to be correct !
  93861. * @param name Name of the uniform, as used in the uniform block in the shader.
  93862. * @param size Data size, or data directly.
  93863. */
  93864. addUniform(name: string, size: number | number[]): void;
  93865. /**
  93866. * Adds a Matrix 4x4 to the uniform buffer.
  93867. * @param name Name of the uniform, as used in the uniform block in the shader.
  93868. * @param mat A 4x4 matrix.
  93869. */
  93870. addMatrix(name: string, mat: Matrix): void;
  93871. /**
  93872. * Adds a vec2 to the uniform buffer.
  93873. * @param name Name of the uniform, as used in the uniform block in the shader.
  93874. * @param x Define the x component value of the vec2
  93875. * @param y Define the y component value of the vec2
  93876. */
  93877. addFloat2(name: string, x: number, y: number): void;
  93878. /**
  93879. * Adds a vec3 to the uniform buffer.
  93880. * @param name Name of the uniform, as used in the uniform block in the shader.
  93881. * @param x Define the x component value of the vec3
  93882. * @param y Define the y component value of the vec3
  93883. * @param z Define the z component value of the vec3
  93884. */
  93885. addFloat3(name: string, x: number, y: number, z: number): void;
  93886. /**
  93887. * Adds a vec3 to the uniform buffer.
  93888. * @param name Name of the uniform, as used in the uniform block in the shader.
  93889. * @param color Define the vec3 from a Color
  93890. */
  93891. addColor3(name: string, color: Color3): void;
  93892. /**
  93893. * Adds a vec4 to the uniform buffer.
  93894. * @param name Name of the uniform, as used in the uniform block in the shader.
  93895. * @param color Define the rgb components from a Color
  93896. * @param alpha Define the a component of the vec4
  93897. */
  93898. addColor4(name: string, color: Color3, alpha: number): void;
  93899. /**
  93900. * Adds a vec3 to the uniform buffer.
  93901. * @param name Name of the uniform, as used in the uniform block in the shader.
  93902. * @param vector Define the vec3 components from a Vector
  93903. */
  93904. addVector3(name: string, vector: Vector3): void;
  93905. /**
  93906. * Adds a Matrix 3x3 to the uniform buffer.
  93907. * @param name Name of the uniform, as used in the uniform block in the shader.
  93908. */
  93909. addMatrix3x3(name: string): void;
  93910. /**
  93911. * Adds a Matrix 2x2 to the uniform buffer.
  93912. * @param name Name of the uniform, as used in the uniform block in the shader.
  93913. */
  93914. addMatrix2x2(name: string): void;
  93915. /**
  93916. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  93917. */
  93918. create(): void;
  93919. /** @hidden */
  93920. _rebuild(): void;
  93921. /**
  93922. * Updates the WebGL Uniform Buffer on the GPU.
  93923. * If the `dynamic` flag is set to true, no cache comparison is done.
  93924. * Otherwise, the buffer will be updated only if the cache differs.
  93925. */
  93926. update(): void;
  93927. /**
  93928. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  93929. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  93930. * @param data Define the flattened data
  93931. * @param size Define the size of the data.
  93932. */
  93933. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  93934. private _valueCache;
  93935. private _cacheMatrix;
  93936. private _updateMatrix3x3ForUniform;
  93937. private _updateMatrix3x3ForEffect;
  93938. private _updateMatrix2x2ForEffect;
  93939. private _updateMatrix2x2ForUniform;
  93940. private _updateFloatForEffect;
  93941. private _updateFloatForUniform;
  93942. private _updateFloat2ForEffect;
  93943. private _updateFloat2ForUniform;
  93944. private _updateFloat3ForEffect;
  93945. private _updateFloat3ForUniform;
  93946. private _updateFloat4ForEffect;
  93947. private _updateFloat4ForUniform;
  93948. private _updateMatrixForEffect;
  93949. private _updateMatrixForUniform;
  93950. private _updateVector3ForEffect;
  93951. private _updateVector3ForUniform;
  93952. private _updateVector4ForEffect;
  93953. private _updateVector4ForUniform;
  93954. private _updateColor3ForEffect;
  93955. private _updateColor3ForUniform;
  93956. private _updateColor4ForEffect;
  93957. private _updateColor4ForUniform;
  93958. /**
  93959. * Sets a sampler uniform on the effect.
  93960. * @param name Define the name of the sampler.
  93961. * @param texture Define the texture to set in the sampler
  93962. */
  93963. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  93964. /**
  93965. * Directly updates the value of the uniform in the cache AND on the GPU.
  93966. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  93967. * @param data Define the flattened data
  93968. */
  93969. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  93970. /**
  93971. * Binds this uniform buffer to an effect.
  93972. * @param effect Define the effect to bind the buffer to
  93973. * @param name Name of the uniform block in the shader.
  93974. */
  93975. bindToEffect(effect: Effect, name: string): void;
  93976. /**
  93977. * Disposes the uniform buffer.
  93978. */
  93979. dispose(): void;
  93980. }
  93981. }
  93982. declare module BABYLON {
  93983. /**
  93984. * Class used to work with sound analyzer using fast fourier transform (FFT)
  93985. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93986. */
  93987. export class Analyser {
  93988. /**
  93989. * Gets or sets the smoothing
  93990. * @ignorenaming
  93991. */
  93992. SMOOTHING: number;
  93993. /**
  93994. * Gets or sets the FFT table size
  93995. * @ignorenaming
  93996. */
  93997. FFT_SIZE: number;
  93998. /**
  93999. * Gets or sets the bar graph amplitude
  94000. * @ignorenaming
  94001. */
  94002. BARGRAPHAMPLITUDE: number;
  94003. /**
  94004. * Gets or sets the position of the debug canvas
  94005. * @ignorenaming
  94006. */
  94007. DEBUGCANVASPOS: {
  94008. x: number;
  94009. y: number;
  94010. };
  94011. /**
  94012. * Gets or sets the debug canvas size
  94013. * @ignorenaming
  94014. */
  94015. DEBUGCANVASSIZE: {
  94016. width: number;
  94017. height: number;
  94018. };
  94019. private _byteFreqs;
  94020. private _byteTime;
  94021. private _floatFreqs;
  94022. private _webAudioAnalyser;
  94023. private _debugCanvas;
  94024. private _debugCanvasContext;
  94025. private _scene;
  94026. private _registerFunc;
  94027. private _audioEngine;
  94028. /**
  94029. * Creates a new analyser
  94030. * @param scene defines hosting scene
  94031. */
  94032. constructor(scene: Scene);
  94033. /**
  94034. * Get the number of data values you will have to play with for the visualization
  94035. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  94036. * @returns a number
  94037. */
  94038. getFrequencyBinCount(): number;
  94039. /**
  94040. * Gets the current frequency data as a byte array
  94041. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  94042. * @returns a Uint8Array
  94043. */
  94044. getByteFrequencyData(): Uint8Array;
  94045. /**
  94046. * Gets the current waveform as a byte array
  94047. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  94048. * @returns a Uint8Array
  94049. */
  94050. getByteTimeDomainData(): Uint8Array;
  94051. /**
  94052. * Gets the current frequency data as a float array
  94053. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  94054. * @returns a Float32Array
  94055. */
  94056. getFloatFrequencyData(): Float32Array;
  94057. /**
  94058. * Renders the debug canvas
  94059. */
  94060. drawDebugCanvas(): void;
  94061. /**
  94062. * Stops rendering the debug canvas and removes it
  94063. */
  94064. stopDebugCanvas(): void;
  94065. /**
  94066. * Connects two audio nodes
  94067. * @param inputAudioNode defines first node to connect
  94068. * @param outputAudioNode defines second node to connect
  94069. */
  94070. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  94071. /**
  94072. * Releases all associated resources
  94073. */
  94074. dispose(): void;
  94075. }
  94076. }
  94077. declare module BABYLON {
  94078. /**
  94079. * This represents an audio engine and it is responsible
  94080. * to play, synchronize and analyse sounds throughout the application.
  94081. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94082. */
  94083. export interface IAudioEngine extends IDisposable {
  94084. /**
  94085. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  94086. */
  94087. readonly canUseWebAudio: boolean;
  94088. /**
  94089. * Gets the current AudioContext if available.
  94090. */
  94091. readonly audioContext: Nullable<AudioContext>;
  94092. /**
  94093. * The master gain node defines the global audio volume of your audio engine.
  94094. */
  94095. readonly masterGain: GainNode;
  94096. /**
  94097. * Gets whether or not mp3 are supported by your browser.
  94098. */
  94099. readonly isMP3supported: boolean;
  94100. /**
  94101. * Gets whether or not ogg are supported by your browser.
  94102. */
  94103. readonly isOGGsupported: boolean;
  94104. /**
  94105. * Defines if Babylon should emit a warning if WebAudio is not supported.
  94106. * @ignoreNaming
  94107. */
  94108. WarnedWebAudioUnsupported: boolean;
  94109. /**
  94110. * Defines if the audio engine relies on a custom unlocked button.
  94111. * In this case, the embedded button will not be displayed.
  94112. */
  94113. useCustomUnlockedButton: boolean;
  94114. /**
  94115. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  94116. */
  94117. readonly unlocked: boolean;
  94118. /**
  94119. * Event raised when audio has been unlocked on the browser.
  94120. */
  94121. onAudioUnlockedObservable: Observable<AudioEngine>;
  94122. /**
  94123. * Event raised when audio has been locked on the browser.
  94124. */
  94125. onAudioLockedObservable: Observable<AudioEngine>;
  94126. /**
  94127. * Flags the audio engine in Locked state.
  94128. * This happens due to new browser policies preventing audio to autoplay.
  94129. */
  94130. lock(): void;
  94131. /**
  94132. * Unlocks the audio engine once a user action has been done on the dom.
  94133. * This is helpful to resume play once browser policies have been satisfied.
  94134. */
  94135. unlock(): void;
  94136. }
  94137. /**
  94138. * This represents the default audio engine used in babylon.
  94139. * It is responsible to play, synchronize and analyse sounds throughout the application.
  94140. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94141. */
  94142. export class AudioEngine implements IAudioEngine {
  94143. private _audioContext;
  94144. private _audioContextInitialized;
  94145. private _muteButton;
  94146. private _hostElement;
  94147. /**
  94148. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  94149. */
  94150. canUseWebAudio: boolean;
  94151. /**
  94152. * The master gain node defines the global audio volume of your audio engine.
  94153. */
  94154. masterGain: GainNode;
  94155. /**
  94156. * Defines if Babylon should emit a warning if WebAudio is not supported.
  94157. * @ignoreNaming
  94158. */
  94159. WarnedWebAudioUnsupported: boolean;
  94160. /**
  94161. * Gets whether or not mp3 are supported by your browser.
  94162. */
  94163. isMP3supported: boolean;
  94164. /**
  94165. * Gets whether or not ogg are supported by your browser.
  94166. */
  94167. isOGGsupported: boolean;
  94168. /**
  94169. * Gets whether audio has been unlocked on the device.
  94170. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  94171. * a user interaction has happened.
  94172. */
  94173. unlocked: boolean;
  94174. /**
  94175. * Defines if the audio engine relies on a custom unlocked button.
  94176. * In this case, the embedded button will not be displayed.
  94177. */
  94178. useCustomUnlockedButton: boolean;
  94179. /**
  94180. * Event raised when audio has been unlocked on the browser.
  94181. */
  94182. onAudioUnlockedObservable: Observable<AudioEngine>;
  94183. /**
  94184. * Event raised when audio has been locked on the browser.
  94185. */
  94186. onAudioLockedObservable: Observable<AudioEngine>;
  94187. /**
  94188. * Gets the current AudioContext if available.
  94189. */
  94190. readonly audioContext: Nullable<AudioContext>;
  94191. private _connectedAnalyser;
  94192. /**
  94193. * Instantiates a new audio engine.
  94194. *
  94195. * There should be only one per page as some browsers restrict the number
  94196. * of audio contexts you can create.
  94197. * @param hostElement defines the host element where to display the mute icon if necessary
  94198. */
  94199. constructor(hostElement?: Nullable<HTMLElement>);
  94200. /**
  94201. * Flags the audio engine in Locked state.
  94202. * This happens due to new browser policies preventing audio to autoplay.
  94203. */
  94204. lock(): void;
  94205. /**
  94206. * Unlocks the audio engine once a user action has been done on the dom.
  94207. * This is helpful to resume play once browser policies have been satisfied.
  94208. */
  94209. unlock(): void;
  94210. private _resumeAudioContext;
  94211. private _initializeAudioContext;
  94212. private _tryToRun;
  94213. private _triggerRunningState;
  94214. private _triggerSuspendedState;
  94215. private _displayMuteButton;
  94216. private _moveButtonToTopLeft;
  94217. private _onResize;
  94218. private _hideMuteButton;
  94219. /**
  94220. * Destroy and release the resources associated with the audio ccontext.
  94221. */
  94222. dispose(): void;
  94223. /**
  94224. * Gets the global volume sets on the master gain.
  94225. * @returns the global volume if set or -1 otherwise
  94226. */
  94227. getGlobalVolume(): number;
  94228. /**
  94229. * Sets the global volume of your experience (sets on the master gain).
  94230. * @param newVolume Defines the new global volume of the application
  94231. */
  94232. setGlobalVolume(newVolume: number): void;
  94233. /**
  94234. * Connect the audio engine to an audio analyser allowing some amazing
  94235. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  94236. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  94237. * @param analyser The analyser to connect to the engine
  94238. */
  94239. connectToAnalyser(analyser: Analyser): void;
  94240. }
  94241. }
  94242. declare module BABYLON {
  94243. /**
  94244. * Interface used to present a loading screen while loading a scene
  94245. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  94246. */
  94247. export interface ILoadingScreen {
  94248. /**
  94249. * Function called to display the loading screen
  94250. */
  94251. displayLoadingUI: () => void;
  94252. /**
  94253. * Function called to hide the loading screen
  94254. */
  94255. hideLoadingUI: () => void;
  94256. /**
  94257. * Gets or sets the color to use for the background
  94258. */
  94259. loadingUIBackgroundColor: string;
  94260. /**
  94261. * Gets or sets the text to display while loading
  94262. */
  94263. loadingUIText: string;
  94264. }
  94265. /**
  94266. * Class used for the default loading screen
  94267. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  94268. */
  94269. export class DefaultLoadingScreen implements ILoadingScreen {
  94270. private _renderingCanvas;
  94271. private _loadingText;
  94272. private _loadingDivBackgroundColor;
  94273. private _loadingDiv;
  94274. private _loadingTextDiv;
  94275. /** Gets or sets the logo url to use for the default loading screen */
  94276. static DefaultLogoUrl: string;
  94277. /** Gets or sets the spinner url to use for the default loading screen */
  94278. static DefaultSpinnerUrl: string;
  94279. /**
  94280. * Creates a new default loading screen
  94281. * @param _renderingCanvas defines the canvas used to render the scene
  94282. * @param _loadingText defines the default text to display
  94283. * @param _loadingDivBackgroundColor defines the default background color
  94284. */
  94285. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  94286. /**
  94287. * Function called to display the loading screen
  94288. */
  94289. displayLoadingUI(): void;
  94290. /**
  94291. * Function called to hide the loading screen
  94292. */
  94293. hideLoadingUI(): void;
  94294. /**
  94295. * Gets or sets the text to display while loading
  94296. */
  94297. loadingUIText: string;
  94298. /**
  94299. * Gets or sets the color to use for the background
  94300. */
  94301. loadingUIBackgroundColor: string;
  94302. private _resizeLoadingUI;
  94303. }
  94304. }
  94305. declare module BABYLON {
  94306. /** @hidden */
  94307. export class WebGLPipelineContext implements IPipelineContext {
  94308. engine: Engine;
  94309. program: Nullable<WebGLProgram>;
  94310. context?: WebGLRenderingContext;
  94311. vertexShader?: WebGLShader;
  94312. fragmentShader?: WebGLShader;
  94313. isParallelCompiled: boolean;
  94314. onCompiled?: () => void;
  94315. transformFeedback?: WebGLTransformFeedback | null;
  94316. readonly isAsync: boolean;
  94317. readonly isReady: boolean;
  94318. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  94319. }
  94320. }
  94321. declare module BABYLON {
  94322. /** @hidden */
  94323. export class WebGLDataBuffer extends DataBuffer {
  94324. private _buffer;
  94325. constructor(resource: WebGLBuffer);
  94326. readonly underlyingResource: any;
  94327. }
  94328. }
  94329. declare module BABYLON {
  94330. /** @hidden */
  94331. export class WebGL2ShaderProcessor implements IShaderProcessor {
  94332. attributeProcessor(attribute: string): string;
  94333. varyingProcessor(varying: string, isFragment: boolean): string;
  94334. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  94335. }
  94336. }
  94337. declare module BABYLON {
  94338. /**
  94339. * This class is used to track a performance counter which is number based.
  94340. * The user has access to many properties which give statistics of different nature.
  94341. *
  94342. * The implementer can track two kinds of Performance Counter: time and count.
  94343. * 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.
  94344. * 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.
  94345. */
  94346. export class PerfCounter {
  94347. /**
  94348. * Gets or sets a global boolean to turn on and off all the counters
  94349. */
  94350. static Enabled: boolean;
  94351. /**
  94352. * Returns the smallest value ever
  94353. */
  94354. readonly min: number;
  94355. /**
  94356. * Returns the biggest value ever
  94357. */
  94358. readonly max: number;
  94359. /**
  94360. * Returns the average value since the performance counter is running
  94361. */
  94362. readonly average: number;
  94363. /**
  94364. * Returns the average value of the last second the counter was monitored
  94365. */
  94366. readonly lastSecAverage: number;
  94367. /**
  94368. * Returns the current value
  94369. */
  94370. readonly current: number;
  94371. /**
  94372. * Gets the accumulated total
  94373. */
  94374. readonly total: number;
  94375. /**
  94376. * Gets the total value count
  94377. */
  94378. readonly count: number;
  94379. /**
  94380. * Creates a new counter
  94381. */
  94382. constructor();
  94383. /**
  94384. * Call this method to start monitoring a new frame.
  94385. * 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.
  94386. */
  94387. fetchNewFrame(): void;
  94388. /**
  94389. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  94390. * @param newCount the count value to add to the monitored count
  94391. * @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.
  94392. */
  94393. addCount(newCount: number, fetchResult: boolean): void;
  94394. /**
  94395. * Start monitoring this performance counter
  94396. */
  94397. beginMonitoring(): void;
  94398. /**
  94399. * Compute the time lapsed since the previous beginMonitoring() call.
  94400. * @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
  94401. */
  94402. endMonitoring(newFrame?: boolean): void;
  94403. private _fetchResult;
  94404. private _startMonitoringTime;
  94405. private _min;
  94406. private _max;
  94407. private _average;
  94408. private _current;
  94409. private _totalValueCount;
  94410. private _totalAccumulated;
  94411. private _lastSecAverage;
  94412. private _lastSecAccumulated;
  94413. private _lastSecTime;
  94414. private _lastSecValueCount;
  94415. }
  94416. }
  94417. declare module BABYLON {
  94418. /**
  94419. * Interface for any object that can request an animation frame
  94420. */
  94421. export interface ICustomAnimationFrameRequester {
  94422. /**
  94423. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  94424. */
  94425. renderFunction?: Function;
  94426. /**
  94427. * Called to request the next frame to render to
  94428. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  94429. */
  94430. requestAnimationFrame: Function;
  94431. /**
  94432. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  94433. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  94434. */
  94435. requestID?: number;
  94436. }
  94437. }
  94438. declare module BABYLON {
  94439. /**
  94440. * Settings for finer control over video usage
  94441. */
  94442. export interface VideoTextureSettings {
  94443. /**
  94444. * Applies `autoplay` to video, if specified
  94445. */
  94446. autoPlay?: boolean;
  94447. /**
  94448. * Applies `loop` to video, if specified
  94449. */
  94450. loop?: boolean;
  94451. /**
  94452. * Automatically updates internal texture from video at every frame in the render loop
  94453. */
  94454. autoUpdateTexture: boolean;
  94455. /**
  94456. * Image src displayed during the video loading or until the user interacts with the video.
  94457. */
  94458. poster?: string;
  94459. }
  94460. /**
  94461. * If you want to display a video in your scene, this is the special texture for that.
  94462. * This special texture works similar to other textures, with the exception of a few parameters.
  94463. * @see https://doc.babylonjs.com/how_to/video_texture
  94464. */
  94465. export class VideoTexture extends Texture {
  94466. /**
  94467. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  94468. */
  94469. readonly autoUpdateTexture: boolean;
  94470. /**
  94471. * The video instance used by the texture internally
  94472. */
  94473. readonly video: HTMLVideoElement;
  94474. private _onUserActionRequestedObservable;
  94475. /**
  94476. * Event triggerd when a dom action is required by the user to play the video.
  94477. * This happens due to recent changes in browser policies preventing video to auto start.
  94478. */
  94479. readonly onUserActionRequestedObservable: Observable<Texture>;
  94480. private _generateMipMaps;
  94481. private _engine;
  94482. private _stillImageCaptured;
  94483. private _displayingPosterTexture;
  94484. private _settings;
  94485. private _createInternalTextureOnEvent;
  94486. private _frameId;
  94487. /**
  94488. * Creates a video texture.
  94489. * If you want to display a video in your scene, this is the special texture for that.
  94490. * This special texture works similar to other textures, with the exception of a few parameters.
  94491. * @see https://doc.babylonjs.com/how_to/video_texture
  94492. * @param name optional name, will detect from video source, if not defined
  94493. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  94494. * @param scene is obviously the current scene.
  94495. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  94496. * @param invertY is false by default but can be used to invert video on Y axis
  94497. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  94498. * @param settings allows finer control over video usage
  94499. */
  94500. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  94501. private _getName;
  94502. private _getVideo;
  94503. private _createInternalTexture;
  94504. private reset;
  94505. /**
  94506. * @hidden Internal method to initiate `update`.
  94507. */
  94508. _rebuild(): void;
  94509. /**
  94510. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  94511. */
  94512. update(): void;
  94513. /**
  94514. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  94515. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  94516. */
  94517. updateTexture(isVisible: boolean): void;
  94518. protected _updateInternalTexture: () => void;
  94519. /**
  94520. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  94521. * @param url New url.
  94522. */
  94523. updateURL(url: string): void;
  94524. /**
  94525. * Dispose the texture and release its associated resources.
  94526. */
  94527. dispose(): void;
  94528. /**
  94529. * Creates a video texture straight from a stream.
  94530. * @param scene Define the scene the texture should be created in
  94531. * @param stream Define the stream the texture should be created from
  94532. * @returns The created video texture as a promise
  94533. */
  94534. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  94535. /**
  94536. * Creates a video texture straight from your WebCam video feed.
  94537. * @param scene Define the scene the texture should be created in
  94538. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  94539. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  94540. * @returns The created video texture as a promise
  94541. */
  94542. static CreateFromWebCamAsync(scene: Scene, constraints: {
  94543. minWidth: number;
  94544. maxWidth: number;
  94545. minHeight: number;
  94546. maxHeight: number;
  94547. deviceId: string;
  94548. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  94549. /**
  94550. * Creates a video texture straight from your WebCam video feed.
  94551. * @param scene Define the scene the texture should be created in
  94552. * @param onReady Define a callback to triggered once the texture will be ready
  94553. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  94554. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  94555. */
  94556. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  94557. minWidth: number;
  94558. maxWidth: number;
  94559. minHeight: number;
  94560. maxHeight: number;
  94561. deviceId: string;
  94562. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  94563. }
  94564. }
  94565. declare module BABYLON {
  94566. /**
  94567. * Defines the interface used by objects containing a viewport (like a camera)
  94568. */
  94569. interface IViewportOwnerLike {
  94570. /**
  94571. * Gets or sets the viewport
  94572. */
  94573. viewport: IViewportLike;
  94574. }
  94575. /**
  94576. * Interface for attribute information associated with buffer instanciation
  94577. */
  94578. export class InstancingAttributeInfo {
  94579. /**
  94580. * Index/offset of the attribute in the vertex shader
  94581. */
  94582. index: number;
  94583. /**
  94584. * size of the attribute, 1, 2, 3 or 4
  94585. */
  94586. attributeSize: number;
  94587. /**
  94588. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  94589. * default is FLOAT
  94590. */
  94591. attribyteType: number;
  94592. /**
  94593. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  94594. */
  94595. normalized: boolean;
  94596. /**
  94597. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  94598. */
  94599. offset: number;
  94600. /**
  94601. * Name of the GLSL attribute, for debugging purpose only
  94602. */
  94603. attributeName: string;
  94604. }
  94605. /**
  94606. * Define options used to create a depth texture
  94607. */
  94608. export class DepthTextureCreationOptions {
  94609. /** Specifies whether or not a stencil should be allocated in the texture */
  94610. generateStencil?: boolean;
  94611. /** Specifies whether or not bilinear filtering is enable on the texture */
  94612. bilinearFiltering?: boolean;
  94613. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  94614. comparisonFunction?: number;
  94615. /** Specifies if the created texture is a cube texture */
  94616. isCube?: boolean;
  94617. }
  94618. /**
  94619. * Class used to describe the capabilities of the engine relatively to the current browser
  94620. */
  94621. export class EngineCapabilities {
  94622. /** Maximum textures units per fragment shader */
  94623. maxTexturesImageUnits: number;
  94624. /** Maximum texture units per vertex shader */
  94625. maxVertexTextureImageUnits: number;
  94626. /** Maximum textures units in the entire pipeline */
  94627. maxCombinedTexturesImageUnits: number;
  94628. /** Maximum texture size */
  94629. maxTextureSize: number;
  94630. /** Maximum cube texture size */
  94631. maxCubemapTextureSize: number;
  94632. /** Maximum render texture size */
  94633. maxRenderTextureSize: number;
  94634. /** Maximum number of vertex attributes */
  94635. maxVertexAttribs: number;
  94636. /** Maximum number of varyings */
  94637. maxVaryingVectors: number;
  94638. /** Maximum number of uniforms per vertex shader */
  94639. maxVertexUniformVectors: number;
  94640. /** Maximum number of uniforms per fragment shader */
  94641. maxFragmentUniformVectors: number;
  94642. /** Defines if standard derivates (dx/dy) are supported */
  94643. standardDerivatives: boolean;
  94644. /** Defines if s3tc texture compression is supported */
  94645. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  94646. /** Defines if pvrtc texture compression is supported */
  94647. pvrtc: any;
  94648. /** Defines if etc1 texture compression is supported */
  94649. etc1: any;
  94650. /** Defines if etc2 texture compression is supported */
  94651. etc2: any;
  94652. /** Defines if astc texture compression is supported */
  94653. astc: any;
  94654. /** Defines if float textures are supported */
  94655. textureFloat: boolean;
  94656. /** Defines if vertex array objects are supported */
  94657. vertexArrayObject: boolean;
  94658. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  94659. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  94660. /** Gets the maximum level of anisotropy supported */
  94661. maxAnisotropy: number;
  94662. /** Defines if instancing is supported */
  94663. instancedArrays: boolean;
  94664. /** Defines if 32 bits indices are supported */
  94665. uintIndices: boolean;
  94666. /** Defines if high precision shaders are supported */
  94667. highPrecisionShaderSupported: boolean;
  94668. /** Defines if depth reading in the fragment shader is supported */
  94669. fragmentDepthSupported: boolean;
  94670. /** Defines if float texture linear filtering is supported*/
  94671. textureFloatLinearFiltering: boolean;
  94672. /** Defines if rendering to float textures is supported */
  94673. textureFloatRender: boolean;
  94674. /** Defines if half float textures are supported*/
  94675. textureHalfFloat: boolean;
  94676. /** Defines if half float texture linear filtering is supported*/
  94677. textureHalfFloatLinearFiltering: boolean;
  94678. /** Defines if rendering to half float textures is supported */
  94679. textureHalfFloatRender: boolean;
  94680. /** Defines if textureLOD shader command is supported */
  94681. textureLOD: boolean;
  94682. /** Defines if draw buffers extension is supported */
  94683. drawBuffersExtension: boolean;
  94684. /** Defines if depth textures are supported */
  94685. depthTextureExtension: boolean;
  94686. /** Defines if float color buffer are supported */
  94687. colorBufferFloat: boolean;
  94688. /** Gets disjoint timer query extension (null if not supported) */
  94689. timerQuery: EXT_disjoint_timer_query;
  94690. /** Defines if timestamp can be used with timer query */
  94691. canUseTimestampForTimerQuery: boolean;
  94692. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  94693. multiview: any;
  94694. /** Function used to let the system compiles shaders in background */
  94695. parallelShaderCompile: {
  94696. COMPLETION_STATUS_KHR: number;
  94697. };
  94698. /** Max number of texture samples for MSAA */
  94699. maxMSAASamples: number;
  94700. }
  94701. /** Interface defining initialization parameters for Engine class */
  94702. export interface EngineOptions extends WebGLContextAttributes {
  94703. /**
  94704. * Defines if the engine should no exceed a specified device ratio
  94705. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  94706. */
  94707. limitDeviceRatio?: number;
  94708. /**
  94709. * Defines if webvr should be enabled automatically
  94710. * @see http://doc.babylonjs.com/how_to/webvr_camera
  94711. */
  94712. autoEnableWebVR?: boolean;
  94713. /**
  94714. * Defines if webgl2 should be turned off even if supported
  94715. * @see http://doc.babylonjs.com/features/webgl2
  94716. */
  94717. disableWebGL2Support?: boolean;
  94718. /**
  94719. * Defines if webaudio should be initialized as well
  94720. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94721. */
  94722. audioEngine?: boolean;
  94723. /**
  94724. * Defines if animations should run using a deterministic lock step
  94725. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94726. */
  94727. deterministicLockstep?: boolean;
  94728. /** Defines the maximum steps to use with deterministic lock step mode */
  94729. lockstepMaxSteps?: number;
  94730. /**
  94731. * Defines that engine should ignore context lost events
  94732. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  94733. */
  94734. doNotHandleContextLost?: boolean;
  94735. /**
  94736. * Defines that engine should ignore modifying touch action attribute and style
  94737. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  94738. */
  94739. doNotHandleTouchAction?: boolean;
  94740. /**
  94741. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  94742. */
  94743. useHighPrecisionFloats?: boolean;
  94744. }
  94745. /**
  94746. * Defines the interface used by display changed events
  94747. */
  94748. export interface IDisplayChangedEventArgs {
  94749. /** Gets the vrDisplay object (if any) */
  94750. vrDisplay: Nullable<any>;
  94751. /** Gets a boolean indicating if webVR is supported */
  94752. vrSupported: boolean;
  94753. }
  94754. /**
  94755. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  94756. */
  94757. export class Engine {
  94758. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  94759. static ExceptionList: ({
  94760. key: string;
  94761. capture: string;
  94762. captureConstraint: number;
  94763. targets: string[];
  94764. } | {
  94765. key: string;
  94766. capture: null;
  94767. captureConstraint: null;
  94768. targets: string[];
  94769. })[];
  94770. /** Gets the list of created engines */
  94771. static readonly Instances: Engine[];
  94772. /**
  94773. * Gets the latest created engine
  94774. */
  94775. static readonly LastCreatedEngine: Nullable<Engine>;
  94776. /**
  94777. * Gets the latest created scene
  94778. */
  94779. static readonly LastCreatedScene: Nullable<Scene>;
  94780. /**
  94781. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  94782. * @param flag defines which part of the materials must be marked as dirty
  94783. * @param predicate defines a predicate used to filter which materials should be affected
  94784. */
  94785. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  94786. /** @hidden */
  94787. static _TextureLoaders: IInternalTextureLoader[];
  94788. /** Defines that alpha blending is disabled */
  94789. static readonly ALPHA_DISABLE: number;
  94790. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  94791. static readonly ALPHA_ADD: number;
  94792. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  94793. static readonly ALPHA_COMBINE: number;
  94794. /** Defines that alpha blending to DEST - SRC * DEST */
  94795. static readonly ALPHA_SUBTRACT: number;
  94796. /** Defines that alpha blending to SRC * DEST */
  94797. static readonly ALPHA_MULTIPLY: number;
  94798. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  94799. static readonly ALPHA_MAXIMIZED: number;
  94800. /** Defines that alpha blending to SRC + DEST */
  94801. static readonly ALPHA_ONEONE: number;
  94802. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  94803. static readonly ALPHA_PREMULTIPLIED: number;
  94804. /**
  94805. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  94806. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  94807. */
  94808. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  94809. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  94810. static readonly ALPHA_INTERPOLATE: number;
  94811. /**
  94812. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  94813. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  94814. */
  94815. static readonly ALPHA_SCREENMODE: number;
  94816. /** Defines that the ressource is not delayed*/
  94817. static readonly DELAYLOADSTATE_NONE: number;
  94818. /** Defines that the ressource was successfully delay loaded */
  94819. static readonly DELAYLOADSTATE_LOADED: number;
  94820. /** Defines that the ressource is currently delay loading */
  94821. static readonly DELAYLOADSTATE_LOADING: number;
  94822. /** Defines that the ressource is delayed and has not started loading */
  94823. static readonly DELAYLOADSTATE_NOTLOADED: number;
  94824. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  94825. static readonly NEVER: number;
  94826. /** 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 */
  94827. static readonly ALWAYS: number;
  94828. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  94829. static readonly LESS: number;
  94830. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  94831. static readonly EQUAL: number;
  94832. /** 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 */
  94833. static readonly LEQUAL: number;
  94834. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  94835. static readonly GREATER: number;
  94836. /** 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 */
  94837. static readonly GEQUAL: number;
  94838. /** 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 */
  94839. static readonly NOTEQUAL: number;
  94840. /** Passed to stencilOperation to specify that stencil value must be kept */
  94841. static readonly KEEP: number;
  94842. /** Passed to stencilOperation to specify that stencil value must be replaced */
  94843. static readonly REPLACE: number;
  94844. /** Passed to stencilOperation to specify that stencil value must be incremented */
  94845. static readonly INCR: number;
  94846. /** Passed to stencilOperation to specify that stencil value must be decremented */
  94847. static readonly DECR: number;
  94848. /** Passed to stencilOperation to specify that stencil value must be inverted */
  94849. static readonly INVERT: number;
  94850. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  94851. static readonly INCR_WRAP: number;
  94852. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  94853. static readonly DECR_WRAP: number;
  94854. /** Texture is not repeating outside of 0..1 UVs */
  94855. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  94856. /** Texture is repeating outside of 0..1 UVs */
  94857. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  94858. /** Texture is repeating and mirrored */
  94859. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  94860. /** ALPHA */
  94861. static readonly TEXTUREFORMAT_ALPHA: number;
  94862. /** LUMINANCE */
  94863. static readonly TEXTUREFORMAT_LUMINANCE: number;
  94864. /** LUMINANCE_ALPHA */
  94865. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  94866. /** RGB */
  94867. static readonly TEXTUREFORMAT_RGB: number;
  94868. /** RGBA */
  94869. static readonly TEXTUREFORMAT_RGBA: number;
  94870. /** RED */
  94871. static readonly TEXTUREFORMAT_RED: number;
  94872. /** RED (2nd reference) */
  94873. static readonly TEXTUREFORMAT_R: number;
  94874. /** RG */
  94875. static readonly TEXTUREFORMAT_RG: number;
  94876. /** RED_INTEGER */
  94877. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  94878. /** RED_INTEGER (2nd reference) */
  94879. static readonly TEXTUREFORMAT_R_INTEGER: number;
  94880. /** RG_INTEGER */
  94881. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  94882. /** RGB_INTEGER */
  94883. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  94884. /** RGBA_INTEGER */
  94885. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  94886. /** UNSIGNED_BYTE */
  94887. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  94888. /** UNSIGNED_BYTE (2nd reference) */
  94889. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  94890. /** FLOAT */
  94891. static readonly TEXTURETYPE_FLOAT: number;
  94892. /** HALF_FLOAT */
  94893. static readonly TEXTURETYPE_HALF_FLOAT: number;
  94894. /** BYTE */
  94895. static readonly TEXTURETYPE_BYTE: number;
  94896. /** SHORT */
  94897. static readonly TEXTURETYPE_SHORT: number;
  94898. /** UNSIGNED_SHORT */
  94899. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  94900. /** INT */
  94901. static readonly TEXTURETYPE_INT: number;
  94902. /** UNSIGNED_INT */
  94903. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  94904. /** UNSIGNED_SHORT_4_4_4_4 */
  94905. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  94906. /** UNSIGNED_SHORT_5_5_5_1 */
  94907. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  94908. /** UNSIGNED_SHORT_5_6_5 */
  94909. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  94910. /** UNSIGNED_INT_2_10_10_10_REV */
  94911. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  94912. /** UNSIGNED_INT_24_8 */
  94913. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  94914. /** UNSIGNED_INT_10F_11F_11F_REV */
  94915. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  94916. /** UNSIGNED_INT_5_9_9_9_REV */
  94917. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  94918. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  94919. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  94920. /** nearest is mag = nearest and min = nearest and mip = linear */
  94921. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  94922. /** Bilinear is mag = linear and min = linear and mip = nearest */
  94923. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  94924. /** Trilinear is mag = linear and min = linear and mip = linear */
  94925. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  94926. /** nearest is mag = nearest and min = nearest and mip = linear */
  94927. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  94928. /** Bilinear is mag = linear and min = linear and mip = nearest */
  94929. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  94930. /** Trilinear is mag = linear and min = linear and mip = linear */
  94931. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  94932. /** mag = nearest and min = nearest and mip = nearest */
  94933. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  94934. /** mag = nearest and min = linear and mip = nearest */
  94935. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  94936. /** mag = nearest and min = linear and mip = linear */
  94937. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  94938. /** mag = nearest and min = linear and mip = none */
  94939. static readonly TEXTURE_NEAREST_LINEAR: number;
  94940. /** mag = nearest and min = nearest and mip = none */
  94941. static readonly TEXTURE_NEAREST_NEAREST: number;
  94942. /** mag = linear and min = nearest and mip = nearest */
  94943. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  94944. /** mag = linear and min = nearest and mip = linear */
  94945. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  94946. /** mag = linear and min = linear and mip = none */
  94947. static readonly TEXTURE_LINEAR_LINEAR: number;
  94948. /** mag = linear and min = nearest and mip = none */
  94949. static readonly TEXTURE_LINEAR_NEAREST: number;
  94950. /** Explicit coordinates mode */
  94951. static readonly TEXTURE_EXPLICIT_MODE: number;
  94952. /** Spherical coordinates mode */
  94953. static readonly TEXTURE_SPHERICAL_MODE: number;
  94954. /** Planar coordinates mode */
  94955. static readonly TEXTURE_PLANAR_MODE: number;
  94956. /** Cubic coordinates mode */
  94957. static readonly TEXTURE_CUBIC_MODE: number;
  94958. /** Projection coordinates mode */
  94959. static readonly TEXTURE_PROJECTION_MODE: number;
  94960. /** Skybox coordinates mode */
  94961. static readonly TEXTURE_SKYBOX_MODE: number;
  94962. /** Inverse Cubic coordinates mode */
  94963. static readonly TEXTURE_INVCUBIC_MODE: number;
  94964. /** Equirectangular coordinates mode */
  94965. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  94966. /** Equirectangular Fixed coordinates mode */
  94967. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  94968. /** Equirectangular Fixed Mirrored coordinates mode */
  94969. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  94970. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  94971. static readonly SCALEMODE_FLOOR: number;
  94972. /** Defines that texture rescaling will look for the nearest power of 2 size */
  94973. static readonly SCALEMODE_NEAREST: number;
  94974. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  94975. static readonly SCALEMODE_CEILING: number;
  94976. /**
  94977. * Returns the current npm package of the sdk
  94978. */
  94979. static readonly NpmPackage: string;
  94980. /**
  94981. * Returns the current version of the framework
  94982. */
  94983. static readonly Version: string;
  94984. /**
  94985. * Returns a string describing the current engine
  94986. */
  94987. readonly description: string;
  94988. /**
  94989. * Gets or sets the epsilon value used by collision engine
  94990. */
  94991. static CollisionsEpsilon: number;
  94992. /**
  94993. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  94994. */
  94995. static ShadersRepository: string;
  94996. /**
  94997. * Method called to create the default loading screen.
  94998. * This can be overriden in your own app.
  94999. * @param canvas The rendering canvas element
  95000. * @returns The loading screen
  95001. */
  95002. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  95003. /**
  95004. * Method called to create the default rescale post process on each engine.
  95005. */
  95006. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  95007. /** @hidden */
  95008. _shaderProcessor: IShaderProcessor;
  95009. /**
  95010. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  95011. */
  95012. forcePOTTextures: boolean;
  95013. /**
  95014. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  95015. */
  95016. isFullscreen: boolean;
  95017. /**
  95018. * Gets a boolean indicating if the pointer is currently locked
  95019. */
  95020. isPointerLock: boolean;
  95021. /**
  95022. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  95023. */
  95024. cullBackFaces: boolean;
  95025. /**
  95026. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  95027. */
  95028. renderEvenInBackground: boolean;
  95029. /**
  95030. * Gets or sets a boolean indicating that cache can be kept between frames
  95031. */
  95032. preventCacheWipeBetweenFrames: boolean;
  95033. /**
  95034. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  95035. **/
  95036. enableOfflineSupport: boolean;
  95037. /**
  95038. * 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)
  95039. **/
  95040. disableManifestCheck: boolean;
  95041. /**
  95042. * Gets the list of created scenes
  95043. */
  95044. scenes: Scene[];
  95045. /**
  95046. * Event raised when a new scene is created
  95047. */
  95048. onNewSceneAddedObservable: Observable<Scene>;
  95049. /**
  95050. * Gets the list of created postprocesses
  95051. */
  95052. postProcesses: PostProcess[];
  95053. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  95054. validateShaderPrograms: boolean;
  95055. /**
  95056. * Observable event triggered each time the rendering canvas is resized
  95057. */
  95058. onResizeObservable: Observable<Engine>;
  95059. /**
  95060. * Observable event triggered each time the canvas loses focus
  95061. */
  95062. onCanvasBlurObservable: Observable<Engine>;
  95063. /**
  95064. * Observable event triggered each time the canvas gains focus
  95065. */
  95066. onCanvasFocusObservable: Observable<Engine>;
  95067. /**
  95068. * Observable event triggered each time the canvas receives pointerout event
  95069. */
  95070. onCanvasPointerOutObservable: Observable<PointerEvent>;
  95071. /**
  95072. * Observable event triggered before each texture is initialized
  95073. */
  95074. onBeforeTextureInitObservable: Observable<Texture>;
  95075. /**
  95076. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  95077. */
  95078. disableUniformBuffers: boolean;
  95079. /** @hidden */
  95080. _uniformBuffers: UniformBuffer[];
  95081. /**
  95082. * Gets a boolean indicating that the engine supports uniform buffers
  95083. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  95084. */
  95085. readonly supportsUniformBuffers: boolean;
  95086. /**
  95087. * Observable raised when the engine begins a new frame
  95088. */
  95089. onBeginFrameObservable: Observable<Engine>;
  95090. /**
  95091. * If set, will be used to request the next animation frame for the render loop
  95092. */
  95093. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  95094. /**
  95095. * Observable raised when the engine ends the current frame
  95096. */
  95097. onEndFrameObservable: Observable<Engine>;
  95098. /**
  95099. * Observable raised when the engine is about to compile a shader
  95100. */
  95101. onBeforeShaderCompilationObservable: Observable<Engine>;
  95102. /**
  95103. * Observable raised when the engine has jsut compiled a shader
  95104. */
  95105. onAfterShaderCompilationObservable: Observable<Engine>;
  95106. /** @hidden */
  95107. _gl: WebGLRenderingContext;
  95108. private _renderingCanvas;
  95109. private _windowIsBackground;
  95110. private _webGLVersion;
  95111. protected _highPrecisionShadersAllowed: boolean;
  95112. /** @hidden */
  95113. readonly _shouldUseHighPrecisionShader: boolean;
  95114. /**
  95115. * Gets a boolean indicating that only power of 2 textures are supported
  95116. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  95117. */
  95118. readonly needPOTTextures: boolean;
  95119. /** @hidden */
  95120. _badOS: boolean;
  95121. /** @hidden */
  95122. _badDesktopOS: boolean;
  95123. /**
  95124. * Gets the audio engine
  95125. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  95126. * @ignorenaming
  95127. */
  95128. static audioEngine: IAudioEngine;
  95129. /**
  95130. * Default AudioEngine factory responsible of creating the Audio Engine.
  95131. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  95132. */
  95133. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  95134. /**
  95135. * Default offline support factory responsible of creating a tool used to store data locally.
  95136. * By default, this will create a Database object if the workload has been embedded.
  95137. */
  95138. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  95139. private _onFocus;
  95140. private _onBlur;
  95141. private _onCanvasPointerOut;
  95142. private _onCanvasBlur;
  95143. private _onCanvasFocus;
  95144. private _onFullscreenChange;
  95145. private _onPointerLockChange;
  95146. private _hardwareScalingLevel;
  95147. /** @hidden */
  95148. _caps: EngineCapabilities;
  95149. private _pointerLockRequested;
  95150. private _isStencilEnable;
  95151. private _colorWrite;
  95152. private _loadingScreen;
  95153. /** @hidden */
  95154. _drawCalls: PerfCounter;
  95155. private _glVersion;
  95156. private _glRenderer;
  95157. private _glVendor;
  95158. private _videoTextureSupported;
  95159. private _renderingQueueLaunched;
  95160. private _activeRenderLoops;
  95161. private _deterministicLockstep;
  95162. private _lockstepMaxSteps;
  95163. /**
  95164. * Observable signaled when a context lost event is raised
  95165. */
  95166. onContextLostObservable: Observable<Engine>;
  95167. /**
  95168. * Observable signaled when a context restored event is raised
  95169. */
  95170. onContextRestoredObservable: Observable<Engine>;
  95171. private _onContextLost;
  95172. private _onContextRestored;
  95173. private _contextWasLost;
  95174. /** @hidden */
  95175. _doNotHandleContextLost: boolean;
  95176. /**
  95177. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  95178. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  95179. */
  95180. doNotHandleContextLost: boolean;
  95181. private _performanceMonitor;
  95182. private _fps;
  95183. private _deltaTime;
  95184. /**
  95185. * Turn this value on if you want to pause FPS computation when in background
  95186. */
  95187. disablePerformanceMonitorInBackground: boolean;
  95188. /**
  95189. * Gets the performance monitor attached to this engine
  95190. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  95191. */
  95192. readonly performanceMonitor: PerformanceMonitor;
  95193. /**
  95194. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  95195. */
  95196. disableVertexArrayObjects: boolean;
  95197. /** @hidden */
  95198. protected _depthCullingState: _DepthCullingState;
  95199. /** @hidden */
  95200. protected _stencilState: _StencilState;
  95201. /** @hidden */
  95202. protected _alphaState: _AlphaState;
  95203. /** @hidden */
  95204. protected _alphaMode: number;
  95205. /** @hidden */
  95206. _internalTexturesCache: InternalTexture[];
  95207. /** @hidden */
  95208. protected _activeChannel: number;
  95209. private _currentTextureChannel;
  95210. /** @hidden */
  95211. protected _boundTexturesCache: {
  95212. [key: string]: Nullable<InternalTexture>;
  95213. };
  95214. /** @hidden */
  95215. protected _currentEffect: Nullable<Effect>;
  95216. /** @hidden */
  95217. protected _currentProgram: Nullable<WebGLProgram>;
  95218. private _compiledEffects;
  95219. private _vertexAttribArraysEnabled;
  95220. /** @hidden */
  95221. protected _cachedViewport: Nullable<IViewportLike>;
  95222. private _cachedVertexArrayObject;
  95223. /** @hidden */
  95224. protected _cachedVertexBuffers: any;
  95225. /** @hidden */
  95226. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  95227. /** @hidden */
  95228. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  95229. /** @hidden */
  95230. _currentRenderTarget: Nullable<InternalTexture>;
  95231. private _uintIndicesCurrentlySet;
  95232. private _currentBoundBuffer;
  95233. /** @hidden */
  95234. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  95235. private _currentBufferPointers;
  95236. private _currentInstanceLocations;
  95237. private _currentInstanceBuffers;
  95238. private _textureUnits;
  95239. /** @hidden */
  95240. _workingCanvas: Nullable<HTMLCanvasElement>;
  95241. /** @hidden */
  95242. _workingContext: Nullable<CanvasRenderingContext2D>;
  95243. private _rescalePostProcess;
  95244. private _dummyFramebuffer;
  95245. private _externalData;
  95246. /** @hidden */
  95247. _bindedRenderFunction: any;
  95248. private _vaoRecordInProgress;
  95249. private _mustWipeVertexAttributes;
  95250. private _emptyTexture;
  95251. private _emptyCubeTexture;
  95252. private _emptyTexture3D;
  95253. /** @hidden */
  95254. _frameHandler: number;
  95255. private _nextFreeTextureSlots;
  95256. private _maxSimultaneousTextures;
  95257. private _activeRequests;
  95258. private _texturesSupported;
  95259. /** @hidden */
  95260. _textureFormatInUse: Nullable<string>;
  95261. /**
  95262. * Gets the list of texture formats supported
  95263. */
  95264. readonly texturesSupported: Array<string>;
  95265. /**
  95266. * Gets the list of texture formats in use
  95267. */
  95268. readonly textureFormatInUse: Nullable<string>;
  95269. /**
  95270. * Gets the current viewport
  95271. */
  95272. readonly currentViewport: Nullable<IViewportLike>;
  95273. /**
  95274. * Gets the default empty texture
  95275. */
  95276. readonly emptyTexture: InternalTexture;
  95277. /**
  95278. * Gets the default empty 3D texture
  95279. */
  95280. readonly emptyTexture3D: InternalTexture;
  95281. /**
  95282. * Gets the default empty cube texture
  95283. */
  95284. readonly emptyCubeTexture: InternalTexture;
  95285. /**
  95286. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  95287. */
  95288. readonly premultipliedAlpha: boolean;
  95289. /**
  95290. * Creates a new engine
  95291. * @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
  95292. * @param antialias defines enable antialiasing (default: false)
  95293. * @param options defines further options to be sent to the getContext() function
  95294. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  95295. */
  95296. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  95297. /**
  95298. * Initializes a webVR display and starts listening to display change events
  95299. * The onVRDisplayChangedObservable will be notified upon these changes
  95300. * @returns The onVRDisplayChangedObservable
  95301. */
  95302. initWebVR(): Observable<IDisplayChangedEventArgs>;
  95303. /** @hidden */
  95304. _prepareVRComponent(): void;
  95305. /** @hidden */
  95306. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  95307. /** @hidden */
  95308. _submitVRFrame(): void;
  95309. /**
  95310. * Call this function to leave webVR mode
  95311. * Will do nothing if webVR is not supported or if there is no webVR device
  95312. * @see http://doc.babylonjs.com/how_to/webvr_camera
  95313. */
  95314. disableVR(): void;
  95315. /**
  95316. * Gets a boolean indicating that the system is in VR mode and is presenting
  95317. * @returns true if VR mode is engaged
  95318. */
  95319. isVRPresenting(): boolean;
  95320. /** @hidden */
  95321. _requestVRFrame(): void;
  95322. private _disableTouchAction;
  95323. private _rebuildInternalTextures;
  95324. private _rebuildEffects;
  95325. /**
  95326. * Gets a boolean indicating if all created effects are ready
  95327. * @returns true if all effects are ready
  95328. */
  95329. areAllEffectsReady(): boolean;
  95330. private _rebuildBuffers;
  95331. private _initGLContext;
  95332. /**
  95333. * Gets version of the current webGL context
  95334. */
  95335. readonly webGLVersion: number;
  95336. /**
  95337. * Gets a string idenfifying the name of the class
  95338. * @returns "Engine" string
  95339. */
  95340. getClassName(): string;
  95341. /**
  95342. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  95343. */
  95344. readonly isStencilEnable: boolean;
  95345. /** @hidden */
  95346. _prepareWorkingCanvas(): void;
  95347. /**
  95348. * Reset the texture cache to empty state
  95349. */
  95350. resetTextureCache(): void;
  95351. /**
  95352. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  95353. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95354. * @returns true if engine is in deterministic lock step mode
  95355. */
  95356. isDeterministicLockStep(): boolean;
  95357. /**
  95358. * Gets the max steps when engine is running in deterministic lock step
  95359. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95360. * @returns the max steps
  95361. */
  95362. getLockstepMaxSteps(): number;
  95363. /**
  95364. * Gets an object containing information about the current webGL context
  95365. * @returns an object containing the vender, the renderer and the version of the current webGL context
  95366. */
  95367. getGlInfo(): {
  95368. vendor: string;
  95369. renderer: string;
  95370. version: string;
  95371. };
  95372. /**
  95373. * Gets current aspect ratio
  95374. * @param viewportOwner defines the camera to use to get the aspect ratio
  95375. * @param useScreen defines if screen size must be used (or the current render target if any)
  95376. * @returns a number defining the aspect ratio
  95377. */
  95378. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  95379. /**
  95380. * Gets current screen aspect ratio
  95381. * @returns a number defining the aspect ratio
  95382. */
  95383. getScreenAspectRatio(): number;
  95384. /**
  95385. * Gets the current render width
  95386. * @param useScreen defines if screen size must be used (or the current render target if any)
  95387. * @returns a number defining the current render width
  95388. */
  95389. getRenderWidth(useScreen?: boolean): number;
  95390. /**
  95391. * Gets the current render height
  95392. * @param useScreen defines if screen size must be used (or the current render target if any)
  95393. * @returns a number defining the current render height
  95394. */
  95395. getRenderHeight(useScreen?: boolean): number;
  95396. /**
  95397. * Gets the HTML canvas attached with the current webGL context
  95398. * @returns a HTML canvas
  95399. */
  95400. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  95401. /**
  95402. * Gets host window
  95403. * @returns the host window object
  95404. */
  95405. getHostWindow(): Window;
  95406. /**
  95407. * Gets host document
  95408. * @returns the host document object
  95409. */
  95410. getHostDocument(): Document;
  95411. /**
  95412. * Gets the client rect of the HTML canvas attached with the current webGL context
  95413. * @returns a client rectanglee
  95414. */
  95415. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  95416. /**
  95417. * Defines the hardware scaling level.
  95418. * By default the hardware scaling level is computed from the window device ratio.
  95419. * 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.
  95420. * @param level defines the level to use
  95421. */
  95422. setHardwareScalingLevel(level: number): void;
  95423. /**
  95424. * Gets the current hardware scaling level.
  95425. * By default the hardware scaling level is computed from the window device ratio.
  95426. * 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.
  95427. * @returns a number indicating the current hardware scaling level
  95428. */
  95429. getHardwareScalingLevel(): number;
  95430. /**
  95431. * Gets the list of loaded textures
  95432. * @returns an array containing all loaded textures
  95433. */
  95434. getLoadedTexturesCache(): InternalTexture[];
  95435. /**
  95436. * Gets the object containing all engine capabilities
  95437. * @returns the EngineCapabilities object
  95438. */
  95439. getCaps(): EngineCapabilities;
  95440. /**
  95441. * Gets the current depth function
  95442. * @returns a number defining the depth function
  95443. */
  95444. getDepthFunction(): Nullable<number>;
  95445. /**
  95446. * Sets the current depth function
  95447. * @param depthFunc defines the function to use
  95448. */
  95449. setDepthFunction(depthFunc: number): void;
  95450. /**
  95451. * Sets the current depth function to GREATER
  95452. */
  95453. setDepthFunctionToGreater(): void;
  95454. /**
  95455. * Sets the current depth function to GEQUAL
  95456. */
  95457. setDepthFunctionToGreaterOrEqual(): void;
  95458. /**
  95459. * Sets the current depth function to LESS
  95460. */
  95461. setDepthFunctionToLess(): void;
  95462. private _cachedStencilBuffer;
  95463. private _cachedStencilFunction;
  95464. private _cachedStencilMask;
  95465. private _cachedStencilOperationPass;
  95466. private _cachedStencilOperationFail;
  95467. private _cachedStencilOperationDepthFail;
  95468. private _cachedStencilReference;
  95469. /**
  95470. * Caches the the state of the stencil buffer
  95471. */
  95472. cacheStencilState(): void;
  95473. /**
  95474. * Restores the state of the stencil buffer
  95475. */
  95476. restoreStencilState(): void;
  95477. /**
  95478. * Sets the current depth function to LEQUAL
  95479. */
  95480. setDepthFunctionToLessOrEqual(): void;
  95481. /**
  95482. * Gets a boolean indicating if stencil buffer is enabled
  95483. * @returns the current stencil buffer state
  95484. */
  95485. getStencilBuffer(): boolean;
  95486. /**
  95487. * Enable or disable the stencil buffer
  95488. * @param enable defines if the stencil buffer must be enabled or disabled
  95489. */
  95490. setStencilBuffer(enable: boolean): void;
  95491. /**
  95492. * Gets the current stencil mask
  95493. * @returns a number defining the new stencil mask to use
  95494. */
  95495. getStencilMask(): number;
  95496. /**
  95497. * Sets the current stencil mask
  95498. * @param mask defines the new stencil mask to use
  95499. */
  95500. setStencilMask(mask: number): void;
  95501. /**
  95502. * Gets the current stencil function
  95503. * @returns a number defining the stencil function to use
  95504. */
  95505. getStencilFunction(): number;
  95506. /**
  95507. * Gets the current stencil reference value
  95508. * @returns a number defining the stencil reference value to use
  95509. */
  95510. getStencilFunctionReference(): number;
  95511. /**
  95512. * Gets the current stencil mask
  95513. * @returns a number defining the stencil mask to use
  95514. */
  95515. getStencilFunctionMask(): number;
  95516. /**
  95517. * Sets the current stencil function
  95518. * @param stencilFunc defines the new stencil function to use
  95519. */
  95520. setStencilFunction(stencilFunc: number): void;
  95521. /**
  95522. * Sets the current stencil reference
  95523. * @param reference defines the new stencil reference to use
  95524. */
  95525. setStencilFunctionReference(reference: number): void;
  95526. /**
  95527. * Sets the current stencil mask
  95528. * @param mask defines the new stencil mask to use
  95529. */
  95530. setStencilFunctionMask(mask: number): void;
  95531. /**
  95532. * Gets the current stencil operation when stencil fails
  95533. * @returns a number defining stencil operation to use when stencil fails
  95534. */
  95535. getStencilOperationFail(): number;
  95536. /**
  95537. * Gets the current stencil operation when depth fails
  95538. * @returns a number defining stencil operation to use when depth fails
  95539. */
  95540. getStencilOperationDepthFail(): number;
  95541. /**
  95542. * Gets the current stencil operation when stencil passes
  95543. * @returns a number defining stencil operation to use when stencil passes
  95544. */
  95545. getStencilOperationPass(): number;
  95546. /**
  95547. * Sets the stencil operation to use when stencil fails
  95548. * @param operation defines the stencil operation to use when stencil fails
  95549. */
  95550. setStencilOperationFail(operation: number): void;
  95551. /**
  95552. * Sets the stencil operation to use when depth fails
  95553. * @param operation defines the stencil operation to use when depth fails
  95554. */
  95555. setStencilOperationDepthFail(operation: number): void;
  95556. /**
  95557. * Sets the stencil operation to use when stencil passes
  95558. * @param operation defines the stencil operation to use when stencil passes
  95559. */
  95560. setStencilOperationPass(operation: number): void;
  95561. /**
  95562. * Sets a boolean indicating if the dithering state is enabled or disabled
  95563. * @param value defines the dithering state
  95564. */
  95565. setDitheringState(value: boolean): void;
  95566. /**
  95567. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  95568. * @param value defines the rasterizer state
  95569. */
  95570. setRasterizerState(value: boolean): void;
  95571. /**
  95572. * stop executing a render loop function and remove it from the execution array
  95573. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  95574. */
  95575. stopRenderLoop(renderFunction?: () => void): void;
  95576. /** @hidden */
  95577. _renderLoop(): void;
  95578. /**
  95579. * Register and execute a render loop. The engine can have more than one render function
  95580. * @param renderFunction defines the function to continuously execute
  95581. */
  95582. runRenderLoop(renderFunction: () => void): void;
  95583. /**
  95584. * Toggle full screen mode
  95585. * @param requestPointerLock defines if a pointer lock should be requested from the user
  95586. */
  95587. switchFullscreen(requestPointerLock: boolean): void;
  95588. /**
  95589. * Enters full screen mode
  95590. * @param requestPointerLock defines if a pointer lock should be requested from the user
  95591. */
  95592. enterFullscreen(requestPointerLock: boolean): void;
  95593. /**
  95594. * Exits full screen mode
  95595. */
  95596. exitFullscreen(): void;
  95597. /**
  95598. * Enters Pointerlock mode
  95599. */
  95600. enterPointerlock(): void;
  95601. /**
  95602. * Exits Pointerlock mode
  95603. */
  95604. exitPointerlock(): void;
  95605. /**
  95606. * Clear the current render buffer or the current render target (if any is set up)
  95607. * @param color defines the color to use
  95608. * @param backBuffer defines if the back buffer must be cleared
  95609. * @param depth defines if the depth buffer must be cleared
  95610. * @param stencil defines if the stencil buffer must be cleared
  95611. */
  95612. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  95613. /**
  95614. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  95615. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  95616. * @param y defines the y-coordinate of the corner of the clear rectangle
  95617. * @param width defines the width of the clear rectangle
  95618. * @param height defines the height of the clear rectangle
  95619. * @param clearColor defines the clear color
  95620. */
  95621. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  95622. /**
  95623. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  95624. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  95625. * @param y defines the y-coordinate of the corner of the clear rectangle
  95626. * @param width defines the width of the clear rectangle
  95627. * @param height defines the height of the clear rectangle
  95628. */
  95629. enableScissor(x: number, y: number, width: number, height: number): void;
  95630. /**
  95631. * Disable previously set scissor test rectangle
  95632. */
  95633. disableScissor(): void;
  95634. private _viewportCached;
  95635. /** @hidden */
  95636. _viewport(x: number, y: number, width: number, height: number): void;
  95637. /**
  95638. * Set the WebGL's viewport
  95639. * @param viewport defines the viewport element to be used
  95640. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  95641. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  95642. */
  95643. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  95644. /**
  95645. * Directly set the WebGL Viewport
  95646. * @param x defines the x coordinate of the viewport (in screen space)
  95647. * @param y defines the y coordinate of the viewport (in screen space)
  95648. * @param width defines the width of the viewport (in screen space)
  95649. * @param height defines the height of the viewport (in screen space)
  95650. * @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
  95651. */
  95652. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  95653. /**
  95654. * Begin a new frame
  95655. */
  95656. beginFrame(): void;
  95657. /**
  95658. * Enf the current frame
  95659. */
  95660. endFrame(): void;
  95661. /**
  95662. * Resize the view according to the canvas' size
  95663. */
  95664. resize(): void;
  95665. /**
  95666. * Force a specific size of the canvas
  95667. * @param width defines the new canvas' width
  95668. * @param height defines the new canvas' height
  95669. */
  95670. setSize(width: number, height: number): void;
  95671. /**
  95672. * Binds the frame buffer to the specified texture.
  95673. * @param texture The texture to render to or null for the default canvas
  95674. * @param faceIndex The face of the texture to render to in case of cube texture
  95675. * @param requiredWidth The width of the target to render to
  95676. * @param requiredHeight The height of the target to render to
  95677. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  95678. * @param depthStencilTexture The depth stencil texture to use to render
  95679. * @param lodLevel defines le lod level to bind to the frame buffer
  95680. */
  95681. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  95682. /** @hidden */
  95683. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  95684. /**
  95685. * Unbind the current render target texture from the webGL context
  95686. * @param texture defines the render target texture to unbind
  95687. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  95688. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  95689. */
  95690. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  95691. /**
  95692. * Force the mipmap generation for the given render target texture
  95693. * @param texture defines the render target texture to use
  95694. */
  95695. generateMipMapsForCubemap(texture: InternalTexture): void;
  95696. /**
  95697. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  95698. */
  95699. flushFramebuffer(): void;
  95700. /**
  95701. * Unbind the current render target and bind the default framebuffer
  95702. */
  95703. restoreDefaultFramebuffer(): void;
  95704. /**
  95705. * Create an uniform buffer
  95706. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  95707. * @param elements defines the content of the uniform buffer
  95708. * @returns the webGL uniform buffer
  95709. */
  95710. createUniformBuffer(elements: FloatArray): DataBuffer;
  95711. /**
  95712. * Create a dynamic uniform buffer
  95713. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  95714. * @param elements defines the content of the uniform buffer
  95715. * @returns the webGL uniform buffer
  95716. */
  95717. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  95718. /**
  95719. * Update an existing uniform buffer
  95720. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  95721. * @param uniformBuffer defines the target uniform buffer
  95722. * @param elements defines the content to update
  95723. * @param offset defines the offset in the uniform buffer where update should start
  95724. * @param count defines the size of the data to update
  95725. */
  95726. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  95727. private _resetVertexBufferBinding;
  95728. /**
  95729. * Creates a vertex buffer
  95730. * @param data the data for the vertex buffer
  95731. * @returns the new WebGL static buffer
  95732. */
  95733. createVertexBuffer(data: DataArray): DataBuffer;
  95734. /**
  95735. * Creates a dynamic vertex buffer
  95736. * @param data the data for the dynamic vertex buffer
  95737. * @returns the new WebGL dynamic buffer
  95738. */
  95739. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  95740. /**
  95741. * Update a dynamic index buffer
  95742. * @param indexBuffer defines the target index buffer
  95743. * @param indices defines the data to update
  95744. * @param offset defines the offset in the target index buffer where update should start
  95745. */
  95746. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  95747. /**
  95748. * Updates a dynamic vertex buffer.
  95749. * @param vertexBuffer the vertex buffer to update
  95750. * @param data the data used to update the vertex buffer
  95751. * @param byteOffset the byte offset of the data
  95752. * @param byteLength the byte length of the data
  95753. */
  95754. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  95755. private _resetIndexBufferBinding;
  95756. /**
  95757. * Creates a new index buffer
  95758. * @param indices defines the content of the index buffer
  95759. * @param updatable defines if the index buffer must be updatable
  95760. * @returns a new webGL buffer
  95761. */
  95762. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  95763. /**
  95764. * Bind a webGL buffer to the webGL context
  95765. * @param buffer defines the buffer to bind
  95766. */
  95767. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  95768. /**
  95769. * Bind an uniform buffer to the current webGL context
  95770. * @param buffer defines the buffer to bind
  95771. */
  95772. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  95773. /**
  95774. * Bind a buffer to the current webGL context at a given location
  95775. * @param buffer defines the buffer to bind
  95776. * @param location defines the index where to bind the buffer
  95777. */
  95778. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  95779. /**
  95780. * Bind a specific block at a given index in a specific shader program
  95781. * @param pipelineContext defines the pipeline context to use
  95782. * @param blockName defines the block name
  95783. * @param index defines the index where to bind the block
  95784. */
  95785. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  95786. private bindIndexBuffer;
  95787. private bindBuffer;
  95788. /**
  95789. * update the bound buffer with the given data
  95790. * @param data defines the data to update
  95791. */
  95792. updateArrayBuffer(data: Float32Array): void;
  95793. private _vertexAttribPointer;
  95794. private _bindIndexBufferWithCache;
  95795. private _bindVertexBuffersAttributes;
  95796. /**
  95797. * Records a vertex array object
  95798. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  95799. * @param vertexBuffers defines the list of vertex buffers to store
  95800. * @param indexBuffer defines the index buffer to store
  95801. * @param effect defines the effect to store
  95802. * @returns the new vertex array object
  95803. */
  95804. recordVertexArrayObject(vertexBuffers: {
  95805. [key: string]: VertexBuffer;
  95806. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  95807. /**
  95808. * Bind a specific vertex array object
  95809. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  95810. * @param vertexArrayObject defines the vertex array object to bind
  95811. * @param indexBuffer defines the index buffer to bind
  95812. */
  95813. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  95814. /**
  95815. * Bind webGl buffers directly to the webGL context
  95816. * @param vertexBuffer defines the vertex buffer to bind
  95817. * @param indexBuffer defines the index buffer to bind
  95818. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  95819. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  95820. * @param effect defines the effect associated with the vertex buffer
  95821. */
  95822. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  95823. private _unbindVertexArrayObject;
  95824. /**
  95825. * Bind a list of vertex buffers to the webGL context
  95826. * @param vertexBuffers defines the list of vertex buffers to bind
  95827. * @param indexBuffer defines the index buffer to bind
  95828. * @param effect defines the effect associated with the vertex buffers
  95829. */
  95830. bindBuffers(vertexBuffers: {
  95831. [key: string]: Nullable<VertexBuffer>;
  95832. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  95833. /**
  95834. * Unbind all instance attributes
  95835. */
  95836. unbindInstanceAttributes(): void;
  95837. /**
  95838. * Release and free the memory of a vertex array object
  95839. * @param vao defines the vertex array object to delete
  95840. */
  95841. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  95842. /** @hidden */
  95843. _releaseBuffer(buffer: DataBuffer): boolean;
  95844. /**
  95845. * Creates a webGL buffer to use with instanciation
  95846. * @param capacity defines the size of the buffer
  95847. * @returns the webGL buffer
  95848. */
  95849. createInstancesBuffer(capacity: number): DataBuffer;
  95850. /**
  95851. * Delete a webGL buffer used with instanciation
  95852. * @param buffer defines the webGL buffer to delete
  95853. */
  95854. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  95855. /**
  95856. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  95857. * @param instancesBuffer defines the webGL buffer to update and bind
  95858. * @param data defines the data to store in the buffer
  95859. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  95860. */
  95861. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  95862. /**
  95863. * Apply all cached states (depth, culling, stencil and alpha)
  95864. */
  95865. applyStates(): void;
  95866. /**
  95867. * Send a draw order
  95868. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  95869. * @param indexStart defines the starting index
  95870. * @param indexCount defines the number of index to draw
  95871. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  95872. */
  95873. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  95874. /**
  95875. * Draw a list of points
  95876. * @param verticesStart defines the index of first vertex to draw
  95877. * @param verticesCount defines the count of vertices to draw
  95878. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  95879. */
  95880. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  95881. /**
  95882. * Draw a list of unindexed primitives
  95883. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  95884. * @param verticesStart defines the index of first vertex to draw
  95885. * @param verticesCount defines the count of vertices to draw
  95886. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  95887. */
  95888. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  95889. /**
  95890. * Draw a list of indexed primitives
  95891. * @param fillMode defines the primitive to use
  95892. * @param indexStart defines the starting index
  95893. * @param indexCount defines the number of index to draw
  95894. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  95895. */
  95896. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  95897. /**
  95898. * Draw a list of unindexed primitives
  95899. * @param fillMode defines the primitive to use
  95900. * @param verticesStart defines the index of first vertex to draw
  95901. * @param verticesCount defines the count of vertices to draw
  95902. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  95903. */
  95904. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  95905. private _drawMode;
  95906. /** @hidden */
  95907. _releaseEffect(effect: Effect): void;
  95908. /** @hidden */
  95909. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  95910. /**
  95911. * Create a new effect (used to store vertex/fragment shaders)
  95912. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  95913. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  95914. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  95915. * @param samplers defines an array of string used to represent textures
  95916. * @param defines defines the string containing the defines to use to compile the shaders
  95917. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  95918. * @param onCompiled defines a function to call when the effect creation is successful
  95919. * @param onError defines a function to call when the effect creation has failed
  95920. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  95921. * @returns the new Effect
  95922. */
  95923. 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;
  95924. private _compileShader;
  95925. private _compileRawShader;
  95926. /**
  95927. * Directly creates a webGL program
  95928. * @param pipelineContext defines the pipeline context to attach to
  95929. * @param vertexCode defines the vertex shader code to use
  95930. * @param fragmentCode defines the fragment shader code to use
  95931. * @param context defines the webGL context to use (if not set, the current one will be used)
  95932. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  95933. * @returns the new webGL program
  95934. */
  95935. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  95936. /**
  95937. * Creates a webGL program
  95938. * @param pipelineContext defines the pipeline context to attach to
  95939. * @param vertexCode defines the vertex shader code to use
  95940. * @param fragmentCode defines the fragment shader code to use
  95941. * @param defines defines the string containing the defines to use to compile the shaders
  95942. * @param context defines the webGL context to use (if not set, the current one will be used)
  95943. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  95944. * @returns the new webGL program
  95945. */
  95946. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  95947. /**
  95948. * Creates a new pipeline context
  95949. * @returns the new pipeline
  95950. */
  95951. createPipelineContext(): WebGLPipelineContext;
  95952. private _createShaderProgram;
  95953. private _finalizePipelineContext;
  95954. /** @hidden */
  95955. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  95956. /** @hidden */
  95957. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  95958. /** @hidden */
  95959. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  95960. /**
  95961. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  95962. * @param pipelineContext defines the pipeline context to use
  95963. * @param uniformsNames defines the list of uniform names
  95964. * @returns an array of webGL uniform locations
  95965. */
  95966. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  95967. /**
  95968. * Gets the lsit of active attributes for a given webGL program
  95969. * @param pipelineContext defines the pipeline context to use
  95970. * @param attributesNames defines the list of attribute names to get
  95971. * @returns an array of indices indicating the offset of each attribute
  95972. */
  95973. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  95974. /**
  95975. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  95976. * @param effect defines the effect to activate
  95977. */
  95978. enableEffect(effect: Nullable<Effect>): void;
  95979. /**
  95980. * Set the value of an uniform to an array of int32
  95981. * @param uniform defines the webGL uniform location where to store the value
  95982. * @param array defines the array of int32 to store
  95983. */
  95984. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  95985. /**
  95986. * Set the value of an uniform to an array of int32 (stored as vec2)
  95987. * @param uniform defines the webGL uniform location where to store the value
  95988. * @param array defines the array of int32 to store
  95989. */
  95990. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  95991. /**
  95992. * Set the value of an uniform to an array of int32 (stored as vec3)
  95993. * @param uniform defines the webGL uniform location where to store the value
  95994. * @param array defines the array of int32 to store
  95995. */
  95996. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  95997. /**
  95998. * Set the value of an uniform to an array of int32 (stored as vec4)
  95999. * @param uniform defines the webGL uniform location where to store the value
  96000. * @param array defines the array of int32 to store
  96001. */
  96002. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96003. /**
  96004. * Set the value of an uniform to an array of float32
  96005. * @param uniform defines the webGL uniform location where to store the value
  96006. * @param array defines the array of float32 to store
  96007. */
  96008. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96009. /**
  96010. * Set the value of an uniform to an array of float32 (stored as vec2)
  96011. * @param uniform defines the webGL uniform location where to store the value
  96012. * @param array defines the array of float32 to store
  96013. */
  96014. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96015. /**
  96016. * Set the value of an uniform to an array of float32 (stored as vec3)
  96017. * @param uniform defines the webGL uniform location where to store the value
  96018. * @param array defines the array of float32 to store
  96019. */
  96020. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96021. /**
  96022. * Set the value of an uniform to an array of float32 (stored as vec4)
  96023. * @param uniform defines the webGL uniform location where to store the value
  96024. * @param array defines the array of float32 to store
  96025. */
  96026. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96027. /**
  96028. * Set the value of an uniform to an array of number
  96029. * @param uniform defines the webGL uniform location where to store the value
  96030. * @param array defines the array of number to store
  96031. */
  96032. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96033. /**
  96034. * Set the value of an uniform to an array of number (stored as vec2)
  96035. * @param uniform defines the webGL uniform location where to store the value
  96036. * @param array defines the array of number to store
  96037. */
  96038. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96039. /**
  96040. * Set the value of an uniform to an array of number (stored as vec3)
  96041. * @param uniform defines the webGL uniform location where to store the value
  96042. * @param array defines the array of number to store
  96043. */
  96044. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96045. /**
  96046. * Set the value of an uniform to an array of number (stored as vec4)
  96047. * @param uniform defines the webGL uniform location where to store the value
  96048. * @param array defines the array of number to store
  96049. */
  96050. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96051. /**
  96052. * Set the value of an uniform to an array of float32 (stored as matrices)
  96053. * @param uniform defines the webGL uniform location where to store the value
  96054. * @param matrices defines the array of float32 to store
  96055. */
  96056. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  96057. /**
  96058. * Set the value of an uniform to a matrix (3x3)
  96059. * @param uniform defines the webGL uniform location where to store the value
  96060. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  96061. */
  96062. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  96063. /**
  96064. * Set the value of an uniform to a matrix (2x2)
  96065. * @param uniform defines the webGL uniform location where to store the value
  96066. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  96067. */
  96068. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  96069. /**
  96070. * Set the value of an uniform to a number (int)
  96071. * @param uniform defines the webGL uniform location where to store the value
  96072. * @param value defines the int number to store
  96073. */
  96074. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  96075. /**
  96076. * Set the value of an uniform to a number (float)
  96077. * @param uniform defines the webGL uniform location where to store the value
  96078. * @param value defines the float number to store
  96079. */
  96080. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  96081. /**
  96082. * Set the value of an uniform to a vec2
  96083. * @param uniform defines the webGL uniform location where to store the value
  96084. * @param x defines the 1st component of the value
  96085. * @param y defines the 2nd component of the value
  96086. */
  96087. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  96088. /**
  96089. * Set the value of an uniform to a vec3
  96090. * @param uniform defines the webGL uniform location where to store the value
  96091. * @param x defines the 1st component of the value
  96092. * @param y defines the 2nd component of the value
  96093. * @param z defines the 3rd component of the value
  96094. */
  96095. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  96096. /**
  96097. * Set the value of an uniform to a boolean
  96098. * @param uniform defines the webGL uniform location where to store the value
  96099. * @param bool defines the boolean to store
  96100. */
  96101. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  96102. /**
  96103. * Set the value of an uniform to a vec4
  96104. * @param uniform defines the webGL uniform location where to store the value
  96105. * @param x defines the 1st component of the value
  96106. * @param y defines the 2nd component of the value
  96107. * @param z defines the 3rd component of the value
  96108. * @param w defines the 4th component of the value
  96109. */
  96110. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  96111. /**
  96112. * Sets a Color4 on a uniform variable
  96113. * @param uniform defines the uniform location
  96114. * @param color4 defines the value to be set
  96115. */
  96116. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  96117. /**
  96118. * Set various states to the webGL context
  96119. * @param culling defines backface culling state
  96120. * @param zOffset defines the value to apply to zOffset (0 by default)
  96121. * @param force defines if states must be applied even if cache is up to date
  96122. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  96123. */
  96124. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  96125. /**
  96126. * Set the z offset to apply to current rendering
  96127. * @param value defines the offset to apply
  96128. */
  96129. setZOffset(value: number): void;
  96130. /**
  96131. * Gets the current value of the zOffset
  96132. * @returns the current zOffset state
  96133. */
  96134. getZOffset(): number;
  96135. /**
  96136. * Enable or disable depth buffering
  96137. * @param enable defines the state to set
  96138. */
  96139. setDepthBuffer(enable: boolean): void;
  96140. /**
  96141. * Gets a boolean indicating if depth writing is enabled
  96142. * @returns the current depth writing state
  96143. */
  96144. getDepthWrite(): boolean;
  96145. /**
  96146. * Enable or disable depth writing
  96147. * @param enable defines the state to set
  96148. */
  96149. setDepthWrite(enable: boolean): void;
  96150. /**
  96151. * Enable or disable color writing
  96152. * @param enable defines the state to set
  96153. */
  96154. setColorWrite(enable: boolean): void;
  96155. /**
  96156. * Gets a boolean indicating if color writing is enabled
  96157. * @returns the current color writing state
  96158. */
  96159. getColorWrite(): boolean;
  96160. /**
  96161. * Sets alpha constants used by some alpha blending modes
  96162. * @param r defines the red component
  96163. * @param g defines the green component
  96164. * @param b defines the blue component
  96165. * @param a defines the alpha component
  96166. */
  96167. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  96168. /**
  96169. * Sets the current alpha mode
  96170. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  96171. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  96172. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  96173. */
  96174. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  96175. /**
  96176. * Gets the current alpha mode
  96177. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  96178. * @returns the current alpha mode
  96179. */
  96180. getAlphaMode(): number;
  96181. /**
  96182. * Clears the list of texture accessible through engine.
  96183. * This can help preventing texture load conflict due to name collision.
  96184. */
  96185. clearInternalTexturesCache(): void;
  96186. /**
  96187. * Force the entire cache to be cleared
  96188. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  96189. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  96190. */
  96191. wipeCaches(bruteForce?: boolean): void;
  96192. /**
  96193. * Set the compressed texture format to use, based on the formats you have, and the formats
  96194. * supported by the hardware / browser.
  96195. *
  96196. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  96197. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  96198. * to API arguments needed to compressed textures. This puts the burden on the container
  96199. * generator to house the arcane code for determining these for current & future formats.
  96200. *
  96201. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  96202. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  96203. *
  96204. * Note: The result of this call is not taken into account when a texture is base64.
  96205. *
  96206. * @param formatsAvailable defines the list of those format families you have created
  96207. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  96208. *
  96209. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  96210. * @returns The extension selected.
  96211. */
  96212. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  96213. /** @hidden */
  96214. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  96215. min: number;
  96216. mag: number;
  96217. };
  96218. /** @hidden */
  96219. _createTexture(): WebGLTexture;
  96220. /**
  96221. * Usually called from Texture.ts.
  96222. * Passed information to create a WebGLTexture
  96223. * @param urlArg defines a value which contains one of the following:
  96224. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  96225. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  96226. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  96227. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  96228. * @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)
  96229. * @param scene needed for loading to the correct scene
  96230. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  96231. * @param onLoad optional callback to be called upon successful completion
  96232. * @param onError optional callback to be called upon failure
  96233. * @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
  96234. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  96235. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  96236. * @param forcedExtension defines the extension to use to pick the right loader
  96237. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  96238. * @returns a InternalTexture for assignment back into BABYLON.Texture
  96239. */
  96240. 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;
  96241. /**
  96242. * @hidden
  96243. * Rescales a texture
  96244. * @param source input texutre
  96245. * @param destination destination texture
  96246. * @param scene scene to use to render the resize
  96247. * @param internalFormat format to use when resizing
  96248. * @param onComplete callback to be called when resize has completed
  96249. */
  96250. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  96251. private _unpackFlipYCached;
  96252. /**
  96253. * In case you are sharing the context with other applications, it might
  96254. * be interested to not cache the unpack flip y state to ensure a consistent
  96255. * value would be set.
  96256. */
  96257. enableUnpackFlipYCached: boolean;
  96258. /** @hidden */
  96259. _unpackFlipY(value: boolean): void;
  96260. /** @hidden */
  96261. _getUnpackAlignement(): number;
  96262. /**
  96263. * Creates a dynamic texture
  96264. * @param width defines the width of the texture
  96265. * @param height defines the height of the texture
  96266. * @param generateMipMaps defines if the engine should generate the mip levels
  96267. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  96268. * @returns the dynamic texture inside an InternalTexture
  96269. */
  96270. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  96271. /**
  96272. * Update the sampling mode of a given texture
  96273. * @param samplingMode defines the required sampling mode
  96274. * @param texture defines the texture to update
  96275. */
  96276. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  96277. /**
  96278. * Update the content of a dynamic texture
  96279. * @param texture defines the texture to update
  96280. * @param canvas defines the canvas containing the source
  96281. * @param invertY defines if data must be stored with Y axis inverted
  96282. * @param premulAlpha defines if alpha is stored as premultiplied
  96283. * @param format defines the format of the data
  96284. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  96285. */
  96286. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  96287. /**
  96288. * Update a video texture
  96289. * @param texture defines the texture to update
  96290. * @param video defines the video element to use
  96291. * @param invertY defines if data must be stored with Y axis inverted
  96292. */
  96293. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  96294. /**
  96295. * Updates a depth texture Comparison Mode and Function.
  96296. * If the comparison Function is equal to 0, the mode will be set to none.
  96297. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  96298. * @param texture The texture to set the comparison function for
  96299. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  96300. */
  96301. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  96302. /** @hidden */
  96303. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  96304. width: number;
  96305. height: number;
  96306. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  96307. /**
  96308. * Creates a depth stencil texture.
  96309. * This is only available in WebGL 2 or with the depth texture extension available.
  96310. * @param size The size of face edge in the texture.
  96311. * @param options The options defining the texture.
  96312. * @returns The texture
  96313. */
  96314. createDepthStencilTexture(size: number | {
  96315. width: number;
  96316. height: number;
  96317. }, options: DepthTextureCreationOptions): InternalTexture;
  96318. /**
  96319. * Creates a depth stencil texture.
  96320. * This is only available in WebGL 2 or with the depth texture extension available.
  96321. * @param size The size of face edge in the texture.
  96322. * @param options The options defining the texture.
  96323. * @returns The texture
  96324. */
  96325. private _createDepthStencilTexture;
  96326. /**
  96327. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  96328. * @param renderTarget The render target to set the frame buffer for
  96329. */
  96330. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  96331. /**
  96332. * Creates a new render target texture
  96333. * @param size defines the size of the texture
  96334. * @param options defines the options used to create the texture
  96335. * @returns a new render target texture stored in an InternalTexture
  96336. */
  96337. createRenderTargetTexture(size: number | {
  96338. width: number;
  96339. height: number;
  96340. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  96341. /** @hidden */
  96342. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  96343. /**
  96344. * Updates the sample count of a render target texture
  96345. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  96346. * @param texture defines the texture to update
  96347. * @param samples defines the sample count to set
  96348. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  96349. */
  96350. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  96351. /** @hidden */
  96352. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96353. /** @hidden */
  96354. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  96355. /** @hidden */
  96356. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96357. /** @hidden */
  96358. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  96359. /**
  96360. * @hidden
  96361. */
  96362. _setCubeMapTextureParams(loadMipmap: boolean): void;
  96363. private _prepareWebGLTextureContinuation;
  96364. private _prepareWebGLTexture;
  96365. /** @hidden */
  96366. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  96367. /** @hidden */
  96368. _releaseFramebufferObjects(texture: InternalTexture): void;
  96369. /** @hidden */
  96370. _releaseTexture(texture: InternalTexture): void;
  96371. private setProgram;
  96372. private _boundUniforms;
  96373. /**
  96374. * Binds an effect to the webGL context
  96375. * @param effect defines the effect to bind
  96376. */
  96377. bindSamplers(effect: Effect): void;
  96378. private _activateCurrentTexture;
  96379. /** @hidden */
  96380. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  96381. /** @hidden */
  96382. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  96383. /**
  96384. * Sets a texture to the webGL context from a postprocess
  96385. * @param channel defines the channel to use
  96386. * @param postProcess defines the source postprocess
  96387. */
  96388. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  96389. /**
  96390. * Binds the output of the passed in post process to the texture channel specified
  96391. * @param channel The channel the texture should be bound to
  96392. * @param postProcess The post process which's output should be bound
  96393. */
  96394. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  96395. /**
  96396. * Unbind all textures from the webGL context
  96397. */
  96398. unbindAllTextures(): void;
  96399. /**
  96400. * Sets a texture to the according uniform.
  96401. * @param channel The texture channel
  96402. * @param uniform The uniform to set
  96403. * @param texture The texture to apply
  96404. */
  96405. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  96406. /**
  96407. * Sets a depth stencil texture from a render target to the according uniform.
  96408. * @param channel The texture channel
  96409. * @param uniform The uniform to set
  96410. * @param texture The render target texture containing the depth stencil texture to apply
  96411. */
  96412. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  96413. private _bindSamplerUniformToChannel;
  96414. private _getTextureWrapMode;
  96415. private _setTexture;
  96416. /**
  96417. * Sets an array of texture to the webGL context
  96418. * @param channel defines the channel where the texture array must be set
  96419. * @param uniform defines the associated uniform location
  96420. * @param textures defines the array of textures to bind
  96421. */
  96422. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  96423. /** @hidden */
  96424. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  96425. private _setTextureParameterFloat;
  96426. private _setTextureParameterInteger;
  96427. /**
  96428. * Reads pixels from the current frame buffer. Please note that this function can be slow
  96429. * @param x defines the x coordinate of the rectangle where pixels must be read
  96430. * @param y defines the y coordinate of the rectangle where pixels must be read
  96431. * @param width defines the width of the rectangle where pixels must be read
  96432. * @param height defines the height of the rectangle where pixels must be read
  96433. * @returns a Uint8Array containing RGBA colors
  96434. */
  96435. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  96436. /**
  96437. * Add an externaly attached data from its key.
  96438. * This method call will fail and return false, if such key already exists.
  96439. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  96440. * @param key the unique key that identifies the data
  96441. * @param data the data object to associate to the key for this Engine instance
  96442. * @return true if no such key were already present and the data was added successfully, false otherwise
  96443. */
  96444. addExternalData<T>(key: string, data: T): boolean;
  96445. /**
  96446. * Get an externaly attached data from its key
  96447. * @param key the unique key that identifies the data
  96448. * @return the associated data, if present (can be null), or undefined if not present
  96449. */
  96450. getExternalData<T>(key: string): T;
  96451. /**
  96452. * Get an externaly attached data from its key, create it using a factory if it's not already present
  96453. * @param key the unique key that identifies the data
  96454. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  96455. * @return the associated data, can be null if the factory returned null.
  96456. */
  96457. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  96458. /**
  96459. * Remove an externaly attached data from the Engine instance
  96460. * @param key the unique key that identifies the data
  96461. * @return true if the data was successfully removed, false if it doesn't exist
  96462. */
  96463. removeExternalData(key: string): boolean;
  96464. /**
  96465. * Unbind all vertex attributes from the webGL context
  96466. */
  96467. unbindAllAttributes(): void;
  96468. /**
  96469. * 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
  96470. */
  96471. releaseEffects(): void;
  96472. /**
  96473. * Dispose and release all associated resources
  96474. */
  96475. dispose(): void;
  96476. /**
  96477. * Display the loading screen
  96478. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  96479. */
  96480. displayLoadingUI(): void;
  96481. /**
  96482. * Hide the loading screen
  96483. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  96484. */
  96485. hideLoadingUI(): void;
  96486. /**
  96487. * Gets the current loading screen object
  96488. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  96489. */
  96490. /**
  96491. * Sets the current loading screen object
  96492. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  96493. */
  96494. loadingScreen: ILoadingScreen;
  96495. /**
  96496. * Sets the current loading screen text
  96497. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  96498. */
  96499. loadingUIText: string;
  96500. /**
  96501. * Sets the current loading screen background color
  96502. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  96503. */
  96504. loadingUIBackgroundColor: string;
  96505. /**
  96506. * Attach a new callback raised when context lost event is fired
  96507. * @param callback defines the callback to call
  96508. */
  96509. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  96510. /**
  96511. * Attach a new callback raised when context restored event is fired
  96512. * @param callback defines the callback to call
  96513. */
  96514. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  96515. /**
  96516. * Gets the source code of the vertex shader associated with a specific webGL program
  96517. * @param program defines the program to use
  96518. * @returns a string containing the source code of the vertex shader associated with the program
  96519. */
  96520. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  96521. /**
  96522. * Gets the source code of the fragment shader associated with a specific webGL program
  96523. * @param program defines the program to use
  96524. * @returns a string containing the source code of the fragment shader associated with the program
  96525. */
  96526. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  96527. /**
  96528. * Get the current error code of the webGL context
  96529. * @returns the error code
  96530. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  96531. */
  96532. getError(): number;
  96533. /**
  96534. * Gets the current framerate
  96535. * @returns a number representing the framerate
  96536. */
  96537. getFps(): number;
  96538. /**
  96539. * Gets the time spent between current and previous frame
  96540. * @returns a number representing the delta time in ms
  96541. */
  96542. getDeltaTime(): number;
  96543. private _measureFps;
  96544. /** @hidden */
  96545. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  96546. private _canRenderToFloatFramebuffer;
  96547. private _canRenderToHalfFloatFramebuffer;
  96548. private _canRenderToFramebuffer;
  96549. /** @hidden */
  96550. _getWebGLTextureType(type: number): number;
  96551. /** @hidden */
  96552. _getInternalFormat(format: number): number;
  96553. /** @hidden */
  96554. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  96555. /** @hidden */
  96556. _getRGBAMultiSampleBufferFormat(type: number): number;
  96557. /** @hidden */
  96558. _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;
  96559. /** @hidden */
  96560. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  96561. /**
  96562. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  96563. * @returns true if the engine can be created
  96564. * @ignorenaming
  96565. */
  96566. static isSupported(): boolean;
  96567. /**
  96568. * Find the next highest power of two.
  96569. * @param x Number to start search from.
  96570. * @return Next highest power of two.
  96571. */
  96572. static CeilingPOT(x: number): number;
  96573. /**
  96574. * Find the next lowest power of two.
  96575. * @param x Number to start search from.
  96576. * @return Next lowest power of two.
  96577. */
  96578. static FloorPOT(x: number): number;
  96579. /**
  96580. * Find the nearest power of two.
  96581. * @param x Number to start search from.
  96582. * @return Next nearest power of two.
  96583. */
  96584. static NearestPOT(x: number): number;
  96585. /**
  96586. * Get the closest exponent of two
  96587. * @param value defines the value to approximate
  96588. * @param max defines the maximum value to return
  96589. * @param mode defines how to define the closest value
  96590. * @returns closest exponent of two of the given value
  96591. */
  96592. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  96593. /**
  96594. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  96595. * @param func - the function to be called
  96596. * @param requester - the object that will request the next frame. Falls back to window.
  96597. * @returns frame number
  96598. */
  96599. static QueueNewFrame(func: () => void, requester?: any): number;
  96600. /**
  96601. * Ask the browser to promote the current element to pointerlock mode
  96602. * @param element defines the DOM element to promote
  96603. */
  96604. static _RequestPointerlock(element: HTMLElement): void;
  96605. /**
  96606. * Asks the browser to exit pointerlock mode
  96607. */
  96608. static _ExitPointerlock(): void;
  96609. /**
  96610. * Ask the browser to promote the current element to fullscreen rendering mode
  96611. * @param element defines the DOM element to promote
  96612. */
  96613. static _RequestFullscreen(element: HTMLElement): void;
  96614. /**
  96615. * Asks the browser to exit fullscreen mode
  96616. */
  96617. static _ExitFullscreen(): void;
  96618. }
  96619. }
  96620. declare module BABYLON {
  96621. /**
  96622. * The engine store class is responsible to hold all the instances of Engine and Scene created
  96623. * during the life time of the application.
  96624. */
  96625. export class EngineStore {
  96626. /** Gets the list of created engines */
  96627. static Instances: Engine[];
  96628. /** @hidden */
  96629. static _LastCreatedScene: Nullable<Scene>;
  96630. /**
  96631. * Gets the latest created engine
  96632. */
  96633. static readonly LastCreatedEngine: Nullable<Engine>;
  96634. /**
  96635. * Gets the latest created scene
  96636. */
  96637. static readonly LastCreatedScene: Nullable<Scene>;
  96638. /**
  96639. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  96640. * @ignorenaming
  96641. */
  96642. static UseFallbackTexture: boolean;
  96643. /**
  96644. * Texture content used if a texture cannot loaded
  96645. * @ignorenaming
  96646. */
  96647. static FallbackTexture: string;
  96648. }
  96649. }
  96650. declare module BABYLON {
  96651. /**
  96652. * Helper class that provides a small promise polyfill
  96653. */
  96654. export class PromisePolyfill {
  96655. /**
  96656. * Static function used to check if the polyfill is required
  96657. * If this is the case then the function will inject the polyfill to window.Promise
  96658. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  96659. */
  96660. static Apply(force?: boolean): void;
  96661. }
  96662. }
  96663. declare module BABYLON {
  96664. /**
  96665. * Interface for screenshot methods with describe argument called `size` as object with options
  96666. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  96667. */
  96668. export interface IScreenshotSize {
  96669. /**
  96670. * number in pixels for canvas height
  96671. */
  96672. height?: number;
  96673. /**
  96674. * multiplier allowing render at a higher or lower resolution
  96675. * If value is defined then height and width will be ignored and taken from camera
  96676. */
  96677. precision?: number;
  96678. /**
  96679. * number in pixels for canvas width
  96680. */
  96681. width?: number;
  96682. }
  96683. }
  96684. declare module BABYLON {
  96685. interface IColor4Like {
  96686. r: float;
  96687. g: float;
  96688. b: float;
  96689. a: float;
  96690. }
  96691. /**
  96692. * Class containing a set of static utilities functions
  96693. */
  96694. export class Tools {
  96695. /**
  96696. * Gets or sets the base URL to use to load assets
  96697. */
  96698. static BaseUrl: string;
  96699. /**
  96700. * Enable/Disable Custom HTTP Request Headers globally.
  96701. * default = false
  96702. * @see CustomRequestHeaders
  96703. */
  96704. static UseCustomRequestHeaders: boolean;
  96705. /**
  96706. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  96707. * i.e. when loading files, where the server/service expects an Authorization header
  96708. */
  96709. static CustomRequestHeaders: {
  96710. [key: string]: string;
  96711. };
  96712. /**
  96713. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  96714. */
  96715. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  96716. /**
  96717. * Default behaviour for cors in the application.
  96718. * It can be a string if the expected behavior is identical in the entire app.
  96719. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  96720. */
  96721. static CorsBehavior: string | ((url: string | string[]) => string);
  96722. /**
  96723. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  96724. * @ignorenaming
  96725. */
  96726. static UseFallbackTexture: boolean;
  96727. /**
  96728. * Use this object to register external classes like custom textures or material
  96729. * to allow the laoders to instantiate them
  96730. */
  96731. static RegisteredExternalClasses: {
  96732. [key: string]: Object;
  96733. };
  96734. /**
  96735. * Texture content used if a texture cannot loaded
  96736. * @ignorenaming
  96737. */
  96738. static fallbackTexture: string;
  96739. /**
  96740. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  96741. * @param u defines the coordinate on X axis
  96742. * @param v defines the coordinate on Y axis
  96743. * @param width defines the width of the source data
  96744. * @param height defines the height of the source data
  96745. * @param pixels defines the source byte array
  96746. * @param color defines the output color
  96747. */
  96748. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  96749. /**
  96750. * Interpolates between a and b via alpha
  96751. * @param a The lower value (returned when alpha = 0)
  96752. * @param b The upper value (returned when alpha = 1)
  96753. * @param alpha The interpolation-factor
  96754. * @return The mixed value
  96755. */
  96756. static Mix(a: number, b: number, alpha: number): number;
  96757. /**
  96758. * Tries to instantiate a new object from a given class name
  96759. * @param className defines the class name to instantiate
  96760. * @returns the new object or null if the system was not able to do the instantiation
  96761. */
  96762. static Instantiate(className: string): any;
  96763. /**
  96764. * Provides a slice function that will work even on IE
  96765. * @param data defines the array to slice
  96766. * @param start defines the start of the data (optional)
  96767. * @param end defines the end of the data (optional)
  96768. * @returns the new sliced array
  96769. */
  96770. static Slice<T>(data: T, start?: number, end?: number): T;
  96771. /**
  96772. * Polyfill for setImmediate
  96773. * @param action defines the action to execute after the current execution block
  96774. */
  96775. static SetImmediate(action: () => void): void;
  96776. /**
  96777. * Function indicating if a number is an exponent of 2
  96778. * @param value defines the value to test
  96779. * @returns true if the value is an exponent of 2
  96780. */
  96781. static IsExponentOfTwo(value: number): boolean;
  96782. private static _tmpFloatArray;
  96783. /**
  96784. * Returns the nearest 32-bit single precision float representation of a Number
  96785. * @param value A Number. If the parameter is of a different type, it will get converted
  96786. * to a number or to NaN if it cannot be converted
  96787. * @returns number
  96788. */
  96789. static FloatRound(value: number): number;
  96790. /**
  96791. * Extracts the filename from a path
  96792. * @param path defines the path to use
  96793. * @returns the filename
  96794. */
  96795. static GetFilename(path: string): string;
  96796. /**
  96797. * Extracts the "folder" part of a path (everything before the filename).
  96798. * @param uri The URI to extract the info from
  96799. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  96800. * @returns The "folder" part of the path
  96801. */
  96802. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  96803. /**
  96804. * Extracts text content from a DOM element hierarchy
  96805. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  96806. */
  96807. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  96808. /**
  96809. * Convert an angle in radians to degrees
  96810. * @param angle defines the angle to convert
  96811. * @returns the angle in degrees
  96812. */
  96813. static ToDegrees(angle: number): number;
  96814. /**
  96815. * Convert an angle in degrees to radians
  96816. * @param angle defines the angle to convert
  96817. * @returns the angle in radians
  96818. */
  96819. static ToRadians(angle: number): number;
  96820. /**
  96821. * Encode a buffer to a base64 string
  96822. * @param buffer defines the buffer to encode
  96823. * @returns the encoded string
  96824. */
  96825. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  96826. /**
  96827. * Returns an array if obj is not an array
  96828. * @param obj defines the object to evaluate as an array
  96829. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  96830. * @returns either obj directly if obj is an array or a new array containing obj
  96831. */
  96832. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  96833. /**
  96834. * Gets the pointer prefix to use
  96835. * @returns "pointer" if touch is enabled. Else returns "mouse"
  96836. */
  96837. static GetPointerPrefix(): string;
  96838. /**
  96839. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  96840. * @param url define the url we are trying
  96841. * @param element define the dom element where to configure the cors policy
  96842. */
  96843. static SetCorsBehavior(url: string | string[], element: {
  96844. crossOrigin: string | null;
  96845. }): void;
  96846. /**
  96847. * Removes unwanted characters from an url
  96848. * @param url defines the url to clean
  96849. * @returns the cleaned url
  96850. */
  96851. static CleanUrl(url: string): string;
  96852. /**
  96853. * Gets or sets a function used to pre-process url before using them to load assets
  96854. */
  96855. static PreprocessUrl: (url: string) => string;
  96856. /**
  96857. * Loads an image as an HTMLImageElement.
  96858. * @param input url string, ArrayBuffer, or Blob to load
  96859. * @param onLoad callback called when the image successfully loads
  96860. * @param onError callback called when the image fails to load
  96861. * @param offlineProvider offline provider for caching
  96862. * @returns the HTMLImageElement of the loaded image
  96863. */
  96864. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  96865. /**
  96866. * Loads a file
  96867. * @param url url string, ArrayBuffer, or Blob to load
  96868. * @param onSuccess callback called when the file successfully loads
  96869. * @param onProgress callback called while file is loading (if the server supports this mode)
  96870. * @param offlineProvider defines the offline provider for caching
  96871. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  96872. * @param onError callback called when the file fails to load
  96873. * @returns a file request object
  96874. */
  96875. 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;
  96876. /**
  96877. * Loads a file from a url
  96878. * @param url the file url to load
  96879. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  96880. */
  96881. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  96882. /**
  96883. * Load a script (identified by an url). When the url returns, the
  96884. * content of this file is added into a new script element, attached to the DOM (body element)
  96885. * @param scriptUrl defines the url of the script to laod
  96886. * @param onSuccess defines the callback called when the script is loaded
  96887. * @param onError defines the callback to call if an error occurs
  96888. * @param scriptId defines the id of the script element
  96889. */
  96890. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  96891. /**
  96892. * Load an asynchronous script (identified by an url). When the url returns, the
  96893. * content of this file is added into a new script element, attached to the DOM (body element)
  96894. * @param scriptUrl defines the url of the script to laod
  96895. * @param scriptId defines the id of the script element
  96896. * @returns a promise request object
  96897. */
  96898. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  96899. /**
  96900. * Loads a file from a blob
  96901. * @param fileToLoad defines the blob to use
  96902. * @param callback defines the callback to call when data is loaded
  96903. * @param progressCallback defines the callback to call during loading process
  96904. * @returns a file request object
  96905. */
  96906. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  96907. /**
  96908. * Loads a file
  96909. * @param fileToLoad defines the file to load
  96910. * @param callback defines the callback to call when data is loaded
  96911. * @param progressCallBack defines the callback to call during loading process
  96912. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  96913. * @returns a file request object
  96914. */
  96915. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  96916. /**
  96917. * Creates a data url from a given string content
  96918. * @param content defines the content to convert
  96919. * @returns the new data url link
  96920. */
  96921. static FileAsURL(content: string): string;
  96922. /**
  96923. * Format the given number to a specific decimal format
  96924. * @param value defines the number to format
  96925. * @param decimals defines the number of decimals to use
  96926. * @returns the formatted string
  96927. */
  96928. static Format(value: number, decimals?: number): string;
  96929. /**
  96930. * Tries to copy an object by duplicating every property
  96931. * @param source defines the source object
  96932. * @param destination defines the target object
  96933. * @param doNotCopyList defines a list of properties to avoid
  96934. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  96935. */
  96936. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  96937. /**
  96938. * Gets a boolean indicating if the given object has no own property
  96939. * @param obj defines the object to test
  96940. * @returns true if object has no own property
  96941. */
  96942. static IsEmpty(obj: any): boolean;
  96943. /**
  96944. * Function used to register events at window level
  96945. * @param windowElement defines the Window object to use
  96946. * @param events defines the events to register
  96947. */
  96948. static RegisterTopRootEvents(windowElement: Window, events: {
  96949. name: string;
  96950. handler: Nullable<(e: FocusEvent) => any>;
  96951. }[]): void;
  96952. /**
  96953. * Function used to unregister events from window level
  96954. * @param windowElement defines the Window object to use
  96955. * @param events defines the events to unregister
  96956. */
  96957. static UnregisterTopRootEvents(windowElement: Window, events: {
  96958. name: string;
  96959. handler: Nullable<(e: FocusEvent) => any>;
  96960. }[]): void;
  96961. /**
  96962. * @ignore
  96963. */
  96964. static _ScreenshotCanvas: HTMLCanvasElement;
  96965. /**
  96966. * Dumps the current bound framebuffer
  96967. * @param width defines the rendering width
  96968. * @param height defines the rendering height
  96969. * @param engine defines the hosting engine
  96970. * @param successCallback defines the callback triggered once the data are available
  96971. * @param mimeType defines the mime type of the result
  96972. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  96973. */
  96974. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  96975. /**
  96976. * Converts the canvas data to blob.
  96977. * This acts as a polyfill for browsers not supporting the to blob function.
  96978. * @param canvas Defines the canvas to extract the data from
  96979. * @param successCallback Defines the callback triggered once the data are available
  96980. * @param mimeType Defines the mime type of the result
  96981. */
  96982. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  96983. /**
  96984. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  96985. * @param successCallback defines the callback triggered once the data are available
  96986. * @param mimeType defines the mime type of the result
  96987. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  96988. */
  96989. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  96990. /**
  96991. * Downloads a blob in the browser
  96992. * @param blob defines the blob to download
  96993. * @param fileName defines the name of the downloaded file
  96994. */
  96995. static Download(blob: Blob, fileName: string): void;
  96996. /**
  96997. * Captures a screenshot of the current rendering
  96998. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  96999. * @param engine defines the rendering engine
  97000. * @param camera defines the source camera
  97001. * @param size This parameter can be set to a single number or to an object with the
  97002. * following (optional) properties: precision, width, height. If a single number is passed,
  97003. * it will be used for both width and height. If an object is passed, the screenshot size
  97004. * will be derived from the parameters. The precision property is a multiplier allowing
  97005. * rendering at a higher or lower resolution
  97006. * @param successCallback defines the callback receives a single parameter which contains the
  97007. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  97008. * src parameter of an <img> to display it
  97009. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  97010. * Check your browser for supported MIME types
  97011. */
  97012. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  97013. /**
  97014. * Captures a screenshot of the current rendering
  97015. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  97016. * @param engine defines the rendering engine
  97017. * @param camera defines the source camera
  97018. * @param size This parameter can be set to a single number or to an object with the
  97019. * following (optional) properties: precision, width, height. If a single number is passed,
  97020. * it will be used for both width and height. If an object is passed, the screenshot size
  97021. * will be derived from the parameters. The precision property is a multiplier allowing
  97022. * rendering at a higher or lower resolution
  97023. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  97024. * Check your browser for supported MIME types
  97025. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  97026. * to the src parameter of an <img> to display it
  97027. */
  97028. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  97029. /**
  97030. * Generates an image screenshot from the specified camera.
  97031. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  97032. * @param engine The engine to use for rendering
  97033. * @param camera The camera to use for rendering
  97034. * @param size This parameter can be set to a single number or to an object with the
  97035. * following (optional) properties: precision, width, height. If a single number is passed,
  97036. * it will be used for both width and height. If an object is passed, the screenshot size
  97037. * will be derived from the parameters. The precision property is a multiplier allowing
  97038. * rendering at a higher or lower resolution
  97039. * @param successCallback The callback receives a single parameter which contains the
  97040. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  97041. * src parameter of an <img> to display it
  97042. * @param mimeType The MIME type of the screenshot image (default: image/png).
  97043. * Check your browser for supported MIME types
  97044. * @param samples Texture samples (default: 1)
  97045. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  97046. * @param fileName A name for for the downloaded file.
  97047. */
  97048. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  97049. /**
  97050. * Generates an image screenshot from the specified camera.
  97051. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  97052. * @param engine The engine to use for rendering
  97053. * @param camera The camera to use for rendering
  97054. * @param size This parameter can be set to a single number or to an object with the
  97055. * following (optional) properties: precision, width, height. If a single number is passed,
  97056. * it will be used for both width and height. If an object is passed, the screenshot size
  97057. * will be derived from the parameters. The precision property is a multiplier allowing
  97058. * rendering at a higher or lower resolution
  97059. * @param mimeType The MIME type of the screenshot image (default: image/png).
  97060. * Check your browser for supported MIME types
  97061. * @param samples Texture samples (default: 1)
  97062. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  97063. * @param fileName A name for for the downloaded file.
  97064. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  97065. * to the src parameter of an <img> to display it
  97066. */
  97067. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  97068. /**
  97069. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  97070. * Be aware Math.random() could cause collisions, but:
  97071. * "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"
  97072. * @returns a pseudo random id
  97073. */
  97074. static RandomId(): string;
  97075. /**
  97076. * Test if the given uri is a base64 string
  97077. * @param uri The uri to test
  97078. * @return True if the uri is a base64 string or false otherwise
  97079. */
  97080. static IsBase64(uri: string): boolean;
  97081. /**
  97082. * Decode the given base64 uri.
  97083. * @param uri The uri to decode
  97084. * @return The decoded base64 data.
  97085. */
  97086. static DecodeBase64(uri: string): ArrayBuffer;
  97087. /**
  97088. * Gets the absolute url.
  97089. * @param url the input url
  97090. * @return the absolute url
  97091. */
  97092. static GetAbsoluteUrl(url: string): string;
  97093. /**
  97094. * No log
  97095. */
  97096. static readonly NoneLogLevel: number;
  97097. /**
  97098. * Only message logs
  97099. */
  97100. static readonly MessageLogLevel: number;
  97101. /**
  97102. * Only warning logs
  97103. */
  97104. static readonly WarningLogLevel: number;
  97105. /**
  97106. * Only error logs
  97107. */
  97108. static readonly ErrorLogLevel: number;
  97109. /**
  97110. * All logs
  97111. */
  97112. static readonly AllLogLevel: number;
  97113. /**
  97114. * Gets a value indicating the number of loading errors
  97115. * @ignorenaming
  97116. */
  97117. static readonly errorsCount: number;
  97118. /**
  97119. * Callback called when a new log is added
  97120. */
  97121. static OnNewCacheEntry: (entry: string) => void;
  97122. /**
  97123. * Log a message to the console
  97124. * @param message defines the message to log
  97125. */
  97126. static Log(message: string): void;
  97127. /**
  97128. * Write a warning message to the console
  97129. * @param message defines the message to log
  97130. */
  97131. static Warn(message: string): void;
  97132. /**
  97133. * Write an error message to the console
  97134. * @param message defines the message to log
  97135. */
  97136. static Error(message: string): void;
  97137. /**
  97138. * Gets current log cache (list of logs)
  97139. */
  97140. static readonly LogCache: string;
  97141. /**
  97142. * Clears the log cache
  97143. */
  97144. static ClearLogCache(): void;
  97145. /**
  97146. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  97147. */
  97148. static LogLevels: number;
  97149. /**
  97150. * Checks if the window object exists
  97151. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  97152. */
  97153. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  97154. /**
  97155. * No performance log
  97156. */
  97157. static readonly PerformanceNoneLogLevel: number;
  97158. /**
  97159. * Use user marks to log performance
  97160. */
  97161. static readonly PerformanceUserMarkLogLevel: number;
  97162. /**
  97163. * Log performance to the console
  97164. */
  97165. static readonly PerformanceConsoleLogLevel: number;
  97166. private static _performance;
  97167. /**
  97168. * Sets the current performance log level
  97169. */
  97170. static PerformanceLogLevel: number;
  97171. private static _StartPerformanceCounterDisabled;
  97172. private static _EndPerformanceCounterDisabled;
  97173. private static _StartUserMark;
  97174. private static _EndUserMark;
  97175. private static _StartPerformanceConsole;
  97176. private static _EndPerformanceConsole;
  97177. /**
  97178. * Starts a performance counter
  97179. */
  97180. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  97181. /**
  97182. * Ends a specific performance coutner
  97183. */
  97184. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  97185. /**
  97186. * Gets either window.performance.now() if supported or Date.now() else
  97187. */
  97188. static readonly Now: number;
  97189. /**
  97190. * This method will return the name of the class used to create the instance of the given object.
  97191. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  97192. * @param object the object to get the class name from
  97193. * @param isType defines if the object is actually a type
  97194. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  97195. */
  97196. static GetClassName(object: any, isType?: boolean): string;
  97197. /**
  97198. * Gets the first element of an array satisfying a given predicate
  97199. * @param array defines the array to browse
  97200. * @param predicate defines the predicate to use
  97201. * @returns null if not found or the element
  97202. */
  97203. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  97204. /**
  97205. * This method will return the name of the full name of the class, including its owning module (if any).
  97206. * 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).
  97207. * @param object the object to get the class name from
  97208. * @param isType defines if the object is actually a type
  97209. * @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.
  97210. * @ignorenaming
  97211. */
  97212. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  97213. /**
  97214. * Returns a promise that resolves after the given amount of time.
  97215. * @param delay Number of milliseconds to delay
  97216. * @returns Promise that resolves after the given amount of time
  97217. */
  97218. static DelayAsync(delay: number): Promise<void>;
  97219. }
  97220. /**
  97221. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  97222. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  97223. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  97224. * @param name The name of the class, case should be preserved
  97225. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  97226. */
  97227. export function className(name: string, module?: string): (target: Object) => void;
  97228. /**
  97229. * An implementation of a loop for asynchronous functions.
  97230. */
  97231. export class AsyncLoop {
  97232. /**
  97233. * Defines the number of iterations for the loop
  97234. */
  97235. iterations: number;
  97236. /**
  97237. * Defines the current index of the loop.
  97238. */
  97239. index: number;
  97240. private _done;
  97241. private _fn;
  97242. private _successCallback;
  97243. /**
  97244. * Constructor.
  97245. * @param iterations the number of iterations.
  97246. * @param func the function to run each iteration
  97247. * @param successCallback the callback that will be called upon succesful execution
  97248. * @param offset starting offset.
  97249. */
  97250. constructor(
  97251. /**
  97252. * Defines the number of iterations for the loop
  97253. */
  97254. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  97255. /**
  97256. * Execute the next iteration. Must be called after the last iteration was finished.
  97257. */
  97258. executeNext(): void;
  97259. /**
  97260. * Break the loop and run the success callback.
  97261. */
  97262. breakLoop(): void;
  97263. /**
  97264. * Create and run an async loop.
  97265. * @param iterations the number of iterations.
  97266. * @param fn the function to run each iteration
  97267. * @param successCallback the callback that will be called upon succesful execution
  97268. * @param offset starting offset.
  97269. * @returns the created async loop object
  97270. */
  97271. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  97272. /**
  97273. * A for-loop that will run a given number of iterations synchronous and the rest async.
  97274. * @param iterations total number of iterations
  97275. * @param syncedIterations number of synchronous iterations in each async iteration.
  97276. * @param fn the function to call each iteration.
  97277. * @param callback a success call back that will be called when iterating stops.
  97278. * @param breakFunction a break condition (optional)
  97279. * @param timeout timeout settings for the setTimeout function. default - 0.
  97280. * @returns the created async loop object
  97281. */
  97282. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  97283. }
  97284. }
  97285. declare module BABYLON {
  97286. /** @hidden */
  97287. export interface ICollisionCoordinator {
  97288. createCollider(): Collider;
  97289. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  97290. init(scene: Scene): void;
  97291. }
  97292. /** @hidden */
  97293. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  97294. private _scene;
  97295. private _scaledPosition;
  97296. private _scaledVelocity;
  97297. private _finalPosition;
  97298. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  97299. createCollider(): Collider;
  97300. init(scene: Scene): void;
  97301. private _collideWithWorld;
  97302. }
  97303. }
  97304. declare module BABYLON {
  97305. /**
  97306. * Class used to manage all inputs for the scene.
  97307. */
  97308. export class InputManager {
  97309. /** The distance in pixel that you have to move to prevent some events */
  97310. static DragMovementThreshold: number;
  97311. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  97312. static LongPressDelay: number;
  97313. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  97314. static DoubleClickDelay: number;
  97315. /** If you need to check double click without raising a single click at first click, enable this flag */
  97316. static ExclusiveDoubleClickMode: boolean;
  97317. private _wheelEventName;
  97318. private _onPointerMove;
  97319. private _onPointerDown;
  97320. private _onPointerUp;
  97321. private _initClickEvent;
  97322. private _initActionManager;
  97323. private _delayedSimpleClick;
  97324. private _delayedSimpleClickTimeout;
  97325. private _previousDelayedSimpleClickTimeout;
  97326. private _meshPickProceed;
  97327. private _previousButtonPressed;
  97328. private _currentPickResult;
  97329. private _previousPickResult;
  97330. private _totalPointersPressed;
  97331. private _doubleClickOccured;
  97332. private _pointerOverMesh;
  97333. private _pickedDownMesh;
  97334. private _pickedUpMesh;
  97335. private _pointerX;
  97336. private _pointerY;
  97337. private _unTranslatedPointerX;
  97338. private _unTranslatedPointerY;
  97339. private _startingPointerPosition;
  97340. private _previousStartingPointerPosition;
  97341. private _startingPointerTime;
  97342. private _previousStartingPointerTime;
  97343. private _pointerCaptures;
  97344. private _onKeyDown;
  97345. private _onKeyUp;
  97346. private _onCanvasFocusObserver;
  97347. private _onCanvasBlurObserver;
  97348. private _scene;
  97349. /**
  97350. * Creates a new InputManager
  97351. * @param scene defines the hosting scene
  97352. */
  97353. constructor(scene: Scene);
  97354. /**
  97355. * Gets the mesh that is currently under the pointer
  97356. */
  97357. readonly meshUnderPointer: Nullable<AbstractMesh>;
  97358. /**
  97359. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  97360. */
  97361. readonly unTranslatedPointer: Vector2;
  97362. /**
  97363. * Gets or sets the current on-screen X position of the pointer
  97364. */
  97365. pointerX: number;
  97366. /**
  97367. * Gets or sets the current on-screen Y position of the pointer
  97368. */
  97369. pointerY: number;
  97370. private _updatePointerPosition;
  97371. private _processPointerMove;
  97372. private _setRayOnPointerInfo;
  97373. private _checkPrePointerObservable;
  97374. /**
  97375. * Use this method to simulate a pointer move on a mesh
  97376. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  97377. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  97378. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  97379. */
  97380. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  97381. /**
  97382. * Use this method to simulate a pointer down on a mesh
  97383. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  97384. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  97385. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  97386. */
  97387. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  97388. private _processPointerDown;
  97389. /** @hidden */
  97390. _isPointerSwiping(): boolean;
  97391. /**
  97392. * Use this method to simulate a pointer up on a mesh
  97393. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  97394. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  97395. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  97396. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  97397. */
  97398. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  97399. private _processPointerUp;
  97400. /**
  97401. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  97402. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  97403. * @returns true if the pointer was captured
  97404. */
  97405. isPointerCaptured(pointerId?: number): boolean;
  97406. /**
  97407. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  97408. * @param attachUp defines if you want to attach events to pointerup
  97409. * @param attachDown defines if you want to attach events to pointerdown
  97410. * @param attachMove defines if you want to attach events to pointermove
  97411. */
  97412. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  97413. /**
  97414. * Detaches all event handlers
  97415. */
  97416. detachControl(): void;
  97417. /**
  97418. * Force the value of meshUnderPointer
  97419. * @param mesh defines the mesh to use
  97420. */
  97421. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  97422. /**
  97423. * Gets the mesh under the pointer
  97424. * @returns a Mesh or null if no mesh is under the pointer
  97425. */
  97426. getPointerOverMesh(): Nullable<AbstractMesh>;
  97427. }
  97428. }
  97429. declare module BABYLON {
  97430. /**
  97431. * Helper class used to generate session unique ID
  97432. */
  97433. export class UniqueIdGenerator {
  97434. private static _UniqueIdCounter;
  97435. /**
  97436. * Gets an unique (relatively to the current scene) Id
  97437. */
  97438. static readonly UniqueId: number;
  97439. }
  97440. }
  97441. declare module BABYLON {
  97442. /**
  97443. * This class defines the direct association between an animation and a target
  97444. */
  97445. export class TargetedAnimation {
  97446. /**
  97447. * Animation to perform
  97448. */
  97449. animation: Animation;
  97450. /**
  97451. * Target to animate
  97452. */
  97453. target: any;
  97454. /**
  97455. * Serialize the object
  97456. * @returns the JSON object representing the current entity
  97457. */
  97458. serialize(): any;
  97459. }
  97460. /**
  97461. * Use this class to create coordinated animations on multiple targets
  97462. */
  97463. export class AnimationGroup implements IDisposable {
  97464. /** The name of the animation group */
  97465. name: string;
  97466. private _scene;
  97467. private _targetedAnimations;
  97468. private _animatables;
  97469. private _from;
  97470. private _to;
  97471. private _isStarted;
  97472. private _isPaused;
  97473. private _speedRatio;
  97474. private _loopAnimation;
  97475. /**
  97476. * Gets or sets the unique id of the node
  97477. */
  97478. uniqueId: number;
  97479. /**
  97480. * This observable will notify when one animation have ended
  97481. */
  97482. onAnimationEndObservable: Observable<TargetedAnimation>;
  97483. /**
  97484. * Observer raised when one animation loops
  97485. */
  97486. onAnimationLoopObservable: Observable<TargetedAnimation>;
  97487. /**
  97488. * This observable will notify when all animations have ended.
  97489. */
  97490. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  97491. /**
  97492. * This observable will notify when all animations have paused.
  97493. */
  97494. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  97495. /**
  97496. * This observable will notify when all animations are playing.
  97497. */
  97498. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  97499. /**
  97500. * Gets the first frame
  97501. */
  97502. readonly from: number;
  97503. /**
  97504. * Gets the last frame
  97505. */
  97506. readonly to: number;
  97507. /**
  97508. * Define if the animations are started
  97509. */
  97510. readonly isStarted: boolean;
  97511. /**
  97512. * Gets a value indicating that the current group is playing
  97513. */
  97514. readonly isPlaying: boolean;
  97515. /**
  97516. * Gets or sets the speed ratio to use for all animations
  97517. */
  97518. /**
  97519. * Gets or sets the speed ratio to use for all animations
  97520. */
  97521. speedRatio: number;
  97522. /**
  97523. * Gets or sets if all animations should loop or not
  97524. */
  97525. loopAnimation: boolean;
  97526. /**
  97527. * Gets the targeted animations for this animation group
  97528. */
  97529. readonly targetedAnimations: Array<TargetedAnimation>;
  97530. /**
  97531. * returning the list of animatables controlled by this animation group.
  97532. */
  97533. readonly animatables: Array<Animatable>;
  97534. /**
  97535. * Instantiates a new Animation Group.
  97536. * This helps managing several animations at once.
  97537. * @see http://doc.babylonjs.com/how_to/group
  97538. * @param name Defines the name of the group
  97539. * @param scene Defines the scene the group belongs to
  97540. */
  97541. constructor(
  97542. /** The name of the animation group */
  97543. name: string, scene?: Nullable<Scene>);
  97544. /**
  97545. * Add an animation (with its target) in the group
  97546. * @param animation defines the animation we want to add
  97547. * @param target defines the target of the animation
  97548. * @returns the TargetedAnimation object
  97549. */
  97550. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  97551. /**
  97552. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  97553. * It can add constant keys at begin or end
  97554. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  97555. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  97556. * @returns the animation group
  97557. */
  97558. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  97559. /**
  97560. * Start all animations on given targets
  97561. * @param loop defines if animations must loop
  97562. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  97563. * @param from defines the from key (optional)
  97564. * @param to defines the to key (optional)
  97565. * @returns the current animation group
  97566. */
  97567. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  97568. /**
  97569. * Pause all animations
  97570. * @returns the animation group
  97571. */
  97572. pause(): AnimationGroup;
  97573. /**
  97574. * Play all animations to initial state
  97575. * This function will start() the animations if they were not started or will restart() them if they were paused
  97576. * @param loop defines if animations must loop
  97577. * @returns the animation group
  97578. */
  97579. play(loop?: boolean): AnimationGroup;
  97580. /**
  97581. * Reset all animations to initial state
  97582. * @returns the animation group
  97583. */
  97584. reset(): AnimationGroup;
  97585. /**
  97586. * Restart animations from key 0
  97587. * @returns the animation group
  97588. */
  97589. restart(): AnimationGroup;
  97590. /**
  97591. * Stop all animations
  97592. * @returns the animation group
  97593. */
  97594. stop(): AnimationGroup;
  97595. /**
  97596. * Set animation weight for all animatables
  97597. * @param weight defines the weight to use
  97598. * @return the animationGroup
  97599. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  97600. */
  97601. setWeightForAllAnimatables(weight: number): AnimationGroup;
  97602. /**
  97603. * Synchronize and normalize all animatables with a source animatable
  97604. * @param root defines the root animatable to synchronize with
  97605. * @return the animationGroup
  97606. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  97607. */
  97608. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  97609. /**
  97610. * Goes to a specific frame in this animation group
  97611. * @param frame the frame number to go to
  97612. * @return the animationGroup
  97613. */
  97614. goToFrame(frame: number): AnimationGroup;
  97615. /**
  97616. * Dispose all associated resources
  97617. */
  97618. dispose(): void;
  97619. private _checkAnimationGroupEnded;
  97620. /**
  97621. * Clone the current animation group and returns a copy
  97622. * @param newName defines the name of the new group
  97623. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  97624. * @returns the new aniamtion group
  97625. */
  97626. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  97627. /**
  97628. * Serializes the animationGroup to an object
  97629. * @returns Serialized object
  97630. */
  97631. serialize(): any;
  97632. /**
  97633. * Returns a new AnimationGroup object parsed from the source provided.
  97634. * @param parsedAnimationGroup defines the source
  97635. * @param scene defines the scene that will receive the animationGroup
  97636. * @returns a new AnimationGroup
  97637. */
  97638. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  97639. /**
  97640. * Returns the string "AnimationGroup"
  97641. * @returns "AnimationGroup"
  97642. */
  97643. getClassName(): string;
  97644. /**
  97645. * Creates a detailled string about the object
  97646. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  97647. * @returns a string representing the object
  97648. */
  97649. toString(fullDetails?: boolean): string;
  97650. }
  97651. }
  97652. declare module BABYLON {
  97653. /**
  97654. * Define an interface for all classes that will hold resources
  97655. */
  97656. export interface IDisposable {
  97657. /**
  97658. * Releases all held resources
  97659. */
  97660. dispose(): void;
  97661. }
  97662. /** Interface defining initialization parameters for Scene class */
  97663. export interface SceneOptions {
  97664. /**
  97665. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  97666. * It will improve performance when the number of geometries becomes important.
  97667. */
  97668. useGeometryUniqueIdsMap?: boolean;
  97669. /**
  97670. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  97671. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  97672. */
  97673. useMaterialMeshMap?: boolean;
  97674. /**
  97675. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  97676. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  97677. */
  97678. useClonedMeshhMap?: boolean;
  97679. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  97680. virtual?: boolean;
  97681. }
  97682. /**
  97683. * Represents a scene to be rendered by the engine.
  97684. * @see http://doc.babylonjs.com/features/scene
  97685. */
  97686. export class Scene extends AbstractScene implements IAnimatable {
  97687. /** The fog is deactivated */
  97688. static readonly FOGMODE_NONE: number;
  97689. /** The fog density is following an exponential function */
  97690. static readonly FOGMODE_EXP: number;
  97691. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  97692. static readonly FOGMODE_EXP2: number;
  97693. /** The fog density is following a linear function. */
  97694. static readonly FOGMODE_LINEAR: number;
  97695. /**
  97696. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  97697. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97698. */
  97699. static MinDeltaTime: number;
  97700. /**
  97701. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  97702. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97703. */
  97704. static MaxDeltaTime: number;
  97705. /**
  97706. * Factory used to create the default material.
  97707. * @param name The name of the material to create
  97708. * @param scene The scene to create the material for
  97709. * @returns The default material
  97710. */
  97711. static DefaultMaterialFactory(scene: Scene): Material;
  97712. /**
  97713. * Factory used to create the a collision coordinator.
  97714. * @returns The collision coordinator
  97715. */
  97716. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  97717. /** @hidden */
  97718. _inputManager: InputManager;
  97719. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  97720. cameraToUseForPointers: Nullable<Camera>;
  97721. /** @hidden */
  97722. readonly _isScene: boolean;
  97723. /**
  97724. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  97725. */
  97726. autoClear: boolean;
  97727. /**
  97728. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  97729. */
  97730. autoClearDepthAndStencil: boolean;
  97731. /**
  97732. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  97733. */
  97734. clearColor: Color4;
  97735. /**
  97736. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  97737. */
  97738. ambientColor: Color3;
  97739. /**
  97740. * This is use to store the default BRDF lookup for PBR materials in your scene.
  97741. * It should only be one of the following (if not the default embedded one):
  97742. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  97743. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  97744. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  97745. * The material properties need to be setup according to the type of texture in use.
  97746. */
  97747. environmentBRDFTexture: BaseTexture;
  97748. /** @hidden */
  97749. protected _environmentTexture: Nullable<BaseTexture>;
  97750. /**
  97751. * Texture used in all pbr material as the reflection texture.
  97752. * As in the majority of the scene they are the same (exception for multi room and so on),
  97753. * this is easier to reference from here than from all the materials.
  97754. */
  97755. /**
  97756. * Texture used in all pbr material as the reflection texture.
  97757. * As in the majority of the scene they are the same (exception for multi room and so on),
  97758. * this is easier to set here than in all the materials.
  97759. */
  97760. environmentTexture: Nullable<BaseTexture>;
  97761. /** @hidden */
  97762. protected _environmentIntensity: number;
  97763. /**
  97764. * Intensity of the environment in all pbr material.
  97765. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  97766. * As in the majority of the scene they are the same (exception for multi room and so on),
  97767. * this is easier to reference from here than from all the materials.
  97768. */
  97769. /**
  97770. * Intensity of the environment in all pbr material.
  97771. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  97772. * As in the majority of the scene they are the same (exception for multi room and so on),
  97773. * this is easier to set here than in all the materials.
  97774. */
  97775. environmentIntensity: number;
  97776. /** @hidden */
  97777. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  97778. /**
  97779. * Default image processing configuration used either in the rendering
  97780. * Forward main pass or through the imageProcessingPostProcess if present.
  97781. * As in the majority of the scene they are the same (exception for multi camera),
  97782. * this is easier to reference from here than from all the materials and post process.
  97783. *
  97784. * No setter as we it is a shared configuration, you can set the values instead.
  97785. */
  97786. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  97787. private _forceWireframe;
  97788. /**
  97789. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  97790. */
  97791. forceWireframe: boolean;
  97792. private _forcePointsCloud;
  97793. /**
  97794. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  97795. */
  97796. forcePointsCloud: boolean;
  97797. /**
  97798. * Gets or sets the active clipplane 1
  97799. */
  97800. clipPlane: Nullable<Plane>;
  97801. /**
  97802. * Gets or sets the active clipplane 2
  97803. */
  97804. clipPlane2: Nullable<Plane>;
  97805. /**
  97806. * Gets or sets the active clipplane 3
  97807. */
  97808. clipPlane3: Nullable<Plane>;
  97809. /**
  97810. * Gets or sets the active clipplane 4
  97811. */
  97812. clipPlane4: Nullable<Plane>;
  97813. /**
  97814. * Gets or sets a boolean indicating if animations are enabled
  97815. */
  97816. animationsEnabled: boolean;
  97817. private _animationPropertiesOverride;
  97818. /**
  97819. * Gets or sets the animation properties override
  97820. */
  97821. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  97822. /**
  97823. * Gets or sets a boolean indicating if a constant deltatime has to be used
  97824. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  97825. */
  97826. useConstantAnimationDeltaTime: boolean;
  97827. /**
  97828. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  97829. * Please note that it requires to run a ray cast through the scene on every frame
  97830. */
  97831. constantlyUpdateMeshUnderPointer: boolean;
  97832. /**
  97833. * Defines the HTML cursor to use when hovering over interactive elements
  97834. */
  97835. hoverCursor: string;
  97836. /**
  97837. * Defines the HTML default cursor to use (empty by default)
  97838. */
  97839. defaultCursor: string;
  97840. /**
  97841. * This is used to call preventDefault() on pointer down
  97842. * in order to block unwanted artifacts like system double clicks
  97843. */
  97844. preventDefaultOnPointerDown: boolean;
  97845. /**
  97846. * This is used to call preventDefault() on pointer up
  97847. * in order to block unwanted artifacts like system double clicks
  97848. */
  97849. preventDefaultOnPointerUp: boolean;
  97850. /**
  97851. * Gets or sets user defined metadata
  97852. */
  97853. metadata: any;
  97854. /**
  97855. * For internal use only. Please do not use.
  97856. */
  97857. reservedDataStore: any;
  97858. /**
  97859. * Gets the name of the plugin used to load this scene (null by default)
  97860. */
  97861. loadingPluginName: string;
  97862. /**
  97863. * Use this array to add regular expressions used to disable offline support for specific urls
  97864. */
  97865. disableOfflineSupportExceptionRules: RegExp[];
  97866. /**
  97867. * An event triggered when the scene is disposed.
  97868. */
  97869. onDisposeObservable: Observable<Scene>;
  97870. private _onDisposeObserver;
  97871. /** Sets a function to be executed when this scene is disposed. */
  97872. onDispose: () => void;
  97873. /**
  97874. * An event triggered before rendering the scene (right after animations and physics)
  97875. */
  97876. onBeforeRenderObservable: Observable<Scene>;
  97877. private _onBeforeRenderObserver;
  97878. /** Sets a function to be executed before rendering this scene */
  97879. beforeRender: Nullable<() => void>;
  97880. /**
  97881. * An event triggered after rendering the scene
  97882. */
  97883. onAfterRenderObservable: Observable<Scene>;
  97884. /**
  97885. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  97886. */
  97887. onAfterRenderCameraObservable: Observable<Camera>;
  97888. private _onAfterRenderObserver;
  97889. /** Sets a function to be executed after rendering this scene */
  97890. afterRender: Nullable<() => void>;
  97891. /**
  97892. * An event triggered before animating the scene
  97893. */
  97894. onBeforeAnimationsObservable: Observable<Scene>;
  97895. /**
  97896. * An event triggered after animations processing
  97897. */
  97898. onAfterAnimationsObservable: Observable<Scene>;
  97899. /**
  97900. * An event triggered before draw calls are ready to be sent
  97901. */
  97902. onBeforeDrawPhaseObservable: Observable<Scene>;
  97903. /**
  97904. * An event triggered after draw calls have been sent
  97905. */
  97906. onAfterDrawPhaseObservable: Observable<Scene>;
  97907. /**
  97908. * An event triggered when the scene is ready
  97909. */
  97910. onReadyObservable: Observable<Scene>;
  97911. /**
  97912. * An event triggered before rendering a camera
  97913. */
  97914. onBeforeCameraRenderObservable: Observable<Camera>;
  97915. private _onBeforeCameraRenderObserver;
  97916. /** Sets a function to be executed before rendering a camera*/
  97917. beforeCameraRender: () => void;
  97918. /**
  97919. * An event triggered after rendering a camera
  97920. */
  97921. onAfterCameraRenderObservable: Observable<Camera>;
  97922. private _onAfterCameraRenderObserver;
  97923. /** Sets a function to be executed after rendering a camera*/
  97924. afterCameraRender: () => void;
  97925. /**
  97926. * An event triggered when active meshes evaluation is about to start
  97927. */
  97928. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  97929. /**
  97930. * An event triggered when active meshes evaluation is done
  97931. */
  97932. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  97933. /**
  97934. * An event triggered when particles rendering is about to start
  97935. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  97936. */
  97937. onBeforeParticlesRenderingObservable: Observable<Scene>;
  97938. /**
  97939. * An event triggered when particles rendering is done
  97940. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  97941. */
  97942. onAfterParticlesRenderingObservable: Observable<Scene>;
  97943. /**
  97944. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  97945. */
  97946. onDataLoadedObservable: Observable<Scene>;
  97947. /**
  97948. * An event triggered when a camera is created
  97949. */
  97950. onNewCameraAddedObservable: Observable<Camera>;
  97951. /**
  97952. * An event triggered when a camera is removed
  97953. */
  97954. onCameraRemovedObservable: Observable<Camera>;
  97955. /**
  97956. * An event triggered when a light is created
  97957. */
  97958. onNewLightAddedObservable: Observable<Light>;
  97959. /**
  97960. * An event triggered when a light is removed
  97961. */
  97962. onLightRemovedObservable: Observable<Light>;
  97963. /**
  97964. * An event triggered when a geometry is created
  97965. */
  97966. onNewGeometryAddedObservable: Observable<Geometry>;
  97967. /**
  97968. * An event triggered when a geometry is removed
  97969. */
  97970. onGeometryRemovedObservable: Observable<Geometry>;
  97971. /**
  97972. * An event triggered when a transform node is created
  97973. */
  97974. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  97975. /**
  97976. * An event triggered when a transform node is removed
  97977. */
  97978. onTransformNodeRemovedObservable: Observable<TransformNode>;
  97979. /**
  97980. * An event triggered when a mesh is created
  97981. */
  97982. onNewMeshAddedObservable: Observable<AbstractMesh>;
  97983. /**
  97984. * An event triggered when a mesh is removed
  97985. */
  97986. onMeshRemovedObservable: Observable<AbstractMesh>;
  97987. /**
  97988. * An event triggered when a skeleton is created
  97989. */
  97990. onNewSkeletonAddedObservable: Observable<Skeleton>;
  97991. /**
  97992. * An event triggered when a skeleton is removed
  97993. */
  97994. onSkeletonRemovedObservable: Observable<Skeleton>;
  97995. /**
  97996. * An event triggered when a material is created
  97997. */
  97998. onNewMaterialAddedObservable: Observable<Material>;
  97999. /**
  98000. * An event triggered when a material is removed
  98001. */
  98002. onMaterialRemovedObservable: Observable<Material>;
  98003. /**
  98004. * An event triggered when a texture is created
  98005. */
  98006. onNewTextureAddedObservable: Observable<BaseTexture>;
  98007. /**
  98008. * An event triggered when a texture is removed
  98009. */
  98010. onTextureRemovedObservable: Observable<BaseTexture>;
  98011. /**
  98012. * An event triggered when render targets are about to be rendered
  98013. * Can happen multiple times per frame.
  98014. */
  98015. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  98016. /**
  98017. * An event triggered when render targets were rendered.
  98018. * Can happen multiple times per frame.
  98019. */
  98020. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  98021. /**
  98022. * An event triggered before calculating deterministic simulation step
  98023. */
  98024. onBeforeStepObservable: Observable<Scene>;
  98025. /**
  98026. * An event triggered after calculating deterministic simulation step
  98027. */
  98028. onAfterStepObservable: Observable<Scene>;
  98029. /**
  98030. * An event triggered when the activeCamera property is updated
  98031. */
  98032. onActiveCameraChanged: Observable<Scene>;
  98033. /**
  98034. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  98035. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  98036. * 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)
  98037. */
  98038. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  98039. /**
  98040. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  98041. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  98042. * 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)
  98043. */
  98044. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  98045. /**
  98046. * This Observable will when a mesh has been imported into the scene.
  98047. */
  98048. onMeshImportedObservable: Observable<AbstractMesh>;
  98049. /**
  98050. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  98051. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  98052. */
  98053. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  98054. /** @hidden */
  98055. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  98056. /**
  98057. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  98058. */
  98059. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  98060. /**
  98061. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  98062. */
  98063. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  98064. /**
  98065. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  98066. */
  98067. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  98068. /** Callback called when a pointer move is detected */
  98069. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  98070. /** Callback called when a pointer down is detected */
  98071. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  98072. /** Callback called when a pointer up is detected */
  98073. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  98074. /** Callback called when a pointer pick is detected */
  98075. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  98076. /**
  98077. * 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).
  98078. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  98079. */
  98080. onPrePointerObservable: Observable<PointerInfoPre>;
  98081. /**
  98082. * Observable event triggered each time an input event is received from the rendering canvas
  98083. */
  98084. onPointerObservable: Observable<PointerInfo>;
  98085. /**
  98086. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  98087. */
  98088. readonly unTranslatedPointer: Vector2;
  98089. /**
  98090. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  98091. */
  98092. static DragMovementThreshold: number;
  98093. /**
  98094. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  98095. */
  98096. static LongPressDelay: number;
  98097. /**
  98098. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  98099. */
  98100. static DoubleClickDelay: number;
  98101. /** If you need to check double click without raising a single click at first click, enable this flag */
  98102. static ExclusiveDoubleClickMode: boolean;
  98103. /** @hidden */
  98104. _mirroredCameraPosition: Nullable<Vector3>;
  98105. /**
  98106. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  98107. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  98108. */
  98109. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  98110. /**
  98111. * Observable event triggered each time an keyboard event is received from the hosting window
  98112. */
  98113. onKeyboardObservable: Observable<KeyboardInfo>;
  98114. private _useRightHandedSystem;
  98115. /**
  98116. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  98117. */
  98118. useRightHandedSystem: boolean;
  98119. private _timeAccumulator;
  98120. private _currentStepId;
  98121. private _currentInternalStep;
  98122. /**
  98123. * Sets the step Id used by deterministic lock step
  98124. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98125. * @param newStepId defines the step Id
  98126. */
  98127. setStepId(newStepId: number): void;
  98128. /**
  98129. * Gets the step Id used by deterministic lock step
  98130. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98131. * @returns the step Id
  98132. */
  98133. getStepId(): number;
  98134. /**
  98135. * Gets the internal step used by deterministic lock step
  98136. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98137. * @returns the internal step
  98138. */
  98139. getInternalStep(): number;
  98140. private _fogEnabled;
  98141. /**
  98142. * Gets or sets a boolean indicating if fog is enabled on this scene
  98143. * @see http://doc.babylonjs.com/babylon101/environment#fog
  98144. * (Default is true)
  98145. */
  98146. fogEnabled: boolean;
  98147. private _fogMode;
  98148. /**
  98149. * Gets or sets the fog mode to use
  98150. * @see http://doc.babylonjs.com/babylon101/environment#fog
  98151. * | mode | value |
  98152. * | --- | --- |
  98153. * | FOGMODE_NONE | 0 |
  98154. * | FOGMODE_EXP | 1 |
  98155. * | FOGMODE_EXP2 | 2 |
  98156. * | FOGMODE_LINEAR | 3 |
  98157. */
  98158. fogMode: number;
  98159. /**
  98160. * Gets or sets the fog color to use
  98161. * @see http://doc.babylonjs.com/babylon101/environment#fog
  98162. * (Default is Color3(0.2, 0.2, 0.3))
  98163. */
  98164. fogColor: Color3;
  98165. /**
  98166. * Gets or sets the fog density to use
  98167. * @see http://doc.babylonjs.com/babylon101/environment#fog
  98168. * (Default is 0.1)
  98169. */
  98170. fogDensity: number;
  98171. /**
  98172. * Gets or sets the fog start distance to use
  98173. * @see http://doc.babylonjs.com/babylon101/environment#fog
  98174. * (Default is 0)
  98175. */
  98176. fogStart: number;
  98177. /**
  98178. * Gets or sets the fog end distance to use
  98179. * @see http://doc.babylonjs.com/babylon101/environment#fog
  98180. * (Default is 1000)
  98181. */
  98182. fogEnd: number;
  98183. private _shadowsEnabled;
  98184. /**
  98185. * Gets or sets a boolean indicating if shadows are enabled on this scene
  98186. */
  98187. shadowsEnabled: boolean;
  98188. private _lightsEnabled;
  98189. /**
  98190. * Gets or sets a boolean indicating if lights are enabled on this scene
  98191. */
  98192. lightsEnabled: boolean;
  98193. /** All of the active cameras added to this scene. */
  98194. activeCameras: Camera[];
  98195. /** @hidden */
  98196. _activeCamera: Nullable<Camera>;
  98197. /** Gets or sets the current active camera */
  98198. activeCamera: Nullable<Camera>;
  98199. private _defaultMaterial;
  98200. /** The default material used on meshes when no material is affected */
  98201. /** The default material used on meshes when no material is affected */
  98202. defaultMaterial: Material;
  98203. private _texturesEnabled;
  98204. /**
  98205. * Gets or sets a boolean indicating if textures are enabled on this scene
  98206. */
  98207. texturesEnabled: boolean;
  98208. /**
  98209. * Gets or sets a boolean indicating if particles are enabled on this scene
  98210. */
  98211. particlesEnabled: boolean;
  98212. /**
  98213. * Gets or sets a boolean indicating if sprites are enabled on this scene
  98214. */
  98215. spritesEnabled: boolean;
  98216. private _skeletonsEnabled;
  98217. /**
  98218. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  98219. */
  98220. skeletonsEnabled: boolean;
  98221. /**
  98222. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  98223. */
  98224. lensFlaresEnabled: boolean;
  98225. /**
  98226. * Gets or sets a boolean indicating if collisions are enabled on this scene
  98227. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  98228. */
  98229. collisionsEnabled: boolean;
  98230. private _collisionCoordinator;
  98231. /** @hidden */
  98232. readonly collisionCoordinator: ICollisionCoordinator;
  98233. /**
  98234. * Defines the gravity applied to this scene (used only for collisions)
  98235. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  98236. */
  98237. gravity: Vector3;
  98238. /**
  98239. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  98240. */
  98241. postProcessesEnabled: boolean;
  98242. /**
  98243. * The list of postprocesses added to the scene
  98244. */
  98245. postProcesses: PostProcess[];
  98246. /**
  98247. * Gets the current postprocess manager
  98248. */
  98249. postProcessManager: PostProcessManager;
  98250. /**
  98251. * Gets or sets a boolean indicating if render targets are enabled on this scene
  98252. */
  98253. renderTargetsEnabled: boolean;
  98254. /**
  98255. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  98256. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  98257. */
  98258. dumpNextRenderTargets: boolean;
  98259. /**
  98260. * The list of user defined render targets added to the scene
  98261. */
  98262. customRenderTargets: RenderTargetTexture[];
  98263. /**
  98264. * Defines if texture loading must be delayed
  98265. * If true, textures will only be loaded when they need to be rendered
  98266. */
  98267. useDelayedTextureLoading: boolean;
  98268. /**
  98269. * Gets the list of meshes imported to the scene through SceneLoader
  98270. */
  98271. importedMeshesFiles: String[];
  98272. /**
  98273. * Gets or sets a boolean indicating if probes are enabled on this scene
  98274. */
  98275. probesEnabled: boolean;
  98276. /**
  98277. * Gets or sets the current offline provider to use to store scene data
  98278. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  98279. */
  98280. offlineProvider: IOfflineProvider;
  98281. /**
  98282. * Gets or sets the action manager associated with the scene
  98283. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  98284. */
  98285. actionManager: AbstractActionManager;
  98286. private _meshesForIntersections;
  98287. /**
  98288. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  98289. */
  98290. proceduralTexturesEnabled: boolean;
  98291. private _engine;
  98292. private _totalVertices;
  98293. /** @hidden */
  98294. _activeIndices: PerfCounter;
  98295. /** @hidden */
  98296. _activeParticles: PerfCounter;
  98297. /** @hidden */
  98298. _activeBones: PerfCounter;
  98299. private _animationRatio;
  98300. /** @hidden */
  98301. _animationTimeLast: number;
  98302. /** @hidden */
  98303. _animationTime: number;
  98304. /**
  98305. * Gets or sets a general scale for animation speed
  98306. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  98307. */
  98308. animationTimeScale: number;
  98309. /** @hidden */
  98310. _cachedMaterial: Nullable<Material>;
  98311. /** @hidden */
  98312. _cachedEffect: Nullable<Effect>;
  98313. /** @hidden */
  98314. _cachedVisibility: Nullable<number>;
  98315. private _renderId;
  98316. private _frameId;
  98317. private _executeWhenReadyTimeoutId;
  98318. private _intermediateRendering;
  98319. private _viewUpdateFlag;
  98320. private _projectionUpdateFlag;
  98321. /** @hidden */
  98322. _toBeDisposed: Nullable<IDisposable>[];
  98323. private _activeRequests;
  98324. /** @hidden */
  98325. _pendingData: any[];
  98326. private _isDisposed;
  98327. /**
  98328. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  98329. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  98330. */
  98331. dispatchAllSubMeshesOfActiveMeshes: boolean;
  98332. private _activeMeshes;
  98333. private _processedMaterials;
  98334. private _renderTargets;
  98335. /** @hidden */
  98336. _activeParticleSystems: SmartArray<IParticleSystem>;
  98337. private _activeSkeletons;
  98338. private _softwareSkinnedMeshes;
  98339. private _renderingManager;
  98340. /** @hidden */
  98341. _activeAnimatables: Animatable[];
  98342. private _transformMatrix;
  98343. private _sceneUbo;
  98344. /** @hidden */
  98345. _viewMatrix: Matrix;
  98346. private _projectionMatrix;
  98347. /** @hidden */
  98348. _forcedViewPosition: Nullable<Vector3>;
  98349. /** @hidden */
  98350. _frustumPlanes: Plane[];
  98351. /**
  98352. * Gets the list of frustum planes (built from the active camera)
  98353. */
  98354. readonly frustumPlanes: Plane[];
  98355. /**
  98356. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  98357. * This is useful if there are more lights that the maximum simulteanous authorized
  98358. */
  98359. requireLightSorting: boolean;
  98360. /** @hidden */
  98361. readonly useMaterialMeshMap: boolean;
  98362. /** @hidden */
  98363. readonly useClonedMeshhMap: boolean;
  98364. private _externalData;
  98365. private _uid;
  98366. /**
  98367. * @hidden
  98368. * Backing store of defined scene components.
  98369. */
  98370. _components: ISceneComponent[];
  98371. /**
  98372. * @hidden
  98373. * Backing store of defined scene components.
  98374. */
  98375. _serializableComponents: ISceneSerializableComponent[];
  98376. /**
  98377. * List of components to register on the next registration step.
  98378. */
  98379. private _transientComponents;
  98380. /**
  98381. * Registers the transient components if needed.
  98382. */
  98383. private _registerTransientComponents;
  98384. /**
  98385. * @hidden
  98386. * Add a component to the scene.
  98387. * Note that the ccomponent could be registered on th next frame if this is called after
  98388. * the register component stage.
  98389. * @param component Defines the component to add to the scene
  98390. */
  98391. _addComponent(component: ISceneComponent): void;
  98392. /**
  98393. * @hidden
  98394. * Gets a component from the scene.
  98395. * @param name defines the name of the component to retrieve
  98396. * @returns the component or null if not present
  98397. */
  98398. _getComponent(name: string): Nullable<ISceneComponent>;
  98399. /**
  98400. * @hidden
  98401. * Defines the actions happening before camera updates.
  98402. */
  98403. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  98404. /**
  98405. * @hidden
  98406. * Defines the actions happening before clear the canvas.
  98407. */
  98408. _beforeClearStage: Stage<SimpleStageAction>;
  98409. /**
  98410. * @hidden
  98411. * Defines the actions when collecting render targets for the frame.
  98412. */
  98413. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  98414. /**
  98415. * @hidden
  98416. * Defines the actions happening for one camera in the frame.
  98417. */
  98418. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  98419. /**
  98420. * @hidden
  98421. * Defines the actions happening during the per mesh ready checks.
  98422. */
  98423. _isReadyForMeshStage: Stage<MeshStageAction>;
  98424. /**
  98425. * @hidden
  98426. * Defines the actions happening before evaluate active mesh checks.
  98427. */
  98428. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  98429. /**
  98430. * @hidden
  98431. * Defines the actions happening during the evaluate sub mesh checks.
  98432. */
  98433. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  98434. /**
  98435. * @hidden
  98436. * Defines the actions happening during the active mesh stage.
  98437. */
  98438. _activeMeshStage: Stage<ActiveMeshStageAction>;
  98439. /**
  98440. * @hidden
  98441. * Defines the actions happening during the per camera render target step.
  98442. */
  98443. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  98444. /**
  98445. * @hidden
  98446. * Defines the actions happening just before the active camera is drawing.
  98447. */
  98448. _beforeCameraDrawStage: Stage<CameraStageAction>;
  98449. /**
  98450. * @hidden
  98451. * Defines the actions happening just before a render target is drawing.
  98452. */
  98453. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  98454. /**
  98455. * @hidden
  98456. * Defines the actions happening just before a rendering group is drawing.
  98457. */
  98458. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  98459. /**
  98460. * @hidden
  98461. * Defines the actions happening just before a mesh is drawing.
  98462. */
  98463. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  98464. /**
  98465. * @hidden
  98466. * Defines the actions happening just after a mesh has been drawn.
  98467. */
  98468. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  98469. /**
  98470. * @hidden
  98471. * Defines the actions happening just after a rendering group has been drawn.
  98472. */
  98473. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  98474. /**
  98475. * @hidden
  98476. * Defines the actions happening just after the active camera has been drawn.
  98477. */
  98478. _afterCameraDrawStage: Stage<CameraStageAction>;
  98479. /**
  98480. * @hidden
  98481. * Defines the actions happening just after a render target has been drawn.
  98482. */
  98483. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  98484. /**
  98485. * @hidden
  98486. * Defines the actions happening just after rendering all cameras and computing intersections.
  98487. */
  98488. _afterRenderStage: Stage<SimpleStageAction>;
  98489. /**
  98490. * @hidden
  98491. * Defines the actions happening when a pointer move event happens.
  98492. */
  98493. _pointerMoveStage: Stage<PointerMoveStageAction>;
  98494. /**
  98495. * @hidden
  98496. * Defines the actions happening when a pointer down event happens.
  98497. */
  98498. _pointerDownStage: Stage<PointerUpDownStageAction>;
  98499. /**
  98500. * @hidden
  98501. * Defines the actions happening when a pointer up event happens.
  98502. */
  98503. _pointerUpStage: Stage<PointerUpDownStageAction>;
  98504. /**
  98505. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  98506. */
  98507. private geometriesByUniqueId;
  98508. /**
  98509. * Creates a new Scene
  98510. * @param engine defines the engine to use to render this scene
  98511. * @param options defines the scene options
  98512. */
  98513. constructor(engine: Engine, options?: SceneOptions);
  98514. /**
  98515. * Gets a string idenfifying the name of the class
  98516. * @returns "Scene" string
  98517. */
  98518. getClassName(): string;
  98519. private _defaultMeshCandidates;
  98520. /**
  98521. * @hidden
  98522. */
  98523. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  98524. private _defaultSubMeshCandidates;
  98525. /**
  98526. * @hidden
  98527. */
  98528. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  98529. /**
  98530. * Sets the default candidate providers for the scene.
  98531. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  98532. * and getCollidingSubMeshCandidates to their default function
  98533. */
  98534. setDefaultCandidateProviders(): void;
  98535. /**
  98536. * Gets the mesh that is currently under the pointer
  98537. */
  98538. readonly meshUnderPointer: Nullable<AbstractMesh>;
  98539. /**
  98540. * Gets or sets the current on-screen X position of the pointer
  98541. */
  98542. pointerX: number;
  98543. /**
  98544. * Gets or sets the current on-screen Y position of the pointer
  98545. */
  98546. pointerY: number;
  98547. /**
  98548. * Gets the cached material (ie. the latest rendered one)
  98549. * @returns the cached material
  98550. */
  98551. getCachedMaterial(): Nullable<Material>;
  98552. /**
  98553. * Gets the cached effect (ie. the latest rendered one)
  98554. * @returns the cached effect
  98555. */
  98556. getCachedEffect(): Nullable<Effect>;
  98557. /**
  98558. * Gets the cached visibility state (ie. the latest rendered one)
  98559. * @returns the cached visibility state
  98560. */
  98561. getCachedVisibility(): Nullable<number>;
  98562. /**
  98563. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  98564. * @param material defines the current material
  98565. * @param effect defines the current effect
  98566. * @param visibility defines the current visibility state
  98567. * @returns true if one parameter is not cached
  98568. */
  98569. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  98570. /**
  98571. * Gets the engine associated with the scene
  98572. * @returns an Engine
  98573. */
  98574. getEngine(): Engine;
  98575. /**
  98576. * Gets the total number of vertices rendered per frame
  98577. * @returns the total number of vertices rendered per frame
  98578. */
  98579. getTotalVertices(): number;
  98580. /**
  98581. * Gets the performance counter for total vertices
  98582. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  98583. */
  98584. readonly totalVerticesPerfCounter: PerfCounter;
  98585. /**
  98586. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  98587. * @returns the total number of active indices rendered per frame
  98588. */
  98589. getActiveIndices(): number;
  98590. /**
  98591. * Gets the performance counter for active indices
  98592. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  98593. */
  98594. readonly totalActiveIndicesPerfCounter: PerfCounter;
  98595. /**
  98596. * Gets the total number of active particles rendered per frame
  98597. * @returns the total number of active particles rendered per frame
  98598. */
  98599. getActiveParticles(): number;
  98600. /**
  98601. * Gets the performance counter for active particles
  98602. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  98603. */
  98604. readonly activeParticlesPerfCounter: PerfCounter;
  98605. /**
  98606. * Gets the total number of active bones rendered per frame
  98607. * @returns the total number of active bones rendered per frame
  98608. */
  98609. getActiveBones(): number;
  98610. /**
  98611. * Gets the performance counter for active bones
  98612. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  98613. */
  98614. readonly activeBonesPerfCounter: PerfCounter;
  98615. /**
  98616. * Gets the array of active meshes
  98617. * @returns an array of AbstractMesh
  98618. */
  98619. getActiveMeshes(): SmartArray<AbstractMesh>;
  98620. /**
  98621. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  98622. * @returns a number
  98623. */
  98624. getAnimationRatio(): number;
  98625. /**
  98626. * Gets an unique Id for the current render phase
  98627. * @returns a number
  98628. */
  98629. getRenderId(): number;
  98630. /**
  98631. * Gets an unique Id for the current frame
  98632. * @returns a number
  98633. */
  98634. getFrameId(): number;
  98635. /** Call this function if you want to manually increment the render Id*/
  98636. incrementRenderId(): void;
  98637. private _createUbo;
  98638. /**
  98639. * Use this method to simulate a pointer move on a mesh
  98640. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  98641. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  98642. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  98643. * @returns the current scene
  98644. */
  98645. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  98646. /**
  98647. * Use this method to simulate a pointer down on a mesh
  98648. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  98649. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  98650. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  98651. * @returns the current scene
  98652. */
  98653. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  98654. /**
  98655. * Use this method to simulate a pointer up on a mesh
  98656. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  98657. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  98658. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  98659. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  98660. * @returns the current scene
  98661. */
  98662. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  98663. /**
  98664. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  98665. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  98666. * @returns true if the pointer was captured
  98667. */
  98668. isPointerCaptured(pointerId?: number): boolean;
  98669. /**
  98670. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  98671. * @param attachUp defines if you want to attach events to pointerup
  98672. * @param attachDown defines if you want to attach events to pointerdown
  98673. * @param attachMove defines if you want to attach events to pointermove
  98674. */
  98675. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  98676. /** Detaches all event handlers*/
  98677. detachControl(): void;
  98678. /**
  98679. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  98680. * Delay loaded resources are not taking in account
  98681. * @return true if all required resources are ready
  98682. */
  98683. isReady(): boolean;
  98684. /** Resets all cached information relative to material (including effect and visibility) */
  98685. resetCachedMaterial(): void;
  98686. /**
  98687. * Registers a function to be called before every frame render
  98688. * @param func defines the function to register
  98689. */
  98690. registerBeforeRender(func: () => void): void;
  98691. /**
  98692. * Unregisters a function called before every frame render
  98693. * @param func defines the function to unregister
  98694. */
  98695. unregisterBeforeRender(func: () => void): void;
  98696. /**
  98697. * Registers a function to be called after every frame render
  98698. * @param func defines the function to register
  98699. */
  98700. registerAfterRender(func: () => void): void;
  98701. /**
  98702. * Unregisters a function called after every frame render
  98703. * @param func defines the function to unregister
  98704. */
  98705. unregisterAfterRender(func: () => void): void;
  98706. private _executeOnceBeforeRender;
  98707. /**
  98708. * The provided function will run before render once and will be disposed afterwards.
  98709. * A timeout delay can be provided so that the function will be executed in N ms.
  98710. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  98711. * @param func The function to be executed.
  98712. * @param timeout optional delay in ms
  98713. */
  98714. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  98715. /** @hidden */
  98716. _addPendingData(data: any): void;
  98717. /** @hidden */
  98718. _removePendingData(data: any): void;
  98719. /**
  98720. * Returns the number of items waiting to be loaded
  98721. * @returns the number of items waiting to be loaded
  98722. */
  98723. getWaitingItemsCount(): number;
  98724. /**
  98725. * Returns a boolean indicating if the scene is still loading data
  98726. */
  98727. readonly isLoading: boolean;
  98728. /**
  98729. * Registers a function to be executed when the scene is ready
  98730. * @param {Function} func - the function to be executed
  98731. */
  98732. executeWhenReady(func: () => void): void;
  98733. /**
  98734. * Returns a promise that resolves when the scene is ready
  98735. * @returns A promise that resolves when the scene is ready
  98736. */
  98737. whenReadyAsync(): Promise<void>;
  98738. /** @hidden */
  98739. _checkIsReady(): void;
  98740. /**
  98741. * Gets all animatable attached to the scene
  98742. */
  98743. readonly animatables: Animatable[];
  98744. /**
  98745. * Resets the last animation time frame.
  98746. * Useful to override when animations start running when loading a scene for the first time.
  98747. */
  98748. resetLastAnimationTimeFrame(): void;
  98749. /**
  98750. * Gets the current view matrix
  98751. * @returns a Matrix
  98752. */
  98753. getViewMatrix(): Matrix;
  98754. /**
  98755. * Gets the current projection matrix
  98756. * @returns a Matrix
  98757. */
  98758. getProjectionMatrix(): Matrix;
  98759. /**
  98760. * Gets the current transform matrix
  98761. * @returns a Matrix made of View * Projection
  98762. */
  98763. getTransformMatrix(): Matrix;
  98764. /**
  98765. * Sets the current transform matrix
  98766. * @param viewL defines the View matrix to use
  98767. * @param projectionL defines the Projection matrix to use
  98768. * @param viewR defines the right View matrix to use (if provided)
  98769. * @param projectionR defines the right Projection matrix to use (if provided)
  98770. */
  98771. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  98772. /**
  98773. * Gets the uniform buffer used to store scene data
  98774. * @returns a UniformBuffer
  98775. */
  98776. getSceneUniformBuffer(): UniformBuffer;
  98777. /**
  98778. * Gets an unique (relatively to the current scene) Id
  98779. * @returns an unique number for the scene
  98780. */
  98781. getUniqueId(): number;
  98782. /**
  98783. * Add a mesh to the list of scene's meshes
  98784. * @param newMesh defines the mesh to add
  98785. * @param recursive if all child meshes should also be added to the scene
  98786. */
  98787. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  98788. /**
  98789. * Remove a mesh for the list of scene's meshes
  98790. * @param toRemove defines the mesh to remove
  98791. * @param recursive if all child meshes should also be removed from the scene
  98792. * @returns the index where the mesh was in the mesh list
  98793. */
  98794. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  98795. /**
  98796. * Add a transform node to the list of scene's transform nodes
  98797. * @param newTransformNode defines the transform node to add
  98798. */
  98799. addTransformNode(newTransformNode: TransformNode): void;
  98800. /**
  98801. * Remove a transform node for the list of scene's transform nodes
  98802. * @param toRemove defines the transform node to remove
  98803. * @returns the index where the transform node was in the transform node list
  98804. */
  98805. removeTransformNode(toRemove: TransformNode): number;
  98806. /**
  98807. * Remove a skeleton for the list of scene's skeletons
  98808. * @param toRemove defines the skeleton to remove
  98809. * @returns the index where the skeleton was in the skeleton list
  98810. */
  98811. removeSkeleton(toRemove: Skeleton): number;
  98812. /**
  98813. * Remove a morph target for the list of scene's morph targets
  98814. * @param toRemove defines the morph target to remove
  98815. * @returns the index where the morph target was in the morph target list
  98816. */
  98817. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  98818. /**
  98819. * Remove a light for the list of scene's lights
  98820. * @param toRemove defines the light to remove
  98821. * @returns the index where the light was in the light list
  98822. */
  98823. removeLight(toRemove: Light): number;
  98824. /**
  98825. * Remove a camera for the list of scene's cameras
  98826. * @param toRemove defines the camera to remove
  98827. * @returns the index where the camera was in the camera list
  98828. */
  98829. removeCamera(toRemove: Camera): number;
  98830. /**
  98831. * Remove a particle system for the list of scene's particle systems
  98832. * @param toRemove defines the particle system to remove
  98833. * @returns the index where the particle system was in the particle system list
  98834. */
  98835. removeParticleSystem(toRemove: IParticleSystem): number;
  98836. /**
  98837. * Remove a animation for the list of scene's animations
  98838. * @param toRemove defines the animation to remove
  98839. * @returns the index where the animation was in the animation list
  98840. */
  98841. removeAnimation(toRemove: Animation): number;
  98842. /**
  98843. * Will stop the animation of the given target
  98844. * @param target - the target
  98845. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  98846. * @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)
  98847. */
  98848. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  98849. /**
  98850. * Removes the given animation group from this scene.
  98851. * @param toRemove The animation group to remove
  98852. * @returns The index of the removed animation group
  98853. */
  98854. removeAnimationGroup(toRemove: AnimationGroup): number;
  98855. /**
  98856. * Removes the given multi-material from this scene.
  98857. * @param toRemove The multi-material to remove
  98858. * @returns The index of the removed multi-material
  98859. */
  98860. removeMultiMaterial(toRemove: MultiMaterial): number;
  98861. /**
  98862. * Removes the given material from this scene.
  98863. * @param toRemove The material to remove
  98864. * @returns The index of the removed material
  98865. */
  98866. removeMaterial(toRemove: Material): number;
  98867. /**
  98868. * Removes the given action manager from this scene.
  98869. * @param toRemove The action manager to remove
  98870. * @returns The index of the removed action manager
  98871. */
  98872. removeActionManager(toRemove: AbstractActionManager): number;
  98873. /**
  98874. * Removes the given texture from this scene.
  98875. * @param toRemove The texture to remove
  98876. * @returns The index of the removed texture
  98877. */
  98878. removeTexture(toRemove: BaseTexture): number;
  98879. /**
  98880. * Adds the given light to this scene
  98881. * @param newLight The light to add
  98882. */
  98883. addLight(newLight: Light): void;
  98884. /**
  98885. * Sorts the list list based on light priorities
  98886. */
  98887. sortLightsByPriority(): void;
  98888. /**
  98889. * Adds the given camera to this scene
  98890. * @param newCamera The camera to add
  98891. */
  98892. addCamera(newCamera: Camera): void;
  98893. /**
  98894. * Adds the given skeleton to this scene
  98895. * @param newSkeleton The skeleton to add
  98896. */
  98897. addSkeleton(newSkeleton: Skeleton): void;
  98898. /**
  98899. * Adds the given particle system to this scene
  98900. * @param newParticleSystem The particle system to add
  98901. */
  98902. addParticleSystem(newParticleSystem: IParticleSystem): void;
  98903. /**
  98904. * Adds the given animation to this scene
  98905. * @param newAnimation The animation to add
  98906. */
  98907. addAnimation(newAnimation: Animation): void;
  98908. /**
  98909. * Adds the given animation group to this scene.
  98910. * @param newAnimationGroup The animation group to add
  98911. */
  98912. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  98913. /**
  98914. * Adds the given multi-material to this scene
  98915. * @param newMultiMaterial The multi-material to add
  98916. */
  98917. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  98918. /**
  98919. * Adds the given material to this scene
  98920. * @param newMaterial The material to add
  98921. */
  98922. addMaterial(newMaterial: Material): void;
  98923. /**
  98924. * Adds the given morph target to this scene
  98925. * @param newMorphTargetManager The morph target to add
  98926. */
  98927. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  98928. /**
  98929. * Adds the given geometry to this scene
  98930. * @param newGeometry The geometry to add
  98931. */
  98932. addGeometry(newGeometry: Geometry): void;
  98933. /**
  98934. * Adds the given action manager to this scene
  98935. * @param newActionManager The action manager to add
  98936. */
  98937. addActionManager(newActionManager: AbstractActionManager): void;
  98938. /**
  98939. * Adds the given texture to this scene.
  98940. * @param newTexture The texture to add
  98941. */
  98942. addTexture(newTexture: BaseTexture): void;
  98943. /**
  98944. * Switch active camera
  98945. * @param newCamera defines the new active camera
  98946. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  98947. */
  98948. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  98949. /**
  98950. * sets the active camera of the scene using its ID
  98951. * @param id defines the camera's ID
  98952. * @return the new active camera or null if none found.
  98953. */
  98954. setActiveCameraByID(id: string): Nullable<Camera>;
  98955. /**
  98956. * sets the active camera of the scene using its name
  98957. * @param name defines the camera's name
  98958. * @returns the new active camera or null if none found.
  98959. */
  98960. setActiveCameraByName(name: string): Nullable<Camera>;
  98961. /**
  98962. * get an animation group using its name
  98963. * @param name defines the material's name
  98964. * @return the animation group or null if none found.
  98965. */
  98966. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  98967. /**
  98968. * Get a material using its unique id
  98969. * @param uniqueId defines the material's unique id
  98970. * @return the material or null if none found.
  98971. */
  98972. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  98973. /**
  98974. * get a material using its id
  98975. * @param id defines the material's ID
  98976. * @return the material or null if none found.
  98977. */
  98978. getMaterialByID(id: string): Nullable<Material>;
  98979. /**
  98980. * Gets a the last added material using a given id
  98981. * @param id defines the material's ID
  98982. * @return the last material with the given id or null if none found.
  98983. */
  98984. getLastMaterialByID(id: string): Nullable<Material>;
  98985. /**
  98986. * Gets a material using its name
  98987. * @param name defines the material's name
  98988. * @return the material or null if none found.
  98989. */
  98990. getMaterialByName(name: string): Nullable<Material>;
  98991. /**
  98992. * Get a texture using its unique id
  98993. * @param uniqueId defines the texture's unique id
  98994. * @return the texture or null if none found.
  98995. */
  98996. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  98997. /**
  98998. * Gets a camera using its id
  98999. * @param id defines the id to look for
  99000. * @returns the camera or null if not found
  99001. */
  99002. getCameraByID(id: string): Nullable<Camera>;
  99003. /**
  99004. * Gets a camera using its unique id
  99005. * @param uniqueId defines the unique id to look for
  99006. * @returns the camera or null if not found
  99007. */
  99008. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  99009. /**
  99010. * Gets a camera using its name
  99011. * @param name defines the camera's name
  99012. * @return the camera or null if none found.
  99013. */
  99014. getCameraByName(name: string): Nullable<Camera>;
  99015. /**
  99016. * Gets a bone using its id
  99017. * @param id defines the bone's id
  99018. * @return the bone or null if not found
  99019. */
  99020. getBoneByID(id: string): Nullable<Bone>;
  99021. /**
  99022. * Gets a bone using its id
  99023. * @param name defines the bone's name
  99024. * @return the bone or null if not found
  99025. */
  99026. getBoneByName(name: string): Nullable<Bone>;
  99027. /**
  99028. * Gets a light node using its name
  99029. * @param name defines the the light's name
  99030. * @return the light or null if none found.
  99031. */
  99032. getLightByName(name: string): Nullable<Light>;
  99033. /**
  99034. * Gets a light node using its id
  99035. * @param id defines the light's id
  99036. * @return the light or null if none found.
  99037. */
  99038. getLightByID(id: string): Nullable<Light>;
  99039. /**
  99040. * Gets a light node using its scene-generated unique ID
  99041. * @param uniqueId defines the light's unique id
  99042. * @return the light or null if none found.
  99043. */
  99044. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  99045. /**
  99046. * Gets a particle system by id
  99047. * @param id defines the particle system id
  99048. * @return the corresponding system or null if none found
  99049. */
  99050. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  99051. /**
  99052. * Gets a geometry using its ID
  99053. * @param id defines the geometry's id
  99054. * @return the geometry or null if none found.
  99055. */
  99056. getGeometryByID(id: string): Nullable<Geometry>;
  99057. private _getGeometryByUniqueID;
  99058. /**
  99059. * Add a new geometry to this scene
  99060. * @param geometry defines the geometry to be added to the scene.
  99061. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  99062. * @return a boolean defining if the geometry was added or not
  99063. */
  99064. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  99065. /**
  99066. * Removes an existing geometry
  99067. * @param geometry defines the geometry to be removed from the scene
  99068. * @return a boolean defining if the geometry was removed or not
  99069. */
  99070. removeGeometry(geometry: Geometry): boolean;
  99071. /**
  99072. * Gets the list of geometries attached to the scene
  99073. * @returns an array of Geometry
  99074. */
  99075. getGeometries(): Geometry[];
  99076. /**
  99077. * Gets the first added mesh found of a given ID
  99078. * @param id defines the id to search for
  99079. * @return the mesh found or null if not found at all
  99080. */
  99081. getMeshByID(id: string): Nullable<AbstractMesh>;
  99082. /**
  99083. * Gets a list of meshes using their id
  99084. * @param id defines the id to search for
  99085. * @returns a list of meshes
  99086. */
  99087. getMeshesByID(id: string): Array<AbstractMesh>;
  99088. /**
  99089. * Gets the first added transform node found of a given ID
  99090. * @param id defines the id to search for
  99091. * @return the found transform node or null if not found at all.
  99092. */
  99093. getTransformNodeByID(id: string): Nullable<TransformNode>;
  99094. /**
  99095. * Gets a transform node with its auto-generated unique id
  99096. * @param uniqueId efines the unique id to search for
  99097. * @return the found transform node or null if not found at all.
  99098. */
  99099. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  99100. /**
  99101. * Gets a list of transform nodes using their id
  99102. * @param id defines the id to search for
  99103. * @returns a list of transform nodes
  99104. */
  99105. getTransformNodesByID(id: string): Array<TransformNode>;
  99106. /**
  99107. * Gets a mesh with its auto-generated unique id
  99108. * @param uniqueId defines the unique id to search for
  99109. * @return the found mesh or null if not found at all.
  99110. */
  99111. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  99112. /**
  99113. * Gets a the last added mesh using a given id
  99114. * @param id defines the id to search for
  99115. * @return the found mesh or null if not found at all.
  99116. */
  99117. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  99118. /**
  99119. * Gets a the last added node (Mesh, Camera, Light) using a given id
  99120. * @param id defines the id to search for
  99121. * @return the found node or null if not found at all
  99122. */
  99123. getLastEntryByID(id: string): Nullable<Node>;
  99124. /**
  99125. * Gets a node (Mesh, Camera, Light) using a given id
  99126. * @param id defines the id to search for
  99127. * @return the found node or null if not found at all
  99128. */
  99129. getNodeByID(id: string): Nullable<Node>;
  99130. /**
  99131. * Gets a node (Mesh, Camera, Light) using a given name
  99132. * @param name defines the name to search for
  99133. * @return the found node or null if not found at all.
  99134. */
  99135. getNodeByName(name: string): Nullable<Node>;
  99136. /**
  99137. * Gets a mesh using a given name
  99138. * @param name defines the name to search for
  99139. * @return the found mesh or null if not found at all.
  99140. */
  99141. getMeshByName(name: string): Nullable<AbstractMesh>;
  99142. /**
  99143. * Gets a transform node using a given name
  99144. * @param name defines the name to search for
  99145. * @return the found transform node or null if not found at all.
  99146. */
  99147. getTransformNodeByName(name: string): Nullable<TransformNode>;
  99148. /**
  99149. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  99150. * @param id defines the id to search for
  99151. * @return the found skeleton or null if not found at all.
  99152. */
  99153. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  99154. /**
  99155. * Gets a skeleton using a given auto generated unique id
  99156. * @param uniqueId defines the unique id to search for
  99157. * @return the found skeleton or null if not found at all.
  99158. */
  99159. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  99160. /**
  99161. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  99162. * @param id defines the id to search for
  99163. * @return the found skeleton or null if not found at all.
  99164. */
  99165. getSkeletonById(id: string): Nullable<Skeleton>;
  99166. /**
  99167. * Gets a skeleton using a given name
  99168. * @param name defines the name to search for
  99169. * @return the found skeleton or null if not found at all.
  99170. */
  99171. getSkeletonByName(name: string): Nullable<Skeleton>;
  99172. /**
  99173. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  99174. * @param id defines the id to search for
  99175. * @return the found morph target manager or null if not found at all.
  99176. */
  99177. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  99178. /**
  99179. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  99180. * @param id defines the id to search for
  99181. * @return the found morph target or null if not found at all.
  99182. */
  99183. getMorphTargetById(id: string): Nullable<MorphTarget>;
  99184. /**
  99185. * Gets a boolean indicating if the given mesh is active
  99186. * @param mesh defines the mesh to look for
  99187. * @returns true if the mesh is in the active list
  99188. */
  99189. isActiveMesh(mesh: AbstractMesh): boolean;
  99190. /**
  99191. * Return a unique id as a string which can serve as an identifier for the scene
  99192. */
  99193. readonly uid: string;
  99194. /**
  99195. * Add an externaly attached data from its key.
  99196. * This method call will fail and return false, if such key already exists.
  99197. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  99198. * @param key the unique key that identifies the data
  99199. * @param data the data object to associate to the key for this Engine instance
  99200. * @return true if no such key were already present and the data was added successfully, false otherwise
  99201. */
  99202. addExternalData<T>(key: string, data: T): boolean;
  99203. /**
  99204. * Get an externaly attached data from its key
  99205. * @param key the unique key that identifies the data
  99206. * @return the associated data, if present (can be null), or undefined if not present
  99207. */
  99208. getExternalData<T>(key: string): Nullable<T>;
  99209. /**
  99210. * Get an externaly attached data from its key, create it using a factory if it's not already present
  99211. * @param key the unique key that identifies the data
  99212. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  99213. * @return the associated data, can be null if the factory returned null.
  99214. */
  99215. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  99216. /**
  99217. * Remove an externaly attached data from the Engine instance
  99218. * @param key the unique key that identifies the data
  99219. * @return true if the data was successfully removed, false if it doesn't exist
  99220. */
  99221. removeExternalData(key: string): boolean;
  99222. private _evaluateSubMesh;
  99223. /**
  99224. * Clear the processed materials smart array preventing retention point in material dispose.
  99225. */
  99226. freeProcessedMaterials(): void;
  99227. private _preventFreeActiveMeshesAndRenderingGroups;
  99228. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  99229. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  99230. * when disposing several meshes in a row or a hierarchy of meshes.
  99231. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  99232. */
  99233. blockfreeActiveMeshesAndRenderingGroups: boolean;
  99234. /**
  99235. * Clear the active meshes smart array preventing retention point in mesh dispose.
  99236. */
  99237. freeActiveMeshes(): void;
  99238. /**
  99239. * Clear the info related to rendering groups preventing retention points during dispose.
  99240. */
  99241. freeRenderingGroups(): void;
  99242. /** @hidden */
  99243. _isInIntermediateRendering(): boolean;
  99244. /**
  99245. * Lambda returning the list of potentially active meshes.
  99246. */
  99247. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  99248. /**
  99249. * Lambda returning the list of potentially active sub meshes.
  99250. */
  99251. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  99252. /**
  99253. * Lambda returning the list of potentially intersecting sub meshes.
  99254. */
  99255. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  99256. /**
  99257. * Lambda returning the list of potentially colliding sub meshes.
  99258. */
  99259. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  99260. private _activeMeshesFrozen;
  99261. /**
  99262. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  99263. * @returns the current scene
  99264. */
  99265. freezeActiveMeshes(): Scene;
  99266. /**
  99267. * Use this function to restart evaluating active meshes on every frame
  99268. * @returns the current scene
  99269. */
  99270. unfreezeActiveMeshes(): Scene;
  99271. private _evaluateActiveMeshes;
  99272. private _activeMesh;
  99273. /**
  99274. * Update the transform matrix to update from the current active camera
  99275. * @param force defines a boolean used to force the update even if cache is up to date
  99276. */
  99277. updateTransformMatrix(force?: boolean): void;
  99278. private _bindFrameBuffer;
  99279. /** @hidden */
  99280. _allowPostProcessClearColor: boolean;
  99281. /** @hidden */
  99282. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  99283. private _processSubCameras;
  99284. private _checkIntersections;
  99285. /** @hidden */
  99286. _advancePhysicsEngineStep(step: number): void;
  99287. /**
  99288. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  99289. */
  99290. getDeterministicFrameTime: () => number;
  99291. /** @hidden */
  99292. _animate(): void;
  99293. /** Execute all animations (for a frame) */
  99294. animate(): void;
  99295. /**
  99296. * Render the scene
  99297. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  99298. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  99299. */
  99300. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  99301. /**
  99302. * Freeze all materials
  99303. * A frozen material will not be updatable but should be faster to render
  99304. */
  99305. freezeMaterials(): void;
  99306. /**
  99307. * Unfreeze all materials
  99308. * A frozen material will not be updatable but should be faster to render
  99309. */
  99310. unfreezeMaterials(): void;
  99311. /**
  99312. * Releases all held ressources
  99313. */
  99314. dispose(): void;
  99315. /**
  99316. * Gets if the scene is already disposed
  99317. */
  99318. readonly isDisposed: boolean;
  99319. /**
  99320. * Call this function to reduce memory footprint of the scene.
  99321. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  99322. */
  99323. clearCachedVertexData(): void;
  99324. /**
  99325. * This function will remove the local cached buffer data from texture.
  99326. * It will save memory but will prevent the texture from being rebuilt
  99327. */
  99328. cleanCachedTextureBuffer(): void;
  99329. /**
  99330. * Get the world extend vectors with an optional filter
  99331. *
  99332. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  99333. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  99334. */
  99335. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  99336. min: Vector3;
  99337. max: Vector3;
  99338. };
  99339. /**
  99340. * Creates a ray that can be used to pick in the scene
  99341. * @param x defines the x coordinate of the origin (on-screen)
  99342. * @param y defines the y coordinate of the origin (on-screen)
  99343. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  99344. * @param camera defines the camera to use for the picking
  99345. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  99346. * @returns a Ray
  99347. */
  99348. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  99349. /**
  99350. * Creates a ray that can be used to pick in the scene
  99351. * @param x defines the x coordinate of the origin (on-screen)
  99352. * @param y defines the y coordinate of the origin (on-screen)
  99353. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  99354. * @param result defines the ray where to store the picking ray
  99355. * @param camera defines the camera to use for the picking
  99356. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  99357. * @returns the current scene
  99358. */
  99359. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  99360. /**
  99361. * Creates a ray that can be used to pick in the scene
  99362. * @param x defines the x coordinate of the origin (on-screen)
  99363. * @param y defines the y coordinate of the origin (on-screen)
  99364. * @param camera defines the camera to use for the picking
  99365. * @returns a Ray
  99366. */
  99367. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  99368. /**
  99369. * Creates a ray that can be used to pick in the scene
  99370. * @param x defines the x coordinate of the origin (on-screen)
  99371. * @param y defines the y coordinate of the origin (on-screen)
  99372. * @param result defines the ray where to store the picking ray
  99373. * @param camera defines the camera to use for the picking
  99374. * @returns the current scene
  99375. */
  99376. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  99377. /** Launch a ray to try to pick a mesh in the scene
  99378. * @param x position on screen
  99379. * @param y position on screen
  99380. * @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
  99381. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  99382. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  99383. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  99384. * @returns a PickingInfo
  99385. */
  99386. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  99387. /** Use the given ray to pick a mesh in the scene
  99388. * @param ray The ray to use to pick meshes
  99389. * @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
  99390. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  99391. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  99392. * @returns a PickingInfo
  99393. */
  99394. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  99395. /**
  99396. * Launch a ray to try to pick a mesh in the scene
  99397. * @param x X position on screen
  99398. * @param y Y position on screen
  99399. * @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
  99400. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  99401. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  99402. * @returns an array of PickingInfo
  99403. */
  99404. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  99405. /**
  99406. * Launch a ray to try to pick a mesh in the scene
  99407. * @param ray Ray to use
  99408. * @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
  99409. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  99410. * @returns an array of PickingInfo
  99411. */
  99412. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  99413. /**
  99414. * Force the value of meshUnderPointer
  99415. * @param mesh defines the mesh to use
  99416. */
  99417. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  99418. /**
  99419. * Gets the mesh under the pointer
  99420. * @returns a Mesh or null if no mesh is under the pointer
  99421. */
  99422. getPointerOverMesh(): Nullable<AbstractMesh>;
  99423. /** @hidden */
  99424. _rebuildGeometries(): void;
  99425. /** @hidden */
  99426. _rebuildTextures(): void;
  99427. private _getByTags;
  99428. /**
  99429. * Get a list of meshes by tags
  99430. * @param tagsQuery defines the tags query to use
  99431. * @param forEach defines a predicate used to filter results
  99432. * @returns an array of Mesh
  99433. */
  99434. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  99435. /**
  99436. * Get a list of cameras by tags
  99437. * @param tagsQuery defines the tags query to use
  99438. * @param forEach defines a predicate used to filter results
  99439. * @returns an array of Camera
  99440. */
  99441. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  99442. /**
  99443. * Get a list of lights by tags
  99444. * @param tagsQuery defines the tags query to use
  99445. * @param forEach defines a predicate used to filter results
  99446. * @returns an array of Light
  99447. */
  99448. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  99449. /**
  99450. * Get a list of materials by tags
  99451. * @param tagsQuery defines the tags query to use
  99452. * @param forEach defines a predicate used to filter results
  99453. * @returns an array of Material
  99454. */
  99455. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  99456. /**
  99457. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  99458. * This allowed control for front to back rendering or reversly depending of the special needs.
  99459. *
  99460. * @param renderingGroupId The rendering group id corresponding to its index
  99461. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  99462. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  99463. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  99464. */
  99465. 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;
  99466. /**
  99467. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  99468. *
  99469. * @param renderingGroupId The rendering group id corresponding to its index
  99470. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  99471. * @param depth Automatically clears depth between groups if true and autoClear is true.
  99472. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  99473. */
  99474. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  99475. /**
  99476. * Gets the current auto clear configuration for one rendering group of the rendering
  99477. * manager.
  99478. * @param index the rendering group index to get the information for
  99479. * @returns The auto clear setup for the requested rendering group
  99480. */
  99481. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  99482. private _blockMaterialDirtyMechanism;
  99483. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  99484. blockMaterialDirtyMechanism: boolean;
  99485. /**
  99486. * Will flag all materials as dirty to trigger new shader compilation
  99487. * @param flag defines the flag used to specify which material part must be marked as dirty
  99488. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  99489. */
  99490. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  99491. /** @hidden */
  99492. _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;
  99493. /** @hidden */
  99494. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  99495. }
  99496. }
  99497. declare module BABYLON {
  99498. /**
  99499. * Set of assets to keep when moving a scene into an asset container.
  99500. */
  99501. export class KeepAssets extends AbstractScene {
  99502. }
  99503. /**
  99504. * Container with a set of assets that can be added or removed from a scene.
  99505. */
  99506. export class AssetContainer extends AbstractScene {
  99507. /**
  99508. * The scene the AssetContainer belongs to.
  99509. */
  99510. scene: Scene;
  99511. /**
  99512. * Instantiates an AssetContainer.
  99513. * @param scene The scene the AssetContainer belongs to.
  99514. */
  99515. constructor(scene: Scene);
  99516. /**
  99517. * Adds all the assets from the container to the scene.
  99518. */
  99519. addAllToScene(): void;
  99520. /**
  99521. * Removes all the assets in the container from the scene
  99522. */
  99523. removeAllFromScene(): void;
  99524. /**
  99525. * Disposes all the assets in the container
  99526. */
  99527. dispose(): void;
  99528. private _moveAssets;
  99529. /**
  99530. * Removes all the assets contained in the scene and adds them to the container.
  99531. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  99532. */
  99533. moveAllFromScene(keepAssets?: KeepAssets): void;
  99534. /**
  99535. * 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.
  99536. * @returns the root mesh
  99537. */
  99538. createRootMesh(): Mesh;
  99539. }
  99540. }
  99541. declare module BABYLON {
  99542. /**
  99543. * Defines how the parser contract is defined.
  99544. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  99545. */
  99546. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  99547. /**
  99548. * Defines how the individual parser contract is defined.
  99549. * These parser can parse an individual asset
  99550. */
  99551. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  99552. /**
  99553. * Base class of the scene acting as a container for the different elements composing a scene.
  99554. * This class is dynamically extended by the different components of the scene increasing
  99555. * flexibility and reducing coupling
  99556. */
  99557. export abstract class AbstractScene {
  99558. /**
  99559. * Stores the list of available parsers in the application.
  99560. */
  99561. private static _BabylonFileParsers;
  99562. /**
  99563. * Stores the list of available individual parsers in the application.
  99564. */
  99565. private static _IndividualBabylonFileParsers;
  99566. /**
  99567. * Adds a parser in the list of available ones
  99568. * @param name Defines the name of the parser
  99569. * @param parser Defines the parser to add
  99570. */
  99571. static AddParser(name: string, parser: BabylonFileParser): void;
  99572. /**
  99573. * Gets a general parser from the list of avaialble ones
  99574. * @param name Defines the name of the parser
  99575. * @returns the requested parser or null
  99576. */
  99577. static GetParser(name: string): Nullable<BabylonFileParser>;
  99578. /**
  99579. * Adds n individual parser in the list of available ones
  99580. * @param name Defines the name of the parser
  99581. * @param parser Defines the parser to add
  99582. */
  99583. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  99584. /**
  99585. * Gets an individual parser from the list of avaialble ones
  99586. * @param name Defines the name of the parser
  99587. * @returns the requested parser or null
  99588. */
  99589. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  99590. /**
  99591. * Parser json data and populate both a scene and its associated container object
  99592. * @param jsonData Defines the data to parse
  99593. * @param scene Defines the scene to parse the data for
  99594. * @param container Defines the container attached to the parsing sequence
  99595. * @param rootUrl Defines the root url of the data
  99596. */
  99597. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  99598. /**
  99599. * Gets the list of root nodes (ie. nodes with no parent)
  99600. */
  99601. rootNodes: Node[];
  99602. /** All of the cameras added to this scene
  99603. * @see http://doc.babylonjs.com/babylon101/cameras
  99604. */
  99605. cameras: Camera[];
  99606. /**
  99607. * All of the lights added to this scene
  99608. * @see http://doc.babylonjs.com/babylon101/lights
  99609. */
  99610. lights: Light[];
  99611. /**
  99612. * All of the (abstract) meshes added to this scene
  99613. */
  99614. meshes: AbstractMesh[];
  99615. /**
  99616. * The list of skeletons added to the scene
  99617. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  99618. */
  99619. skeletons: Skeleton[];
  99620. /**
  99621. * All of the particle systems added to this scene
  99622. * @see http://doc.babylonjs.com/babylon101/particles
  99623. */
  99624. particleSystems: IParticleSystem[];
  99625. /**
  99626. * Gets a list of Animations associated with the scene
  99627. */
  99628. animations: Animation[];
  99629. /**
  99630. * All of the animation groups added to this scene
  99631. * @see http://doc.babylonjs.com/how_to/group
  99632. */
  99633. animationGroups: AnimationGroup[];
  99634. /**
  99635. * All of the multi-materials added to this scene
  99636. * @see http://doc.babylonjs.com/how_to/multi_materials
  99637. */
  99638. multiMaterials: MultiMaterial[];
  99639. /**
  99640. * All of the materials added to this scene
  99641. * In the context of a Scene, it is not supposed to be modified manually.
  99642. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  99643. * Note also that the order of the Material wihin the array is not significant and might change.
  99644. * @see http://doc.babylonjs.com/babylon101/materials
  99645. */
  99646. materials: Material[];
  99647. /**
  99648. * The list of morph target managers added to the scene
  99649. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  99650. */
  99651. morphTargetManagers: MorphTargetManager[];
  99652. /**
  99653. * The list of geometries used in the scene.
  99654. */
  99655. geometries: Geometry[];
  99656. /**
  99657. * All of the tranform nodes added to this scene
  99658. * In the context of a Scene, it is not supposed to be modified manually.
  99659. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  99660. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  99661. * @see http://doc.babylonjs.com/how_to/transformnode
  99662. */
  99663. transformNodes: TransformNode[];
  99664. /**
  99665. * ActionManagers available on the scene.
  99666. */
  99667. actionManagers: AbstractActionManager[];
  99668. /**
  99669. * Textures to keep.
  99670. */
  99671. textures: BaseTexture[];
  99672. /**
  99673. * Environment texture for the scene
  99674. */
  99675. environmentTexture: Nullable<BaseTexture>;
  99676. }
  99677. }
  99678. declare module BABYLON {
  99679. /**
  99680. * Interface used to define options for Sound class
  99681. */
  99682. export interface ISoundOptions {
  99683. /**
  99684. * Does the sound autoplay once loaded.
  99685. */
  99686. autoplay?: boolean;
  99687. /**
  99688. * Does the sound loop after it finishes playing once.
  99689. */
  99690. loop?: boolean;
  99691. /**
  99692. * Sound's volume
  99693. */
  99694. volume?: number;
  99695. /**
  99696. * Is it a spatial sound?
  99697. */
  99698. spatialSound?: boolean;
  99699. /**
  99700. * Maximum distance to hear that sound
  99701. */
  99702. maxDistance?: number;
  99703. /**
  99704. * Uses user defined attenuation function
  99705. */
  99706. useCustomAttenuation?: boolean;
  99707. /**
  99708. * Define the roll off factor of spatial sounds.
  99709. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99710. */
  99711. rolloffFactor?: number;
  99712. /**
  99713. * Define the reference distance the sound should be heard perfectly.
  99714. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99715. */
  99716. refDistance?: number;
  99717. /**
  99718. * Define the distance attenuation model the sound will follow.
  99719. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99720. */
  99721. distanceModel?: string;
  99722. /**
  99723. * Defines the playback speed (1 by default)
  99724. */
  99725. playbackRate?: number;
  99726. /**
  99727. * Defines if the sound is from a streaming source
  99728. */
  99729. streaming?: boolean;
  99730. /**
  99731. * Defines an optional length (in seconds) inside the sound file
  99732. */
  99733. length?: number;
  99734. /**
  99735. * Defines an optional offset (in seconds) inside the sound file
  99736. */
  99737. offset?: number;
  99738. /**
  99739. * If true, URLs will not be required to state the audio file codec to use.
  99740. */
  99741. skipCodecCheck?: boolean;
  99742. }
  99743. /**
  99744. * Defines a sound that can be played in the application.
  99745. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  99746. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99747. */
  99748. export class Sound {
  99749. /**
  99750. * The name of the sound in the scene.
  99751. */
  99752. name: string;
  99753. /**
  99754. * Does the sound autoplay once loaded.
  99755. */
  99756. autoplay: boolean;
  99757. /**
  99758. * Does the sound loop after it finishes playing once.
  99759. */
  99760. loop: boolean;
  99761. /**
  99762. * Does the sound use a custom attenuation curve to simulate the falloff
  99763. * happening when the source gets further away from the camera.
  99764. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  99765. */
  99766. useCustomAttenuation: boolean;
  99767. /**
  99768. * The sound track id this sound belongs to.
  99769. */
  99770. soundTrackId: number;
  99771. /**
  99772. * Is this sound currently played.
  99773. */
  99774. isPlaying: boolean;
  99775. /**
  99776. * Is this sound currently paused.
  99777. */
  99778. isPaused: boolean;
  99779. /**
  99780. * Does this sound enables spatial sound.
  99781. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99782. */
  99783. spatialSound: boolean;
  99784. /**
  99785. * Define the reference distance the sound should be heard perfectly.
  99786. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99787. */
  99788. refDistance: number;
  99789. /**
  99790. * Define the roll off factor of spatial sounds.
  99791. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99792. */
  99793. rolloffFactor: number;
  99794. /**
  99795. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  99796. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99797. */
  99798. maxDistance: number;
  99799. /**
  99800. * Define the distance attenuation model the sound will follow.
  99801. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99802. */
  99803. distanceModel: string;
  99804. /**
  99805. * @hidden
  99806. * Back Compat
  99807. **/
  99808. onended: () => any;
  99809. /**
  99810. * Observable event when the current playing sound finishes.
  99811. */
  99812. onEndedObservable: Observable<Sound>;
  99813. private _panningModel;
  99814. private _playbackRate;
  99815. private _streaming;
  99816. private _startTime;
  99817. private _startOffset;
  99818. private _position;
  99819. /** @hidden */
  99820. _positionInEmitterSpace: boolean;
  99821. private _localDirection;
  99822. private _volume;
  99823. private _isReadyToPlay;
  99824. private _isDirectional;
  99825. private _readyToPlayCallback;
  99826. private _audioBuffer;
  99827. private _soundSource;
  99828. private _streamingSource;
  99829. private _soundPanner;
  99830. private _soundGain;
  99831. private _inputAudioNode;
  99832. private _outputAudioNode;
  99833. private _coneInnerAngle;
  99834. private _coneOuterAngle;
  99835. private _coneOuterGain;
  99836. private _scene;
  99837. private _connectedTransformNode;
  99838. private _customAttenuationFunction;
  99839. private _registerFunc;
  99840. private _isOutputConnected;
  99841. private _htmlAudioElement;
  99842. private _urlType;
  99843. private _length?;
  99844. private _offset?;
  99845. /** @hidden */
  99846. static _SceneComponentInitialization: (scene: Scene) => void;
  99847. /**
  99848. * Create a sound and attach it to a scene
  99849. * @param name Name of your sound
  99850. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  99851. * @param scene defines the scene the sound belongs to
  99852. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  99853. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  99854. */
  99855. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  99856. /**
  99857. * Release the sound and its associated resources
  99858. */
  99859. dispose(): void;
  99860. /**
  99861. * Gets if the sounds is ready to be played or not.
  99862. * @returns true if ready, otherwise false
  99863. */
  99864. isReady(): boolean;
  99865. private _soundLoaded;
  99866. /**
  99867. * Sets the data of the sound from an audiobuffer
  99868. * @param audioBuffer The audioBuffer containing the data
  99869. */
  99870. setAudioBuffer(audioBuffer: AudioBuffer): void;
  99871. /**
  99872. * Updates the current sounds options such as maxdistance, loop...
  99873. * @param options A JSON object containing values named as the object properties
  99874. */
  99875. updateOptions(options: ISoundOptions): void;
  99876. private _createSpatialParameters;
  99877. private _updateSpatialParameters;
  99878. /**
  99879. * Switch the panning model to HRTF:
  99880. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  99881. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99882. */
  99883. switchPanningModelToHRTF(): void;
  99884. /**
  99885. * Switch the panning model to Equal Power:
  99886. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  99887. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99888. */
  99889. switchPanningModelToEqualPower(): void;
  99890. private _switchPanningModel;
  99891. /**
  99892. * Connect this sound to a sound track audio node like gain...
  99893. * @param soundTrackAudioNode the sound track audio node to connect to
  99894. */
  99895. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  99896. /**
  99897. * Transform this sound into a directional source
  99898. * @param coneInnerAngle Size of the inner cone in degree
  99899. * @param coneOuterAngle Size of the outer cone in degree
  99900. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  99901. */
  99902. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  99903. /**
  99904. * Gets or sets the inner angle for the directional cone.
  99905. */
  99906. /**
  99907. * Gets or sets the inner angle for the directional cone.
  99908. */
  99909. directionalConeInnerAngle: number;
  99910. /**
  99911. * Gets or sets the outer angle for the directional cone.
  99912. */
  99913. /**
  99914. * Gets or sets the outer angle for the directional cone.
  99915. */
  99916. directionalConeOuterAngle: number;
  99917. /**
  99918. * Sets the position of the emitter if spatial sound is enabled
  99919. * @param newPosition Defines the new posisiton
  99920. */
  99921. setPosition(newPosition: Vector3): void;
  99922. /**
  99923. * Sets the local direction of the emitter if spatial sound is enabled
  99924. * @param newLocalDirection Defines the new local direction
  99925. */
  99926. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  99927. private _updateDirection;
  99928. /** @hidden */
  99929. updateDistanceFromListener(): void;
  99930. /**
  99931. * Sets a new custom attenuation function for the sound.
  99932. * @param callback Defines the function used for the attenuation
  99933. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  99934. */
  99935. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  99936. /**
  99937. * Play the sound
  99938. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  99939. * @param offset (optional) Start the sound at a specific time in seconds
  99940. * @param length (optional) Sound duration (in seconds)
  99941. */
  99942. play(time?: number, offset?: number, length?: number): void;
  99943. private _onended;
  99944. /**
  99945. * Stop the sound
  99946. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  99947. */
  99948. stop(time?: number): void;
  99949. /**
  99950. * Put the sound in pause
  99951. */
  99952. pause(): void;
  99953. /**
  99954. * Sets a dedicated volume for this sounds
  99955. * @param newVolume Define the new volume of the sound
  99956. * @param time Define time for gradual change to new volume
  99957. */
  99958. setVolume(newVolume: number, time?: number): void;
  99959. /**
  99960. * Set the sound play back rate
  99961. * @param newPlaybackRate Define the playback rate the sound should be played at
  99962. */
  99963. setPlaybackRate(newPlaybackRate: number): void;
  99964. /**
  99965. * Gets the volume of the sound.
  99966. * @returns the volume of the sound
  99967. */
  99968. getVolume(): number;
  99969. /**
  99970. * Attach the sound to a dedicated mesh
  99971. * @param transformNode The transform node to connect the sound with
  99972. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  99973. */
  99974. attachToMesh(transformNode: TransformNode): void;
  99975. /**
  99976. * Detach the sound from the previously attached mesh
  99977. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  99978. */
  99979. detachFromMesh(): void;
  99980. private _onRegisterAfterWorldMatrixUpdate;
  99981. /**
  99982. * Clone the current sound in the scene.
  99983. * @returns the new sound clone
  99984. */
  99985. clone(): Nullable<Sound>;
  99986. /**
  99987. * Gets the current underlying audio buffer containing the data
  99988. * @returns the audio buffer
  99989. */
  99990. getAudioBuffer(): Nullable<AudioBuffer>;
  99991. /**
  99992. * Serializes the Sound in a JSON representation
  99993. * @returns the JSON representation of the sound
  99994. */
  99995. serialize(): any;
  99996. /**
  99997. * Parse a JSON representation of a sound to innstantiate in a given scene
  99998. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  99999. * @param scene Define the scene the new parsed sound should be created in
  100000. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  100001. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  100002. * @returns the newly parsed sound
  100003. */
  100004. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  100005. }
  100006. }
  100007. declare module BABYLON {
  100008. /**
  100009. * This defines an action helpful to play a defined sound on a triggered action.
  100010. */
  100011. export class PlaySoundAction extends Action {
  100012. private _sound;
  100013. /**
  100014. * Instantiate the action
  100015. * @param triggerOptions defines the trigger options
  100016. * @param sound defines the sound to play
  100017. * @param condition defines the trigger related conditions
  100018. */
  100019. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  100020. /** @hidden */
  100021. _prepare(): void;
  100022. /**
  100023. * Execute the action and play the sound.
  100024. */
  100025. execute(): void;
  100026. /**
  100027. * Serializes the actions and its related information.
  100028. * @param parent defines the object to serialize in
  100029. * @returns the serialized object
  100030. */
  100031. serialize(parent: any): any;
  100032. }
  100033. /**
  100034. * This defines an action helpful to stop a defined sound on a triggered action.
  100035. */
  100036. export class StopSoundAction extends Action {
  100037. private _sound;
  100038. /**
  100039. * Instantiate the action
  100040. * @param triggerOptions defines the trigger options
  100041. * @param sound defines the sound to stop
  100042. * @param condition defines the trigger related conditions
  100043. */
  100044. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  100045. /** @hidden */
  100046. _prepare(): void;
  100047. /**
  100048. * Execute the action and stop the sound.
  100049. */
  100050. execute(): void;
  100051. /**
  100052. * Serializes the actions and its related information.
  100053. * @param parent defines the object to serialize in
  100054. * @returns the serialized object
  100055. */
  100056. serialize(parent: any): any;
  100057. }
  100058. }
  100059. declare module BABYLON {
  100060. /**
  100061. * This defines an action responsible to change the value of a property
  100062. * by interpolating between its current value and the newly set one once triggered.
  100063. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  100064. */
  100065. export class InterpolateValueAction extends Action {
  100066. /**
  100067. * Defines the path of the property where the value should be interpolated
  100068. */
  100069. propertyPath: string;
  100070. /**
  100071. * Defines the target value at the end of the interpolation.
  100072. */
  100073. value: any;
  100074. /**
  100075. * Defines the time it will take for the property to interpolate to the value.
  100076. */
  100077. duration: number;
  100078. /**
  100079. * Defines if the other scene animations should be stopped when the action has been triggered
  100080. */
  100081. stopOtherAnimations?: boolean;
  100082. /**
  100083. * Defines a callback raised once the interpolation animation has been done.
  100084. */
  100085. onInterpolationDone?: () => void;
  100086. /**
  100087. * Observable triggered once the interpolation animation has been done.
  100088. */
  100089. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  100090. private _target;
  100091. private _effectiveTarget;
  100092. private _property;
  100093. /**
  100094. * Instantiate the action
  100095. * @param triggerOptions defines the trigger options
  100096. * @param target defines the object containing the value to interpolate
  100097. * @param propertyPath defines the path to the property in the target object
  100098. * @param value defines the target value at the end of the interpolation
  100099. * @param duration deines the time it will take for the property to interpolate to the value.
  100100. * @param condition defines the trigger related conditions
  100101. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  100102. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  100103. */
  100104. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  100105. /** @hidden */
  100106. _prepare(): void;
  100107. /**
  100108. * Execute the action starts the value interpolation.
  100109. */
  100110. execute(): void;
  100111. /**
  100112. * Serializes the actions and its related information.
  100113. * @param parent defines the object to serialize in
  100114. * @returns the serialized object
  100115. */
  100116. serialize(parent: any): any;
  100117. }
  100118. }
  100119. declare module BABYLON {
  100120. /**
  100121. * Options allowed during the creation of a sound track.
  100122. */
  100123. export interface ISoundTrackOptions {
  100124. /**
  100125. * The volume the sound track should take during creation
  100126. */
  100127. volume?: number;
  100128. /**
  100129. * Define if the sound track is the main sound track of the scene
  100130. */
  100131. mainTrack?: boolean;
  100132. }
  100133. /**
  100134. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  100135. * It will be also used in a future release to apply effects on a specific track.
  100136. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  100137. */
  100138. export class SoundTrack {
  100139. /**
  100140. * The unique identifier of the sound track in the scene.
  100141. */
  100142. id: number;
  100143. /**
  100144. * The list of sounds included in the sound track.
  100145. */
  100146. soundCollection: Array<Sound>;
  100147. private _outputAudioNode;
  100148. private _scene;
  100149. private _isMainTrack;
  100150. private _connectedAnalyser;
  100151. private _options;
  100152. private _isInitialized;
  100153. /**
  100154. * Creates a new sound track.
  100155. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  100156. * @param scene Define the scene the sound track belongs to
  100157. * @param options
  100158. */
  100159. constructor(scene: Scene, options?: ISoundTrackOptions);
  100160. private _initializeSoundTrackAudioGraph;
  100161. /**
  100162. * Release the sound track and its associated resources
  100163. */
  100164. dispose(): void;
  100165. /**
  100166. * Adds a sound to this sound track
  100167. * @param sound define the cound to add
  100168. * @ignoreNaming
  100169. */
  100170. AddSound(sound: Sound): void;
  100171. /**
  100172. * Removes a sound to this sound track
  100173. * @param sound define the cound to remove
  100174. * @ignoreNaming
  100175. */
  100176. RemoveSound(sound: Sound): void;
  100177. /**
  100178. * Set a global volume for the full sound track.
  100179. * @param newVolume Define the new volume of the sound track
  100180. */
  100181. setVolume(newVolume: number): void;
  100182. /**
  100183. * Switch the panning model to HRTF:
  100184. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  100185. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100186. */
  100187. switchPanningModelToHRTF(): void;
  100188. /**
  100189. * Switch the panning model to Equal Power:
  100190. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  100191. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100192. */
  100193. switchPanningModelToEqualPower(): void;
  100194. /**
  100195. * Connect the sound track to an audio analyser allowing some amazing
  100196. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  100197. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  100198. * @param analyser The analyser to connect to the engine
  100199. */
  100200. connectToAnalyser(analyser: Analyser): void;
  100201. }
  100202. }
  100203. declare module BABYLON {
  100204. interface AbstractScene {
  100205. /**
  100206. * The list of sounds used in the scene.
  100207. */
  100208. sounds: Nullable<Array<Sound>>;
  100209. }
  100210. interface Scene {
  100211. /**
  100212. * @hidden
  100213. * Backing field
  100214. */
  100215. _mainSoundTrack: SoundTrack;
  100216. /**
  100217. * The main sound track played by the scene.
  100218. * It cotains your primary collection of sounds.
  100219. */
  100220. mainSoundTrack: SoundTrack;
  100221. /**
  100222. * The list of sound tracks added to the scene
  100223. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  100224. */
  100225. soundTracks: Nullable<Array<SoundTrack>>;
  100226. /**
  100227. * Gets a sound using a given name
  100228. * @param name defines the name to search for
  100229. * @return the found sound or null if not found at all.
  100230. */
  100231. getSoundByName(name: string): Nullable<Sound>;
  100232. /**
  100233. * Gets or sets if audio support is enabled
  100234. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  100235. */
  100236. audioEnabled: boolean;
  100237. /**
  100238. * Gets or sets if audio will be output to headphones
  100239. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  100240. */
  100241. headphone: boolean;
  100242. /**
  100243. * Gets or sets custom audio listener position provider
  100244. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  100245. */
  100246. audioListenerPositionProvider: Nullable<() => Vector3>;
  100247. }
  100248. /**
  100249. * Defines the sound scene component responsible to manage any sounds
  100250. * in a given scene.
  100251. */
  100252. export class AudioSceneComponent implements ISceneSerializableComponent {
  100253. /**
  100254. * The component name helpfull to identify the component in the list of scene components.
  100255. */
  100256. readonly name: string;
  100257. /**
  100258. * The scene the component belongs to.
  100259. */
  100260. scene: Scene;
  100261. private _audioEnabled;
  100262. /**
  100263. * Gets whether audio is enabled or not.
  100264. * Please use related enable/disable method to switch state.
  100265. */
  100266. readonly audioEnabled: boolean;
  100267. private _headphone;
  100268. /**
  100269. * Gets whether audio is outputing to headphone or not.
  100270. * Please use the according Switch methods to change output.
  100271. */
  100272. readonly headphone: boolean;
  100273. private _audioListenerPositionProvider;
  100274. /**
  100275. * Gets the current audio listener position provider
  100276. */
  100277. /**
  100278. * Sets a custom listener position for all sounds in the scene
  100279. * By default, this is the position of the first active camera
  100280. */
  100281. audioListenerPositionProvider: Nullable<() => Vector3>;
  100282. /**
  100283. * Creates a new instance of the component for the given scene
  100284. * @param scene Defines the scene to register the component in
  100285. */
  100286. constructor(scene: Scene);
  100287. /**
  100288. * Registers the component in a given scene
  100289. */
  100290. register(): void;
  100291. /**
  100292. * Rebuilds the elements related to this component in case of
  100293. * context lost for instance.
  100294. */
  100295. rebuild(): void;
  100296. /**
  100297. * Serializes the component data to the specified json object
  100298. * @param serializationObject The object to serialize to
  100299. */
  100300. serialize(serializationObject: any): void;
  100301. /**
  100302. * Adds all the elements from the container to the scene
  100303. * @param container the container holding the elements
  100304. */
  100305. addFromContainer(container: AbstractScene): void;
  100306. /**
  100307. * Removes all the elements in the container from the scene
  100308. * @param container contains the elements to remove
  100309. * @param dispose if the removed element should be disposed (default: false)
  100310. */
  100311. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  100312. /**
  100313. * Disposes the component and the associated ressources.
  100314. */
  100315. dispose(): void;
  100316. /**
  100317. * Disables audio in the associated scene.
  100318. */
  100319. disableAudio(): void;
  100320. /**
  100321. * Enables audio in the associated scene.
  100322. */
  100323. enableAudio(): void;
  100324. /**
  100325. * Switch audio to headphone output.
  100326. */
  100327. switchAudioModeForHeadphones(): void;
  100328. /**
  100329. * Switch audio to normal speakers.
  100330. */
  100331. switchAudioModeForNormalSpeakers(): void;
  100332. private _afterRender;
  100333. }
  100334. }
  100335. declare module BABYLON {
  100336. /**
  100337. * Wraps one or more Sound objects and selects one with random weight for playback.
  100338. */
  100339. export class WeightedSound {
  100340. /** When true a Sound will be selected and played when the current playing Sound completes. */
  100341. loop: boolean;
  100342. private _coneInnerAngle;
  100343. private _coneOuterAngle;
  100344. private _volume;
  100345. /** A Sound is currently playing. */
  100346. isPlaying: boolean;
  100347. /** A Sound is currently paused. */
  100348. isPaused: boolean;
  100349. private _sounds;
  100350. private _weights;
  100351. private _currentIndex?;
  100352. /**
  100353. * Creates a new WeightedSound from the list of sounds given.
  100354. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  100355. * @param sounds Array of Sounds that will be selected from.
  100356. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  100357. */
  100358. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  100359. /**
  100360. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  100361. */
  100362. /**
  100363. * The size of cone in degress for a directional sound in which there will be no attenuation.
  100364. */
  100365. directionalConeInnerAngle: number;
  100366. /**
  100367. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  100368. * Listener angles between innerAngle and outerAngle will falloff linearly.
  100369. */
  100370. /**
  100371. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  100372. * Listener angles between innerAngle and outerAngle will falloff linearly.
  100373. */
  100374. directionalConeOuterAngle: number;
  100375. /**
  100376. * Playback volume.
  100377. */
  100378. /**
  100379. * Playback volume.
  100380. */
  100381. volume: number;
  100382. private _onended;
  100383. /**
  100384. * Suspend playback
  100385. */
  100386. pause(): void;
  100387. /**
  100388. * Stop playback
  100389. */
  100390. stop(): void;
  100391. /**
  100392. * Start playback.
  100393. * @param startOffset Position the clip head at a specific time in seconds.
  100394. */
  100395. play(startOffset?: number): void;
  100396. }
  100397. }
  100398. declare module BABYLON {
  100399. /**
  100400. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  100401. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  100402. */
  100403. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  100404. /**
  100405. * Gets the name of the behavior.
  100406. */
  100407. readonly name: string;
  100408. /**
  100409. * The easing function used by animations
  100410. */
  100411. static EasingFunction: BackEase;
  100412. /**
  100413. * The easing mode used by animations
  100414. */
  100415. static EasingMode: number;
  100416. /**
  100417. * The duration of the animation, in milliseconds
  100418. */
  100419. transitionDuration: number;
  100420. /**
  100421. * Length of the distance animated by the transition when lower radius is reached
  100422. */
  100423. lowerRadiusTransitionRange: number;
  100424. /**
  100425. * Length of the distance animated by the transition when upper radius is reached
  100426. */
  100427. upperRadiusTransitionRange: number;
  100428. private _autoTransitionRange;
  100429. /**
  100430. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  100431. */
  100432. /**
  100433. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  100434. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  100435. */
  100436. autoTransitionRange: boolean;
  100437. private _attachedCamera;
  100438. private _onAfterCheckInputsObserver;
  100439. private _onMeshTargetChangedObserver;
  100440. /**
  100441. * Initializes the behavior.
  100442. */
  100443. init(): void;
  100444. /**
  100445. * Attaches the behavior to its arc rotate camera.
  100446. * @param camera Defines the camera to attach the behavior to
  100447. */
  100448. attach(camera: ArcRotateCamera): void;
  100449. /**
  100450. * Detaches the behavior from its current arc rotate camera.
  100451. */
  100452. detach(): void;
  100453. private _radiusIsAnimating;
  100454. private _radiusBounceTransition;
  100455. private _animatables;
  100456. private _cachedWheelPrecision;
  100457. /**
  100458. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  100459. * @param radiusLimit The limit to check against.
  100460. * @return Bool to indicate if at limit.
  100461. */
  100462. private _isRadiusAtLimit;
  100463. /**
  100464. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  100465. * @param radiusDelta The delta by which to animate to. Can be negative.
  100466. */
  100467. private _applyBoundRadiusAnimation;
  100468. /**
  100469. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  100470. */
  100471. protected _clearAnimationLocks(): void;
  100472. /**
  100473. * Stops and removes all animations that have been applied to the camera
  100474. */
  100475. stopAllAnimations(): void;
  100476. }
  100477. }
  100478. declare module BABYLON {
  100479. /**
  100480. * 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.
  100481. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  100482. */
  100483. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  100484. /**
  100485. * Gets the name of the behavior.
  100486. */
  100487. readonly name: string;
  100488. private _mode;
  100489. private _radiusScale;
  100490. private _positionScale;
  100491. private _defaultElevation;
  100492. private _elevationReturnTime;
  100493. private _elevationReturnWaitTime;
  100494. private _zoomStopsAnimation;
  100495. private _framingTime;
  100496. /**
  100497. * The easing function used by animations
  100498. */
  100499. static EasingFunction: ExponentialEase;
  100500. /**
  100501. * The easing mode used by animations
  100502. */
  100503. static EasingMode: number;
  100504. /**
  100505. * Sets the current mode used by the behavior
  100506. */
  100507. /**
  100508. * Gets current mode used by the behavior.
  100509. */
  100510. mode: number;
  100511. /**
  100512. * Sets the scale applied to the radius (1 by default)
  100513. */
  100514. /**
  100515. * Gets the scale applied to the radius
  100516. */
  100517. radiusScale: number;
  100518. /**
  100519. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  100520. */
  100521. /**
  100522. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  100523. */
  100524. positionScale: number;
  100525. /**
  100526. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  100527. * behaviour is triggered, in radians.
  100528. */
  100529. /**
  100530. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  100531. * behaviour is triggered, in radians.
  100532. */
  100533. defaultElevation: number;
  100534. /**
  100535. * Sets the time (in milliseconds) taken to return to the default beta position.
  100536. * Negative value indicates camera should not return to default.
  100537. */
  100538. /**
  100539. * Gets the time (in milliseconds) taken to return to the default beta position.
  100540. * Negative value indicates camera should not return to default.
  100541. */
  100542. elevationReturnTime: number;
  100543. /**
  100544. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  100545. */
  100546. /**
  100547. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  100548. */
  100549. elevationReturnWaitTime: number;
  100550. /**
  100551. * Sets the flag that indicates if user zooming should stop animation.
  100552. */
  100553. /**
  100554. * Gets the flag that indicates if user zooming should stop animation.
  100555. */
  100556. zoomStopsAnimation: boolean;
  100557. /**
  100558. * Sets the transition time when framing the mesh, in milliseconds
  100559. */
  100560. /**
  100561. * Gets the transition time when framing the mesh, in milliseconds
  100562. */
  100563. framingTime: number;
  100564. /**
  100565. * Define if the behavior should automatically change the configured
  100566. * camera limits and sensibilities.
  100567. */
  100568. autoCorrectCameraLimitsAndSensibility: boolean;
  100569. private _onPrePointerObservableObserver;
  100570. private _onAfterCheckInputsObserver;
  100571. private _onMeshTargetChangedObserver;
  100572. private _attachedCamera;
  100573. private _isPointerDown;
  100574. private _lastInteractionTime;
  100575. /**
  100576. * Initializes the behavior.
  100577. */
  100578. init(): void;
  100579. /**
  100580. * Attaches the behavior to its arc rotate camera.
  100581. * @param camera Defines the camera to attach the behavior to
  100582. */
  100583. attach(camera: ArcRotateCamera): void;
  100584. /**
  100585. * Detaches the behavior from its current arc rotate camera.
  100586. */
  100587. detach(): void;
  100588. private _animatables;
  100589. private _betaIsAnimating;
  100590. private _betaTransition;
  100591. private _radiusTransition;
  100592. private _vectorTransition;
  100593. /**
  100594. * Targets the given mesh and updates zoom level accordingly.
  100595. * @param mesh The mesh to target.
  100596. * @param radius Optional. If a cached radius position already exists, overrides default.
  100597. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  100598. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  100599. * @param onAnimationEnd Callback triggered at the end of the framing animation
  100600. */
  100601. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  100602. /**
  100603. * Targets the given mesh with its children and updates zoom level accordingly.
  100604. * @param mesh The mesh to target.
  100605. * @param radius Optional. If a cached radius position already exists, overrides default.
  100606. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  100607. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  100608. * @param onAnimationEnd Callback triggered at the end of the framing animation
  100609. */
  100610. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  100611. /**
  100612. * Targets the given meshes with their children and updates zoom level accordingly.
  100613. * @param meshes The mesh to target.
  100614. * @param radius Optional. If a cached radius position already exists, overrides default.
  100615. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  100616. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  100617. * @param onAnimationEnd Callback triggered at the end of the framing animation
  100618. */
  100619. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  100620. /**
  100621. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  100622. * @param minimumWorld Determines the smaller position of the bounding box extend
  100623. * @param maximumWorld Determines the bigger position of the bounding box extend
  100624. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  100625. * @param onAnimationEnd Callback triggered at the end of the framing animation
  100626. */
  100627. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  100628. /**
  100629. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  100630. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  100631. * frustum width.
  100632. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  100633. * to fully enclose the mesh in the viewing frustum.
  100634. */
  100635. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  100636. /**
  100637. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  100638. * is automatically returned to its default position (expected to be above ground plane).
  100639. */
  100640. private _maintainCameraAboveGround;
  100641. /**
  100642. * Returns the frustum slope based on the canvas ratio and camera FOV
  100643. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  100644. */
  100645. private _getFrustumSlope;
  100646. /**
  100647. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  100648. */
  100649. private _clearAnimationLocks;
  100650. /**
  100651. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  100652. */
  100653. private _applyUserInteraction;
  100654. /**
  100655. * Stops and removes all animations that have been applied to the camera
  100656. */
  100657. stopAllAnimations(): void;
  100658. /**
  100659. * Gets a value indicating if the user is moving the camera
  100660. */
  100661. readonly isUserIsMoving: boolean;
  100662. /**
  100663. * The camera can move all the way towards the mesh.
  100664. */
  100665. static IgnoreBoundsSizeMode: number;
  100666. /**
  100667. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  100668. */
  100669. static FitFrustumSidesMode: number;
  100670. }
  100671. }
  100672. declare module BABYLON {
  100673. /**
  100674. * Base class for Camera Pointer Inputs.
  100675. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  100676. * for example usage.
  100677. */
  100678. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  100679. /**
  100680. * Defines the camera the input is attached to.
  100681. */
  100682. abstract camera: Camera;
  100683. /**
  100684. * Whether keyboard modifier keys are pressed at time of last mouse event.
  100685. */
  100686. protected _altKey: boolean;
  100687. protected _ctrlKey: boolean;
  100688. protected _metaKey: boolean;
  100689. protected _shiftKey: boolean;
  100690. /**
  100691. * Which mouse buttons were pressed at time of last mouse event.
  100692. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  100693. */
  100694. protected _buttonsPressed: number;
  100695. /**
  100696. * Defines the buttons associated with the input to handle camera move.
  100697. */
  100698. buttons: number[];
  100699. /**
  100700. * Attach the input controls to a specific dom element to get the input from.
  100701. * @param element Defines the element the controls should be listened from
  100702. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100703. */
  100704. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100705. /**
  100706. * Detach the current controls from the specified dom element.
  100707. * @param element Defines the element to stop listening the inputs from
  100708. */
  100709. detachControl(element: Nullable<HTMLElement>): void;
  100710. /**
  100711. * Gets the class name of the current input.
  100712. * @returns the class name
  100713. */
  100714. getClassName(): string;
  100715. /**
  100716. * Get the friendly name associated with the input class.
  100717. * @returns the input friendly name
  100718. */
  100719. getSimpleName(): string;
  100720. /**
  100721. * Called on pointer POINTERDOUBLETAP event.
  100722. * Override this method to provide functionality on POINTERDOUBLETAP event.
  100723. */
  100724. protected onDoubleTap(type: string): void;
  100725. /**
  100726. * Called on pointer POINTERMOVE event if only a single touch is active.
  100727. * Override this method to provide functionality.
  100728. */
  100729. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  100730. /**
  100731. * Called on pointer POINTERMOVE event if multiple touches are active.
  100732. * Override this method to provide functionality.
  100733. */
  100734. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  100735. /**
  100736. * Called on JS contextmenu event.
  100737. * Override this method to provide functionality.
  100738. */
  100739. protected onContextMenu(evt: PointerEvent): void;
  100740. /**
  100741. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  100742. * press.
  100743. * Override this method to provide functionality.
  100744. */
  100745. protected onButtonDown(evt: PointerEvent): void;
  100746. /**
  100747. * Called each time a new POINTERUP event occurs. Ie, for each button
  100748. * release.
  100749. * Override this method to provide functionality.
  100750. */
  100751. protected onButtonUp(evt: PointerEvent): void;
  100752. /**
  100753. * Called when window becomes inactive.
  100754. * Override this method to provide functionality.
  100755. */
  100756. protected onLostFocus(): void;
  100757. private _pointerInput;
  100758. private _observer;
  100759. private _onLostFocus;
  100760. private pointA;
  100761. private pointB;
  100762. }
  100763. }
  100764. declare module BABYLON {
  100765. /**
  100766. * Manage the pointers inputs to control an arc rotate camera.
  100767. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100768. */
  100769. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  100770. /**
  100771. * Defines the camera the input is attached to.
  100772. */
  100773. camera: ArcRotateCamera;
  100774. /**
  100775. * Gets the class name of the current input.
  100776. * @returns the class name
  100777. */
  100778. getClassName(): string;
  100779. /**
  100780. * Defines the buttons associated with the input to handle camera move.
  100781. */
  100782. buttons: number[];
  100783. /**
  100784. * Defines the pointer angular sensibility along the X axis or how fast is
  100785. * the camera rotating.
  100786. */
  100787. angularSensibilityX: number;
  100788. /**
  100789. * Defines the pointer angular sensibility along the Y axis or how fast is
  100790. * the camera rotating.
  100791. */
  100792. angularSensibilityY: number;
  100793. /**
  100794. * Defines the pointer pinch precision or how fast is the camera zooming.
  100795. */
  100796. pinchPrecision: number;
  100797. /**
  100798. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  100799. * from 0.
  100800. * It defines the percentage of current camera.radius to use as delta when
  100801. * pinch zoom is used.
  100802. */
  100803. pinchDeltaPercentage: number;
  100804. /**
  100805. * Defines the pointer panning sensibility or how fast is the camera moving.
  100806. */
  100807. panningSensibility: number;
  100808. /**
  100809. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  100810. */
  100811. multiTouchPanning: boolean;
  100812. /**
  100813. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  100814. * zoom (pinch) through multitouch.
  100815. */
  100816. multiTouchPanAndZoom: boolean;
  100817. /**
  100818. * Revers pinch action direction.
  100819. */
  100820. pinchInwards: boolean;
  100821. private _isPanClick;
  100822. private _twoFingerActivityCount;
  100823. private _isPinching;
  100824. /**
  100825. * Called on pointer POINTERMOVE event if only a single touch is active.
  100826. */
  100827. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  100828. /**
  100829. * Called on pointer POINTERDOUBLETAP event.
  100830. */
  100831. protected onDoubleTap(type: string): void;
  100832. /**
  100833. * Called on pointer POINTERMOVE event if multiple touches are active.
  100834. */
  100835. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  100836. /**
  100837. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  100838. * press.
  100839. */
  100840. protected onButtonDown(evt: PointerEvent): void;
  100841. /**
  100842. * Called each time a new POINTERUP event occurs. Ie, for each button
  100843. * release.
  100844. */
  100845. protected onButtonUp(evt: PointerEvent): void;
  100846. /**
  100847. * Called when window becomes inactive.
  100848. */
  100849. protected onLostFocus(): void;
  100850. }
  100851. }
  100852. declare module BABYLON {
  100853. /**
  100854. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  100855. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100856. */
  100857. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  100858. /**
  100859. * Defines the camera the input is attached to.
  100860. */
  100861. camera: ArcRotateCamera;
  100862. /**
  100863. * Defines the list of key codes associated with the up action (increase alpha)
  100864. */
  100865. keysUp: number[];
  100866. /**
  100867. * Defines the list of key codes associated with the down action (decrease alpha)
  100868. */
  100869. keysDown: number[];
  100870. /**
  100871. * Defines the list of key codes associated with the left action (increase beta)
  100872. */
  100873. keysLeft: number[];
  100874. /**
  100875. * Defines the list of key codes associated with the right action (decrease beta)
  100876. */
  100877. keysRight: number[];
  100878. /**
  100879. * Defines the list of key codes associated with the reset action.
  100880. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  100881. */
  100882. keysReset: number[];
  100883. /**
  100884. * Defines the panning sensibility of the inputs.
  100885. * (How fast is the camera paning)
  100886. */
  100887. panningSensibility: number;
  100888. /**
  100889. * Defines the zooming sensibility of the inputs.
  100890. * (How fast is the camera zooming)
  100891. */
  100892. zoomingSensibility: number;
  100893. /**
  100894. * Defines wether maintaining the alt key down switch the movement mode from
  100895. * orientation to zoom.
  100896. */
  100897. useAltToZoom: boolean;
  100898. /**
  100899. * Rotation speed of the camera
  100900. */
  100901. angularSpeed: number;
  100902. private _keys;
  100903. private _ctrlPressed;
  100904. private _altPressed;
  100905. private _onCanvasBlurObserver;
  100906. private _onKeyboardObserver;
  100907. private _engine;
  100908. private _scene;
  100909. /**
  100910. * Attach the input controls to a specific dom element to get the input from.
  100911. * @param element Defines the element the controls should be listened from
  100912. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100913. */
  100914. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100915. /**
  100916. * Detach the current controls from the specified dom element.
  100917. * @param element Defines the element to stop listening the inputs from
  100918. */
  100919. detachControl(element: Nullable<HTMLElement>): void;
  100920. /**
  100921. * Update the current camera state depending on the inputs that have been used this frame.
  100922. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100923. */
  100924. checkInputs(): void;
  100925. /**
  100926. * Gets the class name of the current intput.
  100927. * @returns the class name
  100928. */
  100929. getClassName(): string;
  100930. /**
  100931. * Get the friendly name associated with the input class.
  100932. * @returns the input friendly name
  100933. */
  100934. getSimpleName(): string;
  100935. }
  100936. }
  100937. declare module BABYLON {
  100938. /**
  100939. * Manage the mouse wheel inputs to control an arc rotate camera.
  100940. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100941. */
  100942. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  100943. /**
  100944. * Defines the camera the input is attached to.
  100945. */
  100946. camera: ArcRotateCamera;
  100947. /**
  100948. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  100949. */
  100950. wheelPrecision: number;
  100951. /**
  100952. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  100953. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  100954. */
  100955. wheelDeltaPercentage: number;
  100956. private _wheel;
  100957. private _observer;
  100958. private computeDeltaFromMouseWheelLegacyEvent;
  100959. /**
  100960. * Attach the input controls to a specific dom element to get the input from.
  100961. * @param element Defines the element the controls should be listened from
  100962. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100963. */
  100964. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100965. /**
  100966. * Detach the current controls from the specified dom element.
  100967. * @param element Defines the element to stop listening the inputs from
  100968. */
  100969. detachControl(element: Nullable<HTMLElement>): void;
  100970. /**
  100971. * Gets the class name of the current intput.
  100972. * @returns the class name
  100973. */
  100974. getClassName(): string;
  100975. /**
  100976. * Get the friendly name associated with the input class.
  100977. * @returns the input friendly name
  100978. */
  100979. getSimpleName(): string;
  100980. }
  100981. }
  100982. declare module BABYLON {
  100983. /**
  100984. * Default Inputs manager for the ArcRotateCamera.
  100985. * It groups all the default supported inputs for ease of use.
  100986. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100987. */
  100988. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  100989. /**
  100990. * Instantiates a new ArcRotateCameraInputsManager.
  100991. * @param camera Defines the camera the inputs belong to
  100992. */
  100993. constructor(camera: ArcRotateCamera);
  100994. /**
  100995. * Add mouse wheel input support to the input manager.
  100996. * @returns the current input manager
  100997. */
  100998. addMouseWheel(): ArcRotateCameraInputsManager;
  100999. /**
  101000. * Add pointers input support to the input manager.
  101001. * @returns the current input manager
  101002. */
  101003. addPointers(): ArcRotateCameraInputsManager;
  101004. /**
  101005. * Add keyboard input support to the input manager.
  101006. * @returns the current input manager
  101007. */
  101008. addKeyboard(): ArcRotateCameraInputsManager;
  101009. }
  101010. }
  101011. declare module BABYLON {
  101012. /**
  101013. * This represents an orbital type of camera.
  101014. *
  101015. * 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.
  101016. * 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.
  101017. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  101018. */
  101019. export class ArcRotateCamera extends TargetCamera {
  101020. /**
  101021. * Defines the rotation angle of the camera along the longitudinal axis.
  101022. */
  101023. alpha: number;
  101024. /**
  101025. * Defines the rotation angle of the camera along the latitudinal axis.
  101026. */
  101027. beta: number;
  101028. /**
  101029. * Defines the radius of the camera from it s target point.
  101030. */
  101031. radius: number;
  101032. protected _target: Vector3;
  101033. protected _targetHost: Nullable<AbstractMesh>;
  101034. /**
  101035. * Defines the target point of the camera.
  101036. * The camera looks towards it form the radius distance.
  101037. */
  101038. target: Vector3;
  101039. /**
  101040. * Define the current local position of the camera in the scene
  101041. */
  101042. position: Vector3;
  101043. protected _upVector: Vector3;
  101044. protected _upToYMatrix: Matrix;
  101045. protected _YToUpMatrix: Matrix;
  101046. /**
  101047. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  101048. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  101049. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  101050. */
  101051. upVector: Vector3;
  101052. /**
  101053. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  101054. */
  101055. setMatUp(): void;
  101056. /**
  101057. * Current inertia value on the longitudinal axis.
  101058. * The bigger this number the longer it will take for the camera to stop.
  101059. */
  101060. inertialAlphaOffset: number;
  101061. /**
  101062. * Current inertia value on the latitudinal axis.
  101063. * The bigger this number the longer it will take for the camera to stop.
  101064. */
  101065. inertialBetaOffset: number;
  101066. /**
  101067. * Current inertia value on the radius axis.
  101068. * The bigger this number the longer it will take for the camera to stop.
  101069. */
  101070. inertialRadiusOffset: number;
  101071. /**
  101072. * Minimum allowed angle on the longitudinal axis.
  101073. * This can help limiting how the Camera is able to move in the scene.
  101074. */
  101075. lowerAlphaLimit: Nullable<number>;
  101076. /**
  101077. * Maximum allowed angle on the longitudinal axis.
  101078. * This can help limiting how the Camera is able to move in the scene.
  101079. */
  101080. upperAlphaLimit: Nullable<number>;
  101081. /**
  101082. * Minimum allowed angle on the latitudinal axis.
  101083. * This can help limiting how the Camera is able to move in the scene.
  101084. */
  101085. lowerBetaLimit: number;
  101086. /**
  101087. * Maximum allowed angle on the latitudinal axis.
  101088. * This can help limiting how the Camera is able to move in the scene.
  101089. */
  101090. upperBetaLimit: number;
  101091. /**
  101092. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  101093. * This can help limiting how the Camera is able to move in the scene.
  101094. */
  101095. lowerRadiusLimit: Nullable<number>;
  101096. /**
  101097. * Maximum allowed distance of the camera to the target (The camera can not get further).
  101098. * This can help limiting how the Camera is able to move in the scene.
  101099. */
  101100. upperRadiusLimit: Nullable<number>;
  101101. /**
  101102. * Defines the current inertia value used during panning of the camera along the X axis.
  101103. */
  101104. inertialPanningX: number;
  101105. /**
  101106. * Defines the current inertia value used during panning of the camera along the Y axis.
  101107. */
  101108. inertialPanningY: number;
  101109. /**
  101110. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  101111. * Basically if your fingers moves away from more than this distance you will be considered
  101112. * in pinch mode.
  101113. */
  101114. pinchToPanMaxDistance: number;
  101115. /**
  101116. * Defines the maximum distance the camera can pan.
  101117. * This could help keeping the cammera always in your scene.
  101118. */
  101119. panningDistanceLimit: Nullable<number>;
  101120. /**
  101121. * Defines the target of the camera before paning.
  101122. */
  101123. panningOriginTarget: Vector3;
  101124. /**
  101125. * Defines the value of the inertia used during panning.
  101126. * 0 would mean stop inertia and one would mean no decelleration at all.
  101127. */
  101128. panningInertia: number;
  101129. /**
  101130. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  101131. */
  101132. angularSensibilityX: number;
  101133. /**
  101134. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  101135. */
  101136. angularSensibilityY: number;
  101137. /**
  101138. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  101139. */
  101140. pinchPrecision: number;
  101141. /**
  101142. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  101143. * It will be used instead of pinchDeltaPrecision if different from 0.
  101144. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  101145. */
  101146. pinchDeltaPercentage: number;
  101147. /**
  101148. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  101149. */
  101150. panningSensibility: number;
  101151. /**
  101152. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  101153. */
  101154. keysUp: number[];
  101155. /**
  101156. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  101157. */
  101158. keysDown: number[];
  101159. /**
  101160. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  101161. */
  101162. keysLeft: number[];
  101163. /**
  101164. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  101165. */
  101166. keysRight: number[];
  101167. /**
  101168. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  101169. */
  101170. wheelPrecision: number;
  101171. /**
  101172. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  101173. * It will be used instead of pinchDeltaPrecision if different from 0.
  101174. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  101175. */
  101176. wheelDeltaPercentage: number;
  101177. /**
  101178. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  101179. */
  101180. zoomOnFactor: number;
  101181. /**
  101182. * Defines a screen offset for the camera position.
  101183. */
  101184. targetScreenOffset: Vector2;
  101185. /**
  101186. * Allows the camera to be completely reversed.
  101187. * If false the camera can not arrive upside down.
  101188. */
  101189. allowUpsideDown: boolean;
  101190. /**
  101191. * Define if double tap/click is used to restore the previously saved state of the camera.
  101192. */
  101193. useInputToRestoreState: boolean;
  101194. /** @hidden */
  101195. _viewMatrix: Matrix;
  101196. /** @hidden */
  101197. _useCtrlForPanning: boolean;
  101198. /** @hidden */
  101199. _panningMouseButton: number;
  101200. /**
  101201. * Defines the input associated to the camera.
  101202. */
  101203. inputs: ArcRotateCameraInputsManager;
  101204. /** @hidden */
  101205. _reset: () => void;
  101206. /**
  101207. * Defines the allowed panning axis.
  101208. */
  101209. panningAxis: Vector3;
  101210. protected _localDirection: Vector3;
  101211. protected _transformedDirection: Vector3;
  101212. private _bouncingBehavior;
  101213. /**
  101214. * Gets the bouncing behavior of the camera if it has been enabled.
  101215. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  101216. */
  101217. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  101218. /**
  101219. * Defines if the bouncing behavior of the camera is enabled on the camera.
  101220. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  101221. */
  101222. useBouncingBehavior: boolean;
  101223. private _framingBehavior;
  101224. /**
  101225. * Gets the framing behavior of the camera if it has been enabled.
  101226. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  101227. */
  101228. readonly framingBehavior: Nullable<FramingBehavior>;
  101229. /**
  101230. * Defines if the framing behavior of the camera is enabled on the camera.
  101231. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  101232. */
  101233. useFramingBehavior: boolean;
  101234. private _autoRotationBehavior;
  101235. /**
  101236. * Gets the auto rotation behavior of the camera if it has been enabled.
  101237. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  101238. */
  101239. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  101240. /**
  101241. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  101242. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  101243. */
  101244. useAutoRotationBehavior: boolean;
  101245. /**
  101246. * Observable triggered when the mesh target has been changed on the camera.
  101247. */
  101248. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  101249. /**
  101250. * Event raised when the camera is colliding with a mesh.
  101251. */
  101252. onCollide: (collidedMesh: AbstractMesh) => void;
  101253. /**
  101254. * Defines whether the camera should check collision with the objects oh the scene.
  101255. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  101256. */
  101257. checkCollisions: boolean;
  101258. /**
  101259. * Defines the collision radius of the camera.
  101260. * This simulates a sphere around the camera.
  101261. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  101262. */
  101263. collisionRadius: Vector3;
  101264. protected _collider: Collider;
  101265. protected _previousPosition: Vector3;
  101266. protected _collisionVelocity: Vector3;
  101267. protected _newPosition: Vector3;
  101268. protected _previousAlpha: number;
  101269. protected _previousBeta: number;
  101270. protected _previousRadius: number;
  101271. protected _collisionTriggered: boolean;
  101272. protected _targetBoundingCenter: Nullable<Vector3>;
  101273. private _computationVector;
  101274. /**
  101275. * Instantiates a new ArcRotateCamera in a given scene
  101276. * @param name Defines the name of the camera
  101277. * @param alpha Defines the camera rotation along the logitudinal axis
  101278. * @param beta Defines the camera rotation along the latitudinal axis
  101279. * @param radius Defines the camera distance from its target
  101280. * @param target Defines the camera target
  101281. * @param scene Defines the scene the camera belongs to
  101282. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  101283. */
  101284. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  101285. /** @hidden */
  101286. _initCache(): void;
  101287. /** @hidden */
  101288. _updateCache(ignoreParentClass?: boolean): void;
  101289. protected _getTargetPosition(): Vector3;
  101290. private _storedAlpha;
  101291. private _storedBeta;
  101292. private _storedRadius;
  101293. private _storedTarget;
  101294. private _storedTargetScreenOffset;
  101295. /**
  101296. * Stores the current state of the camera (alpha, beta, radius and target)
  101297. * @returns the camera itself
  101298. */
  101299. storeState(): Camera;
  101300. /**
  101301. * @hidden
  101302. * Restored camera state. You must call storeState() first
  101303. */
  101304. _restoreStateValues(): boolean;
  101305. /** @hidden */
  101306. _isSynchronizedViewMatrix(): boolean;
  101307. /**
  101308. * Attached controls to the current camera.
  101309. * @param element Defines the element the controls should be listened from
  101310. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101311. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  101312. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  101313. */
  101314. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  101315. /**
  101316. * Detach the current controls from the camera.
  101317. * The camera will stop reacting to inputs.
  101318. * @param element Defines the element to stop listening the inputs from
  101319. */
  101320. detachControl(element: HTMLElement): void;
  101321. /** @hidden */
  101322. _checkInputs(): void;
  101323. protected _checkLimits(): void;
  101324. /**
  101325. * Rebuilds angles (alpha, beta) and radius from the give position and target
  101326. */
  101327. rebuildAnglesAndRadius(): void;
  101328. /**
  101329. * Use a position to define the current camera related information like aplha, beta and radius
  101330. * @param position Defines the position to set the camera at
  101331. */
  101332. setPosition(position: Vector3): void;
  101333. /**
  101334. * Defines the target the camera should look at.
  101335. * This will automatically adapt alpha beta and radius to fit within the new target.
  101336. * @param target Defines the new target as a Vector or a mesh
  101337. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  101338. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  101339. */
  101340. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  101341. /** @hidden */
  101342. _getViewMatrix(): Matrix;
  101343. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  101344. /**
  101345. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  101346. * @param meshes Defines the mesh to zoom on
  101347. * @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)
  101348. */
  101349. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  101350. /**
  101351. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  101352. * The target will be changed but the radius
  101353. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  101354. * @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)
  101355. */
  101356. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  101357. min: Vector3;
  101358. max: Vector3;
  101359. distance: number;
  101360. }, doNotUpdateMaxZ?: boolean): void;
  101361. /**
  101362. * @override
  101363. * Override Camera.createRigCamera
  101364. */
  101365. createRigCamera(name: string, cameraIndex: number): Camera;
  101366. /**
  101367. * @hidden
  101368. * @override
  101369. * Override Camera._updateRigCameras
  101370. */
  101371. _updateRigCameras(): void;
  101372. /**
  101373. * Destroy the camera and release the current resources hold by it.
  101374. */
  101375. dispose(): void;
  101376. /**
  101377. * Gets the current object class name.
  101378. * @return the class name
  101379. */
  101380. getClassName(): string;
  101381. }
  101382. }
  101383. declare module BABYLON {
  101384. /**
  101385. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  101386. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  101387. */
  101388. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  101389. /**
  101390. * Gets the name of the behavior.
  101391. */
  101392. readonly name: string;
  101393. private _zoomStopsAnimation;
  101394. private _idleRotationSpeed;
  101395. private _idleRotationWaitTime;
  101396. private _idleRotationSpinupTime;
  101397. /**
  101398. * Sets the flag that indicates if user zooming should stop animation.
  101399. */
  101400. /**
  101401. * Gets the flag that indicates if user zooming should stop animation.
  101402. */
  101403. zoomStopsAnimation: boolean;
  101404. /**
  101405. * Sets the default speed at which the camera rotates around the model.
  101406. */
  101407. /**
  101408. * Gets the default speed at which the camera rotates around the model.
  101409. */
  101410. idleRotationSpeed: number;
  101411. /**
  101412. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  101413. */
  101414. /**
  101415. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  101416. */
  101417. idleRotationWaitTime: number;
  101418. /**
  101419. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  101420. */
  101421. /**
  101422. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  101423. */
  101424. idleRotationSpinupTime: number;
  101425. /**
  101426. * Gets a value indicating if the camera is currently rotating because of this behavior
  101427. */
  101428. readonly rotationInProgress: boolean;
  101429. private _onPrePointerObservableObserver;
  101430. private _onAfterCheckInputsObserver;
  101431. private _attachedCamera;
  101432. private _isPointerDown;
  101433. private _lastFrameTime;
  101434. private _lastInteractionTime;
  101435. private _cameraRotationSpeed;
  101436. /**
  101437. * Initializes the behavior.
  101438. */
  101439. init(): void;
  101440. /**
  101441. * Attaches the behavior to its arc rotate camera.
  101442. * @param camera Defines the camera to attach the behavior to
  101443. */
  101444. attach(camera: ArcRotateCamera): void;
  101445. /**
  101446. * Detaches the behavior from its current arc rotate camera.
  101447. */
  101448. detach(): void;
  101449. /**
  101450. * Returns true if user is scrolling.
  101451. * @return true if user is scrolling.
  101452. */
  101453. private _userIsZooming;
  101454. private _lastFrameRadius;
  101455. private _shouldAnimationStopForInteraction;
  101456. /**
  101457. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  101458. */
  101459. private _applyUserInteraction;
  101460. private _userIsMoving;
  101461. }
  101462. }
  101463. declare module BABYLON {
  101464. /**
  101465. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  101466. */
  101467. export class AttachToBoxBehavior implements Behavior<Mesh> {
  101468. private ui;
  101469. /**
  101470. * The name of the behavior
  101471. */
  101472. name: string;
  101473. /**
  101474. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  101475. */
  101476. distanceAwayFromFace: number;
  101477. /**
  101478. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  101479. */
  101480. distanceAwayFromBottomOfFace: number;
  101481. private _faceVectors;
  101482. private _target;
  101483. private _scene;
  101484. private _onRenderObserver;
  101485. private _tmpMatrix;
  101486. private _tmpVector;
  101487. /**
  101488. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  101489. * @param ui The transform node that should be attched to the mesh
  101490. */
  101491. constructor(ui: TransformNode);
  101492. /**
  101493. * Initializes the behavior
  101494. */
  101495. init(): void;
  101496. private _closestFace;
  101497. private _zeroVector;
  101498. private _lookAtTmpMatrix;
  101499. private _lookAtToRef;
  101500. /**
  101501. * Attaches the AttachToBoxBehavior to the passed in mesh
  101502. * @param target The mesh that the specified node will be attached to
  101503. */
  101504. attach(target: Mesh): void;
  101505. /**
  101506. * Detaches the behavior from the mesh
  101507. */
  101508. detach(): void;
  101509. }
  101510. }
  101511. declare module BABYLON {
  101512. /**
  101513. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  101514. */
  101515. export class FadeInOutBehavior implements Behavior<Mesh> {
  101516. /**
  101517. * Time in milliseconds to delay before fading in (Default: 0)
  101518. */
  101519. delay: number;
  101520. /**
  101521. * Time in milliseconds for the mesh to fade in (Default: 300)
  101522. */
  101523. fadeInTime: number;
  101524. private _millisecondsPerFrame;
  101525. private _hovered;
  101526. private _hoverValue;
  101527. private _ownerNode;
  101528. /**
  101529. * Instatiates the FadeInOutBehavior
  101530. */
  101531. constructor();
  101532. /**
  101533. * The name of the behavior
  101534. */
  101535. readonly name: string;
  101536. /**
  101537. * Initializes the behavior
  101538. */
  101539. init(): void;
  101540. /**
  101541. * Attaches the fade behavior on the passed in mesh
  101542. * @param ownerNode The mesh that will be faded in/out once attached
  101543. */
  101544. attach(ownerNode: Mesh): void;
  101545. /**
  101546. * Detaches the behavior from the mesh
  101547. */
  101548. detach(): void;
  101549. /**
  101550. * Triggers the mesh to begin fading in or out
  101551. * @param value if the object should fade in or out (true to fade in)
  101552. */
  101553. fadeIn(value: boolean): void;
  101554. private _update;
  101555. private _setAllVisibility;
  101556. }
  101557. }
  101558. declare module BABYLON {
  101559. /**
  101560. * Class containing a set of static utilities functions for managing Pivots
  101561. * @hidden
  101562. */
  101563. export class PivotTools {
  101564. private static _PivotCached;
  101565. private static _OldPivotPoint;
  101566. private static _PivotTranslation;
  101567. private static _PivotTmpVector;
  101568. /** @hidden */
  101569. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  101570. /** @hidden */
  101571. static _RestorePivotPoint(mesh: AbstractMesh): void;
  101572. }
  101573. }
  101574. declare module BABYLON {
  101575. /**
  101576. * Class containing static functions to help procedurally build meshes
  101577. */
  101578. export class PlaneBuilder {
  101579. /**
  101580. * Creates a plane mesh
  101581. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  101582. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  101583. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  101584. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  101585. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  101586. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101587. * @param name defines the name of the mesh
  101588. * @param options defines the options used to create the mesh
  101589. * @param scene defines the hosting scene
  101590. * @returns the plane mesh
  101591. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  101592. */
  101593. static CreatePlane(name: string, options: {
  101594. size?: number;
  101595. width?: number;
  101596. height?: number;
  101597. sideOrientation?: number;
  101598. frontUVs?: Vector4;
  101599. backUVs?: Vector4;
  101600. updatable?: boolean;
  101601. sourcePlane?: Plane;
  101602. }, scene?: Nullable<Scene>): Mesh;
  101603. }
  101604. }
  101605. declare module BABYLON {
  101606. /**
  101607. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  101608. */
  101609. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  101610. private static _AnyMouseID;
  101611. /**
  101612. * Abstract mesh the behavior is set on
  101613. */
  101614. attachedNode: AbstractMesh;
  101615. private _dragPlane;
  101616. private _scene;
  101617. private _pointerObserver;
  101618. private _beforeRenderObserver;
  101619. private static _planeScene;
  101620. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  101621. /**
  101622. * 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)
  101623. */
  101624. maxDragAngle: number;
  101625. /**
  101626. * @hidden
  101627. */
  101628. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  101629. /**
  101630. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  101631. */
  101632. currentDraggingPointerID: number;
  101633. /**
  101634. * The last position where the pointer hit the drag plane in world space
  101635. */
  101636. lastDragPosition: Vector3;
  101637. /**
  101638. * If the behavior is currently in a dragging state
  101639. */
  101640. dragging: boolean;
  101641. /**
  101642. * 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)
  101643. */
  101644. dragDeltaRatio: number;
  101645. /**
  101646. * If the drag plane orientation should be updated during the dragging (Default: true)
  101647. */
  101648. updateDragPlane: boolean;
  101649. private _debugMode;
  101650. private _moving;
  101651. /**
  101652. * Fires each time the attached mesh is dragged with the pointer
  101653. * * delta between last drag position and current drag position in world space
  101654. * * dragDistance along the drag axis
  101655. * * dragPlaneNormal normal of the current drag plane used during the drag
  101656. * * dragPlanePoint in world space where the drag intersects the drag plane
  101657. */
  101658. onDragObservable: Observable<{
  101659. delta: Vector3;
  101660. dragPlanePoint: Vector3;
  101661. dragPlaneNormal: Vector3;
  101662. dragDistance: number;
  101663. pointerId: number;
  101664. }>;
  101665. /**
  101666. * Fires each time a drag begins (eg. mouse down on mesh)
  101667. */
  101668. onDragStartObservable: Observable<{
  101669. dragPlanePoint: Vector3;
  101670. pointerId: number;
  101671. }>;
  101672. /**
  101673. * Fires each time a drag ends (eg. mouse release after drag)
  101674. */
  101675. onDragEndObservable: Observable<{
  101676. dragPlanePoint: Vector3;
  101677. pointerId: number;
  101678. }>;
  101679. /**
  101680. * If the attached mesh should be moved when dragged
  101681. */
  101682. moveAttached: boolean;
  101683. /**
  101684. * If the drag behavior will react to drag events (Default: true)
  101685. */
  101686. enabled: boolean;
  101687. /**
  101688. * If pointer events should start and release the drag (Default: true)
  101689. */
  101690. startAndReleaseDragOnPointerEvents: boolean;
  101691. /**
  101692. * If camera controls should be detached during the drag
  101693. */
  101694. detachCameraControls: boolean;
  101695. /**
  101696. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  101697. */
  101698. useObjectOrienationForDragging: boolean;
  101699. private _options;
  101700. /**
  101701. * Creates a pointer drag behavior that can be attached to a mesh
  101702. * @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)
  101703. */
  101704. constructor(options?: {
  101705. dragAxis?: Vector3;
  101706. dragPlaneNormal?: Vector3;
  101707. });
  101708. /**
  101709. * Predicate to determine if it is valid to move the object to a new position when it is moved
  101710. */
  101711. validateDrag: (targetPosition: Vector3) => boolean;
  101712. /**
  101713. * The name of the behavior
  101714. */
  101715. readonly name: string;
  101716. /**
  101717. * Initializes the behavior
  101718. */
  101719. init(): void;
  101720. private _tmpVector;
  101721. private _alternatePickedPoint;
  101722. private _worldDragAxis;
  101723. private _targetPosition;
  101724. private _attachedElement;
  101725. /**
  101726. * Attaches the drag behavior the passed in mesh
  101727. * @param ownerNode The mesh that will be dragged around once attached
  101728. */
  101729. attach(ownerNode: AbstractMesh): void;
  101730. /**
  101731. * Force relase the drag action by code.
  101732. */
  101733. releaseDrag(): void;
  101734. private _startDragRay;
  101735. private _lastPointerRay;
  101736. /**
  101737. * Simulates the start of a pointer drag event on the behavior
  101738. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  101739. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  101740. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  101741. */
  101742. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  101743. private _startDrag;
  101744. private _dragDelta;
  101745. private _moveDrag;
  101746. private _pickWithRayOnDragPlane;
  101747. private _pointA;
  101748. private _pointB;
  101749. private _pointC;
  101750. private _lineA;
  101751. private _lineB;
  101752. private _localAxis;
  101753. private _lookAt;
  101754. private _updateDragPlanePosition;
  101755. /**
  101756. * Detaches the behavior from the mesh
  101757. */
  101758. detach(): void;
  101759. }
  101760. }
  101761. declare module BABYLON {
  101762. /**
  101763. * A behavior that when attached to a mesh will allow the mesh to be scaled
  101764. */
  101765. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  101766. private _dragBehaviorA;
  101767. private _dragBehaviorB;
  101768. private _startDistance;
  101769. private _initialScale;
  101770. private _targetScale;
  101771. private _ownerNode;
  101772. private _sceneRenderObserver;
  101773. /**
  101774. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  101775. */
  101776. constructor();
  101777. /**
  101778. * The name of the behavior
  101779. */
  101780. readonly name: string;
  101781. /**
  101782. * Initializes the behavior
  101783. */
  101784. init(): void;
  101785. private _getCurrentDistance;
  101786. /**
  101787. * Attaches the scale behavior the passed in mesh
  101788. * @param ownerNode The mesh that will be scaled around once attached
  101789. */
  101790. attach(ownerNode: Mesh): void;
  101791. /**
  101792. * Detaches the behavior from the mesh
  101793. */
  101794. detach(): void;
  101795. }
  101796. }
  101797. declare module BABYLON {
  101798. /**
  101799. * 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
  101800. */
  101801. export class SixDofDragBehavior implements Behavior<Mesh> {
  101802. private static _virtualScene;
  101803. private _ownerNode;
  101804. private _sceneRenderObserver;
  101805. private _scene;
  101806. private _targetPosition;
  101807. private _virtualOriginMesh;
  101808. private _virtualDragMesh;
  101809. private _pointerObserver;
  101810. private _moving;
  101811. private _startingOrientation;
  101812. /**
  101813. * 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)
  101814. */
  101815. private zDragFactor;
  101816. /**
  101817. * If the object should rotate to face the drag origin
  101818. */
  101819. rotateDraggedObject: boolean;
  101820. /**
  101821. * If the behavior is currently in a dragging state
  101822. */
  101823. dragging: boolean;
  101824. /**
  101825. * 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)
  101826. */
  101827. dragDeltaRatio: number;
  101828. /**
  101829. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  101830. */
  101831. currentDraggingPointerID: number;
  101832. /**
  101833. * If camera controls should be detached during the drag
  101834. */
  101835. detachCameraControls: boolean;
  101836. /**
  101837. * Fires each time a drag starts
  101838. */
  101839. onDragStartObservable: Observable<{}>;
  101840. /**
  101841. * Fires each time a drag ends (eg. mouse release after drag)
  101842. */
  101843. onDragEndObservable: Observable<{}>;
  101844. /**
  101845. * 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
  101846. */
  101847. constructor();
  101848. /**
  101849. * The name of the behavior
  101850. */
  101851. readonly name: string;
  101852. /**
  101853. * Initializes the behavior
  101854. */
  101855. init(): void;
  101856. /**
  101857. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  101858. */
  101859. private readonly _pointerCamera;
  101860. /**
  101861. * Attaches the scale behavior the passed in mesh
  101862. * @param ownerNode The mesh that will be scaled around once attached
  101863. */
  101864. attach(ownerNode: Mesh): void;
  101865. /**
  101866. * Detaches the behavior from the mesh
  101867. */
  101868. detach(): void;
  101869. }
  101870. }
  101871. declare module BABYLON {
  101872. /**
  101873. * Class used to apply inverse kinematics to bones
  101874. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  101875. */
  101876. export class BoneIKController {
  101877. private static _tmpVecs;
  101878. private static _tmpQuat;
  101879. private static _tmpMats;
  101880. /**
  101881. * Gets or sets the target mesh
  101882. */
  101883. targetMesh: AbstractMesh;
  101884. /** Gets or sets the mesh used as pole */
  101885. poleTargetMesh: AbstractMesh;
  101886. /**
  101887. * Gets or sets the bone used as pole
  101888. */
  101889. poleTargetBone: Nullable<Bone>;
  101890. /**
  101891. * Gets or sets the target position
  101892. */
  101893. targetPosition: Vector3;
  101894. /**
  101895. * Gets or sets the pole target position
  101896. */
  101897. poleTargetPosition: Vector3;
  101898. /**
  101899. * Gets or sets the pole target local offset
  101900. */
  101901. poleTargetLocalOffset: Vector3;
  101902. /**
  101903. * Gets or sets the pole angle
  101904. */
  101905. poleAngle: number;
  101906. /**
  101907. * Gets or sets the mesh associated with the controller
  101908. */
  101909. mesh: AbstractMesh;
  101910. /**
  101911. * 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)
  101912. */
  101913. slerpAmount: number;
  101914. private _bone1Quat;
  101915. private _bone1Mat;
  101916. private _bone2Ang;
  101917. private _bone1;
  101918. private _bone2;
  101919. private _bone1Length;
  101920. private _bone2Length;
  101921. private _maxAngle;
  101922. private _maxReach;
  101923. private _rightHandedSystem;
  101924. private _bendAxis;
  101925. private _slerping;
  101926. private _adjustRoll;
  101927. /**
  101928. * Gets or sets maximum allowed angle
  101929. */
  101930. maxAngle: number;
  101931. /**
  101932. * Creates a new BoneIKController
  101933. * @param mesh defines the mesh to control
  101934. * @param bone defines the bone to control
  101935. * @param options defines options to set up the controller
  101936. */
  101937. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  101938. targetMesh?: AbstractMesh;
  101939. poleTargetMesh?: AbstractMesh;
  101940. poleTargetBone?: Bone;
  101941. poleTargetLocalOffset?: Vector3;
  101942. poleAngle?: number;
  101943. bendAxis?: Vector3;
  101944. maxAngle?: number;
  101945. slerpAmount?: number;
  101946. });
  101947. private _setMaxAngle;
  101948. /**
  101949. * Force the controller to update the bones
  101950. */
  101951. update(): void;
  101952. }
  101953. }
  101954. declare module BABYLON {
  101955. /**
  101956. * Class used to make a bone look toward a point in space
  101957. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  101958. */
  101959. export class BoneLookController {
  101960. private static _tmpVecs;
  101961. private static _tmpQuat;
  101962. private static _tmpMats;
  101963. /**
  101964. * The target Vector3 that the bone will look at
  101965. */
  101966. target: Vector3;
  101967. /**
  101968. * The mesh that the bone is attached to
  101969. */
  101970. mesh: AbstractMesh;
  101971. /**
  101972. * The bone that will be looking to the target
  101973. */
  101974. bone: Bone;
  101975. /**
  101976. * The up axis of the coordinate system that is used when the bone is rotated
  101977. */
  101978. upAxis: Vector3;
  101979. /**
  101980. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  101981. */
  101982. upAxisSpace: Space;
  101983. /**
  101984. * Used to make an adjustment to the yaw of the bone
  101985. */
  101986. adjustYaw: number;
  101987. /**
  101988. * Used to make an adjustment to the pitch of the bone
  101989. */
  101990. adjustPitch: number;
  101991. /**
  101992. * Used to make an adjustment to the roll of the bone
  101993. */
  101994. adjustRoll: number;
  101995. /**
  101996. * 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)
  101997. */
  101998. slerpAmount: number;
  101999. private _minYaw;
  102000. private _maxYaw;
  102001. private _minPitch;
  102002. private _maxPitch;
  102003. private _minYawSin;
  102004. private _minYawCos;
  102005. private _maxYawSin;
  102006. private _maxYawCos;
  102007. private _midYawConstraint;
  102008. private _minPitchTan;
  102009. private _maxPitchTan;
  102010. private _boneQuat;
  102011. private _slerping;
  102012. private _transformYawPitch;
  102013. private _transformYawPitchInv;
  102014. private _firstFrameSkipped;
  102015. private _yawRange;
  102016. private _fowardAxis;
  102017. /**
  102018. * Gets or sets the minimum yaw angle that the bone can look to
  102019. */
  102020. minYaw: number;
  102021. /**
  102022. * Gets or sets the maximum yaw angle that the bone can look to
  102023. */
  102024. maxYaw: number;
  102025. /**
  102026. * Gets or sets the minimum pitch angle that the bone can look to
  102027. */
  102028. minPitch: number;
  102029. /**
  102030. * Gets or sets the maximum pitch angle that the bone can look to
  102031. */
  102032. maxPitch: number;
  102033. /**
  102034. * Create a BoneLookController
  102035. * @param mesh the mesh that the bone belongs to
  102036. * @param bone the bone that will be looking to the target
  102037. * @param target the target Vector3 to look at
  102038. * @param options optional settings:
  102039. * * maxYaw: the maximum angle the bone will yaw to
  102040. * * minYaw: the minimum angle the bone will yaw to
  102041. * * maxPitch: the maximum angle the bone will pitch to
  102042. * * minPitch: the minimum angle the bone will yaw to
  102043. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  102044. * * upAxis: the up axis of the coordinate system
  102045. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  102046. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  102047. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  102048. * * adjustYaw: used to make an adjustment to the yaw of the bone
  102049. * * adjustPitch: used to make an adjustment to the pitch of the bone
  102050. * * adjustRoll: used to make an adjustment to the roll of the bone
  102051. **/
  102052. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  102053. maxYaw?: number;
  102054. minYaw?: number;
  102055. maxPitch?: number;
  102056. minPitch?: number;
  102057. slerpAmount?: number;
  102058. upAxis?: Vector3;
  102059. upAxisSpace?: Space;
  102060. yawAxis?: Vector3;
  102061. pitchAxis?: Vector3;
  102062. adjustYaw?: number;
  102063. adjustPitch?: number;
  102064. adjustRoll?: number;
  102065. });
  102066. /**
  102067. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  102068. */
  102069. update(): void;
  102070. private _getAngleDiff;
  102071. private _getAngleBetween;
  102072. private _isAngleBetween;
  102073. }
  102074. }
  102075. declare module BABYLON {
  102076. /**
  102077. * Manage the gamepad inputs to control an arc rotate camera.
  102078. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102079. */
  102080. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  102081. /**
  102082. * Defines the camera the input is attached to.
  102083. */
  102084. camera: ArcRotateCamera;
  102085. /**
  102086. * Defines the gamepad the input is gathering event from.
  102087. */
  102088. gamepad: Nullable<Gamepad>;
  102089. /**
  102090. * Defines the gamepad rotation sensiblity.
  102091. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  102092. */
  102093. gamepadRotationSensibility: number;
  102094. /**
  102095. * Defines the gamepad move sensiblity.
  102096. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  102097. */
  102098. gamepadMoveSensibility: number;
  102099. private _onGamepadConnectedObserver;
  102100. private _onGamepadDisconnectedObserver;
  102101. /**
  102102. * Attach the input controls to a specific dom element to get the input from.
  102103. * @param element Defines the element the controls should be listened from
  102104. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102105. */
  102106. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102107. /**
  102108. * Detach the current controls from the specified dom element.
  102109. * @param element Defines the element to stop listening the inputs from
  102110. */
  102111. detachControl(element: Nullable<HTMLElement>): void;
  102112. /**
  102113. * Update the current camera state depending on the inputs that have been used this frame.
  102114. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  102115. */
  102116. checkInputs(): void;
  102117. /**
  102118. * Gets the class name of the current intput.
  102119. * @returns the class name
  102120. */
  102121. getClassName(): string;
  102122. /**
  102123. * Get the friendly name associated with the input class.
  102124. * @returns the input friendly name
  102125. */
  102126. getSimpleName(): string;
  102127. }
  102128. }
  102129. declare module BABYLON {
  102130. interface ArcRotateCameraInputsManager {
  102131. /**
  102132. * Add orientation input support to the input manager.
  102133. * @returns the current input manager
  102134. */
  102135. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  102136. }
  102137. /**
  102138. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  102139. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102140. */
  102141. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  102142. /**
  102143. * Defines the camera the input is attached to.
  102144. */
  102145. camera: ArcRotateCamera;
  102146. /**
  102147. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  102148. */
  102149. alphaCorrection: number;
  102150. /**
  102151. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  102152. */
  102153. gammaCorrection: number;
  102154. private _alpha;
  102155. private _gamma;
  102156. private _dirty;
  102157. private _deviceOrientationHandler;
  102158. /**
  102159. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  102160. */
  102161. constructor();
  102162. /**
  102163. * Attach the input controls to a specific dom element to get the input from.
  102164. * @param element Defines the element the controls should be listened from
  102165. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102166. */
  102167. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102168. /** @hidden */
  102169. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  102170. /**
  102171. * Update the current camera state depending on the inputs that have been used this frame.
  102172. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  102173. */
  102174. checkInputs(): void;
  102175. /**
  102176. * Detach the current controls from the specified dom element.
  102177. * @param element Defines the element to stop listening the inputs from
  102178. */
  102179. detachControl(element: Nullable<HTMLElement>): void;
  102180. /**
  102181. * Gets the class name of the current intput.
  102182. * @returns the class name
  102183. */
  102184. getClassName(): string;
  102185. /**
  102186. * Get the friendly name associated with the input class.
  102187. * @returns the input friendly name
  102188. */
  102189. getSimpleName(): string;
  102190. }
  102191. }
  102192. declare module BABYLON {
  102193. /**
  102194. * Listen to mouse events to control the camera.
  102195. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102196. */
  102197. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  102198. /**
  102199. * Defines the camera the input is attached to.
  102200. */
  102201. camera: FlyCamera;
  102202. /**
  102203. * Defines if touch is enabled. (Default is true.)
  102204. */
  102205. touchEnabled: boolean;
  102206. /**
  102207. * Defines the buttons associated with the input to handle camera rotation.
  102208. */
  102209. buttons: number[];
  102210. /**
  102211. * Assign buttons for Yaw control.
  102212. */
  102213. buttonsYaw: number[];
  102214. /**
  102215. * Assign buttons for Pitch control.
  102216. */
  102217. buttonsPitch: number[];
  102218. /**
  102219. * Assign buttons for Roll control.
  102220. */
  102221. buttonsRoll: number[];
  102222. /**
  102223. * Detect if any button is being pressed while mouse is moved.
  102224. * -1 = Mouse locked.
  102225. * 0 = Left button.
  102226. * 1 = Middle Button.
  102227. * 2 = Right Button.
  102228. */
  102229. activeButton: number;
  102230. /**
  102231. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  102232. * Higher values reduce its sensitivity.
  102233. */
  102234. angularSensibility: number;
  102235. private _mousemoveCallback;
  102236. private _observer;
  102237. private _rollObserver;
  102238. private previousPosition;
  102239. private noPreventDefault;
  102240. private element;
  102241. /**
  102242. * Listen to mouse events to control the camera.
  102243. * @param touchEnabled Define if touch is enabled. (Default is true.)
  102244. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102245. */
  102246. constructor(touchEnabled?: boolean);
  102247. /**
  102248. * Attach the mouse control to the HTML DOM element.
  102249. * @param element Defines the element that listens to the input events.
  102250. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  102251. */
  102252. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102253. /**
  102254. * Detach the current controls from the specified dom element.
  102255. * @param element Defines the element to stop listening the inputs from
  102256. */
  102257. detachControl(element: Nullable<HTMLElement>): void;
  102258. /**
  102259. * Gets the class name of the current input.
  102260. * @returns the class name.
  102261. */
  102262. getClassName(): string;
  102263. /**
  102264. * Get the friendly name associated with the input class.
  102265. * @returns the input's friendly name.
  102266. */
  102267. getSimpleName(): string;
  102268. private _pointerInput;
  102269. private _onMouseMove;
  102270. /**
  102271. * Rotate camera by mouse offset.
  102272. */
  102273. private rotateCamera;
  102274. }
  102275. }
  102276. declare module BABYLON {
  102277. /**
  102278. * Default Inputs manager for the FlyCamera.
  102279. * It groups all the default supported inputs for ease of use.
  102280. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102281. */
  102282. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  102283. /**
  102284. * Instantiates a new FlyCameraInputsManager.
  102285. * @param camera Defines the camera the inputs belong to.
  102286. */
  102287. constructor(camera: FlyCamera);
  102288. /**
  102289. * Add keyboard input support to the input manager.
  102290. * @returns the new FlyCameraKeyboardMoveInput().
  102291. */
  102292. addKeyboard(): FlyCameraInputsManager;
  102293. /**
  102294. * Add mouse input support to the input manager.
  102295. * @param touchEnabled Enable touch screen support.
  102296. * @returns the new FlyCameraMouseInput().
  102297. */
  102298. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  102299. }
  102300. }
  102301. declare module BABYLON {
  102302. /**
  102303. * This is a flying camera, designed for 3D movement and rotation in all directions,
  102304. * such as in a 3D Space Shooter or a Flight Simulator.
  102305. */
  102306. export class FlyCamera extends TargetCamera {
  102307. /**
  102308. * Define the collision ellipsoid of the camera.
  102309. * This is helpful for simulating a camera body, like a player's body.
  102310. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  102311. */
  102312. ellipsoid: Vector3;
  102313. /**
  102314. * Define an offset for the position of the ellipsoid around the camera.
  102315. * This can be helpful if the camera is attached away from the player's body center,
  102316. * such as at its head.
  102317. */
  102318. ellipsoidOffset: Vector3;
  102319. /**
  102320. * Enable or disable collisions of the camera with the rest of the scene objects.
  102321. */
  102322. checkCollisions: boolean;
  102323. /**
  102324. * Enable or disable gravity on the camera.
  102325. */
  102326. applyGravity: boolean;
  102327. /**
  102328. * Define the current direction the camera is moving to.
  102329. */
  102330. cameraDirection: Vector3;
  102331. /**
  102332. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  102333. * This overrides and empties cameraRotation.
  102334. */
  102335. rotationQuaternion: Quaternion;
  102336. /**
  102337. * Track Roll to maintain the wanted Rolling when looking around.
  102338. */
  102339. _trackRoll: number;
  102340. /**
  102341. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  102342. */
  102343. rollCorrect: number;
  102344. /**
  102345. * Mimic a banked turn, Rolling the camera when Yawing.
  102346. * It's recommended to use rollCorrect = 10 for faster banking correction.
  102347. */
  102348. bankedTurn: boolean;
  102349. /**
  102350. * Limit in radians for how much Roll banking will add. (Default: 90°)
  102351. */
  102352. bankedTurnLimit: number;
  102353. /**
  102354. * Value of 0 disables the banked Roll.
  102355. * Value of 1 is equal to the Yaw angle in radians.
  102356. */
  102357. bankedTurnMultiplier: number;
  102358. /**
  102359. * The inputs manager loads all the input sources, such as keyboard and mouse.
  102360. */
  102361. inputs: FlyCameraInputsManager;
  102362. /**
  102363. * Gets the input sensibility for mouse input.
  102364. * Higher values reduce sensitivity.
  102365. */
  102366. /**
  102367. * Sets the input sensibility for a mouse input.
  102368. * Higher values reduce sensitivity.
  102369. */
  102370. angularSensibility: number;
  102371. /**
  102372. * Get the keys for camera movement forward.
  102373. */
  102374. /**
  102375. * Set the keys for camera movement forward.
  102376. */
  102377. keysForward: number[];
  102378. /**
  102379. * Get the keys for camera movement backward.
  102380. */
  102381. keysBackward: number[];
  102382. /**
  102383. * Get the keys for camera movement up.
  102384. */
  102385. /**
  102386. * Set the keys for camera movement up.
  102387. */
  102388. keysUp: number[];
  102389. /**
  102390. * Get the keys for camera movement down.
  102391. */
  102392. /**
  102393. * Set the keys for camera movement down.
  102394. */
  102395. keysDown: number[];
  102396. /**
  102397. * Get the keys for camera movement left.
  102398. */
  102399. /**
  102400. * Set the keys for camera movement left.
  102401. */
  102402. keysLeft: number[];
  102403. /**
  102404. * Set the keys for camera movement right.
  102405. */
  102406. /**
  102407. * Set the keys for camera movement right.
  102408. */
  102409. keysRight: number[];
  102410. /**
  102411. * Event raised when the camera collides with a mesh in the scene.
  102412. */
  102413. onCollide: (collidedMesh: AbstractMesh) => void;
  102414. private _collider;
  102415. private _needMoveForGravity;
  102416. private _oldPosition;
  102417. private _diffPosition;
  102418. private _newPosition;
  102419. /** @hidden */
  102420. _localDirection: Vector3;
  102421. /** @hidden */
  102422. _transformedDirection: Vector3;
  102423. /**
  102424. * Instantiates a FlyCamera.
  102425. * This is a flying camera, designed for 3D movement and rotation in all directions,
  102426. * such as in a 3D Space Shooter or a Flight Simulator.
  102427. * @param name Define the name of the camera in the scene.
  102428. * @param position Define the starting position of the camera in the scene.
  102429. * @param scene Define the scene the camera belongs to.
  102430. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  102431. */
  102432. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  102433. /**
  102434. * Attach a control to the HTML DOM element.
  102435. * @param element Defines the element that listens to the input events.
  102436. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  102437. */
  102438. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102439. /**
  102440. * Detach a control from the HTML DOM element.
  102441. * The camera will stop reacting to that input.
  102442. * @param element Defines the element that listens to the input events.
  102443. */
  102444. detachControl(element: HTMLElement): void;
  102445. private _collisionMask;
  102446. /**
  102447. * Get the mask that the camera ignores in collision events.
  102448. */
  102449. /**
  102450. * Set the mask that the camera ignores in collision events.
  102451. */
  102452. collisionMask: number;
  102453. /** @hidden */
  102454. _collideWithWorld(displacement: Vector3): void;
  102455. /** @hidden */
  102456. private _onCollisionPositionChange;
  102457. /** @hidden */
  102458. _checkInputs(): void;
  102459. /** @hidden */
  102460. _decideIfNeedsToMove(): boolean;
  102461. /** @hidden */
  102462. _updatePosition(): void;
  102463. /**
  102464. * Restore the Roll to its target value at the rate specified.
  102465. * @param rate - Higher means slower restoring.
  102466. * @hidden
  102467. */
  102468. restoreRoll(rate: number): void;
  102469. /**
  102470. * Destroy the camera and release the current resources held by it.
  102471. */
  102472. dispose(): void;
  102473. /**
  102474. * Get the current object class name.
  102475. * @returns the class name.
  102476. */
  102477. getClassName(): string;
  102478. }
  102479. }
  102480. declare module BABYLON {
  102481. /**
  102482. * Listen to keyboard events to control the camera.
  102483. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102484. */
  102485. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  102486. /**
  102487. * Defines the camera the input is attached to.
  102488. */
  102489. camera: FlyCamera;
  102490. /**
  102491. * The list of keyboard keys used to control the forward move of the camera.
  102492. */
  102493. keysForward: number[];
  102494. /**
  102495. * The list of keyboard keys used to control the backward move of the camera.
  102496. */
  102497. keysBackward: number[];
  102498. /**
  102499. * The list of keyboard keys used to control the forward move of the camera.
  102500. */
  102501. keysUp: number[];
  102502. /**
  102503. * The list of keyboard keys used to control the backward move of the camera.
  102504. */
  102505. keysDown: number[];
  102506. /**
  102507. * The list of keyboard keys used to control the right strafe move of the camera.
  102508. */
  102509. keysRight: number[];
  102510. /**
  102511. * The list of keyboard keys used to control the left strafe move of the camera.
  102512. */
  102513. keysLeft: number[];
  102514. private _keys;
  102515. private _onCanvasBlurObserver;
  102516. private _onKeyboardObserver;
  102517. private _engine;
  102518. private _scene;
  102519. /**
  102520. * Attach the input controls to a specific dom element to get the input from.
  102521. * @param element Defines the element the controls should be listened from
  102522. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102523. */
  102524. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102525. /**
  102526. * Detach the current controls from the specified dom element.
  102527. * @param element Defines the element to stop listening the inputs from
  102528. */
  102529. detachControl(element: Nullable<HTMLElement>): void;
  102530. /**
  102531. * Gets the class name of the current intput.
  102532. * @returns the class name
  102533. */
  102534. getClassName(): string;
  102535. /** @hidden */
  102536. _onLostFocus(e: FocusEvent): void;
  102537. /**
  102538. * Get the friendly name associated with the input class.
  102539. * @returns the input friendly name
  102540. */
  102541. getSimpleName(): string;
  102542. /**
  102543. * Update the current camera state depending on the inputs that have been used this frame.
  102544. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  102545. */
  102546. checkInputs(): void;
  102547. }
  102548. }
  102549. declare module BABYLON {
  102550. /**
  102551. * Manage the mouse wheel inputs to control a follow camera.
  102552. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102553. */
  102554. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  102555. /**
  102556. * Defines the camera the input is attached to.
  102557. */
  102558. camera: FollowCamera;
  102559. /**
  102560. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  102561. */
  102562. axisControlRadius: boolean;
  102563. /**
  102564. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  102565. */
  102566. axisControlHeight: boolean;
  102567. /**
  102568. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  102569. */
  102570. axisControlRotation: boolean;
  102571. /**
  102572. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  102573. * relation to mouseWheel events.
  102574. */
  102575. wheelPrecision: number;
  102576. /**
  102577. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  102578. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  102579. */
  102580. wheelDeltaPercentage: number;
  102581. private _wheel;
  102582. private _observer;
  102583. /**
  102584. * Attach the input controls to a specific dom element to get the input from.
  102585. * @param element Defines the element the controls should be listened from
  102586. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102587. */
  102588. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102589. /**
  102590. * Detach the current controls from the specified dom element.
  102591. * @param element Defines the element to stop listening the inputs from
  102592. */
  102593. detachControl(element: Nullable<HTMLElement>): void;
  102594. /**
  102595. * Gets the class name of the current intput.
  102596. * @returns the class name
  102597. */
  102598. getClassName(): string;
  102599. /**
  102600. * Get the friendly name associated with the input class.
  102601. * @returns the input friendly name
  102602. */
  102603. getSimpleName(): string;
  102604. }
  102605. }
  102606. declare module BABYLON {
  102607. /**
  102608. * Manage the pointers inputs to control an follow camera.
  102609. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102610. */
  102611. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  102612. /**
  102613. * Defines the camera the input is attached to.
  102614. */
  102615. camera: FollowCamera;
  102616. /**
  102617. * Gets the class name of the current input.
  102618. * @returns the class name
  102619. */
  102620. getClassName(): string;
  102621. /**
  102622. * Defines the pointer angular sensibility along the X axis or how fast is
  102623. * the camera rotating.
  102624. * A negative number will reverse the axis direction.
  102625. */
  102626. angularSensibilityX: number;
  102627. /**
  102628. * Defines the pointer angular sensibility along the Y axis or how fast is
  102629. * the camera rotating.
  102630. * A negative number will reverse the axis direction.
  102631. */
  102632. angularSensibilityY: number;
  102633. /**
  102634. * Defines the pointer pinch precision or how fast is the camera zooming.
  102635. * A negative number will reverse the axis direction.
  102636. */
  102637. pinchPrecision: number;
  102638. /**
  102639. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  102640. * from 0.
  102641. * It defines the percentage of current camera.radius to use as delta when
  102642. * pinch zoom is used.
  102643. */
  102644. pinchDeltaPercentage: number;
  102645. /**
  102646. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  102647. */
  102648. axisXControlRadius: boolean;
  102649. /**
  102650. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  102651. */
  102652. axisXControlHeight: boolean;
  102653. /**
  102654. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  102655. */
  102656. axisXControlRotation: boolean;
  102657. /**
  102658. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  102659. */
  102660. axisYControlRadius: boolean;
  102661. /**
  102662. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  102663. */
  102664. axisYControlHeight: boolean;
  102665. /**
  102666. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  102667. */
  102668. axisYControlRotation: boolean;
  102669. /**
  102670. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  102671. */
  102672. axisPinchControlRadius: boolean;
  102673. /**
  102674. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  102675. */
  102676. axisPinchControlHeight: boolean;
  102677. /**
  102678. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  102679. */
  102680. axisPinchControlRotation: boolean;
  102681. /**
  102682. * Log error messages if basic misconfiguration has occurred.
  102683. */
  102684. warningEnable: boolean;
  102685. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  102686. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  102687. private _warningCounter;
  102688. private _warning;
  102689. }
  102690. }
  102691. declare module BABYLON {
  102692. /**
  102693. * Default Inputs manager for the FollowCamera.
  102694. * It groups all the default supported inputs for ease of use.
  102695. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102696. */
  102697. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  102698. /**
  102699. * Instantiates a new FollowCameraInputsManager.
  102700. * @param camera Defines the camera the inputs belong to
  102701. */
  102702. constructor(camera: FollowCamera);
  102703. /**
  102704. * Add keyboard input support to the input manager.
  102705. * @returns the current input manager
  102706. */
  102707. addKeyboard(): FollowCameraInputsManager;
  102708. /**
  102709. * Add mouse wheel input support to the input manager.
  102710. * @returns the current input manager
  102711. */
  102712. addMouseWheel(): FollowCameraInputsManager;
  102713. /**
  102714. * Add pointers input support to the input manager.
  102715. * @returns the current input manager
  102716. */
  102717. addPointers(): FollowCameraInputsManager;
  102718. /**
  102719. * Add orientation input support to the input manager.
  102720. * @returns the current input manager
  102721. */
  102722. addVRDeviceOrientation(): FollowCameraInputsManager;
  102723. }
  102724. }
  102725. declare module BABYLON {
  102726. /**
  102727. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  102728. * an arc rotate version arcFollowCamera are available.
  102729. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  102730. */
  102731. export class FollowCamera extends TargetCamera {
  102732. /**
  102733. * Distance the follow camera should follow an object at
  102734. */
  102735. radius: number;
  102736. /**
  102737. * Minimum allowed distance of the camera to the axis of rotation
  102738. * (The camera can not get closer).
  102739. * This can help limiting how the Camera is able to move in the scene.
  102740. */
  102741. lowerRadiusLimit: Nullable<number>;
  102742. /**
  102743. * Maximum allowed distance of the camera to the axis of rotation
  102744. * (The camera can not get further).
  102745. * This can help limiting how the Camera is able to move in the scene.
  102746. */
  102747. upperRadiusLimit: Nullable<number>;
  102748. /**
  102749. * Define a rotation offset between the camera and the object it follows
  102750. */
  102751. rotationOffset: number;
  102752. /**
  102753. * Minimum allowed angle to camera position relative to target object.
  102754. * This can help limiting how the Camera is able to move in the scene.
  102755. */
  102756. lowerRotationOffsetLimit: Nullable<number>;
  102757. /**
  102758. * Maximum allowed angle to camera position relative to target object.
  102759. * This can help limiting how the Camera is able to move in the scene.
  102760. */
  102761. upperRotationOffsetLimit: Nullable<number>;
  102762. /**
  102763. * Define a height offset between the camera and the object it follows.
  102764. * It can help following an object from the top (like a car chaing a plane)
  102765. */
  102766. heightOffset: number;
  102767. /**
  102768. * Minimum allowed height of camera position relative to target object.
  102769. * This can help limiting how the Camera is able to move in the scene.
  102770. */
  102771. lowerHeightOffsetLimit: Nullable<number>;
  102772. /**
  102773. * Maximum allowed height of camera position relative to target object.
  102774. * This can help limiting how the Camera is able to move in the scene.
  102775. */
  102776. upperHeightOffsetLimit: Nullable<number>;
  102777. /**
  102778. * Define how fast the camera can accelerate to follow it s target.
  102779. */
  102780. cameraAcceleration: number;
  102781. /**
  102782. * Define the speed limit of the camera following an object.
  102783. */
  102784. maxCameraSpeed: number;
  102785. /**
  102786. * Define the target of the camera.
  102787. */
  102788. lockedTarget: Nullable<AbstractMesh>;
  102789. /**
  102790. * Defines the input associated with the camera.
  102791. */
  102792. inputs: FollowCameraInputsManager;
  102793. /**
  102794. * Instantiates the follow camera.
  102795. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  102796. * @param name Define the name of the camera in the scene
  102797. * @param position Define the position of the camera
  102798. * @param scene Define the scene the camera belong to
  102799. * @param lockedTarget Define the target of the camera
  102800. */
  102801. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  102802. private _follow;
  102803. /**
  102804. * Attached controls to the current camera.
  102805. * @param element Defines the element the controls should be listened from
  102806. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102807. */
  102808. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102809. /**
  102810. * Detach the current controls from the camera.
  102811. * The camera will stop reacting to inputs.
  102812. * @param element Defines the element to stop listening the inputs from
  102813. */
  102814. detachControl(element: HTMLElement): void;
  102815. /** @hidden */
  102816. _checkInputs(): void;
  102817. private _checkLimits;
  102818. /**
  102819. * Gets the camera class name.
  102820. * @returns the class name
  102821. */
  102822. getClassName(): string;
  102823. }
  102824. /**
  102825. * Arc Rotate version of the follow camera.
  102826. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  102827. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  102828. */
  102829. export class ArcFollowCamera extends TargetCamera {
  102830. /** The longitudinal angle of the camera */
  102831. alpha: number;
  102832. /** The latitudinal angle of the camera */
  102833. beta: number;
  102834. /** The radius of the camera from its target */
  102835. radius: number;
  102836. /** Define the camera target (the messh it should follow) */
  102837. target: Nullable<AbstractMesh>;
  102838. private _cartesianCoordinates;
  102839. /**
  102840. * Instantiates a new ArcFollowCamera
  102841. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  102842. * @param name Define the name of the camera
  102843. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  102844. * @param beta Define the rotation angle of the camera around the elevation axis
  102845. * @param radius Define the radius of the camera from its target point
  102846. * @param target Define the target of the camera
  102847. * @param scene Define the scene the camera belongs to
  102848. */
  102849. constructor(name: string,
  102850. /** The longitudinal angle of the camera */
  102851. alpha: number,
  102852. /** The latitudinal angle of the camera */
  102853. beta: number,
  102854. /** The radius of the camera from its target */
  102855. radius: number,
  102856. /** Define the camera target (the messh it should follow) */
  102857. target: Nullable<AbstractMesh>, scene: Scene);
  102858. private _follow;
  102859. /** @hidden */
  102860. _checkInputs(): void;
  102861. /**
  102862. * Returns the class name of the object.
  102863. * It is mostly used internally for serialization purposes.
  102864. */
  102865. getClassName(): string;
  102866. }
  102867. }
  102868. declare module BABYLON {
  102869. /**
  102870. * Manage the keyboard inputs to control the movement of a follow camera.
  102871. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102872. */
  102873. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  102874. /**
  102875. * Defines the camera the input is attached to.
  102876. */
  102877. camera: FollowCamera;
  102878. /**
  102879. * Defines the list of key codes associated with the up action (increase heightOffset)
  102880. */
  102881. keysHeightOffsetIncr: number[];
  102882. /**
  102883. * Defines the list of key codes associated with the down action (decrease heightOffset)
  102884. */
  102885. keysHeightOffsetDecr: number[];
  102886. /**
  102887. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  102888. */
  102889. keysHeightOffsetModifierAlt: boolean;
  102890. /**
  102891. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  102892. */
  102893. keysHeightOffsetModifierCtrl: boolean;
  102894. /**
  102895. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  102896. */
  102897. keysHeightOffsetModifierShift: boolean;
  102898. /**
  102899. * Defines the list of key codes associated with the left action (increase rotationOffset)
  102900. */
  102901. keysRotationOffsetIncr: number[];
  102902. /**
  102903. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  102904. */
  102905. keysRotationOffsetDecr: number[];
  102906. /**
  102907. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  102908. */
  102909. keysRotationOffsetModifierAlt: boolean;
  102910. /**
  102911. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  102912. */
  102913. keysRotationOffsetModifierCtrl: boolean;
  102914. /**
  102915. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  102916. */
  102917. keysRotationOffsetModifierShift: boolean;
  102918. /**
  102919. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  102920. */
  102921. keysRadiusIncr: number[];
  102922. /**
  102923. * Defines the list of key codes associated with the zoom-out action (increase radius)
  102924. */
  102925. keysRadiusDecr: number[];
  102926. /**
  102927. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  102928. */
  102929. keysRadiusModifierAlt: boolean;
  102930. /**
  102931. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  102932. */
  102933. keysRadiusModifierCtrl: boolean;
  102934. /**
  102935. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  102936. */
  102937. keysRadiusModifierShift: boolean;
  102938. /**
  102939. * Defines the rate of change of heightOffset.
  102940. */
  102941. heightSensibility: number;
  102942. /**
  102943. * Defines the rate of change of rotationOffset.
  102944. */
  102945. rotationSensibility: number;
  102946. /**
  102947. * Defines the rate of change of radius.
  102948. */
  102949. radiusSensibility: number;
  102950. private _keys;
  102951. private _ctrlPressed;
  102952. private _altPressed;
  102953. private _shiftPressed;
  102954. private _onCanvasBlurObserver;
  102955. private _onKeyboardObserver;
  102956. private _engine;
  102957. private _scene;
  102958. /**
  102959. * Attach the input controls to a specific dom element to get the input from.
  102960. * @param element Defines the element the controls should be listened from
  102961. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102962. */
  102963. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102964. /**
  102965. * Detach the current controls from the specified dom element.
  102966. * @param element Defines the element to stop listening the inputs from
  102967. */
  102968. detachControl(element: Nullable<HTMLElement>): void;
  102969. /**
  102970. * Update the current camera state depending on the inputs that have been used this frame.
  102971. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  102972. */
  102973. checkInputs(): void;
  102974. /**
  102975. * Gets the class name of the current input.
  102976. * @returns the class name
  102977. */
  102978. getClassName(): string;
  102979. /**
  102980. * Get the friendly name associated with the input class.
  102981. * @returns the input friendly name
  102982. */
  102983. getSimpleName(): string;
  102984. /**
  102985. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  102986. * allow modification of the heightOffset value.
  102987. */
  102988. private _modifierHeightOffset;
  102989. /**
  102990. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  102991. * allow modification of the rotationOffset value.
  102992. */
  102993. private _modifierRotationOffset;
  102994. /**
  102995. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  102996. * allow modification of the radius value.
  102997. */
  102998. private _modifierRadius;
  102999. }
  103000. }
  103001. declare module BABYLON {
  103002. interface FreeCameraInputsManager {
  103003. /**
  103004. * @hidden
  103005. */
  103006. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  103007. /**
  103008. * Add orientation input support to the input manager.
  103009. * @returns the current input manager
  103010. */
  103011. addDeviceOrientation(): FreeCameraInputsManager;
  103012. }
  103013. /**
  103014. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  103015. * Screen rotation is taken into account.
  103016. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103017. */
  103018. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  103019. private _camera;
  103020. private _screenOrientationAngle;
  103021. private _constantTranform;
  103022. private _screenQuaternion;
  103023. private _alpha;
  103024. private _beta;
  103025. private _gamma;
  103026. /**
  103027. * Can be used to detect if a device orientation sensor is availible on a device
  103028. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  103029. * @returns a promise that will resolve on orientation change
  103030. */
  103031. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  103032. /**
  103033. * @hidden
  103034. */
  103035. _onDeviceOrientationChangedObservable: Observable<void>;
  103036. /**
  103037. * Instantiates a new input
  103038. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103039. */
  103040. constructor();
  103041. /**
  103042. * Define the camera controlled by the input.
  103043. */
  103044. camera: FreeCamera;
  103045. /**
  103046. * Attach the input controls to a specific dom element to get the input from.
  103047. * @param element Defines the element the controls should be listened from
  103048. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103049. */
  103050. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103051. private _orientationChanged;
  103052. private _deviceOrientation;
  103053. /**
  103054. * Detach the current controls from the specified dom element.
  103055. * @param element Defines the element to stop listening the inputs from
  103056. */
  103057. detachControl(element: Nullable<HTMLElement>): void;
  103058. /**
  103059. * Update the current camera state depending on the inputs that have been used this frame.
  103060. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103061. */
  103062. checkInputs(): void;
  103063. /**
  103064. * Gets the class name of the current intput.
  103065. * @returns the class name
  103066. */
  103067. getClassName(): string;
  103068. /**
  103069. * Get the friendly name associated with the input class.
  103070. * @returns the input friendly name
  103071. */
  103072. getSimpleName(): string;
  103073. }
  103074. }
  103075. declare module BABYLON {
  103076. /**
  103077. * Manage the gamepad inputs to control a free camera.
  103078. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103079. */
  103080. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  103081. /**
  103082. * Define the camera the input is attached to.
  103083. */
  103084. camera: FreeCamera;
  103085. /**
  103086. * Define the Gamepad controlling the input
  103087. */
  103088. gamepad: Nullable<Gamepad>;
  103089. /**
  103090. * Defines the gamepad rotation sensiblity.
  103091. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  103092. */
  103093. gamepadAngularSensibility: number;
  103094. /**
  103095. * Defines the gamepad move sensiblity.
  103096. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  103097. */
  103098. gamepadMoveSensibility: number;
  103099. private _onGamepadConnectedObserver;
  103100. private _onGamepadDisconnectedObserver;
  103101. private _cameraTransform;
  103102. private _deltaTransform;
  103103. private _vector3;
  103104. private _vector2;
  103105. /**
  103106. * Attach the input controls to a specific dom element to get the input from.
  103107. * @param element Defines the element the controls should be listened from
  103108. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103109. */
  103110. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103111. /**
  103112. * Detach the current controls from the specified dom element.
  103113. * @param element Defines the element to stop listening the inputs from
  103114. */
  103115. detachControl(element: Nullable<HTMLElement>): void;
  103116. /**
  103117. * Update the current camera state depending on the inputs that have been used this frame.
  103118. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103119. */
  103120. checkInputs(): void;
  103121. /**
  103122. * Gets the class name of the current intput.
  103123. * @returns the class name
  103124. */
  103125. getClassName(): string;
  103126. /**
  103127. * Get the friendly name associated with the input class.
  103128. * @returns the input friendly name
  103129. */
  103130. getSimpleName(): string;
  103131. }
  103132. }
  103133. declare module BABYLON {
  103134. /**
  103135. * Defines the potential axis of a Joystick
  103136. */
  103137. export enum JoystickAxis {
  103138. /** X axis */
  103139. X = 0,
  103140. /** Y axis */
  103141. Y = 1,
  103142. /** Z axis */
  103143. Z = 2
  103144. }
  103145. /**
  103146. * Class used to define virtual joystick (used in touch mode)
  103147. */
  103148. export class VirtualJoystick {
  103149. /**
  103150. * Gets or sets a boolean indicating that left and right values must be inverted
  103151. */
  103152. reverseLeftRight: boolean;
  103153. /**
  103154. * Gets or sets a boolean indicating that up and down values must be inverted
  103155. */
  103156. reverseUpDown: boolean;
  103157. /**
  103158. * Gets the offset value for the position (ie. the change of the position value)
  103159. */
  103160. deltaPosition: Vector3;
  103161. /**
  103162. * Gets a boolean indicating if the virtual joystick was pressed
  103163. */
  103164. pressed: boolean;
  103165. /**
  103166. * Canvas the virtual joystick will render onto, default z-index of this is 5
  103167. */
  103168. static Canvas: Nullable<HTMLCanvasElement>;
  103169. private static _globalJoystickIndex;
  103170. private static vjCanvasContext;
  103171. private static vjCanvasWidth;
  103172. private static vjCanvasHeight;
  103173. private static halfWidth;
  103174. private _action;
  103175. private _axisTargetedByLeftAndRight;
  103176. private _axisTargetedByUpAndDown;
  103177. private _joystickSensibility;
  103178. private _inversedSensibility;
  103179. private _joystickPointerID;
  103180. private _joystickColor;
  103181. private _joystickPointerPos;
  103182. private _joystickPreviousPointerPos;
  103183. private _joystickPointerStartPos;
  103184. private _deltaJoystickVector;
  103185. private _leftJoystick;
  103186. private _touches;
  103187. private _onPointerDownHandlerRef;
  103188. private _onPointerMoveHandlerRef;
  103189. private _onPointerUpHandlerRef;
  103190. private _onResize;
  103191. /**
  103192. * Creates a new virtual joystick
  103193. * @param leftJoystick defines that the joystick is for left hand (false by default)
  103194. */
  103195. constructor(leftJoystick?: boolean);
  103196. /**
  103197. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  103198. * @param newJoystickSensibility defines the new sensibility
  103199. */
  103200. setJoystickSensibility(newJoystickSensibility: number): void;
  103201. private _onPointerDown;
  103202. private _onPointerMove;
  103203. private _onPointerUp;
  103204. /**
  103205. * Change the color of the virtual joystick
  103206. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  103207. */
  103208. setJoystickColor(newColor: string): void;
  103209. /**
  103210. * Defines a callback to call when the joystick is touched
  103211. * @param action defines the callback
  103212. */
  103213. setActionOnTouch(action: () => any): void;
  103214. /**
  103215. * Defines which axis you'd like to control for left & right
  103216. * @param axis defines the axis to use
  103217. */
  103218. setAxisForLeftRight(axis: JoystickAxis): void;
  103219. /**
  103220. * Defines which axis you'd like to control for up & down
  103221. * @param axis defines the axis to use
  103222. */
  103223. setAxisForUpDown(axis: JoystickAxis): void;
  103224. private _drawVirtualJoystick;
  103225. /**
  103226. * Release internal HTML canvas
  103227. */
  103228. releaseCanvas(): void;
  103229. }
  103230. }
  103231. declare module BABYLON {
  103232. interface FreeCameraInputsManager {
  103233. /**
  103234. * Add virtual joystick input support to the input manager.
  103235. * @returns the current input manager
  103236. */
  103237. addVirtualJoystick(): FreeCameraInputsManager;
  103238. }
  103239. /**
  103240. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  103241. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103242. */
  103243. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  103244. /**
  103245. * Defines the camera the input is attached to.
  103246. */
  103247. camera: FreeCamera;
  103248. private _leftjoystick;
  103249. private _rightjoystick;
  103250. /**
  103251. * Gets the left stick of the virtual joystick.
  103252. * @returns The virtual Joystick
  103253. */
  103254. getLeftJoystick(): VirtualJoystick;
  103255. /**
  103256. * Gets the right stick of the virtual joystick.
  103257. * @returns The virtual Joystick
  103258. */
  103259. getRightJoystick(): VirtualJoystick;
  103260. /**
  103261. * Update the current camera state depending on the inputs that have been used this frame.
  103262. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103263. */
  103264. checkInputs(): void;
  103265. /**
  103266. * Attach the input controls to a specific dom element to get the input from.
  103267. * @param element Defines the element the controls should be listened from
  103268. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103269. */
  103270. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103271. /**
  103272. * Detach the current controls from the specified dom element.
  103273. * @param element Defines the element to stop listening the inputs from
  103274. */
  103275. detachControl(element: Nullable<HTMLElement>): void;
  103276. /**
  103277. * Gets the class name of the current intput.
  103278. * @returns the class name
  103279. */
  103280. getClassName(): string;
  103281. /**
  103282. * Get the friendly name associated with the input class.
  103283. * @returns the input friendly name
  103284. */
  103285. getSimpleName(): string;
  103286. }
  103287. }
  103288. declare module BABYLON {
  103289. /**
  103290. * This represents a FPS type of camera controlled by touch.
  103291. * This is like a universal camera minus the Gamepad controls.
  103292. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  103293. */
  103294. export class TouchCamera extends FreeCamera {
  103295. /**
  103296. * Defines the touch sensibility for rotation.
  103297. * The higher the faster.
  103298. */
  103299. touchAngularSensibility: number;
  103300. /**
  103301. * Defines the touch sensibility for move.
  103302. * The higher the faster.
  103303. */
  103304. touchMoveSensibility: number;
  103305. /**
  103306. * Instantiates a new touch camera.
  103307. * This represents a FPS type of camera controlled by touch.
  103308. * This is like a universal camera minus the Gamepad controls.
  103309. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  103310. * @param name Define the name of the camera in the scene
  103311. * @param position Define the start position of the camera in the scene
  103312. * @param scene Define the scene the camera belongs to
  103313. */
  103314. constructor(name: string, position: Vector3, scene: Scene);
  103315. /**
  103316. * Gets the current object class name.
  103317. * @return the class name
  103318. */
  103319. getClassName(): string;
  103320. /** @hidden */
  103321. _setupInputs(): void;
  103322. }
  103323. }
  103324. declare module BABYLON {
  103325. /**
  103326. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  103327. * being tilted forward or back and left or right.
  103328. */
  103329. export class DeviceOrientationCamera extends FreeCamera {
  103330. private _initialQuaternion;
  103331. private _quaternionCache;
  103332. private _tmpDragQuaternion;
  103333. private _disablePointerInputWhenUsingDeviceOrientation;
  103334. /**
  103335. * Creates a new device orientation camera
  103336. * @param name The name of the camera
  103337. * @param position The start position camera
  103338. * @param scene The scene the camera belongs to
  103339. */
  103340. constructor(name: string, position: Vector3, scene: Scene);
  103341. /**
  103342. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  103343. */
  103344. disablePointerInputWhenUsingDeviceOrientation: boolean;
  103345. private _dragFactor;
  103346. /**
  103347. * Enabled turning on the y axis when the orientation sensor is active
  103348. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  103349. */
  103350. enableHorizontalDragging(dragFactor?: number): void;
  103351. /**
  103352. * Gets the current instance class name ("DeviceOrientationCamera").
  103353. * This helps avoiding instanceof at run time.
  103354. * @returns the class name
  103355. */
  103356. getClassName(): string;
  103357. /**
  103358. * @hidden
  103359. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  103360. */
  103361. _checkInputs(): void;
  103362. /**
  103363. * Reset the camera to its default orientation on the specified axis only.
  103364. * @param axis The axis to reset
  103365. */
  103366. resetToCurrentRotation(axis?: Axis): void;
  103367. }
  103368. }
  103369. declare module BABYLON {
  103370. /**
  103371. * Defines supported buttons for XBox360 compatible gamepads
  103372. */
  103373. export enum Xbox360Button {
  103374. /** A */
  103375. A = 0,
  103376. /** B */
  103377. B = 1,
  103378. /** X */
  103379. X = 2,
  103380. /** Y */
  103381. Y = 3,
  103382. /** Start */
  103383. Start = 4,
  103384. /** Back */
  103385. Back = 5,
  103386. /** Left button */
  103387. LB = 6,
  103388. /** Right button */
  103389. RB = 7,
  103390. /** Left stick */
  103391. LeftStick = 8,
  103392. /** Right stick */
  103393. RightStick = 9
  103394. }
  103395. /** Defines values for XBox360 DPad */
  103396. export enum Xbox360Dpad {
  103397. /** Up */
  103398. Up = 0,
  103399. /** Down */
  103400. Down = 1,
  103401. /** Left */
  103402. Left = 2,
  103403. /** Right */
  103404. Right = 3
  103405. }
  103406. /**
  103407. * Defines a XBox360 gamepad
  103408. */
  103409. export class Xbox360Pad extends Gamepad {
  103410. private _leftTrigger;
  103411. private _rightTrigger;
  103412. private _onlefttriggerchanged;
  103413. private _onrighttriggerchanged;
  103414. private _onbuttondown;
  103415. private _onbuttonup;
  103416. private _ondpaddown;
  103417. private _ondpadup;
  103418. /** Observable raised when a button is pressed */
  103419. onButtonDownObservable: Observable<Xbox360Button>;
  103420. /** Observable raised when a button is released */
  103421. onButtonUpObservable: Observable<Xbox360Button>;
  103422. /** Observable raised when a pad is pressed */
  103423. onPadDownObservable: Observable<Xbox360Dpad>;
  103424. /** Observable raised when a pad is released */
  103425. onPadUpObservable: Observable<Xbox360Dpad>;
  103426. private _buttonA;
  103427. private _buttonB;
  103428. private _buttonX;
  103429. private _buttonY;
  103430. private _buttonBack;
  103431. private _buttonStart;
  103432. private _buttonLB;
  103433. private _buttonRB;
  103434. private _buttonLeftStick;
  103435. private _buttonRightStick;
  103436. private _dPadUp;
  103437. private _dPadDown;
  103438. private _dPadLeft;
  103439. private _dPadRight;
  103440. private _isXboxOnePad;
  103441. /**
  103442. * Creates a new XBox360 gamepad object
  103443. * @param id defines the id of this gamepad
  103444. * @param index defines its index
  103445. * @param gamepad defines the internal HTML gamepad object
  103446. * @param xboxOne defines if it is a XBox One gamepad
  103447. */
  103448. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  103449. /**
  103450. * Defines the callback to call when left trigger is pressed
  103451. * @param callback defines the callback to use
  103452. */
  103453. onlefttriggerchanged(callback: (value: number) => void): void;
  103454. /**
  103455. * Defines the callback to call when right trigger is pressed
  103456. * @param callback defines the callback to use
  103457. */
  103458. onrighttriggerchanged(callback: (value: number) => void): void;
  103459. /**
  103460. * Gets the left trigger value
  103461. */
  103462. /**
  103463. * Sets the left trigger value
  103464. */
  103465. leftTrigger: number;
  103466. /**
  103467. * Gets the right trigger value
  103468. */
  103469. /**
  103470. * Sets the right trigger value
  103471. */
  103472. rightTrigger: number;
  103473. /**
  103474. * Defines the callback to call when a button is pressed
  103475. * @param callback defines the callback to use
  103476. */
  103477. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  103478. /**
  103479. * Defines the callback to call when a button is released
  103480. * @param callback defines the callback to use
  103481. */
  103482. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  103483. /**
  103484. * Defines the callback to call when a pad is pressed
  103485. * @param callback defines the callback to use
  103486. */
  103487. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  103488. /**
  103489. * Defines the callback to call when a pad is released
  103490. * @param callback defines the callback to use
  103491. */
  103492. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  103493. private _setButtonValue;
  103494. private _setDPadValue;
  103495. /**
  103496. * Gets the value of the `A` button
  103497. */
  103498. /**
  103499. * Sets the value of the `A` button
  103500. */
  103501. buttonA: number;
  103502. /**
  103503. * Gets the value of the `B` button
  103504. */
  103505. /**
  103506. * Sets the value of the `B` button
  103507. */
  103508. buttonB: number;
  103509. /**
  103510. * Gets the value of the `X` button
  103511. */
  103512. /**
  103513. * Sets the value of the `X` button
  103514. */
  103515. buttonX: number;
  103516. /**
  103517. * Gets the value of the `Y` button
  103518. */
  103519. /**
  103520. * Sets the value of the `Y` button
  103521. */
  103522. buttonY: number;
  103523. /**
  103524. * Gets the value of the `Start` button
  103525. */
  103526. /**
  103527. * Sets the value of the `Start` button
  103528. */
  103529. buttonStart: number;
  103530. /**
  103531. * Gets the value of the `Back` button
  103532. */
  103533. /**
  103534. * Sets the value of the `Back` button
  103535. */
  103536. buttonBack: number;
  103537. /**
  103538. * Gets the value of the `Left` button
  103539. */
  103540. /**
  103541. * Sets the value of the `Left` button
  103542. */
  103543. buttonLB: number;
  103544. /**
  103545. * Gets the value of the `Right` button
  103546. */
  103547. /**
  103548. * Sets the value of the `Right` button
  103549. */
  103550. buttonRB: number;
  103551. /**
  103552. * Gets the value of the Left joystick
  103553. */
  103554. /**
  103555. * Sets the value of the Left joystick
  103556. */
  103557. buttonLeftStick: number;
  103558. /**
  103559. * Gets the value of the Right joystick
  103560. */
  103561. /**
  103562. * Sets the value of the Right joystick
  103563. */
  103564. buttonRightStick: number;
  103565. /**
  103566. * Gets the value of D-pad up
  103567. */
  103568. /**
  103569. * Sets the value of D-pad up
  103570. */
  103571. dPadUp: number;
  103572. /**
  103573. * Gets the value of D-pad down
  103574. */
  103575. /**
  103576. * Sets the value of D-pad down
  103577. */
  103578. dPadDown: number;
  103579. /**
  103580. * Gets the value of D-pad left
  103581. */
  103582. /**
  103583. * Sets the value of D-pad left
  103584. */
  103585. dPadLeft: number;
  103586. /**
  103587. * Gets the value of D-pad right
  103588. */
  103589. /**
  103590. * Sets the value of D-pad right
  103591. */
  103592. dPadRight: number;
  103593. /**
  103594. * Force the gamepad to synchronize with device values
  103595. */
  103596. update(): void;
  103597. /**
  103598. * Disposes the gamepad
  103599. */
  103600. dispose(): void;
  103601. }
  103602. }
  103603. declare module BABYLON {
  103604. /**
  103605. * Defines supported buttons for DualShock compatible gamepads
  103606. */
  103607. export enum DualShockButton {
  103608. /** Cross */
  103609. Cross = 0,
  103610. /** Circle */
  103611. Circle = 1,
  103612. /** Square */
  103613. Square = 2,
  103614. /** Triangle */
  103615. Triangle = 3,
  103616. /** Options */
  103617. Options = 4,
  103618. /** Share */
  103619. Share = 5,
  103620. /** L1 */
  103621. L1 = 6,
  103622. /** R1 */
  103623. R1 = 7,
  103624. /** Left stick */
  103625. LeftStick = 8,
  103626. /** Right stick */
  103627. RightStick = 9
  103628. }
  103629. /** Defines values for DualShock DPad */
  103630. export enum DualShockDpad {
  103631. /** Up */
  103632. Up = 0,
  103633. /** Down */
  103634. Down = 1,
  103635. /** Left */
  103636. Left = 2,
  103637. /** Right */
  103638. Right = 3
  103639. }
  103640. /**
  103641. * Defines a DualShock gamepad
  103642. */
  103643. export class DualShockPad extends Gamepad {
  103644. private _leftTrigger;
  103645. private _rightTrigger;
  103646. private _onlefttriggerchanged;
  103647. private _onrighttriggerchanged;
  103648. private _onbuttondown;
  103649. private _onbuttonup;
  103650. private _ondpaddown;
  103651. private _ondpadup;
  103652. /** Observable raised when a button is pressed */
  103653. onButtonDownObservable: Observable<DualShockButton>;
  103654. /** Observable raised when a button is released */
  103655. onButtonUpObservable: Observable<DualShockButton>;
  103656. /** Observable raised when a pad is pressed */
  103657. onPadDownObservable: Observable<DualShockDpad>;
  103658. /** Observable raised when a pad is released */
  103659. onPadUpObservable: Observable<DualShockDpad>;
  103660. private _buttonCross;
  103661. private _buttonCircle;
  103662. private _buttonSquare;
  103663. private _buttonTriangle;
  103664. private _buttonShare;
  103665. private _buttonOptions;
  103666. private _buttonL1;
  103667. private _buttonR1;
  103668. private _buttonLeftStick;
  103669. private _buttonRightStick;
  103670. private _dPadUp;
  103671. private _dPadDown;
  103672. private _dPadLeft;
  103673. private _dPadRight;
  103674. /**
  103675. * Creates a new DualShock gamepad object
  103676. * @param id defines the id of this gamepad
  103677. * @param index defines its index
  103678. * @param gamepad defines the internal HTML gamepad object
  103679. */
  103680. constructor(id: string, index: number, gamepad: any);
  103681. /**
  103682. * Defines the callback to call when left trigger is pressed
  103683. * @param callback defines the callback to use
  103684. */
  103685. onlefttriggerchanged(callback: (value: number) => void): void;
  103686. /**
  103687. * Defines the callback to call when right trigger is pressed
  103688. * @param callback defines the callback to use
  103689. */
  103690. onrighttriggerchanged(callback: (value: number) => void): void;
  103691. /**
  103692. * Gets the left trigger value
  103693. */
  103694. /**
  103695. * Sets the left trigger value
  103696. */
  103697. leftTrigger: number;
  103698. /**
  103699. * Gets the right trigger value
  103700. */
  103701. /**
  103702. * Sets the right trigger value
  103703. */
  103704. rightTrigger: number;
  103705. /**
  103706. * Defines the callback to call when a button is pressed
  103707. * @param callback defines the callback to use
  103708. */
  103709. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  103710. /**
  103711. * Defines the callback to call when a button is released
  103712. * @param callback defines the callback to use
  103713. */
  103714. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  103715. /**
  103716. * Defines the callback to call when a pad is pressed
  103717. * @param callback defines the callback to use
  103718. */
  103719. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  103720. /**
  103721. * Defines the callback to call when a pad is released
  103722. * @param callback defines the callback to use
  103723. */
  103724. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  103725. private _setButtonValue;
  103726. private _setDPadValue;
  103727. /**
  103728. * Gets the value of the `Cross` button
  103729. */
  103730. /**
  103731. * Sets the value of the `Cross` button
  103732. */
  103733. buttonCross: number;
  103734. /**
  103735. * Gets the value of the `Circle` button
  103736. */
  103737. /**
  103738. * Sets the value of the `Circle` button
  103739. */
  103740. buttonCircle: number;
  103741. /**
  103742. * Gets the value of the `Square` button
  103743. */
  103744. /**
  103745. * Sets the value of the `Square` button
  103746. */
  103747. buttonSquare: number;
  103748. /**
  103749. * Gets the value of the `Triangle` button
  103750. */
  103751. /**
  103752. * Sets the value of the `Triangle` button
  103753. */
  103754. buttonTriangle: number;
  103755. /**
  103756. * Gets the value of the `Options` button
  103757. */
  103758. /**
  103759. * Sets the value of the `Options` button
  103760. */
  103761. buttonOptions: number;
  103762. /**
  103763. * Gets the value of the `Share` button
  103764. */
  103765. /**
  103766. * Sets the value of the `Share` button
  103767. */
  103768. buttonShare: number;
  103769. /**
  103770. * Gets the value of the `L1` button
  103771. */
  103772. /**
  103773. * Sets the value of the `L1` button
  103774. */
  103775. buttonL1: number;
  103776. /**
  103777. * Gets the value of the `R1` button
  103778. */
  103779. /**
  103780. * Sets the value of the `R1` button
  103781. */
  103782. buttonR1: number;
  103783. /**
  103784. * Gets the value of the Left joystick
  103785. */
  103786. /**
  103787. * Sets the value of the Left joystick
  103788. */
  103789. buttonLeftStick: number;
  103790. /**
  103791. * Gets the value of the Right joystick
  103792. */
  103793. /**
  103794. * Sets the value of the Right joystick
  103795. */
  103796. buttonRightStick: number;
  103797. /**
  103798. * Gets the value of D-pad up
  103799. */
  103800. /**
  103801. * Sets the value of D-pad up
  103802. */
  103803. dPadUp: number;
  103804. /**
  103805. * Gets the value of D-pad down
  103806. */
  103807. /**
  103808. * Sets the value of D-pad down
  103809. */
  103810. dPadDown: number;
  103811. /**
  103812. * Gets the value of D-pad left
  103813. */
  103814. /**
  103815. * Sets the value of D-pad left
  103816. */
  103817. dPadLeft: number;
  103818. /**
  103819. * Gets the value of D-pad right
  103820. */
  103821. /**
  103822. * Sets the value of D-pad right
  103823. */
  103824. dPadRight: number;
  103825. /**
  103826. * Force the gamepad to synchronize with device values
  103827. */
  103828. update(): void;
  103829. /**
  103830. * Disposes the gamepad
  103831. */
  103832. dispose(): void;
  103833. }
  103834. }
  103835. declare module BABYLON {
  103836. /**
  103837. * Manager for handling gamepads
  103838. */
  103839. export class GamepadManager {
  103840. private _scene?;
  103841. private _babylonGamepads;
  103842. private _oneGamepadConnected;
  103843. /** @hidden */
  103844. _isMonitoring: boolean;
  103845. private _gamepadEventSupported;
  103846. private _gamepadSupport;
  103847. /**
  103848. * observable to be triggered when the gamepad controller has been connected
  103849. */
  103850. onGamepadConnectedObservable: Observable<Gamepad>;
  103851. /**
  103852. * observable to be triggered when the gamepad controller has been disconnected
  103853. */
  103854. onGamepadDisconnectedObservable: Observable<Gamepad>;
  103855. private _onGamepadConnectedEvent;
  103856. private _onGamepadDisconnectedEvent;
  103857. /**
  103858. * Initializes the gamepad manager
  103859. * @param _scene BabylonJS scene
  103860. */
  103861. constructor(_scene?: Scene | undefined);
  103862. /**
  103863. * The gamepads in the game pad manager
  103864. */
  103865. readonly gamepads: Gamepad[];
  103866. /**
  103867. * Get the gamepad controllers based on type
  103868. * @param type The type of gamepad controller
  103869. * @returns Nullable gamepad
  103870. */
  103871. getGamepadByType(type?: number): Nullable<Gamepad>;
  103872. /**
  103873. * Disposes the gamepad manager
  103874. */
  103875. dispose(): void;
  103876. private _addNewGamepad;
  103877. private _startMonitoringGamepads;
  103878. private _stopMonitoringGamepads;
  103879. /** @hidden */
  103880. _checkGamepadsStatus(): void;
  103881. private _updateGamepadObjects;
  103882. }
  103883. }
  103884. declare module BABYLON {
  103885. interface Scene {
  103886. /** @hidden */
  103887. _gamepadManager: Nullable<GamepadManager>;
  103888. /**
  103889. * Gets the gamepad manager associated with the scene
  103890. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  103891. */
  103892. gamepadManager: GamepadManager;
  103893. }
  103894. /**
  103895. * Interface representing a free camera inputs manager
  103896. */
  103897. interface FreeCameraInputsManager {
  103898. /**
  103899. * Adds gamepad input support to the FreeCameraInputsManager.
  103900. * @returns the FreeCameraInputsManager
  103901. */
  103902. addGamepad(): FreeCameraInputsManager;
  103903. }
  103904. /**
  103905. * Interface representing an arc rotate camera inputs manager
  103906. */
  103907. interface ArcRotateCameraInputsManager {
  103908. /**
  103909. * Adds gamepad input support to the ArcRotateCamera InputManager.
  103910. * @returns the camera inputs manager
  103911. */
  103912. addGamepad(): ArcRotateCameraInputsManager;
  103913. }
  103914. /**
  103915. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  103916. */
  103917. export class GamepadSystemSceneComponent implements ISceneComponent {
  103918. /**
  103919. * The component name helpfull to identify the component in the list of scene components.
  103920. */
  103921. readonly name: string;
  103922. /**
  103923. * The scene the component belongs to.
  103924. */
  103925. scene: Scene;
  103926. /**
  103927. * Creates a new instance of the component for the given scene
  103928. * @param scene Defines the scene to register the component in
  103929. */
  103930. constructor(scene: Scene);
  103931. /**
  103932. * Registers the component in a given scene
  103933. */
  103934. register(): void;
  103935. /**
  103936. * Rebuilds the elements related to this component in case of
  103937. * context lost for instance.
  103938. */
  103939. rebuild(): void;
  103940. /**
  103941. * Disposes the component and the associated ressources
  103942. */
  103943. dispose(): void;
  103944. private _beforeCameraUpdate;
  103945. }
  103946. }
  103947. declare module BABYLON {
  103948. /**
  103949. * 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,
  103950. * which still works and will still be found in many Playgrounds.
  103951. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  103952. */
  103953. export class UniversalCamera extends TouchCamera {
  103954. /**
  103955. * Defines the gamepad rotation sensiblity.
  103956. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  103957. */
  103958. gamepadAngularSensibility: number;
  103959. /**
  103960. * Defines the gamepad move sensiblity.
  103961. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  103962. */
  103963. gamepadMoveSensibility: number;
  103964. /**
  103965. * 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,
  103966. * which still works and will still be found in many Playgrounds.
  103967. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  103968. * @param name Define the name of the camera in the scene
  103969. * @param position Define the start position of the camera in the scene
  103970. * @param scene Define the scene the camera belongs to
  103971. */
  103972. constructor(name: string, position: Vector3, scene: Scene);
  103973. /**
  103974. * Gets the current object class name.
  103975. * @return the class name
  103976. */
  103977. getClassName(): string;
  103978. }
  103979. }
  103980. declare module BABYLON {
  103981. /**
  103982. * This represents a FPS type of camera. This is only here for back compat purpose.
  103983. * Please use the UniversalCamera instead as both are identical.
  103984. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  103985. */
  103986. export class GamepadCamera extends UniversalCamera {
  103987. /**
  103988. * Instantiates a new Gamepad Camera
  103989. * This represents a FPS type of camera. This is only here for back compat purpose.
  103990. * Please use the UniversalCamera instead as both are identical.
  103991. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  103992. * @param name Define the name of the camera in the scene
  103993. * @param position Define the start position of the camera in the scene
  103994. * @param scene Define the scene the camera belongs to
  103995. */
  103996. constructor(name: string, position: Vector3, scene: Scene);
  103997. /**
  103998. * Gets the current object class name.
  103999. * @return the class name
  104000. */
  104001. getClassName(): string;
  104002. }
  104003. }
  104004. declare module BABYLON {
  104005. /** @hidden */
  104006. export var passPixelShader: {
  104007. name: string;
  104008. shader: string;
  104009. };
  104010. }
  104011. declare module BABYLON {
  104012. /** @hidden */
  104013. export var passCubePixelShader: {
  104014. name: string;
  104015. shader: string;
  104016. };
  104017. }
  104018. declare module BABYLON {
  104019. /**
  104020. * PassPostProcess which produces an output the same as it's input
  104021. */
  104022. export class PassPostProcess extends PostProcess {
  104023. /**
  104024. * Creates the PassPostProcess
  104025. * @param name The name of the effect.
  104026. * @param options The required width/height ratio to downsize to before computing the render pass.
  104027. * @param camera The camera to apply the render pass to.
  104028. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  104029. * @param engine The engine which the post process will be applied. (default: current engine)
  104030. * @param reusable If the post process can be reused on the same frame. (default: false)
  104031. * @param textureType The type of texture to be used when performing the post processing.
  104032. * @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)
  104033. */
  104034. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  104035. }
  104036. /**
  104037. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  104038. */
  104039. export class PassCubePostProcess extends PostProcess {
  104040. private _face;
  104041. /**
  104042. * Gets or sets the cube face to display.
  104043. * * 0 is +X
  104044. * * 1 is -X
  104045. * * 2 is +Y
  104046. * * 3 is -Y
  104047. * * 4 is +Z
  104048. * * 5 is -Z
  104049. */
  104050. face: number;
  104051. /**
  104052. * Creates the PassCubePostProcess
  104053. * @param name The name of the effect.
  104054. * @param options The required width/height ratio to downsize to before computing the render pass.
  104055. * @param camera The camera to apply the render pass to.
  104056. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  104057. * @param engine The engine which the post process will be applied. (default: current engine)
  104058. * @param reusable If the post process can be reused on the same frame. (default: false)
  104059. * @param textureType The type of texture to be used when performing the post processing.
  104060. * @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)
  104061. */
  104062. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  104063. }
  104064. }
  104065. declare module BABYLON {
  104066. /** @hidden */
  104067. export var anaglyphPixelShader: {
  104068. name: string;
  104069. shader: string;
  104070. };
  104071. }
  104072. declare module BABYLON {
  104073. /**
  104074. * Postprocess used to generate anaglyphic rendering
  104075. */
  104076. export class AnaglyphPostProcess extends PostProcess {
  104077. private _passedProcess;
  104078. /**
  104079. * Creates a new AnaglyphPostProcess
  104080. * @param name defines postprocess name
  104081. * @param options defines creation options or target ratio scale
  104082. * @param rigCameras defines cameras using this postprocess
  104083. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  104084. * @param engine defines hosting engine
  104085. * @param reusable defines if the postprocess will be reused multiple times per frame
  104086. */
  104087. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  104088. }
  104089. }
  104090. declare module BABYLON {
  104091. /**
  104092. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  104093. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  104094. */
  104095. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  104096. /**
  104097. * Creates a new AnaglyphArcRotateCamera
  104098. * @param name defines camera name
  104099. * @param alpha defines alpha angle (in radians)
  104100. * @param beta defines beta angle (in radians)
  104101. * @param radius defines radius
  104102. * @param target defines camera target
  104103. * @param interaxialDistance defines distance between each color axis
  104104. * @param scene defines the hosting scene
  104105. */
  104106. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  104107. /**
  104108. * Gets camera class name
  104109. * @returns AnaglyphArcRotateCamera
  104110. */
  104111. getClassName(): string;
  104112. }
  104113. }
  104114. declare module BABYLON {
  104115. /**
  104116. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  104117. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  104118. */
  104119. export class AnaglyphFreeCamera extends FreeCamera {
  104120. /**
  104121. * Creates a new AnaglyphFreeCamera
  104122. * @param name defines camera name
  104123. * @param position defines initial position
  104124. * @param interaxialDistance defines distance between each color axis
  104125. * @param scene defines the hosting scene
  104126. */
  104127. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  104128. /**
  104129. * Gets camera class name
  104130. * @returns AnaglyphFreeCamera
  104131. */
  104132. getClassName(): string;
  104133. }
  104134. }
  104135. declare module BABYLON {
  104136. /**
  104137. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  104138. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  104139. */
  104140. export class AnaglyphGamepadCamera extends GamepadCamera {
  104141. /**
  104142. * Creates a new AnaglyphGamepadCamera
  104143. * @param name defines camera name
  104144. * @param position defines initial position
  104145. * @param interaxialDistance defines distance between each color axis
  104146. * @param scene defines the hosting scene
  104147. */
  104148. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  104149. /**
  104150. * Gets camera class name
  104151. * @returns AnaglyphGamepadCamera
  104152. */
  104153. getClassName(): string;
  104154. }
  104155. }
  104156. declare module BABYLON {
  104157. /**
  104158. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  104159. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  104160. */
  104161. export class AnaglyphUniversalCamera extends UniversalCamera {
  104162. /**
  104163. * Creates a new AnaglyphUniversalCamera
  104164. * @param name defines camera name
  104165. * @param position defines initial position
  104166. * @param interaxialDistance defines distance between each color axis
  104167. * @param scene defines the hosting scene
  104168. */
  104169. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  104170. /**
  104171. * Gets camera class name
  104172. * @returns AnaglyphUniversalCamera
  104173. */
  104174. getClassName(): string;
  104175. }
  104176. }
  104177. declare module BABYLON {
  104178. /** @hidden */
  104179. export var stereoscopicInterlacePixelShader: {
  104180. name: string;
  104181. shader: string;
  104182. };
  104183. }
  104184. declare module BABYLON {
  104185. /**
  104186. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  104187. */
  104188. export class StereoscopicInterlacePostProcess extends PostProcess {
  104189. private _stepSize;
  104190. private _passedProcess;
  104191. /**
  104192. * Initializes a StereoscopicInterlacePostProcess
  104193. * @param name The name of the effect.
  104194. * @param rigCameras The rig cameras to be appled to the post process
  104195. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  104196. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  104197. * @param engine The engine which the post process will be applied. (default: current engine)
  104198. * @param reusable If the post process can be reused on the same frame. (default: false)
  104199. */
  104200. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  104201. }
  104202. }
  104203. declare module BABYLON {
  104204. /**
  104205. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  104206. * @see http://doc.babylonjs.com/features/cameras
  104207. */
  104208. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  104209. /**
  104210. * Creates a new StereoscopicArcRotateCamera
  104211. * @param name defines camera name
  104212. * @param alpha defines alpha angle (in radians)
  104213. * @param beta defines beta angle (in radians)
  104214. * @param radius defines radius
  104215. * @param target defines camera target
  104216. * @param interaxialDistance defines distance between each color axis
  104217. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  104218. * @param scene defines the hosting scene
  104219. */
  104220. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  104221. /**
  104222. * Gets camera class name
  104223. * @returns StereoscopicArcRotateCamera
  104224. */
  104225. getClassName(): string;
  104226. }
  104227. }
  104228. declare module BABYLON {
  104229. /**
  104230. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  104231. * @see http://doc.babylonjs.com/features/cameras
  104232. */
  104233. export class StereoscopicFreeCamera extends FreeCamera {
  104234. /**
  104235. * Creates a new StereoscopicFreeCamera
  104236. * @param name defines camera name
  104237. * @param position defines initial position
  104238. * @param interaxialDistance defines distance between each color axis
  104239. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  104240. * @param scene defines the hosting scene
  104241. */
  104242. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  104243. /**
  104244. * Gets camera class name
  104245. * @returns StereoscopicFreeCamera
  104246. */
  104247. getClassName(): string;
  104248. }
  104249. }
  104250. declare module BABYLON {
  104251. /**
  104252. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  104253. * @see http://doc.babylonjs.com/features/cameras
  104254. */
  104255. export class StereoscopicGamepadCamera extends GamepadCamera {
  104256. /**
  104257. * Creates a new StereoscopicGamepadCamera
  104258. * @param name defines camera name
  104259. * @param position defines initial position
  104260. * @param interaxialDistance defines distance between each color axis
  104261. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  104262. * @param scene defines the hosting scene
  104263. */
  104264. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  104265. /**
  104266. * Gets camera class name
  104267. * @returns StereoscopicGamepadCamera
  104268. */
  104269. getClassName(): string;
  104270. }
  104271. }
  104272. declare module BABYLON {
  104273. /**
  104274. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  104275. * @see http://doc.babylonjs.com/features/cameras
  104276. */
  104277. export class StereoscopicUniversalCamera extends UniversalCamera {
  104278. /**
  104279. * Creates a new StereoscopicUniversalCamera
  104280. * @param name defines camera name
  104281. * @param position defines initial position
  104282. * @param interaxialDistance defines distance between each color axis
  104283. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  104284. * @param scene defines the hosting scene
  104285. */
  104286. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  104287. /**
  104288. * Gets camera class name
  104289. * @returns StereoscopicUniversalCamera
  104290. */
  104291. getClassName(): string;
  104292. }
  104293. }
  104294. declare module BABYLON {
  104295. /**
  104296. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  104297. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  104298. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  104299. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  104300. */
  104301. export class VirtualJoysticksCamera extends FreeCamera {
  104302. /**
  104303. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  104304. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  104305. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  104306. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  104307. * @param name Define the name of the camera in the scene
  104308. * @param position Define the start position of the camera in the scene
  104309. * @param scene Define the scene the camera belongs to
  104310. */
  104311. constructor(name: string, position: Vector3, scene: Scene);
  104312. /**
  104313. * Gets the current object class name.
  104314. * @return the class name
  104315. */
  104316. getClassName(): string;
  104317. }
  104318. }
  104319. declare module BABYLON {
  104320. /**
  104321. * This represents all the required metrics to create a VR camera.
  104322. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  104323. */
  104324. export class VRCameraMetrics {
  104325. /**
  104326. * Define the horizontal resolution off the screen.
  104327. */
  104328. hResolution: number;
  104329. /**
  104330. * Define the vertical resolution off the screen.
  104331. */
  104332. vResolution: number;
  104333. /**
  104334. * Define the horizontal screen size.
  104335. */
  104336. hScreenSize: number;
  104337. /**
  104338. * Define the vertical screen size.
  104339. */
  104340. vScreenSize: number;
  104341. /**
  104342. * Define the vertical screen center position.
  104343. */
  104344. vScreenCenter: number;
  104345. /**
  104346. * Define the distance of the eyes to the screen.
  104347. */
  104348. eyeToScreenDistance: number;
  104349. /**
  104350. * Define the distance between both lenses
  104351. */
  104352. lensSeparationDistance: number;
  104353. /**
  104354. * Define the distance between both viewer's eyes.
  104355. */
  104356. interpupillaryDistance: number;
  104357. /**
  104358. * Define the distortion factor of the VR postprocess.
  104359. * Please, touch with care.
  104360. */
  104361. distortionK: number[];
  104362. /**
  104363. * Define the chromatic aberration correction factors for the VR post process.
  104364. */
  104365. chromaAbCorrection: number[];
  104366. /**
  104367. * Define the scale factor of the post process.
  104368. * The smaller the better but the slower.
  104369. */
  104370. postProcessScaleFactor: number;
  104371. /**
  104372. * Define an offset for the lens center.
  104373. */
  104374. lensCenterOffset: number;
  104375. /**
  104376. * Define if the current vr camera should compensate the distortion of the lense or not.
  104377. */
  104378. compensateDistortion: boolean;
  104379. /**
  104380. * Defines if multiview should be enabled when rendering (Default: false)
  104381. */
  104382. multiviewEnabled: boolean;
  104383. /**
  104384. * Gets the rendering aspect ratio based on the provided resolutions.
  104385. */
  104386. readonly aspectRatio: number;
  104387. /**
  104388. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  104389. */
  104390. readonly aspectRatioFov: number;
  104391. /**
  104392. * @hidden
  104393. */
  104394. readonly leftHMatrix: Matrix;
  104395. /**
  104396. * @hidden
  104397. */
  104398. readonly rightHMatrix: Matrix;
  104399. /**
  104400. * @hidden
  104401. */
  104402. readonly leftPreViewMatrix: Matrix;
  104403. /**
  104404. * @hidden
  104405. */
  104406. readonly rightPreViewMatrix: Matrix;
  104407. /**
  104408. * Get the default VRMetrics based on the most generic setup.
  104409. * @returns the default vr metrics
  104410. */
  104411. static GetDefault(): VRCameraMetrics;
  104412. }
  104413. }
  104414. declare module BABYLON {
  104415. /** @hidden */
  104416. export var vrDistortionCorrectionPixelShader: {
  104417. name: string;
  104418. shader: string;
  104419. };
  104420. }
  104421. declare module BABYLON {
  104422. /**
  104423. * VRDistortionCorrectionPostProcess used for mobile VR
  104424. */
  104425. export class VRDistortionCorrectionPostProcess extends PostProcess {
  104426. private _isRightEye;
  104427. private _distortionFactors;
  104428. private _postProcessScaleFactor;
  104429. private _lensCenterOffset;
  104430. private _scaleIn;
  104431. private _scaleFactor;
  104432. private _lensCenter;
  104433. /**
  104434. * Initializes the VRDistortionCorrectionPostProcess
  104435. * @param name The name of the effect.
  104436. * @param camera The camera to apply the render pass to.
  104437. * @param isRightEye If this is for the right eye distortion
  104438. * @param vrMetrics All the required metrics for the VR camera
  104439. */
  104440. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  104441. }
  104442. }
  104443. declare module BABYLON {
  104444. /**
  104445. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  104446. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  104447. */
  104448. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  104449. /**
  104450. * Creates a new VRDeviceOrientationArcRotateCamera
  104451. * @param name defines camera name
  104452. * @param alpha defines the camera rotation along the logitudinal axis
  104453. * @param beta defines the camera rotation along the latitudinal axis
  104454. * @param radius defines the camera distance from its target
  104455. * @param target defines the camera target
  104456. * @param scene defines the scene the camera belongs to
  104457. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  104458. * @param vrCameraMetrics defines the vr metrics associated to the camera
  104459. */
  104460. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  104461. /**
  104462. * Gets camera class name
  104463. * @returns VRDeviceOrientationArcRotateCamera
  104464. */
  104465. getClassName(): string;
  104466. }
  104467. }
  104468. declare module BABYLON {
  104469. /**
  104470. * Camera used to simulate VR rendering (based on FreeCamera)
  104471. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  104472. */
  104473. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  104474. /**
  104475. * Creates a new VRDeviceOrientationFreeCamera
  104476. * @param name defines camera name
  104477. * @param position defines the start position of the camera
  104478. * @param scene defines the scene the camera belongs to
  104479. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  104480. * @param vrCameraMetrics defines the vr metrics associated to the camera
  104481. */
  104482. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  104483. /**
  104484. * Gets camera class name
  104485. * @returns VRDeviceOrientationFreeCamera
  104486. */
  104487. getClassName(): string;
  104488. }
  104489. }
  104490. declare module BABYLON {
  104491. /**
  104492. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  104493. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  104494. */
  104495. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  104496. /**
  104497. * Creates a new VRDeviceOrientationGamepadCamera
  104498. * @param name defines camera name
  104499. * @param position defines the start position of the camera
  104500. * @param scene defines the scene the camera belongs to
  104501. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  104502. * @param vrCameraMetrics defines the vr metrics associated to the camera
  104503. */
  104504. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  104505. /**
  104506. * Gets camera class name
  104507. * @returns VRDeviceOrientationGamepadCamera
  104508. */
  104509. getClassName(): string;
  104510. }
  104511. }
  104512. declare module BABYLON {
  104513. /**
  104514. * Base class of materials working in push mode in babylon JS
  104515. * @hidden
  104516. */
  104517. export class PushMaterial extends Material {
  104518. protected _activeEffect: Effect;
  104519. protected _normalMatrix: Matrix;
  104520. /**
  104521. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  104522. * This means that the material can keep using a previous shader while a new one is being compiled.
  104523. * This is mostly used when shader parallel compilation is supported (true by default)
  104524. */
  104525. allowShaderHotSwapping: boolean;
  104526. constructor(name: string, scene: Scene);
  104527. getEffect(): Effect;
  104528. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  104529. /**
  104530. * Binds the given world matrix to the active effect
  104531. *
  104532. * @param world the matrix to bind
  104533. */
  104534. bindOnlyWorldMatrix(world: Matrix): void;
  104535. /**
  104536. * Binds the given normal matrix to the active effect
  104537. *
  104538. * @param normalMatrix the matrix to bind
  104539. */
  104540. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  104541. bind(world: Matrix, mesh?: Mesh): void;
  104542. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  104543. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  104544. }
  104545. }
  104546. declare module BABYLON {
  104547. /**
  104548. * This groups all the flags used to control the materials channel.
  104549. */
  104550. export class MaterialFlags {
  104551. private static _DiffuseTextureEnabled;
  104552. /**
  104553. * Are diffuse textures enabled in the application.
  104554. */
  104555. static DiffuseTextureEnabled: boolean;
  104556. private static _AmbientTextureEnabled;
  104557. /**
  104558. * Are ambient textures enabled in the application.
  104559. */
  104560. static AmbientTextureEnabled: boolean;
  104561. private static _OpacityTextureEnabled;
  104562. /**
  104563. * Are opacity textures enabled in the application.
  104564. */
  104565. static OpacityTextureEnabled: boolean;
  104566. private static _ReflectionTextureEnabled;
  104567. /**
  104568. * Are reflection textures enabled in the application.
  104569. */
  104570. static ReflectionTextureEnabled: boolean;
  104571. private static _EmissiveTextureEnabled;
  104572. /**
  104573. * Are emissive textures enabled in the application.
  104574. */
  104575. static EmissiveTextureEnabled: boolean;
  104576. private static _SpecularTextureEnabled;
  104577. /**
  104578. * Are specular textures enabled in the application.
  104579. */
  104580. static SpecularTextureEnabled: boolean;
  104581. private static _BumpTextureEnabled;
  104582. /**
  104583. * Are bump textures enabled in the application.
  104584. */
  104585. static BumpTextureEnabled: boolean;
  104586. private static _LightmapTextureEnabled;
  104587. /**
  104588. * Are lightmap textures enabled in the application.
  104589. */
  104590. static LightmapTextureEnabled: boolean;
  104591. private static _RefractionTextureEnabled;
  104592. /**
  104593. * Are refraction textures enabled in the application.
  104594. */
  104595. static RefractionTextureEnabled: boolean;
  104596. private static _ColorGradingTextureEnabled;
  104597. /**
  104598. * Are color grading textures enabled in the application.
  104599. */
  104600. static ColorGradingTextureEnabled: boolean;
  104601. private static _FresnelEnabled;
  104602. /**
  104603. * Are fresnels enabled in the application.
  104604. */
  104605. static FresnelEnabled: boolean;
  104606. private static _ClearCoatTextureEnabled;
  104607. /**
  104608. * Are clear coat textures enabled in the application.
  104609. */
  104610. static ClearCoatTextureEnabled: boolean;
  104611. private static _ClearCoatBumpTextureEnabled;
  104612. /**
  104613. * Are clear coat bump textures enabled in the application.
  104614. */
  104615. static ClearCoatBumpTextureEnabled: boolean;
  104616. private static _ClearCoatTintTextureEnabled;
  104617. /**
  104618. * Are clear coat tint textures enabled in the application.
  104619. */
  104620. static ClearCoatTintTextureEnabled: boolean;
  104621. private static _SheenTextureEnabled;
  104622. /**
  104623. * Are sheen textures enabled in the application.
  104624. */
  104625. static SheenTextureEnabled: boolean;
  104626. private static _AnisotropicTextureEnabled;
  104627. /**
  104628. * Are anisotropic textures enabled in the application.
  104629. */
  104630. static AnisotropicTextureEnabled: boolean;
  104631. private static _ThicknessTextureEnabled;
  104632. /**
  104633. * Are thickness textures enabled in the application.
  104634. */
  104635. static ThicknessTextureEnabled: boolean;
  104636. }
  104637. }
  104638. declare module BABYLON {
  104639. /** @hidden */
  104640. export var defaultFragmentDeclaration: {
  104641. name: string;
  104642. shader: string;
  104643. };
  104644. }
  104645. declare module BABYLON {
  104646. /** @hidden */
  104647. export var defaultUboDeclaration: {
  104648. name: string;
  104649. shader: string;
  104650. };
  104651. }
  104652. declare module BABYLON {
  104653. /** @hidden */
  104654. export var lightFragmentDeclaration: {
  104655. name: string;
  104656. shader: string;
  104657. };
  104658. }
  104659. declare module BABYLON {
  104660. /** @hidden */
  104661. export var lightUboDeclaration: {
  104662. name: string;
  104663. shader: string;
  104664. };
  104665. }
  104666. declare module BABYLON {
  104667. /** @hidden */
  104668. export var lightsFragmentFunctions: {
  104669. name: string;
  104670. shader: string;
  104671. };
  104672. }
  104673. declare module BABYLON {
  104674. /** @hidden */
  104675. export var shadowsFragmentFunctions: {
  104676. name: string;
  104677. shader: string;
  104678. };
  104679. }
  104680. declare module BABYLON {
  104681. /** @hidden */
  104682. export var fresnelFunction: {
  104683. name: string;
  104684. shader: string;
  104685. };
  104686. }
  104687. declare module BABYLON {
  104688. /** @hidden */
  104689. export var reflectionFunction: {
  104690. name: string;
  104691. shader: string;
  104692. };
  104693. }
  104694. declare module BABYLON {
  104695. /** @hidden */
  104696. export var bumpFragmentFunctions: {
  104697. name: string;
  104698. shader: string;
  104699. };
  104700. }
  104701. declare module BABYLON {
  104702. /** @hidden */
  104703. export var logDepthDeclaration: {
  104704. name: string;
  104705. shader: string;
  104706. };
  104707. }
  104708. declare module BABYLON {
  104709. /** @hidden */
  104710. export var bumpFragment: {
  104711. name: string;
  104712. shader: string;
  104713. };
  104714. }
  104715. declare module BABYLON {
  104716. /** @hidden */
  104717. export var depthPrePass: {
  104718. name: string;
  104719. shader: string;
  104720. };
  104721. }
  104722. declare module BABYLON {
  104723. /** @hidden */
  104724. export var lightFragment: {
  104725. name: string;
  104726. shader: string;
  104727. };
  104728. }
  104729. declare module BABYLON {
  104730. /** @hidden */
  104731. export var logDepthFragment: {
  104732. name: string;
  104733. shader: string;
  104734. };
  104735. }
  104736. declare module BABYLON {
  104737. /** @hidden */
  104738. export var defaultPixelShader: {
  104739. name: string;
  104740. shader: string;
  104741. };
  104742. }
  104743. declare module BABYLON {
  104744. /** @hidden */
  104745. export var defaultVertexDeclaration: {
  104746. name: string;
  104747. shader: string;
  104748. };
  104749. }
  104750. declare module BABYLON {
  104751. /** @hidden */
  104752. export var bumpVertexDeclaration: {
  104753. name: string;
  104754. shader: string;
  104755. };
  104756. }
  104757. declare module BABYLON {
  104758. /** @hidden */
  104759. export var bumpVertex: {
  104760. name: string;
  104761. shader: string;
  104762. };
  104763. }
  104764. declare module BABYLON {
  104765. /** @hidden */
  104766. export var fogVertex: {
  104767. name: string;
  104768. shader: string;
  104769. };
  104770. }
  104771. declare module BABYLON {
  104772. /** @hidden */
  104773. export var shadowsVertex: {
  104774. name: string;
  104775. shader: string;
  104776. };
  104777. }
  104778. declare module BABYLON {
  104779. /** @hidden */
  104780. export var pointCloudVertex: {
  104781. name: string;
  104782. shader: string;
  104783. };
  104784. }
  104785. declare module BABYLON {
  104786. /** @hidden */
  104787. export var logDepthVertex: {
  104788. name: string;
  104789. shader: string;
  104790. };
  104791. }
  104792. declare module BABYLON {
  104793. /** @hidden */
  104794. export var defaultVertexShader: {
  104795. name: string;
  104796. shader: string;
  104797. };
  104798. }
  104799. declare module BABYLON {
  104800. /** @hidden */
  104801. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  104802. MAINUV1: boolean;
  104803. MAINUV2: boolean;
  104804. DIFFUSE: boolean;
  104805. DIFFUSEDIRECTUV: number;
  104806. AMBIENT: boolean;
  104807. AMBIENTDIRECTUV: number;
  104808. OPACITY: boolean;
  104809. OPACITYDIRECTUV: number;
  104810. OPACITYRGB: boolean;
  104811. REFLECTION: boolean;
  104812. EMISSIVE: boolean;
  104813. EMISSIVEDIRECTUV: number;
  104814. SPECULAR: boolean;
  104815. SPECULARDIRECTUV: number;
  104816. BUMP: boolean;
  104817. BUMPDIRECTUV: number;
  104818. PARALLAX: boolean;
  104819. PARALLAXOCCLUSION: boolean;
  104820. SPECULAROVERALPHA: boolean;
  104821. CLIPPLANE: boolean;
  104822. CLIPPLANE2: boolean;
  104823. CLIPPLANE3: boolean;
  104824. CLIPPLANE4: boolean;
  104825. ALPHATEST: boolean;
  104826. DEPTHPREPASS: boolean;
  104827. ALPHAFROMDIFFUSE: boolean;
  104828. POINTSIZE: boolean;
  104829. FOG: boolean;
  104830. SPECULARTERM: boolean;
  104831. DIFFUSEFRESNEL: boolean;
  104832. OPACITYFRESNEL: boolean;
  104833. REFLECTIONFRESNEL: boolean;
  104834. REFRACTIONFRESNEL: boolean;
  104835. EMISSIVEFRESNEL: boolean;
  104836. FRESNEL: boolean;
  104837. NORMAL: boolean;
  104838. UV1: boolean;
  104839. UV2: boolean;
  104840. VERTEXCOLOR: boolean;
  104841. VERTEXALPHA: boolean;
  104842. NUM_BONE_INFLUENCERS: number;
  104843. BonesPerMesh: number;
  104844. BONETEXTURE: boolean;
  104845. INSTANCES: boolean;
  104846. GLOSSINESS: boolean;
  104847. ROUGHNESS: boolean;
  104848. EMISSIVEASILLUMINATION: boolean;
  104849. LINKEMISSIVEWITHDIFFUSE: boolean;
  104850. REFLECTIONFRESNELFROMSPECULAR: boolean;
  104851. LIGHTMAP: boolean;
  104852. LIGHTMAPDIRECTUV: number;
  104853. OBJECTSPACE_NORMALMAP: boolean;
  104854. USELIGHTMAPASSHADOWMAP: boolean;
  104855. REFLECTIONMAP_3D: boolean;
  104856. REFLECTIONMAP_SPHERICAL: boolean;
  104857. REFLECTIONMAP_PLANAR: boolean;
  104858. REFLECTIONMAP_CUBIC: boolean;
  104859. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  104860. REFLECTIONMAP_PROJECTION: boolean;
  104861. REFLECTIONMAP_SKYBOX: boolean;
  104862. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  104863. REFLECTIONMAP_EXPLICIT: boolean;
  104864. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  104865. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  104866. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  104867. INVERTCUBICMAP: boolean;
  104868. LOGARITHMICDEPTH: boolean;
  104869. REFRACTION: boolean;
  104870. REFRACTIONMAP_3D: boolean;
  104871. REFLECTIONOVERALPHA: boolean;
  104872. TWOSIDEDLIGHTING: boolean;
  104873. SHADOWFLOAT: boolean;
  104874. MORPHTARGETS: boolean;
  104875. MORPHTARGETS_NORMAL: boolean;
  104876. MORPHTARGETS_TANGENT: boolean;
  104877. MORPHTARGETS_UV: boolean;
  104878. NUM_MORPH_INFLUENCERS: number;
  104879. NONUNIFORMSCALING: boolean;
  104880. PREMULTIPLYALPHA: boolean;
  104881. IMAGEPROCESSING: boolean;
  104882. VIGNETTE: boolean;
  104883. VIGNETTEBLENDMODEMULTIPLY: boolean;
  104884. VIGNETTEBLENDMODEOPAQUE: boolean;
  104885. TONEMAPPING: boolean;
  104886. TONEMAPPING_ACES: boolean;
  104887. CONTRAST: boolean;
  104888. COLORCURVES: boolean;
  104889. COLORGRADING: boolean;
  104890. COLORGRADING3D: boolean;
  104891. SAMPLER3DGREENDEPTH: boolean;
  104892. SAMPLER3DBGRMAP: boolean;
  104893. IMAGEPROCESSINGPOSTPROCESS: boolean;
  104894. MULTIVIEW: boolean;
  104895. /**
  104896. * If the reflection texture on this material is in linear color space
  104897. * @hidden
  104898. */
  104899. IS_REFLECTION_LINEAR: boolean;
  104900. /**
  104901. * If the refraction texture on this material is in linear color space
  104902. * @hidden
  104903. */
  104904. IS_REFRACTION_LINEAR: boolean;
  104905. EXPOSURE: boolean;
  104906. constructor();
  104907. setReflectionMode(modeToEnable: string): void;
  104908. }
  104909. /**
  104910. * This is the default material used in Babylon. It is the best trade off between quality
  104911. * and performances.
  104912. * @see http://doc.babylonjs.com/babylon101/materials
  104913. */
  104914. export class StandardMaterial extends PushMaterial {
  104915. private _diffuseTexture;
  104916. /**
  104917. * The basic texture of the material as viewed under a light.
  104918. */
  104919. diffuseTexture: Nullable<BaseTexture>;
  104920. private _ambientTexture;
  104921. /**
  104922. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  104923. */
  104924. ambientTexture: Nullable<BaseTexture>;
  104925. private _opacityTexture;
  104926. /**
  104927. * Define the transparency of the material from a texture.
  104928. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  104929. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  104930. */
  104931. opacityTexture: Nullable<BaseTexture>;
  104932. private _reflectionTexture;
  104933. /**
  104934. * Define the texture used to display the reflection.
  104935. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104936. */
  104937. reflectionTexture: Nullable<BaseTexture>;
  104938. private _emissiveTexture;
  104939. /**
  104940. * Define texture of the material as if self lit.
  104941. * This will be mixed in the final result even in the absence of light.
  104942. */
  104943. emissiveTexture: Nullable<BaseTexture>;
  104944. private _specularTexture;
  104945. /**
  104946. * Define how the color and intensity of the highlight given by the light in the material.
  104947. */
  104948. specularTexture: Nullable<BaseTexture>;
  104949. private _bumpTexture;
  104950. /**
  104951. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  104952. * 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.
  104953. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  104954. */
  104955. bumpTexture: Nullable<BaseTexture>;
  104956. private _lightmapTexture;
  104957. /**
  104958. * Complex lighting can be computationally expensive to compute at runtime.
  104959. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  104960. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  104961. */
  104962. lightmapTexture: Nullable<BaseTexture>;
  104963. private _refractionTexture;
  104964. /**
  104965. * Define the texture used to display the refraction.
  104966. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104967. */
  104968. refractionTexture: Nullable<BaseTexture>;
  104969. /**
  104970. * The color of the material lit by the environmental background lighting.
  104971. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  104972. */
  104973. ambientColor: Color3;
  104974. /**
  104975. * The basic color of the material as viewed under a light.
  104976. */
  104977. diffuseColor: Color3;
  104978. /**
  104979. * Define how the color and intensity of the highlight given by the light in the material.
  104980. */
  104981. specularColor: Color3;
  104982. /**
  104983. * Define the color of the material as if self lit.
  104984. * This will be mixed in the final result even in the absence of light.
  104985. */
  104986. emissiveColor: Color3;
  104987. /**
  104988. * Defines how sharp are the highlights in the material.
  104989. * The bigger the value the sharper giving a more glossy feeling to the result.
  104990. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  104991. */
  104992. specularPower: number;
  104993. private _useAlphaFromDiffuseTexture;
  104994. /**
  104995. * Does the transparency come from the diffuse texture alpha channel.
  104996. */
  104997. useAlphaFromDiffuseTexture: boolean;
  104998. private _useEmissiveAsIllumination;
  104999. /**
  105000. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  105001. */
  105002. useEmissiveAsIllumination: boolean;
  105003. private _linkEmissiveWithDiffuse;
  105004. /**
  105005. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  105006. * the emissive level when the final color is close to one.
  105007. */
  105008. linkEmissiveWithDiffuse: boolean;
  105009. private _useSpecularOverAlpha;
  105010. /**
  105011. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  105012. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  105013. */
  105014. useSpecularOverAlpha: boolean;
  105015. private _useReflectionOverAlpha;
  105016. /**
  105017. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  105018. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  105019. */
  105020. useReflectionOverAlpha: boolean;
  105021. private _disableLighting;
  105022. /**
  105023. * Does lights from the scene impacts this material.
  105024. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  105025. */
  105026. disableLighting: boolean;
  105027. private _useObjectSpaceNormalMap;
  105028. /**
  105029. * Allows using an object space normal map (instead of tangent space).
  105030. */
  105031. useObjectSpaceNormalMap: boolean;
  105032. private _useParallax;
  105033. /**
  105034. * Is parallax enabled or not.
  105035. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  105036. */
  105037. useParallax: boolean;
  105038. private _useParallaxOcclusion;
  105039. /**
  105040. * Is parallax occlusion enabled or not.
  105041. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  105042. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  105043. */
  105044. useParallaxOcclusion: boolean;
  105045. /**
  105046. * 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.
  105047. */
  105048. parallaxScaleBias: number;
  105049. private _roughness;
  105050. /**
  105051. * Helps to define how blurry the reflections should appears in the material.
  105052. */
  105053. roughness: number;
  105054. /**
  105055. * In case of refraction, define the value of the index of refraction.
  105056. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105057. */
  105058. indexOfRefraction: number;
  105059. /**
  105060. * Invert the refraction texture alongside the y axis.
  105061. * It can be useful with procedural textures or probe for instance.
  105062. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105063. */
  105064. invertRefractionY: boolean;
  105065. /**
  105066. * Defines the alpha limits in alpha test mode.
  105067. */
  105068. alphaCutOff: number;
  105069. private _useLightmapAsShadowmap;
  105070. /**
  105071. * In case of light mapping, define whether the map contains light or shadow informations.
  105072. */
  105073. useLightmapAsShadowmap: boolean;
  105074. private _diffuseFresnelParameters;
  105075. /**
  105076. * Define the diffuse fresnel parameters of the material.
  105077. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105078. */
  105079. diffuseFresnelParameters: FresnelParameters;
  105080. private _opacityFresnelParameters;
  105081. /**
  105082. * Define the opacity fresnel parameters of the material.
  105083. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105084. */
  105085. opacityFresnelParameters: FresnelParameters;
  105086. private _reflectionFresnelParameters;
  105087. /**
  105088. * Define the reflection fresnel parameters of the material.
  105089. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105090. */
  105091. reflectionFresnelParameters: FresnelParameters;
  105092. private _refractionFresnelParameters;
  105093. /**
  105094. * Define the refraction fresnel parameters of the material.
  105095. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105096. */
  105097. refractionFresnelParameters: FresnelParameters;
  105098. private _emissiveFresnelParameters;
  105099. /**
  105100. * Define the emissive fresnel parameters of the material.
  105101. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105102. */
  105103. emissiveFresnelParameters: FresnelParameters;
  105104. private _useReflectionFresnelFromSpecular;
  105105. /**
  105106. * If true automatically deducts the fresnels values from the material specularity.
  105107. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105108. */
  105109. useReflectionFresnelFromSpecular: boolean;
  105110. private _useGlossinessFromSpecularMapAlpha;
  105111. /**
  105112. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  105113. */
  105114. useGlossinessFromSpecularMapAlpha: boolean;
  105115. private _maxSimultaneousLights;
  105116. /**
  105117. * Defines the maximum number of lights that can be used in the material
  105118. */
  105119. maxSimultaneousLights: number;
  105120. private _invertNormalMapX;
  105121. /**
  105122. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  105123. */
  105124. invertNormalMapX: boolean;
  105125. private _invertNormalMapY;
  105126. /**
  105127. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  105128. */
  105129. invertNormalMapY: boolean;
  105130. private _twoSidedLighting;
  105131. /**
  105132. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  105133. */
  105134. twoSidedLighting: boolean;
  105135. /**
  105136. * Default configuration related to image processing available in the standard Material.
  105137. */
  105138. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  105139. /**
  105140. * Gets the image processing configuration used either in this material.
  105141. */
  105142. /**
  105143. * Sets the Default image processing configuration used either in the this material.
  105144. *
  105145. * If sets to null, the scene one is in use.
  105146. */
  105147. imageProcessingConfiguration: ImageProcessingConfiguration;
  105148. /**
  105149. * Keep track of the image processing observer to allow dispose and replace.
  105150. */
  105151. private _imageProcessingObserver;
  105152. /**
  105153. * Attaches a new image processing configuration to the Standard Material.
  105154. * @param configuration
  105155. */
  105156. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  105157. /**
  105158. * Gets wether the color curves effect is enabled.
  105159. */
  105160. /**
  105161. * Sets wether the color curves effect is enabled.
  105162. */
  105163. cameraColorCurvesEnabled: boolean;
  105164. /**
  105165. * Gets wether the color grading effect is enabled.
  105166. */
  105167. /**
  105168. * Gets wether the color grading effect is enabled.
  105169. */
  105170. cameraColorGradingEnabled: boolean;
  105171. /**
  105172. * Gets wether tonemapping is enabled or not.
  105173. */
  105174. /**
  105175. * Sets wether tonemapping is enabled or not
  105176. */
  105177. cameraToneMappingEnabled: boolean;
  105178. /**
  105179. * The camera exposure used on this material.
  105180. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  105181. * This corresponds to a photographic exposure.
  105182. */
  105183. /**
  105184. * The camera exposure used on this material.
  105185. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  105186. * This corresponds to a photographic exposure.
  105187. */
  105188. cameraExposure: number;
  105189. /**
  105190. * Gets The camera contrast used on this material.
  105191. */
  105192. /**
  105193. * Sets The camera contrast used on this material.
  105194. */
  105195. cameraContrast: number;
  105196. /**
  105197. * Gets the Color Grading 2D Lookup Texture.
  105198. */
  105199. /**
  105200. * Sets the Color Grading 2D Lookup Texture.
  105201. */
  105202. cameraColorGradingTexture: Nullable<BaseTexture>;
  105203. /**
  105204. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  105205. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  105206. * 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;
  105207. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  105208. */
  105209. /**
  105210. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  105211. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  105212. * 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;
  105213. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  105214. */
  105215. cameraColorCurves: Nullable<ColorCurves>;
  105216. /**
  105217. * Custom callback helping to override the default shader used in the material.
  105218. */
  105219. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  105220. protected _renderTargets: SmartArray<RenderTargetTexture>;
  105221. protected _worldViewProjectionMatrix: Matrix;
  105222. protected _globalAmbientColor: Color3;
  105223. protected _useLogarithmicDepth: boolean;
  105224. protected _rebuildInParallel: boolean;
  105225. /**
  105226. * Instantiates a new standard material.
  105227. * This is the default material used in Babylon. It is the best trade off between quality
  105228. * and performances.
  105229. * @see http://doc.babylonjs.com/babylon101/materials
  105230. * @param name Define the name of the material in the scene
  105231. * @param scene Define the scene the material belong to
  105232. */
  105233. constructor(name: string, scene: Scene);
  105234. /**
  105235. * Gets a boolean indicating that current material needs to register RTT
  105236. */
  105237. readonly hasRenderTargetTextures: boolean;
  105238. /**
  105239. * Gets the current class name of the material e.g. "StandardMaterial"
  105240. * Mainly use in serialization.
  105241. * @returns the class name
  105242. */
  105243. getClassName(): string;
  105244. /**
  105245. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  105246. * You can try switching to logarithmic depth.
  105247. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  105248. */
  105249. useLogarithmicDepth: boolean;
  105250. /**
  105251. * Specifies if the material will require alpha blending
  105252. * @returns a boolean specifying if alpha blending is needed
  105253. */
  105254. needAlphaBlending(): boolean;
  105255. /**
  105256. * Specifies if this material should be rendered in alpha test mode
  105257. * @returns a boolean specifying if an alpha test is needed.
  105258. */
  105259. needAlphaTesting(): boolean;
  105260. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  105261. /**
  105262. * Get the texture used for alpha test purpose.
  105263. * @returns the diffuse texture in case of the standard material.
  105264. */
  105265. getAlphaTestTexture(): Nullable<BaseTexture>;
  105266. /**
  105267. * Get if the submesh is ready to be used and all its information available.
  105268. * Child classes can use it to update shaders
  105269. * @param mesh defines the mesh to check
  105270. * @param subMesh defines which submesh to check
  105271. * @param useInstances specifies that instances should be used
  105272. * @returns a boolean indicating that the submesh is ready or not
  105273. */
  105274. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  105275. /**
  105276. * Builds the material UBO layouts.
  105277. * Used internally during the effect preparation.
  105278. */
  105279. buildUniformLayout(): void;
  105280. /**
  105281. * Unbinds the material from the mesh
  105282. */
  105283. unbind(): void;
  105284. /**
  105285. * Binds the submesh to this material by preparing the effect and shader to draw
  105286. * @param world defines the world transformation matrix
  105287. * @param mesh defines the mesh containing the submesh
  105288. * @param subMesh defines the submesh to bind the material to
  105289. */
  105290. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  105291. /**
  105292. * Get the list of animatables in the material.
  105293. * @returns the list of animatables object used in the material
  105294. */
  105295. getAnimatables(): IAnimatable[];
  105296. /**
  105297. * Gets the active textures from the material
  105298. * @returns an array of textures
  105299. */
  105300. getActiveTextures(): BaseTexture[];
  105301. /**
  105302. * Specifies if the material uses a texture
  105303. * @param texture defines the texture to check against the material
  105304. * @returns a boolean specifying if the material uses the texture
  105305. */
  105306. hasTexture(texture: BaseTexture): boolean;
  105307. /**
  105308. * Disposes the material
  105309. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  105310. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  105311. */
  105312. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  105313. /**
  105314. * Makes a duplicate of the material, and gives it a new name
  105315. * @param name defines the new name for the duplicated material
  105316. * @returns the cloned material
  105317. */
  105318. clone(name: string): StandardMaterial;
  105319. /**
  105320. * Serializes this material in a JSON representation
  105321. * @returns the serialized material object
  105322. */
  105323. serialize(): any;
  105324. /**
  105325. * Creates a standard material from parsed material data
  105326. * @param source defines the JSON representation of the material
  105327. * @param scene defines the hosting scene
  105328. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  105329. * @returns a new standard material
  105330. */
  105331. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  105332. /**
  105333. * Are diffuse textures enabled in the application.
  105334. */
  105335. static DiffuseTextureEnabled: boolean;
  105336. /**
  105337. * Are ambient textures enabled in the application.
  105338. */
  105339. static AmbientTextureEnabled: boolean;
  105340. /**
  105341. * Are opacity textures enabled in the application.
  105342. */
  105343. static OpacityTextureEnabled: boolean;
  105344. /**
  105345. * Are reflection textures enabled in the application.
  105346. */
  105347. static ReflectionTextureEnabled: boolean;
  105348. /**
  105349. * Are emissive textures enabled in the application.
  105350. */
  105351. static EmissiveTextureEnabled: boolean;
  105352. /**
  105353. * Are specular textures enabled in the application.
  105354. */
  105355. static SpecularTextureEnabled: boolean;
  105356. /**
  105357. * Are bump textures enabled in the application.
  105358. */
  105359. static BumpTextureEnabled: boolean;
  105360. /**
  105361. * Are lightmap textures enabled in the application.
  105362. */
  105363. static LightmapTextureEnabled: boolean;
  105364. /**
  105365. * Are refraction textures enabled in the application.
  105366. */
  105367. static RefractionTextureEnabled: boolean;
  105368. /**
  105369. * Are color grading textures enabled in the application.
  105370. */
  105371. static ColorGradingTextureEnabled: boolean;
  105372. /**
  105373. * Are fresnels enabled in the application.
  105374. */
  105375. static FresnelEnabled: boolean;
  105376. }
  105377. }
  105378. declare module BABYLON {
  105379. /**
  105380. * A class extending Texture allowing drawing on a texture
  105381. * @see http://doc.babylonjs.com/how_to/dynamictexture
  105382. */
  105383. export class DynamicTexture extends Texture {
  105384. private _generateMipMaps;
  105385. private _canvas;
  105386. private _context;
  105387. private _engine;
  105388. /**
  105389. * Creates a DynamicTexture
  105390. * @param name defines the name of the texture
  105391. * @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
  105392. * @param scene defines the scene where you want the texture
  105393. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  105394. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  105395. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  105396. */
  105397. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  105398. /**
  105399. * Get the current class name of the texture useful for serialization or dynamic coding.
  105400. * @returns "DynamicTexture"
  105401. */
  105402. getClassName(): string;
  105403. /**
  105404. * Gets the current state of canRescale
  105405. */
  105406. readonly canRescale: boolean;
  105407. private _recreate;
  105408. /**
  105409. * Scales the texture
  105410. * @param ratio the scale factor to apply to both width and height
  105411. */
  105412. scale(ratio: number): void;
  105413. /**
  105414. * Resizes the texture
  105415. * @param width the new width
  105416. * @param height the new height
  105417. */
  105418. scaleTo(width: number, height: number): void;
  105419. /**
  105420. * Gets the context of the canvas used by the texture
  105421. * @returns the canvas context of the dynamic texture
  105422. */
  105423. getContext(): CanvasRenderingContext2D;
  105424. /**
  105425. * Clears the texture
  105426. */
  105427. clear(): void;
  105428. /**
  105429. * Updates the texture
  105430. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  105431. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  105432. */
  105433. update(invertY?: boolean, premulAlpha?: boolean): void;
  105434. /**
  105435. * Draws text onto the texture
  105436. * @param text defines the text to be drawn
  105437. * @param x defines the placement of the text from the left
  105438. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  105439. * @param font defines the font to be used with font-style, font-size, font-name
  105440. * @param color defines the color used for the text
  105441. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  105442. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  105443. * @param update defines whether texture is immediately update (default is true)
  105444. */
  105445. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  105446. /**
  105447. * Clones the texture
  105448. * @returns the clone of the texture.
  105449. */
  105450. clone(): DynamicTexture;
  105451. /**
  105452. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  105453. * @returns a serialized dynamic texture object
  105454. */
  105455. serialize(): any;
  105456. /** @hidden */
  105457. _rebuild(): void;
  105458. }
  105459. }
  105460. declare module BABYLON {
  105461. /** @hidden */
  105462. export var imageProcessingPixelShader: {
  105463. name: string;
  105464. shader: string;
  105465. };
  105466. }
  105467. declare module BABYLON {
  105468. /**
  105469. * ImageProcessingPostProcess
  105470. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  105471. */
  105472. export class ImageProcessingPostProcess extends PostProcess {
  105473. /**
  105474. * Default configuration related to image processing available in the PBR Material.
  105475. */
  105476. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  105477. /**
  105478. * Gets the image processing configuration used either in this material.
  105479. */
  105480. /**
  105481. * Sets the Default image processing configuration used either in the this material.
  105482. *
  105483. * If sets to null, the scene one is in use.
  105484. */
  105485. imageProcessingConfiguration: ImageProcessingConfiguration;
  105486. /**
  105487. * Keep track of the image processing observer to allow dispose and replace.
  105488. */
  105489. private _imageProcessingObserver;
  105490. /**
  105491. * Attaches a new image processing configuration to the PBR Material.
  105492. * @param configuration
  105493. */
  105494. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  105495. /**
  105496. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  105497. */
  105498. /**
  105499. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  105500. */
  105501. colorCurves: Nullable<ColorCurves>;
  105502. /**
  105503. * Gets wether the color curves effect is enabled.
  105504. */
  105505. /**
  105506. * Sets wether the color curves effect is enabled.
  105507. */
  105508. colorCurvesEnabled: boolean;
  105509. /**
  105510. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  105511. */
  105512. /**
  105513. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  105514. */
  105515. colorGradingTexture: Nullable<BaseTexture>;
  105516. /**
  105517. * Gets wether the color grading effect is enabled.
  105518. */
  105519. /**
  105520. * Gets wether the color grading effect is enabled.
  105521. */
  105522. colorGradingEnabled: boolean;
  105523. /**
  105524. * Gets exposure used in the effect.
  105525. */
  105526. /**
  105527. * Sets exposure used in the effect.
  105528. */
  105529. exposure: number;
  105530. /**
  105531. * Gets wether tonemapping is enabled or not.
  105532. */
  105533. /**
  105534. * Sets wether tonemapping is enabled or not
  105535. */
  105536. toneMappingEnabled: boolean;
  105537. /**
  105538. * Gets the type of tone mapping effect.
  105539. */
  105540. /**
  105541. * Sets the type of tone mapping effect.
  105542. */
  105543. toneMappingType: number;
  105544. /**
  105545. * Gets contrast used in the effect.
  105546. */
  105547. /**
  105548. * Sets contrast used in the effect.
  105549. */
  105550. contrast: number;
  105551. /**
  105552. * Gets Vignette stretch size.
  105553. */
  105554. /**
  105555. * Sets Vignette stretch size.
  105556. */
  105557. vignetteStretch: number;
  105558. /**
  105559. * Gets Vignette centre X Offset.
  105560. */
  105561. /**
  105562. * Sets Vignette centre X Offset.
  105563. */
  105564. vignetteCentreX: number;
  105565. /**
  105566. * Gets Vignette centre Y Offset.
  105567. */
  105568. /**
  105569. * Sets Vignette centre Y Offset.
  105570. */
  105571. vignetteCentreY: number;
  105572. /**
  105573. * Gets Vignette weight or intensity of the vignette effect.
  105574. */
  105575. /**
  105576. * Sets Vignette weight or intensity of the vignette effect.
  105577. */
  105578. vignetteWeight: number;
  105579. /**
  105580. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  105581. * if vignetteEnabled is set to true.
  105582. */
  105583. /**
  105584. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  105585. * if vignetteEnabled is set to true.
  105586. */
  105587. vignetteColor: Color4;
  105588. /**
  105589. * Gets Camera field of view used by the Vignette effect.
  105590. */
  105591. /**
  105592. * Sets Camera field of view used by the Vignette effect.
  105593. */
  105594. vignetteCameraFov: number;
  105595. /**
  105596. * Gets the vignette blend mode allowing different kind of effect.
  105597. */
  105598. /**
  105599. * Sets the vignette blend mode allowing different kind of effect.
  105600. */
  105601. vignetteBlendMode: number;
  105602. /**
  105603. * Gets wether the vignette effect is enabled.
  105604. */
  105605. /**
  105606. * Sets wether the vignette effect is enabled.
  105607. */
  105608. vignetteEnabled: boolean;
  105609. private _fromLinearSpace;
  105610. /**
  105611. * Gets wether the input of the processing is in Gamma or Linear Space.
  105612. */
  105613. /**
  105614. * Sets wether the input of the processing is in Gamma or Linear Space.
  105615. */
  105616. fromLinearSpace: boolean;
  105617. /**
  105618. * Defines cache preventing GC.
  105619. */
  105620. private _defines;
  105621. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  105622. /**
  105623. * "ImageProcessingPostProcess"
  105624. * @returns "ImageProcessingPostProcess"
  105625. */
  105626. getClassName(): string;
  105627. protected _updateParameters(): void;
  105628. dispose(camera?: Camera): void;
  105629. }
  105630. }
  105631. declare module BABYLON {
  105632. /**
  105633. * Class containing static functions to help procedurally build meshes
  105634. */
  105635. export class GroundBuilder {
  105636. /**
  105637. * Creates a ground mesh
  105638. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  105639. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  105640. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105641. * @param name defines the name of the mesh
  105642. * @param options defines the options used to create the mesh
  105643. * @param scene defines the hosting scene
  105644. * @returns the ground mesh
  105645. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  105646. */
  105647. static CreateGround(name: string, options: {
  105648. width?: number;
  105649. height?: number;
  105650. subdivisions?: number;
  105651. subdivisionsX?: number;
  105652. subdivisionsY?: number;
  105653. updatable?: boolean;
  105654. }, scene: any): Mesh;
  105655. /**
  105656. * Creates a tiled ground mesh
  105657. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  105658. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  105659. * * 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
  105660. * * 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
  105661. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105662. * @param name defines the name of the mesh
  105663. * @param options defines the options used to create the mesh
  105664. * @param scene defines the hosting scene
  105665. * @returns the tiled ground mesh
  105666. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  105667. */
  105668. static CreateTiledGround(name: string, options: {
  105669. xmin: number;
  105670. zmin: number;
  105671. xmax: number;
  105672. zmax: number;
  105673. subdivisions?: {
  105674. w: number;
  105675. h: number;
  105676. };
  105677. precision?: {
  105678. w: number;
  105679. h: number;
  105680. };
  105681. updatable?: boolean;
  105682. }, scene?: Nullable<Scene>): Mesh;
  105683. /**
  105684. * Creates a ground mesh from a height map
  105685. * * The parameter `url` sets the URL of the height map image resource.
  105686. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  105687. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  105688. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  105689. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  105690. * * 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.
  105691. * * 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).
  105692. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  105693. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105694. * @param name defines the name of the mesh
  105695. * @param url defines the url to the height map
  105696. * @param options defines the options used to create the mesh
  105697. * @param scene defines the hosting scene
  105698. * @returns the ground mesh
  105699. * @see https://doc.babylonjs.com/babylon101/height_map
  105700. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  105701. */
  105702. static CreateGroundFromHeightMap(name: string, url: string, options: {
  105703. width?: number;
  105704. height?: number;
  105705. subdivisions?: number;
  105706. minHeight?: number;
  105707. maxHeight?: number;
  105708. colorFilter?: Color3;
  105709. alphaFilter?: number;
  105710. updatable?: boolean;
  105711. onReady?: (mesh: GroundMesh) => void;
  105712. }, scene?: Nullable<Scene>): GroundMesh;
  105713. }
  105714. }
  105715. declare module BABYLON {
  105716. /**
  105717. * Class containing static functions to help procedurally build meshes
  105718. */
  105719. export class TorusBuilder {
  105720. /**
  105721. * Creates a torus mesh
  105722. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  105723. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  105724. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  105725. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105726. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105727. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105728. * @param name defines the name of the mesh
  105729. * @param options defines the options used to create the mesh
  105730. * @param scene defines the hosting scene
  105731. * @returns the torus mesh
  105732. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  105733. */
  105734. static CreateTorus(name: string, options: {
  105735. diameter?: number;
  105736. thickness?: number;
  105737. tessellation?: number;
  105738. updatable?: boolean;
  105739. sideOrientation?: number;
  105740. frontUVs?: Vector4;
  105741. backUVs?: Vector4;
  105742. }, scene: any): Mesh;
  105743. }
  105744. }
  105745. declare module BABYLON {
  105746. /**
  105747. * Class containing static functions to help procedurally build meshes
  105748. */
  105749. export class CylinderBuilder {
  105750. /**
  105751. * Creates a cylinder or a cone mesh
  105752. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  105753. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  105754. * * 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.
  105755. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  105756. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  105757. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  105758. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  105759. * * 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).
  105760. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  105761. * * 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).
  105762. * * 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
  105763. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  105764. * * 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
  105765. * * 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.
  105766. * * If `enclose` is false, a ring surface is one element.
  105767. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  105768. * * 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
  105769. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105770. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105771. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105772. * @param name defines the name of the mesh
  105773. * @param options defines the options used to create the mesh
  105774. * @param scene defines the hosting scene
  105775. * @returns the cylinder mesh
  105776. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  105777. */
  105778. static CreateCylinder(name: string, options: {
  105779. height?: number;
  105780. diameterTop?: number;
  105781. diameterBottom?: number;
  105782. diameter?: number;
  105783. tessellation?: number;
  105784. subdivisions?: number;
  105785. arc?: number;
  105786. faceColors?: Color4[];
  105787. faceUV?: Vector4[];
  105788. updatable?: boolean;
  105789. hasRings?: boolean;
  105790. enclose?: boolean;
  105791. cap?: number;
  105792. sideOrientation?: number;
  105793. frontUVs?: Vector4;
  105794. backUVs?: Vector4;
  105795. }, scene: any): Mesh;
  105796. }
  105797. }
  105798. declare module BABYLON {
  105799. /**
  105800. * Options to modify the vr teleportation behavior.
  105801. */
  105802. export interface VRTeleportationOptions {
  105803. /**
  105804. * The name of the mesh which should be used as the teleportation floor. (default: null)
  105805. */
  105806. floorMeshName?: string;
  105807. /**
  105808. * A list of meshes to be used as the teleportation floor. (default: empty)
  105809. */
  105810. floorMeshes?: Mesh[];
  105811. }
  105812. /**
  105813. * Options to modify the vr experience helper's behavior.
  105814. */
  105815. export interface VRExperienceHelperOptions extends WebVROptions {
  105816. /**
  105817. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  105818. */
  105819. createDeviceOrientationCamera?: boolean;
  105820. /**
  105821. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  105822. */
  105823. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  105824. /**
  105825. * Uses the main button on the controller to toggle the laser casted. (default: true)
  105826. */
  105827. laserToggle?: boolean;
  105828. /**
  105829. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  105830. */
  105831. floorMeshes?: Mesh[];
  105832. /**
  105833. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  105834. */
  105835. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  105836. }
  105837. /**
  105838. * Event containing information after VR has been entered
  105839. */
  105840. export class OnAfterEnteringVRObservableEvent {
  105841. /**
  105842. * If entering vr was successful
  105843. */
  105844. success: boolean;
  105845. }
  105846. /**
  105847. * Helps to quickly add VR support to an existing scene.
  105848. * See http://doc.babylonjs.com/how_to/webvr_helper
  105849. */
  105850. export class VRExperienceHelper {
  105851. /** Options to modify the vr experience helper's behavior. */
  105852. webVROptions: VRExperienceHelperOptions;
  105853. private _scene;
  105854. private _position;
  105855. private _btnVR;
  105856. private _btnVRDisplayed;
  105857. private _webVRsupported;
  105858. private _webVRready;
  105859. private _webVRrequesting;
  105860. private _webVRpresenting;
  105861. private _hasEnteredVR;
  105862. private _fullscreenVRpresenting;
  105863. private _canvas;
  105864. private _webVRCamera;
  105865. private _vrDeviceOrientationCamera;
  105866. private _deviceOrientationCamera;
  105867. private _existingCamera;
  105868. private _onKeyDown;
  105869. private _onVrDisplayPresentChange;
  105870. private _onVRDisplayChanged;
  105871. private _onVRRequestPresentStart;
  105872. private _onVRRequestPresentComplete;
  105873. /**
  105874. * 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)
  105875. */
  105876. enableGazeEvenWhenNoPointerLock: boolean;
  105877. /**
  105878. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  105879. */
  105880. exitVROnDoubleTap: boolean;
  105881. /**
  105882. * Observable raised right before entering VR.
  105883. */
  105884. onEnteringVRObservable: Observable<VRExperienceHelper>;
  105885. /**
  105886. * Observable raised when entering VR has completed.
  105887. */
  105888. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  105889. /**
  105890. * Observable raised when exiting VR.
  105891. */
  105892. onExitingVRObservable: Observable<VRExperienceHelper>;
  105893. /**
  105894. * Observable raised when controller mesh is loaded.
  105895. */
  105896. onControllerMeshLoadedObservable: Observable<WebVRController>;
  105897. /** Return this.onEnteringVRObservable
  105898. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  105899. */
  105900. readonly onEnteringVR: Observable<VRExperienceHelper>;
  105901. /** Return this.onExitingVRObservable
  105902. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  105903. */
  105904. readonly onExitingVR: Observable<VRExperienceHelper>;
  105905. /** Return this.onControllerMeshLoadedObservable
  105906. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  105907. */
  105908. readonly onControllerMeshLoaded: Observable<WebVRController>;
  105909. private _rayLength;
  105910. private _useCustomVRButton;
  105911. private _teleportationRequested;
  105912. private _teleportActive;
  105913. private _floorMeshName;
  105914. private _floorMeshesCollection;
  105915. private _rotationAllowed;
  105916. private _teleportBackwardsVector;
  105917. private _teleportationTarget;
  105918. private _isDefaultTeleportationTarget;
  105919. private _postProcessMove;
  105920. private _teleportationFillColor;
  105921. private _teleportationBorderColor;
  105922. private _rotationAngle;
  105923. private _haloCenter;
  105924. private _cameraGazer;
  105925. private _padSensibilityUp;
  105926. private _padSensibilityDown;
  105927. private _leftController;
  105928. private _rightController;
  105929. /**
  105930. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  105931. */
  105932. onNewMeshSelected: Observable<AbstractMesh>;
  105933. /**
  105934. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  105935. * This observable will provide the mesh and the controller used to select the mesh
  105936. */
  105937. onMeshSelectedWithController: Observable<{
  105938. mesh: AbstractMesh;
  105939. controller: WebVRController;
  105940. }>;
  105941. /**
  105942. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  105943. */
  105944. onNewMeshPicked: Observable<PickingInfo>;
  105945. private _circleEase;
  105946. /**
  105947. * Observable raised before camera teleportation
  105948. */
  105949. onBeforeCameraTeleport: Observable<Vector3>;
  105950. /**
  105951. * Observable raised after camera teleportation
  105952. */
  105953. onAfterCameraTeleport: Observable<Vector3>;
  105954. /**
  105955. * Observable raised when current selected mesh gets unselected
  105956. */
  105957. onSelectedMeshUnselected: Observable<AbstractMesh>;
  105958. private _raySelectionPredicate;
  105959. /**
  105960. * To be optionaly changed by user to define custom ray selection
  105961. */
  105962. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  105963. /**
  105964. * To be optionaly changed by user to define custom selection logic (after ray selection)
  105965. */
  105966. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  105967. /**
  105968. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  105969. */
  105970. teleportationEnabled: boolean;
  105971. private _defaultHeight;
  105972. private _teleportationInitialized;
  105973. private _interactionsEnabled;
  105974. private _interactionsRequested;
  105975. private _displayGaze;
  105976. private _displayLaserPointer;
  105977. /**
  105978. * The mesh used to display where the user is going to teleport.
  105979. */
  105980. /**
  105981. * Sets the mesh to be used to display where the user is going to teleport.
  105982. */
  105983. teleportationTarget: Mesh;
  105984. /**
  105985. * 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
  105986. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  105987. * See http://doc.babylonjs.com/resources/baking_transformations
  105988. */
  105989. gazeTrackerMesh: Mesh;
  105990. /**
  105991. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  105992. */
  105993. updateGazeTrackerScale: boolean;
  105994. /**
  105995. * If the gaze trackers color should be updated when selecting meshes
  105996. */
  105997. updateGazeTrackerColor: boolean;
  105998. /**
  105999. * The gaze tracking mesh corresponding to the left controller
  106000. */
  106001. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  106002. /**
  106003. * The gaze tracking mesh corresponding to the right controller
  106004. */
  106005. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  106006. /**
  106007. * If the ray of the gaze should be displayed.
  106008. */
  106009. /**
  106010. * Sets if the ray of the gaze should be displayed.
  106011. */
  106012. displayGaze: boolean;
  106013. /**
  106014. * If the ray of the LaserPointer should be displayed.
  106015. */
  106016. /**
  106017. * Sets if the ray of the LaserPointer should be displayed.
  106018. */
  106019. displayLaserPointer: boolean;
  106020. /**
  106021. * The deviceOrientationCamera used as the camera when not in VR.
  106022. */
  106023. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  106024. /**
  106025. * Based on the current WebVR support, returns the current VR camera used.
  106026. */
  106027. readonly currentVRCamera: Nullable<Camera>;
  106028. /**
  106029. * The webVRCamera which is used when in VR.
  106030. */
  106031. readonly webVRCamera: WebVRFreeCamera;
  106032. /**
  106033. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  106034. */
  106035. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  106036. /**
  106037. * The html button that is used to trigger entering into VR.
  106038. */
  106039. readonly vrButton: Nullable<HTMLButtonElement>;
  106040. private readonly _teleportationRequestInitiated;
  106041. /**
  106042. * Defines wether or not Pointer lock should be requested when switching to
  106043. * full screen.
  106044. */
  106045. requestPointerLockOnFullScreen: boolean;
  106046. /**
  106047. * Instantiates a VRExperienceHelper.
  106048. * Helps to quickly add VR support to an existing scene.
  106049. * @param scene The scene the VRExperienceHelper belongs to.
  106050. * @param webVROptions Options to modify the vr experience helper's behavior.
  106051. */
  106052. constructor(scene: Scene,
  106053. /** Options to modify the vr experience helper's behavior. */
  106054. webVROptions?: VRExperienceHelperOptions);
  106055. private _onDefaultMeshLoaded;
  106056. private _onResize;
  106057. private _onFullscreenChange;
  106058. /**
  106059. * Gets a value indicating if we are currently in VR mode.
  106060. */
  106061. readonly isInVRMode: boolean;
  106062. private onVrDisplayPresentChange;
  106063. private onVRDisplayChanged;
  106064. private moveButtonToBottomRight;
  106065. private displayVRButton;
  106066. private updateButtonVisibility;
  106067. private _cachedAngularSensibility;
  106068. /**
  106069. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  106070. * Otherwise, will use the fullscreen API.
  106071. */
  106072. enterVR(): void;
  106073. /**
  106074. * Attempt to exit VR, or fullscreen.
  106075. */
  106076. exitVR(): void;
  106077. /**
  106078. * The position of the vr experience helper.
  106079. */
  106080. /**
  106081. * Sets the position of the vr experience helper.
  106082. */
  106083. position: Vector3;
  106084. /**
  106085. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  106086. */
  106087. enableInteractions(): void;
  106088. private readonly _noControllerIsActive;
  106089. private beforeRender;
  106090. private _isTeleportationFloor;
  106091. /**
  106092. * Adds a floor mesh to be used for teleportation.
  106093. * @param floorMesh the mesh to be used for teleportation.
  106094. */
  106095. addFloorMesh(floorMesh: Mesh): void;
  106096. /**
  106097. * Removes a floor mesh from being used for teleportation.
  106098. * @param floorMesh the mesh to be removed.
  106099. */
  106100. removeFloorMesh(floorMesh: Mesh): void;
  106101. /**
  106102. * Enables interactions and teleportation using the VR controllers and gaze.
  106103. * @param vrTeleportationOptions options to modify teleportation behavior.
  106104. */
  106105. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  106106. private _onNewGamepadConnected;
  106107. private _tryEnableInteractionOnController;
  106108. private _onNewGamepadDisconnected;
  106109. private _enableInteractionOnController;
  106110. private _checkTeleportWithRay;
  106111. private _checkRotate;
  106112. private _checkTeleportBackwards;
  106113. private _enableTeleportationOnController;
  106114. private _createTeleportationCircles;
  106115. private _displayTeleportationTarget;
  106116. private _hideTeleportationTarget;
  106117. private _rotateCamera;
  106118. private _moveTeleportationSelectorTo;
  106119. private _workingVector;
  106120. private _workingQuaternion;
  106121. private _workingMatrix;
  106122. /**
  106123. * Teleports the users feet to the desired location
  106124. * @param location The location where the user's feet should be placed
  106125. */
  106126. teleportCamera(location: Vector3): void;
  106127. private _convertNormalToDirectionOfRay;
  106128. private _castRayAndSelectObject;
  106129. private _notifySelectedMeshUnselected;
  106130. /**
  106131. * Sets the color of the laser ray from the vr controllers.
  106132. * @param color new color for the ray.
  106133. */
  106134. changeLaserColor(color: Color3): void;
  106135. /**
  106136. * Sets the color of the ray from the vr headsets gaze.
  106137. * @param color new color for the ray.
  106138. */
  106139. changeGazeColor(color: Color3): void;
  106140. /**
  106141. * Exits VR and disposes of the vr experience helper
  106142. */
  106143. dispose(): void;
  106144. /**
  106145. * Gets the name of the VRExperienceHelper class
  106146. * @returns "VRExperienceHelper"
  106147. */
  106148. getClassName(): string;
  106149. }
  106150. }
  106151. declare module BABYLON {
  106152. /**
  106153. * Manages an XRSession to work with Babylon's engine
  106154. * @see https://doc.babylonjs.com/how_to/webxr
  106155. */
  106156. export class WebXRSessionManager implements IDisposable {
  106157. private scene;
  106158. /**
  106159. * Fires every time a new xrFrame arrives which can be used to update the camera
  106160. */
  106161. onXRFrameObservable: Observable<any>;
  106162. /**
  106163. * Fires when the xr session is ended either by the device or manually done
  106164. */
  106165. onXRSessionEnded: Observable<any>;
  106166. /**
  106167. * Underlying xr session
  106168. */
  106169. session: XRSession;
  106170. /**
  106171. * Type of reference space used when creating the session
  106172. */
  106173. referenceSpace: XRReferenceSpace;
  106174. /** @hidden */
  106175. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  106176. /**
  106177. * Current XR frame
  106178. */
  106179. currentFrame: Nullable<XRFrame>;
  106180. private _xrNavigator;
  106181. private baseLayer;
  106182. /**
  106183. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  106184. * @param scene The scene which the session should be created for
  106185. */
  106186. constructor(scene: Scene);
  106187. /**
  106188. * Initializes the manager
  106189. * After initialization enterXR can be called to start an XR session
  106190. * @returns Promise which resolves after it is initialized
  106191. */
  106192. initializeAsync(): Promise<void>;
  106193. /**
  106194. * Initializes an xr session
  106195. * @param xrSessionMode mode to initialize
  106196. * @returns a promise which will resolve once the session has been initialized
  106197. */
  106198. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  106199. /**
  106200. * Sets the reference space on the xr session
  106201. * @param referenceSpace space to set
  106202. * @returns a promise that will resolve once the reference space has been set
  106203. */
  106204. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  106205. /**
  106206. * Updates the render state of the session
  106207. * @param state state to set
  106208. * @returns a promise that resolves once the render state has been updated
  106209. */
  106210. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  106211. /**
  106212. * Starts rendering to the xr layer
  106213. * @returns a promise that will resolve once rendering has started
  106214. */
  106215. startRenderingToXRAsync(): Promise<void>;
  106216. /**
  106217. * Stops the xrSession and restores the renderloop
  106218. * @returns Promise which resolves after it exits XR
  106219. */
  106220. exitXRAsync(): Promise<unknown>;
  106221. /**
  106222. * Checks if a session would be supported for the creation options specified
  106223. * @param sessionMode session mode to check if supported eg. immersive-vr
  106224. * @returns true if supported
  106225. */
  106226. supportsSessionAsync(sessionMode: XRSessionMode): any;
  106227. /**
  106228. * @hidden
  106229. * Converts the render layer of xrSession to a render target
  106230. * @param session session to create render target for
  106231. * @param scene scene the new render target should be created for
  106232. */
  106233. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  106234. /**
  106235. * Disposes of the session manager
  106236. */
  106237. dispose(): void;
  106238. }
  106239. }
  106240. declare module BABYLON {
  106241. /**
  106242. * WebXR Camera which holds the views for the xrSession
  106243. * @see https://doc.babylonjs.com/how_to/webxr
  106244. */
  106245. export class WebXRCamera extends FreeCamera {
  106246. private static _TmpMatrix;
  106247. /**
  106248. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  106249. * @param name the name of the camera
  106250. * @param scene the scene to add the camera to
  106251. */
  106252. constructor(name: string, scene: Scene);
  106253. private _updateNumberOfRigCameras;
  106254. /** @hidden */
  106255. _updateForDualEyeDebugging(pupilDistance?: number): void;
  106256. /**
  106257. * Updates the cameras position from the current pose information of the XR session
  106258. * @param xrSessionManager the session containing pose information
  106259. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  106260. */
  106261. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  106262. }
  106263. }
  106264. declare module BABYLON {
  106265. /**
  106266. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  106267. */
  106268. export class WebXRManagedOutputCanvas implements IDisposable {
  106269. private helper;
  106270. private _canvas;
  106271. /**
  106272. * xrpresent context of the canvas which can be used to display/mirror xr content
  106273. */
  106274. canvasContext: WebGLRenderingContext;
  106275. /**
  106276. * xr layer for the canvas
  106277. */
  106278. xrLayer: Nullable<XRWebGLLayer>;
  106279. /**
  106280. * Initializes the xr layer for the session
  106281. * @param xrSession xr session
  106282. * @returns a promise that will resolve once the XR Layer has been created
  106283. */
  106284. initializeXRLayerAsync(xrSession: any): any;
  106285. /**
  106286. * Initializes the canvas to be added/removed upon entering/exiting xr
  106287. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  106288. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  106289. */
  106290. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  106291. /**
  106292. * Disposes of the object
  106293. */
  106294. dispose(): void;
  106295. private _setManagedOutputCanvas;
  106296. private _addCanvas;
  106297. private _removeCanvas;
  106298. }
  106299. }
  106300. declare module BABYLON {
  106301. /**
  106302. * States of the webXR experience
  106303. */
  106304. export enum WebXRState {
  106305. /**
  106306. * Transitioning to being in XR mode
  106307. */
  106308. ENTERING_XR = 0,
  106309. /**
  106310. * Transitioning to non XR mode
  106311. */
  106312. EXITING_XR = 1,
  106313. /**
  106314. * In XR mode and presenting
  106315. */
  106316. IN_XR = 2,
  106317. /**
  106318. * Not entered XR mode
  106319. */
  106320. NOT_IN_XR = 3
  106321. }
  106322. /**
  106323. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  106324. * @see https://doc.babylonjs.com/how_to/webxr
  106325. */
  106326. export class WebXRExperienceHelper implements IDisposable {
  106327. private scene;
  106328. /**
  106329. * 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
  106330. */
  106331. container: AbstractMesh;
  106332. /**
  106333. * Camera used to render xr content
  106334. */
  106335. camera: WebXRCamera;
  106336. /**
  106337. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  106338. */
  106339. state: WebXRState;
  106340. private _setState;
  106341. private static _TmpVector;
  106342. /**
  106343. * Fires when the state of the experience helper has changed
  106344. */
  106345. onStateChangedObservable: Observable<WebXRState>;
  106346. /** Session manager used to keep track of xr session */
  106347. sessionManager: WebXRSessionManager;
  106348. private _nonVRCamera;
  106349. private _originalSceneAutoClear;
  106350. private _supported;
  106351. /**
  106352. * Creates the experience helper
  106353. * @param scene the scene to attach the experience helper to
  106354. * @returns a promise for the experience helper
  106355. */
  106356. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  106357. /**
  106358. * Creates a WebXRExperienceHelper
  106359. * @param scene The scene the helper should be created in
  106360. */
  106361. private constructor();
  106362. /**
  106363. * Exits XR mode and returns the scene to its original state
  106364. * @returns promise that resolves after xr mode has exited
  106365. */
  106366. exitXRAsync(): Promise<unknown>;
  106367. /**
  106368. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  106369. * @param sessionCreationOptions options for the XR session
  106370. * @param referenceSpaceType frame of reference of the XR session
  106371. * @param outputCanvas the output canvas that will be used to enter XR mode
  106372. * @returns promise that resolves after xr mode has entered
  106373. */
  106374. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  106375. /**
  106376. * Updates the global position of the camera by moving the camera's container
  106377. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  106378. * @param position The desired global position of the camera
  106379. */
  106380. setPositionOfCameraUsingContainer(position: Vector3): void;
  106381. /**
  106382. * Rotates the xr camera by rotating the camera's container around the camera's position
  106383. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  106384. * @param rotation the desired quaternion rotation to apply to the camera
  106385. */
  106386. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  106387. /**
  106388. * Disposes of the experience helper
  106389. */
  106390. dispose(): void;
  106391. }
  106392. }
  106393. declare module BABYLON {
  106394. /**
  106395. * Button which can be used to enter a different mode of XR
  106396. */
  106397. export class WebXREnterExitUIButton {
  106398. /** button element */
  106399. element: HTMLElement;
  106400. /** XR initialization options for the button */
  106401. sessionMode: XRSessionMode;
  106402. /** Reference space type */
  106403. referenceSpaceType: XRReferenceSpaceType;
  106404. /**
  106405. * Creates a WebXREnterExitUIButton
  106406. * @param element button element
  106407. * @param sessionMode XR initialization session mode
  106408. * @param referenceSpaceType the type of reference space to be used
  106409. */
  106410. constructor(
  106411. /** button element */
  106412. element: HTMLElement,
  106413. /** XR initialization options for the button */
  106414. sessionMode: XRSessionMode,
  106415. /** Reference space type */
  106416. referenceSpaceType: XRReferenceSpaceType);
  106417. /**
  106418. * Overwritable function which can be used to update the button's visuals when the state changes
  106419. * @param activeButton the current active button in the UI
  106420. */
  106421. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  106422. }
  106423. /**
  106424. * Options to create the webXR UI
  106425. */
  106426. export class WebXREnterExitUIOptions {
  106427. /**
  106428. * Context to enter xr with
  106429. */
  106430. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  106431. /**
  106432. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  106433. */
  106434. customButtons?: Array<WebXREnterExitUIButton>;
  106435. }
  106436. /**
  106437. * UI to allow the user to enter/exit XR mode
  106438. */
  106439. export class WebXREnterExitUI implements IDisposable {
  106440. private scene;
  106441. private _overlay;
  106442. private _buttons;
  106443. private _activeButton;
  106444. /**
  106445. * Fired every time the active button is changed.
  106446. *
  106447. * When xr is entered via a button that launches xr that button will be the callback parameter
  106448. *
  106449. * When exiting xr the callback parameter will be null)
  106450. */
  106451. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  106452. /**
  106453. * Creates UI to allow the user to enter/exit XR mode
  106454. * @param scene the scene to add the ui to
  106455. * @param helper the xr experience helper to enter/exit xr with
  106456. * @param options options to configure the UI
  106457. * @returns the created ui
  106458. */
  106459. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  106460. private constructor();
  106461. private _updateButtons;
  106462. /**
  106463. * Disposes of the object
  106464. */
  106465. dispose(): void;
  106466. }
  106467. }
  106468. declare module BABYLON {
  106469. /**
  106470. * Represents an XR input
  106471. */
  106472. export class WebXRController {
  106473. private scene;
  106474. /** The underlying input source for the controller */
  106475. inputSource: XRInputSource;
  106476. private parentContainer;
  106477. /**
  106478. * 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
  106479. */
  106480. grip?: AbstractMesh;
  106481. /**
  106482. * Pointer which can be used to select objects or attach a visible laser to
  106483. */
  106484. pointer: AbstractMesh;
  106485. /**
  106486. * Event that fires when the controller is removed/disposed
  106487. */
  106488. onDisposeObservable: Observable<{}>;
  106489. private _tmpMatrix;
  106490. private _tmpQuaternion;
  106491. private _tmpVector;
  106492. /**
  106493. * Creates the controller
  106494. * @see https://doc.babylonjs.com/how_to/webxr
  106495. * @param scene the scene which the controller should be associated to
  106496. * @param inputSource the underlying input source for the controller
  106497. * @param parentContainer parent that the controller meshes should be children of
  106498. */
  106499. constructor(scene: Scene,
  106500. /** The underlying input source for the controller */
  106501. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  106502. /**
  106503. * Updates the controller pose based on the given XRFrame
  106504. * @param xrFrame xr frame to update the pose with
  106505. * @param referenceSpace reference space to use
  106506. */
  106507. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  106508. /**
  106509. * Gets a world space ray coming from the controller
  106510. * @param result the resulting ray
  106511. */
  106512. getWorldPointerRayToRef(result: Ray): void;
  106513. /**
  106514. * Disposes of the object
  106515. */
  106516. dispose(): void;
  106517. }
  106518. }
  106519. declare module BABYLON {
  106520. /**
  106521. * XR input used to track XR inputs such as controllers/rays
  106522. */
  106523. export class WebXRInput implements IDisposable {
  106524. /**
  106525. * Base experience the input listens to
  106526. */
  106527. baseExperience: WebXRExperienceHelper;
  106528. /**
  106529. * XR controllers being tracked
  106530. */
  106531. controllers: Array<WebXRController>;
  106532. private _frameObserver;
  106533. private _stateObserver;
  106534. /**
  106535. * Event when a controller has been connected/added
  106536. */
  106537. onControllerAddedObservable: Observable<WebXRController>;
  106538. /**
  106539. * Event when a controller has been removed/disconnected
  106540. */
  106541. onControllerRemovedObservable: Observable<WebXRController>;
  106542. /**
  106543. * Initializes the WebXRInput
  106544. * @param baseExperience experience helper which the input should be created for
  106545. */
  106546. constructor(
  106547. /**
  106548. * Base experience the input listens to
  106549. */
  106550. baseExperience: WebXRExperienceHelper);
  106551. private _onInputSourcesChange;
  106552. private _addAndRemoveControllers;
  106553. /**
  106554. * Disposes of the object
  106555. */
  106556. dispose(): void;
  106557. }
  106558. }
  106559. declare module BABYLON {
  106560. /**
  106561. * Enables teleportation
  106562. */
  106563. export class WebXRControllerTeleportation {
  106564. private _teleportationFillColor;
  106565. private _teleportationBorderColor;
  106566. private _tmpRay;
  106567. private _tmpVector;
  106568. /**
  106569. * Creates a WebXRControllerTeleportation
  106570. * @param input input manager to add teleportation to
  106571. * @param floorMeshes floormeshes which can be teleported to
  106572. */
  106573. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  106574. }
  106575. }
  106576. declare module BABYLON {
  106577. /**
  106578. * Handles pointer input automatically for the pointer of XR controllers
  106579. */
  106580. export class WebXRControllerPointerSelection {
  106581. private static _idCounter;
  106582. private _tmpRay;
  106583. /**
  106584. * Creates a WebXRControllerPointerSelection
  106585. * @param input input manager to setup pointer selection
  106586. */
  106587. constructor(input: WebXRInput);
  106588. private _convertNormalToDirectionOfRay;
  106589. private _updatePointerDistance;
  106590. }
  106591. }
  106592. declare module BABYLON {
  106593. /**
  106594. * Class used to represent data loading progression
  106595. */
  106596. export class SceneLoaderProgressEvent {
  106597. /** defines if data length to load can be evaluated */
  106598. readonly lengthComputable: boolean;
  106599. /** defines the loaded data length */
  106600. readonly loaded: number;
  106601. /** defines the data length to load */
  106602. readonly total: number;
  106603. /**
  106604. * Create a new progress event
  106605. * @param lengthComputable defines if data length to load can be evaluated
  106606. * @param loaded defines the loaded data length
  106607. * @param total defines the data length to load
  106608. */
  106609. constructor(
  106610. /** defines if data length to load can be evaluated */
  106611. lengthComputable: boolean,
  106612. /** defines the loaded data length */
  106613. loaded: number,
  106614. /** defines the data length to load */
  106615. total: number);
  106616. /**
  106617. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  106618. * @param event defines the source event
  106619. * @returns a new SceneLoaderProgressEvent
  106620. */
  106621. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  106622. }
  106623. /**
  106624. * Interface used by SceneLoader plugins to define supported file extensions
  106625. */
  106626. export interface ISceneLoaderPluginExtensions {
  106627. /**
  106628. * Defines the list of supported extensions
  106629. */
  106630. [extension: string]: {
  106631. isBinary: boolean;
  106632. };
  106633. }
  106634. /**
  106635. * Interface used by SceneLoader plugin factory
  106636. */
  106637. export interface ISceneLoaderPluginFactory {
  106638. /**
  106639. * Defines the name of the factory
  106640. */
  106641. name: string;
  106642. /**
  106643. * Function called to create a new plugin
  106644. * @return the new plugin
  106645. */
  106646. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  106647. /**
  106648. * Boolean indicating if the plugin can direct load specific data
  106649. */
  106650. canDirectLoad?: (data: string) => boolean;
  106651. }
  106652. /**
  106653. * Interface used to define a SceneLoader plugin
  106654. */
  106655. export interface ISceneLoaderPlugin {
  106656. /**
  106657. * The friendly name of this plugin.
  106658. */
  106659. name: string;
  106660. /**
  106661. * The file extensions supported by this plugin.
  106662. */
  106663. extensions: string | ISceneLoaderPluginExtensions;
  106664. /**
  106665. * Import meshes into a scene.
  106666. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  106667. * @param scene The scene to import into
  106668. * @param data The data to import
  106669. * @param rootUrl The root url for scene and resources
  106670. * @param meshes The meshes array to import into
  106671. * @param particleSystems The particle systems array to import into
  106672. * @param skeletons The skeletons array to import into
  106673. * @param onError The callback when import fails
  106674. * @returns True if successful or false otherwise
  106675. */
  106676. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  106677. /**
  106678. * Load into a scene.
  106679. * @param scene The scene to load into
  106680. * @param data The data to import
  106681. * @param rootUrl The root url for scene and resources
  106682. * @param onError The callback when import fails
  106683. * @returns true if successful or false otherwise
  106684. */
  106685. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  106686. /**
  106687. * The callback that returns true if the data can be directly loaded.
  106688. */
  106689. canDirectLoad?: (data: string) => boolean;
  106690. /**
  106691. * The callback that allows custom handling of the root url based on the response url.
  106692. */
  106693. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  106694. /**
  106695. * Load into an asset container.
  106696. * @param scene The scene to load into
  106697. * @param data The data to import
  106698. * @param rootUrl The root url for scene and resources
  106699. * @param onError The callback when import fails
  106700. * @returns The loaded asset container
  106701. */
  106702. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  106703. }
  106704. /**
  106705. * Interface used to define an async SceneLoader plugin
  106706. */
  106707. export interface ISceneLoaderPluginAsync {
  106708. /**
  106709. * The friendly name of this plugin.
  106710. */
  106711. name: string;
  106712. /**
  106713. * The file extensions supported by this plugin.
  106714. */
  106715. extensions: string | ISceneLoaderPluginExtensions;
  106716. /**
  106717. * Import meshes into a scene.
  106718. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  106719. * @param scene The scene to import into
  106720. * @param data The data to import
  106721. * @param rootUrl The root url for scene and resources
  106722. * @param onProgress The callback when the load progresses
  106723. * @param fileName Defines the name of the file to load
  106724. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  106725. */
  106726. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  106727. meshes: AbstractMesh[];
  106728. particleSystems: IParticleSystem[];
  106729. skeletons: Skeleton[];
  106730. animationGroups: AnimationGroup[];
  106731. }>;
  106732. /**
  106733. * Load into a scene.
  106734. * @param scene The scene to load into
  106735. * @param data The data to import
  106736. * @param rootUrl The root url for scene and resources
  106737. * @param onProgress The callback when the load progresses
  106738. * @param fileName Defines the name of the file to load
  106739. * @returns Nothing
  106740. */
  106741. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  106742. /**
  106743. * The callback that returns true if the data can be directly loaded.
  106744. */
  106745. canDirectLoad?: (data: string) => boolean;
  106746. /**
  106747. * The callback that allows custom handling of the root url based on the response url.
  106748. */
  106749. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  106750. /**
  106751. * Load into an asset container.
  106752. * @param scene The scene to load into
  106753. * @param data The data to import
  106754. * @param rootUrl The root url for scene and resources
  106755. * @param onProgress The callback when the load progresses
  106756. * @param fileName Defines the name of the file to load
  106757. * @returns The loaded asset container
  106758. */
  106759. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  106760. }
  106761. /**
  106762. * Class used to load scene from various file formats using registered plugins
  106763. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  106764. */
  106765. export class SceneLoader {
  106766. /**
  106767. * No logging while loading
  106768. */
  106769. static readonly NO_LOGGING: number;
  106770. /**
  106771. * Minimal logging while loading
  106772. */
  106773. static readonly MINIMAL_LOGGING: number;
  106774. /**
  106775. * Summary logging while loading
  106776. */
  106777. static readonly SUMMARY_LOGGING: number;
  106778. /**
  106779. * Detailled logging while loading
  106780. */
  106781. static readonly DETAILED_LOGGING: number;
  106782. /**
  106783. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  106784. */
  106785. static ForceFullSceneLoadingForIncremental: boolean;
  106786. /**
  106787. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  106788. */
  106789. static ShowLoadingScreen: boolean;
  106790. /**
  106791. * Defines the current logging level (while loading the scene)
  106792. * @ignorenaming
  106793. */
  106794. static loggingLevel: number;
  106795. /**
  106796. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  106797. */
  106798. static CleanBoneMatrixWeights: boolean;
  106799. /**
  106800. * Event raised when a plugin is used to load a scene
  106801. */
  106802. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  106803. private static _registeredPlugins;
  106804. private static _getDefaultPlugin;
  106805. private static _getPluginForExtension;
  106806. private static _getPluginForDirectLoad;
  106807. private static _getPluginForFilename;
  106808. private static _getDirectLoad;
  106809. private static _loadData;
  106810. private static _getFileInfo;
  106811. /**
  106812. * Gets a plugin that can load the given extension
  106813. * @param extension defines the extension to load
  106814. * @returns a plugin or null if none works
  106815. */
  106816. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  106817. /**
  106818. * Gets a boolean indicating that the given extension can be loaded
  106819. * @param extension defines the extension to load
  106820. * @returns true if the extension is supported
  106821. */
  106822. static IsPluginForExtensionAvailable(extension: string): boolean;
  106823. /**
  106824. * Adds a new plugin to the list of registered plugins
  106825. * @param plugin defines the plugin to add
  106826. */
  106827. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  106828. /**
  106829. * Import meshes into a scene
  106830. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  106831. * @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)
  106832. * @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)
  106833. * @param scene the instance of BABYLON.Scene to append to
  106834. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  106835. * @param onProgress a callback with a progress event for each file being loaded
  106836. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  106837. * @param pluginExtension the extension used to determine the plugin
  106838. * @returns The loaded plugin
  106839. */
  106840. 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>;
  106841. /**
  106842. * Import meshes into a scene
  106843. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  106844. * @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)
  106845. * @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)
  106846. * @param scene the instance of BABYLON.Scene to append to
  106847. * @param onProgress a callback with a progress event for each file being loaded
  106848. * @param pluginExtension the extension used to determine the plugin
  106849. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  106850. */
  106851. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  106852. meshes: AbstractMesh[];
  106853. particleSystems: IParticleSystem[];
  106854. skeletons: Skeleton[];
  106855. animationGroups: AnimationGroup[];
  106856. }>;
  106857. /**
  106858. * Load a scene
  106859. * @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)
  106860. * @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)
  106861. * @param engine is the instance of BABYLON.Engine to use to create the scene
  106862. * @param onSuccess a callback with the scene when import succeeds
  106863. * @param onProgress a callback with a progress event for each file being loaded
  106864. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  106865. * @param pluginExtension the extension used to determine the plugin
  106866. * @returns The loaded plugin
  106867. */
  106868. 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>;
  106869. /**
  106870. * Load a scene
  106871. * @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)
  106872. * @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)
  106873. * @param engine is the instance of BABYLON.Engine to use to create the scene
  106874. * @param onProgress a callback with a progress event for each file being loaded
  106875. * @param pluginExtension the extension used to determine the plugin
  106876. * @returns The loaded scene
  106877. */
  106878. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  106879. /**
  106880. * Append a scene
  106881. * @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)
  106882. * @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)
  106883. * @param scene is the instance of BABYLON.Scene to append to
  106884. * @param onSuccess a callback with the scene when import succeeds
  106885. * @param onProgress a callback with a progress event for each file being loaded
  106886. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  106887. * @param pluginExtension the extension used to determine the plugin
  106888. * @returns The loaded plugin
  106889. */
  106890. 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>;
  106891. /**
  106892. * Append a scene
  106893. * @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)
  106894. * @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)
  106895. * @param scene is the instance of BABYLON.Scene to append to
  106896. * @param onProgress a callback with a progress event for each file being loaded
  106897. * @param pluginExtension the extension used to determine the plugin
  106898. * @returns The given scene
  106899. */
  106900. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  106901. /**
  106902. * Load a scene into an asset container
  106903. * @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)
  106904. * @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)
  106905. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  106906. * @param onSuccess a callback with the scene when import succeeds
  106907. * @param onProgress a callback with a progress event for each file being loaded
  106908. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  106909. * @param pluginExtension the extension used to determine the plugin
  106910. * @returns The loaded plugin
  106911. */
  106912. 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>;
  106913. /**
  106914. * Load a scene into an asset container
  106915. * @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)
  106916. * @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)
  106917. * @param scene is the instance of Scene to append to
  106918. * @param onProgress a callback with a progress event for each file being loaded
  106919. * @param pluginExtension the extension used to determine the plugin
  106920. * @returns The loaded asset container
  106921. */
  106922. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  106923. }
  106924. }
  106925. declare module BABYLON {
  106926. /**
  106927. * Generic Controller
  106928. */
  106929. export class GenericController extends WebVRController {
  106930. /**
  106931. * Base Url for the controller model.
  106932. */
  106933. static readonly MODEL_BASE_URL: string;
  106934. /**
  106935. * File name for the controller model.
  106936. */
  106937. static readonly MODEL_FILENAME: string;
  106938. /**
  106939. * Creates a new GenericController from a gamepad
  106940. * @param vrGamepad the gamepad that the controller should be created from
  106941. */
  106942. constructor(vrGamepad: any);
  106943. /**
  106944. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  106945. * @param scene scene in which to add meshes
  106946. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  106947. */
  106948. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  106949. /**
  106950. * Called once for each button that changed state since the last frame
  106951. * @param buttonIdx Which button index changed
  106952. * @param state New state of the button
  106953. * @param changes Which properties on the state changed since last frame
  106954. */
  106955. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  106956. }
  106957. }
  106958. declare module BABYLON {
  106959. /**
  106960. * Defines the WindowsMotionController object that the state of the windows motion controller
  106961. */
  106962. export class WindowsMotionController extends WebVRController {
  106963. /**
  106964. * The base url used to load the left and right controller models
  106965. */
  106966. static MODEL_BASE_URL: string;
  106967. /**
  106968. * The name of the left controller model file
  106969. */
  106970. static MODEL_LEFT_FILENAME: string;
  106971. /**
  106972. * The name of the right controller model file
  106973. */
  106974. static MODEL_RIGHT_FILENAME: string;
  106975. /**
  106976. * The controller name prefix for this controller type
  106977. */
  106978. static readonly GAMEPAD_ID_PREFIX: string;
  106979. /**
  106980. * The controller id pattern for this controller type
  106981. */
  106982. private static readonly GAMEPAD_ID_PATTERN;
  106983. private _loadedMeshInfo;
  106984. private readonly _mapping;
  106985. /**
  106986. * Fired when the trackpad on this controller is clicked
  106987. */
  106988. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  106989. /**
  106990. * Fired when the trackpad on this controller is modified
  106991. */
  106992. onTrackpadValuesChangedObservable: Observable<StickValues>;
  106993. /**
  106994. * The current x and y values of this controller's trackpad
  106995. */
  106996. trackpad: StickValues;
  106997. /**
  106998. * Creates a new WindowsMotionController from a gamepad
  106999. * @param vrGamepad the gamepad that the controller should be created from
  107000. */
  107001. constructor(vrGamepad: any);
  107002. /**
  107003. * Fired when the trigger on this controller is modified
  107004. */
  107005. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107006. /**
  107007. * Fired when the menu button on this controller is modified
  107008. */
  107009. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107010. /**
  107011. * Fired when the grip button on this controller is modified
  107012. */
  107013. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107014. /**
  107015. * Fired when the thumbstick button on this controller is modified
  107016. */
  107017. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107018. /**
  107019. * Fired when the touchpad button on this controller is modified
  107020. */
  107021. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107022. /**
  107023. * Fired when the touchpad values on this controller are modified
  107024. */
  107025. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  107026. private _updateTrackpad;
  107027. /**
  107028. * Called once per frame by the engine.
  107029. */
  107030. update(): void;
  107031. /**
  107032. * Called once for each button that changed state since the last frame
  107033. * @param buttonIdx Which button index changed
  107034. * @param state New state of the button
  107035. * @param changes Which properties on the state changed since last frame
  107036. */
  107037. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  107038. /**
  107039. * Moves the buttons on the controller mesh based on their current state
  107040. * @param buttonName the name of the button to move
  107041. * @param buttonValue the value of the button which determines the buttons new position
  107042. */
  107043. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  107044. /**
  107045. * Moves the axis on the controller mesh based on its current state
  107046. * @param axis the index of the axis
  107047. * @param axisValue the value of the axis which determines the meshes new position
  107048. * @hidden
  107049. */
  107050. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  107051. /**
  107052. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  107053. * @param scene scene in which to add meshes
  107054. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  107055. */
  107056. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  107057. /**
  107058. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  107059. * can be transformed by button presses and axes values, based on this._mapping.
  107060. *
  107061. * @param scene scene in which the meshes exist
  107062. * @param meshes list of meshes that make up the controller model to process
  107063. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  107064. */
  107065. private processModel;
  107066. private createMeshInfo;
  107067. /**
  107068. * Gets the ray of the controller in the direction the controller is pointing
  107069. * @param length the length the resulting ray should be
  107070. * @returns a ray in the direction the controller is pointing
  107071. */
  107072. getForwardRay(length?: number): Ray;
  107073. /**
  107074. * Disposes of the controller
  107075. */
  107076. dispose(): void;
  107077. }
  107078. }
  107079. declare module BABYLON {
  107080. /**
  107081. * Oculus Touch Controller
  107082. */
  107083. export class OculusTouchController extends WebVRController {
  107084. /**
  107085. * Base Url for the controller model.
  107086. */
  107087. static MODEL_BASE_URL: string;
  107088. /**
  107089. * File name for the left controller model.
  107090. */
  107091. static MODEL_LEFT_FILENAME: string;
  107092. /**
  107093. * File name for the right controller model.
  107094. */
  107095. static MODEL_RIGHT_FILENAME: string;
  107096. /**
  107097. * Base Url for the Quest controller model.
  107098. */
  107099. static QUEST_MODEL_BASE_URL: string;
  107100. /**
  107101. * @hidden
  107102. * If the controllers are running on a device that needs the updated Quest controller models
  107103. */
  107104. static _IsQuest: boolean;
  107105. /**
  107106. * Fired when the secondary trigger on this controller is modified
  107107. */
  107108. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  107109. /**
  107110. * Fired when the thumb rest on this controller is modified
  107111. */
  107112. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  107113. /**
  107114. * Creates a new OculusTouchController from a gamepad
  107115. * @param vrGamepad the gamepad that the controller should be created from
  107116. */
  107117. constructor(vrGamepad: any);
  107118. /**
  107119. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  107120. * @param scene scene in which to add meshes
  107121. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  107122. */
  107123. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  107124. /**
  107125. * Fired when the A button on this controller is modified
  107126. */
  107127. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107128. /**
  107129. * Fired when the B button on this controller is modified
  107130. */
  107131. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107132. /**
  107133. * Fired when the X button on this controller is modified
  107134. */
  107135. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107136. /**
  107137. * Fired when the Y button on this controller is modified
  107138. */
  107139. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107140. /**
  107141. * Called once for each button that changed state since the last frame
  107142. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  107143. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  107144. * 2) secondary trigger (same)
  107145. * 3) A (right) X (left), touch, pressed = value
  107146. * 4) B / Y
  107147. * 5) thumb rest
  107148. * @param buttonIdx Which button index changed
  107149. * @param state New state of the button
  107150. * @param changes Which properties on the state changed since last frame
  107151. */
  107152. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  107153. }
  107154. }
  107155. declare module BABYLON {
  107156. /**
  107157. * Vive Controller
  107158. */
  107159. export class ViveController extends WebVRController {
  107160. /**
  107161. * Base Url for the controller model.
  107162. */
  107163. static MODEL_BASE_URL: string;
  107164. /**
  107165. * File name for the controller model.
  107166. */
  107167. static MODEL_FILENAME: string;
  107168. /**
  107169. * Creates a new ViveController from a gamepad
  107170. * @param vrGamepad the gamepad that the controller should be created from
  107171. */
  107172. constructor(vrGamepad: any);
  107173. /**
  107174. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  107175. * @param scene scene in which to add meshes
  107176. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  107177. */
  107178. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  107179. /**
  107180. * Fired when the left button on this controller is modified
  107181. */
  107182. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107183. /**
  107184. * Fired when the right button on this controller is modified
  107185. */
  107186. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107187. /**
  107188. * Fired when the menu button on this controller is modified
  107189. */
  107190. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107191. /**
  107192. * Called once for each button that changed state since the last frame
  107193. * Vive mapping:
  107194. * 0: touchpad
  107195. * 1: trigger
  107196. * 2: left AND right buttons
  107197. * 3: menu button
  107198. * @param buttonIdx Which button index changed
  107199. * @param state New state of the button
  107200. * @param changes Which properties on the state changed since last frame
  107201. */
  107202. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  107203. }
  107204. }
  107205. declare module BABYLON {
  107206. /**
  107207. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  107208. */
  107209. export class WebXRControllerModelLoader {
  107210. /**
  107211. * Creates the WebXRControllerModelLoader
  107212. * @param input xr input that creates the controllers
  107213. */
  107214. constructor(input: WebXRInput);
  107215. }
  107216. }
  107217. declare module BABYLON {
  107218. /**
  107219. * Contains an array of blocks representing the octree
  107220. */
  107221. export interface IOctreeContainer<T> {
  107222. /**
  107223. * Blocks within the octree
  107224. */
  107225. blocks: Array<OctreeBlock<T>>;
  107226. }
  107227. /**
  107228. * Class used to store a cell in an octree
  107229. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  107230. */
  107231. export class OctreeBlock<T> {
  107232. /**
  107233. * Gets the content of the current block
  107234. */
  107235. entries: T[];
  107236. /**
  107237. * Gets the list of block children
  107238. */
  107239. blocks: Array<OctreeBlock<T>>;
  107240. private _depth;
  107241. private _maxDepth;
  107242. private _capacity;
  107243. private _minPoint;
  107244. private _maxPoint;
  107245. private _boundingVectors;
  107246. private _creationFunc;
  107247. /**
  107248. * Creates a new block
  107249. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  107250. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  107251. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  107252. * @param depth defines the current depth of this block in the octree
  107253. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  107254. * @param creationFunc defines a callback to call when an element is added to the block
  107255. */
  107256. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  107257. /**
  107258. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  107259. */
  107260. readonly capacity: number;
  107261. /**
  107262. * Gets the minimum vector (in world space) of the block's bounding box
  107263. */
  107264. readonly minPoint: Vector3;
  107265. /**
  107266. * Gets the maximum vector (in world space) of the block's bounding box
  107267. */
  107268. readonly maxPoint: Vector3;
  107269. /**
  107270. * Add a new element to this block
  107271. * @param entry defines the element to add
  107272. */
  107273. addEntry(entry: T): void;
  107274. /**
  107275. * Remove an element from this block
  107276. * @param entry defines the element to remove
  107277. */
  107278. removeEntry(entry: T): void;
  107279. /**
  107280. * Add an array of elements to this block
  107281. * @param entries defines the array of elements to add
  107282. */
  107283. addEntries(entries: T[]): void;
  107284. /**
  107285. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  107286. * @param frustumPlanes defines the frustum planes to test
  107287. * @param selection defines the array to store current content if selection is positive
  107288. * @param allowDuplicate defines if the selection array can contains duplicated entries
  107289. */
  107290. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  107291. /**
  107292. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  107293. * @param sphereCenter defines the bounding sphere center
  107294. * @param sphereRadius defines the bounding sphere radius
  107295. * @param selection defines the array to store current content if selection is positive
  107296. * @param allowDuplicate defines if the selection array can contains duplicated entries
  107297. */
  107298. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  107299. /**
  107300. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  107301. * @param ray defines the ray to test with
  107302. * @param selection defines the array to store current content if selection is positive
  107303. */
  107304. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  107305. /**
  107306. * Subdivide the content into child blocks (this block will then be empty)
  107307. */
  107308. createInnerBlocks(): void;
  107309. /**
  107310. * @hidden
  107311. */
  107312. 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;
  107313. }
  107314. }
  107315. declare module BABYLON {
  107316. /**
  107317. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  107318. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  107319. */
  107320. export class Octree<T> {
  107321. /** 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.) */
  107322. maxDepth: number;
  107323. /**
  107324. * Blocks within the octree containing objects
  107325. */
  107326. blocks: Array<OctreeBlock<T>>;
  107327. /**
  107328. * Content stored in the octree
  107329. */
  107330. dynamicContent: T[];
  107331. private _maxBlockCapacity;
  107332. private _selectionContent;
  107333. private _creationFunc;
  107334. /**
  107335. * Creates a octree
  107336. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  107337. * @param creationFunc function to be used to instatiate the octree
  107338. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  107339. * @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.)
  107340. */
  107341. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  107342. /** 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.) */
  107343. maxDepth?: number);
  107344. /**
  107345. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  107346. * @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);
  107347. * @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);
  107348. * @param entries meshes to be added to the octree blocks
  107349. */
  107350. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  107351. /**
  107352. * Adds a mesh to the octree
  107353. * @param entry Mesh to add to the octree
  107354. */
  107355. addMesh(entry: T): void;
  107356. /**
  107357. * Remove an element from the octree
  107358. * @param entry defines the element to remove
  107359. */
  107360. removeMesh(entry: T): void;
  107361. /**
  107362. * Selects an array of meshes within the frustum
  107363. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  107364. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  107365. * @returns array of meshes within the frustum
  107366. */
  107367. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  107368. /**
  107369. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  107370. * @param sphereCenter defines the bounding sphere center
  107371. * @param sphereRadius defines the bounding sphere radius
  107372. * @param allowDuplicate defines if the selection array can contains duplicated entries
  107373. * @returns an array of objects that intersect the sphere
  107374. */
  107375. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  107376. /**
  107377. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  107378. * @param ray defines the ray to test with
  107379. * @returns array of intersected objects
  107380. */
  107381. intersectsRay(ray: Ray): SmartArray<T>;
  107382. /**
  107383. * Adds a mesh into the octree block if it intersects the block
  107384. */
  107385. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  107386. /**
  107387. * Adds a submesh into the octree block if it intersects the block
  107388. */
  107389. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  107390. }
  107391. }
  107392. declare module BABYLON {
  107393. interface Scene {
  107394. /**
  107395. * @hidden
  107396. * Backing Filed
  107397. */
  107398. _selectionOctree: Octree<AbstractMesh>;
  107399. /**
  107400. * Gets the octree used to boost mesh selection (picking)
  107401. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  107402. */
  107403. selectionOctree: Octree<AbstractMesh>;
  107404. /**
  107405. * Creates or updates the octree used to boost selection (picking)
  107406. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  107407. * @param maxCapacity defines the maximum capacity per leaf
  107408. * @param maxDepth defines the maximum depth of the octree
  107409. * @returns an octree of AbstractMesh
  107410. */
  107411. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  107412. }
  107413. interface AbstractMesh {
  107414. /**
  107415. * @hidden
  107416. * Backing Field
  107417. */
  107418. _submeshesOctree: Octree<SubMesh>;
  107419. /**
  107420. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  107421. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  107422. * @param maxCapacity defines the maximum size of each block (64 by default)
  107423. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  107424. * @returns the new octree
  107425. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  107426. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  107427. */
  107428. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  107429. }
  107430. /**
  107431. * Defines the octree scene component responsible to manage any octrees
  107432. * in a given scene.
  107433. */
  107434. export class OctreeSceneComponent {
  107435. /**
  107436. * The component name help to identify the component in the list of scene components.
  107437. */
  107438. readonly name: string;
  107439. /**
  107440. * The scene the component belongs to.
  107441. */
  107442. scene: Scene;
  107443. /**
  107444. * Indicates if the meshes have been checked to make sure they are isEnabled()
  107445. */
  107446. readonly checksIsEnabled: boolean;
  107447. /**
  107448. * Creates a new instance of the component for the given scene
  107449. * @param scene Defines the scene to register the component in
  107450. */
  107451. constructor(scene: Scene);
  107452. /**
  107453. * Registers the component in a given scene
  107454. */
  107455. register(): void;
  107456. /**
  107457. * Return the list of active meshes
  107458. * @returns the list of active meshes
  107459. */
  107460. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  107461. /**
  107462. * Return the list of active sub meshes
  107463. * @param mesh The mesh to get the candidates sub meshes from
  107464. * @returns the list of active sub meshes
  107465. */
  107466. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  107467. private _tempRay;
  107468. /**
  107469. * Return the list of sub meshes intersecting with a given local ray
  107470. * @param mesh defines the mesh to find the submesh for
  107471. * @param localRay defines the ray in local space
  107472. * @returns the list of intersecting sub meshes
  107473. */
  107474. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  107475. /**
  107476. * Return the list of sub meshes colliding with a collider
  107477. * @param mesh defines the mesh to find the submesh for
  107478. * @param collider defines the collider to evaluate the collision against
  107479. * @returns the list of colliding sub meshes
  107480. */
  107481. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  107482. /**
  107483. * Rebuilds the elements related to this component in case of
  107484. * context lost for instance.
  107485. */
  107486. rebuild(): void;
  107487. /**
  107488. * Disposes the component and the associated ressources.
  107489. */
  107490. dispose(): void;
  107491. }
  107492. }
  107493. declare module BABYLON {
  107494. /**
  107495. * Renders a layer on top of an existing scene
  107496. */
  107497. export class UtilityLayerRenderer implements IDisposable {
  107498. /** the original scene that will be rendered on top of */
  107499. originalScene: Scene;
  107500. private _pointerCaptures;
  107501. private _lastPointerEvents;
  107502. private static _DefaultUtilityLayer;
  107503. private static _DefaultKeepDepthUtilityLayer;
  107504. private _sharedGizmoLight;
  107505. private _renderCamera;
  107506. /**
  107507. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  107508. * @returns the camera that is used when rendering the utility layer
  107509. */
  107510. getRenderCamera(): Nullable<Camera>;
  107511. /**
  107512. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  107513. * @param cam the camera that should be used when rendering the utility layer
  107514. */
  107515. setRenderCamera(cam: Nullable<Camera>): void;
  107516. /**
  107517. * @hidden
  107518. * Light which used by gizmos to get light shading
  107519. */
  107520. _getSharedGizmoLight(): HemisphericLight;
  107521. /**
  107522. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  107523. */
  107524. pickUtilitySceneFirst: boolean;
  107525. /**
  107526. * 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)
  107527. */
  107528. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  107529. /**
  107530. * 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)
  107531. */
  107532. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  107533. /**
  107534. * The scene that is rendered on top of the original scene
  107535. */
  107536. utilityLayerScene: Scene;
  107537. /**
  107538. * If the utility layer should automatically be rendered on top of existing scene
  107539. */
  107540. shouldRender: boolean;
  107541. /**
  107542. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  107543. */
  107544. onlyCheckPointerDownEvents: boolean;
  107545. /**
  107546. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  107547. */
  107548. processAllEvents: boolean;
  107549. /**
  107550. * Observable raised when the pointer move from the utility layer scene to the main scene
  107551. */
  107552. onPointerOutObservable: Observable<number>;
  107553. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  107554. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  107555. private _afterRenderObserver;
  107556. private _sceneDisposeObserver;
  107557. private _originalPointerObserver;
  107558. /**
  107559. * Instantiates a UtilityLayerRenderer
  107560. * @param originalScene the original scene that will be rendered on top of
  107561. * @param handleEvents boolean indicating if the utility layer should handle events
  107562. */
  107563. constructor(
  107564. /** the original scene that will be rendered on top of */
  107565. originalScene: Scene, handleEvents?: boolean);
  107566. private _notifyObservers;
  107567. /**
  107568. * Renders the utility layers scene on top of the original scene
  107569. */
  107570. render(): void;
  107571. /**
  107572. * Disposes of the renderer
  107573. */
  107574. dispose(): void;
  107575. private _updateCamera;
  107576. }
  107577. }
  107578. declare module BABYLON {
  107579. /**
  107580. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  107581. */
  107582. export class Gizmo implements IDisposable {
  107583. /** The utility layer the gizmo will be added to */
  107584. gizmoLayer: UtilityLayerRenderer;
  107585. /**
  107586. * The root mesh of the gizmo
  107587. */
  107588. _rootMesh: Mesh;
  107589. private _attachedMesh;
  107590. /**
  107591. * Ratio for the scale of the gizmo (Default: 1)
  107592. */
  107593. scaleRatio: number;
  107594. /**
  107595. * If a custom mesh has been set (Default: false)
  107596. */
  107597. protected _customMeshSet: boolean;
  107598. /**
  107599. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  107600. * * When set, interactions will be enabled
  107601. */
  107602. attachedMesh: Nullable<AbstractMesh>;
  107603. /**
  107604. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  107605. * @param mesh The mesh to replace the default mesh of the gizmo
  107606. */
  107607. setCustomMesh(mesh: Mesh): void;
  107608. /**
  107609. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  107610. */
  107611. updateGizmoRotationToMatchAttachedMesh: boolean;
  107612. /**
  107613. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  107614. */
  107615. updateGizmoPositionToMatchAttachedMesh: boolean;
  107616. /**
  107617. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  107618. */
  107619. updateScale: boolean;
  107620. protected _interactionsEnabled: boolean;
  107621. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  107622. private _beforeRenderObserver;
  107623. private _tempVector;
  107624. /**
  107625. * Creates a gizmo
  107626. * @param gizmoLayer The utility layer the gizmo will be added to
  107627. */
  107628. constructor(
  107629. /** The utility layer the gizmo will be added to */
  107630. gizmoLayer?: UtilityLayerRenderer);
  107631. /**
  107632. * Updates the gizmo to match the attached mesh's position/rotation
  107633. */
  107634. protected _update(): void;
  107635. /**
  107636. * Disposes of the gizmo
  107637. */
  107638. dispose(): void;
  107639. }
  107640. }
  107641. declare module BABYLON {
  107642. /**
  107643. * Single plane drag gizmo
  107644. */
  107645. export class PlaneDragGizmo extends Gizmo {
  107646. /**
  107647. * Drag behavior responsible for the gizmos dragging interactions
  107648. */
  107649. dragBehavior: PointerDragBehavior;
  107650. private _pointerObserver;
  107651. /**
  107652. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  107653. */
  107654. snapDistance: number;
  107655. /**
  107656. * Event that fires each time the gizmo snaps to a new location.
  107657. * * snapDistance is the the change in distance
  107658. */
  107659. onSnapObservable: Observable<{
  107660. snapDistance: number;
  107661. }>;
  107662. private _plane;
  107663. private _coloredMaterial;
  107664. private _hoverMaterial;
  107665. private _isEnabled;
  107666. private _parent;
  107667. /** @hidden */
  107668. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  107669. /** @hidden */
  107670. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  107671. /**
  107672. * Creates a PlaneDragGizmo
  107673. * @param gizmoLayer The utility layer the gizmo will be added to
  107674. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  107675. * @param color The color of the gizmo
  107676. */
  107677. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  107678. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  107679. /**
  107680. * If the gizmo is enabled
  107681. */
  107682. isEnabled: boolean;
  107683. /**
  107684. * Disposes of the gizmo
  107685. */
  107686. dispose(): void;
  107687. }
  107688. }
  107689. declare module BABYLON {
  107690. /**
  107691. * Gizmo that enables dragging a mesh along 3 axis
  107692. */
  107693. export class PositionGizmo extends Gizmo {
  107694. /**
  107695. * Internal gizmo used for interactions on the x axis
  107696. */
  107697. xGizmo: AxisDragGizmo;
  107698. /**
  107699. * Internal gizmo used for interactions on the y axis
  107700. */
  107701. yGizmo: AxisDragGizmo;
  107702. /**
  107703. * Internal gizmo used for interactions on the z axis
  107704. */
  107705. zGizmo: AxisDragGizmo;
  107706. /**
  107707. * Internal gizmo used for interactions on the yz plane
  107708. */
  107709. xPlaneGizmo: PlaneDragGizmo;
  107710. /**
  107711. * Internal gizmo used for interactions on the xz plane
  107712. */
  107713. yPlaneGizmo: PlaneDragGizmo;
  107714. /**
  107715. * Internal gizmo used for interactions on the xy plane
  107716. */
  107717. zPlaneGizmo: PlaneDragGizmo;
  107718. /**
  107719. * private variables
  107720. */
  107721. private _meshAttached;
  107722. private _updateGizmoRotationToMatchAttachedMesh;
  107723. private _snapDistance;
  107724. private _scaleRatio;
  107725. /** Fires an event when any of it's sub gizmos are dragged */
  107726. onDragStartObservable: Observable<unknown>;
  107727. /** Fires an event when any of it's sub gizmos are released from dragging */
  107728. onDragEndObservable: Observable<unknown>;
  107729. /**
  107730. * If set to true, planar drag is enabled
  107731. */
  107732. private _planarGizmoEnabled;
  107733. attachedMesh: Nullable<AbstractMesh>;
  107734. /**
  107735. * Creates a PositionGizmo
  107736. * @param gizmoLayer The utility layer the gizmo will be added to
  107737. */
  107738. constructor(gizmoLayer?: UtilityLayerRenderer);
  107739. /**
  107740. * If the planar drag gizmo is enabled
  107741. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  107742. */
  107743. planarGizmoEnabled: boolean;
  107744. updateGizmoRotationToMatchAttachedMesh: boolean;
  107745. /**
  107746. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  107747. */
  107748. snapDistance: number;
  107749. /**
  107750. * Ratio for the scale of the gizmo (Default: 1)
  107751. */
  107752. scaleRatio: number;
  107753. /**
  107754. * Disposes of the gizmo
  107755. */
  107756. dispose(): void;
  107757. /**
  107758. * CustomMeshes are not supported by this gizmo
  107759. * @param mesh The mesh to replace the default mesh of the gizmo
  107760. */
  107761. setCustomMesh(mesh: Mesh): void;
  107762. }
  107763. }
  107764. declare module BABYLON {
  107765. /**
  107766. * Single axis drag gizmo
  107767. */
  107768. export class AxisDragGizmo extends Gizmo {
  107769. /**
  107770. * Drag behavior responsible for the gizmos dragging interactions
  107771. */
  107772. dragBehavior: PointerDragBehavior;
  107773. private _pointerObserver;
  107774. /**
  107775. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  107776. */
  107777. snapDistance: number;
  107778. /**
  107779. * Event that fires each time the gizmo snaps to a new location.
  107780. * * snapDistance is the the change in distance
  107781. */
  107782. onSnapObservable: Observable<{
  107783. snapDistance: number;
  107784. }>;
  107785. private _isEnabled;
  107786. private _parent;
  107787. private _arrow;
  107788. private _coloredMaterial;
  107789. private _hoverMaterial;
  107790. /** @hidden */
  107791. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  107792. /** @hidden */
  107793. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  107794. /**
  107795. * Creates an AxisDragGizmo
  107796. * @param gizmoLayer The utility layer the gizmo will be added to
  107797. * @param dragAxis The axis which the gizmo will be able to drag on
  107798. * @param color The color of the gizmo
  107799. */
  107800. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  107801. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  107802. /**
  107803. * If the gizmo is enabled
  107804. */
  107805. isEnabled: boolean;
  107806. /**
  107807. * Disposes of the gizmo
  107808. */
  107809. dispose(): void;
  107810. }
  107811. }
  107812. declare module BABYLON.Debug {
  107813. /**
  107814. * The Axes viewer will show 3 axes in a specific point in space
  107815. */
  107816. export class AxesViewer {
  107817. private _xAxis;
  107818. private _yAxis;
  107819. private _zAxis;
  107820. private _scaleLinesFactor;
  107821. private _instanced;
  107822. /**
  107823. * Gets the hosting scene
  107824. */
  107825. scene: Scene;
  107826. /**
  107827. * Gets or sets a number used to scale line length
  107828. */
  107829. scaleLines: number;
  107830. /** Gets the node hierarchy used to render x-axis */
  107831. readonly xAxis: TransformNode;
  107832. /** Gets the node hierarchy used to render y-axis */
  107833. readonly yAxis: TransformNode;
  107834. /** Gets the node hierarchy used to render z-axis */
  107835. readonly zAxis: TransformNode;
  107836. /**
  107837. * Creates a new AxesViewer
  107838. * @param scene defines the hosting scene
  107839. * @param scaleLines defines a number used to scale line length (1 by default)
  107840. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  107841. * @param xAxis defines the node hierarchy used to render the x-axis
  107842. * @param yAxis defines the node hierarchy used to render the y-axis
  107843. * @param zAxis defines the node hierarchy used to render the z-axis
  107844. */
  107845. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  107846. /**
  107847. * Force the viewer to update
  107848. * @param position defines the position of the viewer
  107849. * @param xaxis defines the x axis of the viewer
  107850. * @param yaxis defines the y axis of the viewer
  107851. * @param zaxis defines the z axis of the viewer
  107852. */
  107853. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  107854. /**
  107855. * Creates an instance of this axes viewer.
  107856. * @returns a new axes viewer with instanced meshes
  107857. */
  107858. createInstance(): AxesViewer;
  107859. /** Releases resources */
  107860. dispose(): void;
  107861. private static _SetRenderingGroupId;
  107862. }
  107863. }
  107864. declare module BABYLON.Debug {
  107865. /**
  107866. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  107867. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  107868. */
  107869. export class BoneAxesViewer extends AxesViewer {
  107870. /**
  107871. * Gets or sets the target mesh where to display the axes viewer
  107872. */
  107873. mesh: Nullable<Mesh>;
  107874. /**
  107875. * Gets or sets the target bone where to display the axes viewer
  107876. */
  107877. bone: Nullable<Bone>;
  107878. /** Gets current position */
  107879. pos: Vector3;
  107880. /** Gets direction of X axis */
  107881. xaxis: Vector3;
  107882. /** Gets direction of Y axis */
  107883. yaxis: Vector3;
  107884. /** Gets direction of Z axis */
  107885. zaxis: Vector3;
  107886. /**
  107887. * Creates a new BoneAxesViewer
  107888. * @param scene defines the hosting scene
  107889. * @param bone defines the target bone
  107890. * @param mesh defines the target mesh
  107891. * @param scaleLines defines a scaling factor for line length (1 by default)
  107892. */
  107893. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  107894. /**
  107895. * Force the viewer to update
  107896. */
  107897. update(): void;
  107898. /** Releases resources */
  107899. dispose(): void;
  107900. }
  107901. }
  107902. declare module BABYLON {
  107903. /**
  107904. * Interface used to define scene explorer extensibility option
  107905. */
  107906. export interface IExplorerExtensibilityOption {
  107907. /**
  107908. * Define the option label
  107909. */
  107910. label: string;
  107911. /**
  107912. * Defines the action to execute on click
  107913. */
  107914. action: (entity: any) => void;
  107915. }
  107916. /**
  107917. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  107918. */
  107919. export interface IExplorerExtensibilityGroup {
  107920. /**
  107921. * Defines a predicate to test if a given type mut be extended
  107922. */
  107923. predicate: (entity: any) => boolean;
  107924. /**
  107925. * Gets the list of options added to a type
  107926. */
  107927. entries: IExplorerExtensibilityOption[];
  107928. }
  107929. /**
  107930. * Interface used to define the options to use to create the Inspector
  107931. */
  107932. export interface IInspectorOptions {
  107933. /**
  107934. * Display in overlay mode (default: false)
  107935. */
  107936. overlay?: boolean;
  107937. /**
  107938. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  107939. */
  107940. globalRoot?: HTMLElement;
  107941. /**
  107942. * Display the Scene explorer
  107943. */
  107944. showExplorer?: boolean;
  107945. /**
  107946. * Display the property inspector
  107947. */
  107948. showInspector?: boolean;
  107949. /**
  107950. * Display in embed mode (both panes on the right)
  107951. */
  107952. embedMode?: boolean;
  107953. /**
  107954. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  107955. */
  107956. handleResize?: boolean;
  107957. /**
  107958. * Allow the panes to popup (default: true)
  107959. */
  107960. enablePopup?: boolean;
  107961. /**
  107962. * Allow the panes to be closed by users (default: true)
  107963. */
  107964. enableClose?: boolean;
  107965. /**
  107966. * Optional list of extensibility entries
  107967. */
  107968. explorerExtensibility?: IExplorerExtensibilityGroup[];
  107969. /**
  107970. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  107971. */
  107972. inspectorURL?: string;
  107973. }
  107974. interface Scene {
  107975. /**
  107976. * @hidden
  107977. * Backing field
  107978. */
  107979. _debugLayer: DebugLayer;
  107980. /**
  107981. * Gets the debug layer (aka Inspector) associated with the scene
  107982. * @see http://doc.babylonjs.com/features/playground_debuglayer
  107983. */
  107984. debugLayer: DebugLayer;
  107985. }
  107986. /**
  107987. * The debug layer (aka Inspector) is the go to tool in order to better understand
  107988. * what is happening in your scene
  107989. * @see http://doc.babylonjs.com/features/playground_debuglayer
  107990. */
  107991. export class DebugLayer {
  107992. /**
  107993. * Define the url to get the inspector script from.
  107994. * By default it uses the babylonjs CDN.
  107995. * @ignoreNaming
  107996. */
  107997. static InspectorURL: string;
  107998. private _scene;
  107999. private BJSINSPECTOR;
  108000. private _onPropertyChangedObservable?;
  108001. /**
  108002. * Observable triggered when a property is changed through the inspector.
  108003. */
  108004. readonly onPropertyChangedObservable: any;
  108005. /**
  108006. * Instantiates a new debug layer.
  108007. * The debug layer (aka Inspector) is the go to tool in order to better understand
  108008. * what is happening in your scene
  108009. * @see http://doc.babylonjs.com/features/playground_debuglayer
  108010. * @param scene Defines the scene to inspect
  108011. */
  108012. constructor(scene: Scene);
  108013. /** Creates the inspector window. */
  108014. private _createInspector;
  108015. /**
  108016. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  108017. * @param entity defines the entity to select
  108018. * @param lineContainerTitle defines the specific block to highlight
  108019. */
  108020. select(entity: any, lineContainerTitle?: string): void;
  108021. /** Get the inspector from bundle or global */
  108022. private _getGlobalInspector;
  108023. /**
  108024. * Get if the inspector is visible or not.
  108025. * @returns true if visible otherwise, false
  108026. */
  108027. isVisible(): boolean;
  108028. /**
  108029. * Hide the inspector and close its window.
  108030. */
  108031. hide(): void;
  108032. /**
  108033. * Launch the debugLayer.
  108034. * @param config Define the configuration of the inspector
  108035. * @return a promise fulfilled when the debug layer is visible
  108036. */
  108037. show(config?: IInspectorOptions): Promise<DebugLayer>;
  108038. }
  108039. }
  108040. declare module BABYLON {
  108041. /**
  108042. * Class containing static functions to help procedurally build meshes
  108043. */
  108044. export class BoxBuilder {
  108045. /**
  108046. * Creates a box mesh
  108047. * * The parameter `size` sets the size (float) of each box side (default 1)
  108048. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  108049. * * 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)
  108050. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  108051. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108052. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108053. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108054. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  108055. * @param name defines the name of the mesh
  108056. * @param options defines the options used to create the mesh
  108057. * @param scene defines the hosting scene
  108058. * @returns the box mesh
  108059. */
  108060. static CreateBox(name: string, options: {
  108061. size?: number;
  108062. width?: number;
  108063. height?: number;
  108064. depth?: number;
  108065. faceUV?: Vector4[];
  108066. faceColors?: Color4[];
  108067. sideOrientation?: number;
  108068. frontUVs?: Vector4;
  108069. backUVs?: Vector4;
  108070. wrap?: boolean;
  108071. topBaseAt?: number;
  108072. bottomBaseAt?: number;
  108073. updatable?: boolean;
  108074. }, scene?: Nullable<Scene>): Mesh;
  108075. }
  108076. }
  108077. declare module BABYLON {
  108078. /**
  108079. * Class containing static functions to help procedurally build meshes
  108080. */
  108081. export class SphereBuilder {
  108082. /**
  108083. * Creates a sphere mesh
  108084. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  108085. * * 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`)
  108086. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  108087. * * 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
  108088. * * 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)
  108089. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108090. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108091. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108092. * @param name defines the name of the mesh
  108093. * @param options defines the options used to create the mesh
  108094. * @param scene defines the hosting scene
  108095. * @returns the sphere mesh
  108096. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  108097. */
  108098. static CreateSphere(name: string, options: {
  108099. segments?: number;
  108100. diameter?: number;
  108101. diameterX?: number;
  108102. diameterY?: number;
  108103. diameterZ?: number;
  108104. arc?: number;
  108105. slice?: number;
  108106. sideOrientation?: number;
  108107. frontUVs?: Vector4;
  108108. backUVs?: Vector4;
  108109. updatable?: boolean;
  108110. }, scene?: Nullable<Scene>): Mesh;
  108111. }
  108112. }
  108113. declare module BABYLON.Debug {
  108114. /**
  108115. * Used to show the physics impostor around the specific mesh
  108116. */
  108117. export class PhysicsViewer {
  108118. /** @hidden */
  108119. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  108120. /** @hidden */
  108121. protected _meshes: Array<Nullable<AbstractMesh>>;
  108122. /** @hidden */
  108123. protected _scene: Nullable<Scene>;
  108124. /** @hidden */
  108125. protected _numMeshes: number;
  108126. /** @hidden */
  108127. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  108128. private _renderFunction;
  108129. private _utilityLayer;
  108130. private _debugBoxMesh;
  108131. private _debugSphereMesh;
  108132. private _debugCylinderMesh;
  108133. private _debugMaterial;
  108134. private _debugMeshMeshes;
  108135. /**
  108136. * Creates a new PhysicsViewer
  108137. * @param scene defines the hosting scene
  108138. */
  108139. constructor(scene: Scene);
  108140. /** @hidden */
  108141. protected _updateDebugMeshes(): void;
  108142. /**
  108143. * Renders a specified physic impostor
  108144. * @param impostor defines the impostor to render
  108145. * @param targetMesh defines the mesh represented by the impostor
  108146. * @returns the new debug mesh used to render the impostor
  108147. */
  108148. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  108149. /**
  108150. * Hides a specified physic impostor
  108151. * @param impostor defines the impostor to hide
  108152. */
  108153. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  108154. private _getDebugMaterial;
  108155. private _getDebugBoxMesh;
  108156. private _getDebugSphereMesh;
  108157. private _getDebugCylinderMesh;
  108158. private _getDebugMeshMesh;
  108159. private _getDebugMesh;
  108160. /** Releases all resources */
  108161. dispose(): void;
  108162. }
  108163. }
  108164. declare module BABYLON {
  108165. /**
  108166. * Class containing static functions to help procedurally build meshes
  108167. */
  108168. export class LinesBuilder {
  108169. /**
  108170. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  108171. * * 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
  108172. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  108173. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  108174. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  108175. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  108176. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  108177. * * 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
  108178. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  108179. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108180. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  108181. * @param name defines the name of the new line system
  108182. * @param options defines the options used to create the line system
  108183. * @param scene defines the hosting scene
  108184. * @returns a new line system mesh
  108185. */
  108186. static CreateLineSystem(name: string, options: {
  108187. lines: Vector3[][];
  108188. updatable?: boolean;
  108189. instance?: Nullable<LinesMesh>;
  108190. colors?: Nullable<Color4[][]>;
  108191. useVertexAlpha?: boolean;
  108192. }, scene: Nullable<Scene>): LinesMesh;
  108193. /**
  108194. * Creates a line mesh
  108195. * 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
  108196. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  108197. * * The parameter `points` is an array successive Vector3
  108198. * * 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
  108199. * * The optional parameter `colors` is an array of successive Color4, one per line point
  108200. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  108201. * * When updating an instance, remember that only point positions can change, not the number of points
  108202. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108203. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  108204. * @param name defines the name of the new line system
  108205. * @param options defines the options used to create the line system
  108206. * @param scene defines the hosting scene
  108207. * @returns a new line mesh
  108208. */
  108209. static CreateLines(name: string, options: {
  108210. points: Vector3[];
  108211. updatable?: boolean;
  108212. instance?: Nullable<LinesMesh>;
  108213. colors?: Color4[];
  108214. useVertexAlpha?: boolean;
  108215. }, scene?: Nullable<Scene>): LinesMesh;
  108216. /**
  108217. * Creates a dashed line mesh
  108218. * * 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
  108219. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  108220. * * The parameter `points` is an array successive Vector3
  108221. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  108222. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  108223. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  108224. * * 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
  108225. * * When updating an instance, remember that only point positions can change, not the number of points
  108226. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108227. * @param name defines the name of the mesh
  108228. * @param options defines the options used to create the mesh
  108229. * @param scene defines the hosting scene
  108230. * @returns the dashed line mesh
  108231. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  108232. */
  108233. static CreateDashedLines(name: string, options: {
  108234. points: Vector3[];
  108235. dashSize?: number;
  108236. gapSize?: number;
  108237. dashNb?: number;
  108238. updatable?: boolean;
  108239. instance?: LinesMesh;
  108240. }, scene?: Nullable<Scene>): LinesMesh;
  108241. }
  108242. }
  108243. declare module BABYLON {
  108244. /**
  108245. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  108246. * in order to better appreciate the issue one might have.
  108247. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  108248. */
  108249. export class RayHelper {
  108250. /**
  108251. * Defines the ray we are currently tryin to visualize.
  108252. */
  108253. ray: Nullable<Ray>;
  108254. private _renderPoints;
  108255. private _renderLine;
  108256. private _renderFunction;
  108257. private _scene;
  108258. private _updateToMeshFunction;
  108259. private _attachedToMesh;
  108260. private _meshSpaceDirection;
  108261. private _meshSpaceOrigin;
  108262. /**
  108263. * Helper function to create a colored helper in a scene in one line.
  108264. * @param ray Defines the ray we are currently tryin to visualize
  108265. * @param scene Defines the scene the ray is used in
  108266. * @param color Defines the color we want to see the ray in
  108267. * @returns The newly created ray helper.
  108268. */
  108269. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  108270. /**
  108271. * Instantiate a new ray helper.
  108272. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  108273. * in order to better appreciate the issue one might have.
  108274. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  108275. * @param ray Defines the ray we are currently tryin to visualize
  108276. */
  108277. constructor(ray: Ray);
  108278. /**
  108279. * Shows the ray we are willing to debug.
  108280. * @param scene Defines the scene the ray needs to be rendered in
  108281. * @param color Defines the color the ray needs to be rendered in
  108282. */
  108283. show(scene: Scene, color?: Color3): void;
  108284. /**
  108285. * Hides the ray we are debugging.
  108286. */
  108287. hide(): void;
  108288. private _render;
  108289. /**
  108290. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  108291. * @param mesh Defines the mesh we want the helper attached to
  108292. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  108293. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  108294. * @param length Defines the length of the ray
  108295. */
  108296. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  108297. /**
  108298. * Detach the ray helper from the mesh it has previously been attached to.
  108299. */
  108300. detachFromMesh(): void;
  108301. private _updateToMesh;
  108302. /**
  108303. * Dispose the helper and release its associated resources.
  108304. */
  108305. dispose(): void;
  108306. }
  108307. }
  108308. declare module BABYLON.Debug {
  108309. /**
  108310. * Class used to render a debug view of a given skeleton
  108311. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  108312. */
  108313. export class SkeletonViewer {
  108314. /** defines the skeleton to render */
  108315. skeleton: Skeleton;
  108316. /** defines the mesh attached to the skeleton */
  108317. mesh: AbstractMesh;
  108318. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  108319. autoUpdateBonesMatrices: boolean;
  108320. /** defines the rendering group id to use with the viewer */
  108321. renderingGroupId: number;
  108322. /** Gets or sets the color used to render the skeleton */
  108323. color: Color3;
  108324. private _scene;
  108325. private _debugLines;
  108326. private _debugMesh;
  108327. private _isEnabled;
  108328. private _renderFunction;
  108329. private _utilityLayer;
  108330. /**
  108331. * Returns the mesh used to render the bones
  108332. */
  108333. readonly debugMesh: Nullable<LinesMesh>;
  108334. /**
  108335. * Creates a new SkeletonViewer
  108336. * @param skeleton defines the skeleton to render
  108337. * @param mesh defines the mesh attached to the skeleton
  108338. * @param scene defines the hosting scene
  108339. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  108340. * @param renderingGroupId defines the rendering group id to use with the viewer
  108341. */
  108342. constructor(
  108343. /** defines the skeleton to render */
  108344. skeleton: Skeleton,
  108345. /** defines the mesh attached to the skeleton */
  108346. mesh: AbstractMesh, scene: Scene,
  108347. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  108348. autoUpdateBonesMatrices?: boolean,
  108349. /** defines the rendering group id to use with the viewer */
  108350. renderingGroupId?: number);
  108351. /** Gets or sets a boolean indicating if the viewer is enabled */
  108352. isEnabled: boolean;
  108353. private _getBonePosition;
  108354. private _getLinesForBonesWithLength;
  108355. private _getLinesForBonesNoLength;
  108356. /** Update the viewer to sync with current skeleton state */
  108357. update(): void;
  108358. /** Release associated resources */
  108359. dispose(): void;
  108360. }
  108361. }
  108362. declare module BABYLON {
  108363. /**
  108364. * Options to create the null engine
  108365. */
  108366. export class NullEngineOptions {
  108367. /**
  108368. * Render width (Default: 512)
  108369. */
  108370. renderWidth: number;
  108371. /**
  108372. * Render height (Default: 256)
  108373. */
  108374. renderHeight: number;
  108375. /**
  108376. * Texture size (Default: 512)
  108377. */
  108378. textureSize: number;
  108379. /**
  108380. * If delta time between frames should be constant
  108381. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108382. */
  108383. deterministicLockstep: boolean;
  108384. /**
  108385. * Maximum about of steps between frames (Default: 4)
  108386. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108387. */
  108388. lockstepMaxSteps: number;
  108389. }
  108390. /**
  108391. * The null engine class provides support for headless version of babylon.js.
  108392. * This can be used in server side scenario or for testing purposes
  108393. */
  108394. export class NullEngine extends Engine {
  108395. private _options;
  108396. /**
  108397. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108398. */
  108399. isDeterministicLockStep(): boolean;
  108400. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  108401. getLockstepMaxSteps(): number;
  108402. /**
  108403. * Sets hardware scaling, used to save performance if needed
  108404. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  108405. */
  108406. getHardwareScalingLevel(): number;
  108407. constructor(options?: NullEngineOptions);
  108408. createVertexBuffer(vertices: FloatArray): DataBuffer;
  108409. createIndexBuffer(indices: IndicesArray): DataBuffer;
  108410. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  108411. getRenderWidth(useScreen?: boolean): number;
  108412. getRenderHeight(useScreen?: boolean): number;
  108413. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  108414. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  108415. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  108416. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  108417. bindSamplers(effect: Effect): void;
  108418. enableEffect(effect: Effect): void;
  108419. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  108420. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  108421. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  108422. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  108423. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  108424. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  108425. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  108426. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  108427. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  108428. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  108429. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  108430. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  108431. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  108432. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  108433. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  108434. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  108435. setFloat(uniform: WebGLUniformLocation, value: number): void;
  108436. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  108437. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  108438. setBool(uniform: WebGLUniformLocation, bool: number): void;
  108439. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  108440. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  108441. bindBuffers(vertexBuffers: {
  108442. [key: string]: VertexBuffer;
  108443. }, indexBuffer: DataBuffer, effect: Effect): void;
  108444. wipeCaches(bruteForce?: boolean): void;
  108445. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  108446. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  108447. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  108448. /** @hidden */
  108449. _createTexture(): WebGLTexture;
  108450. /** @hidden */
  108451. _releaseTexture(texture: InternalTexture): void;
  108452. 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;
  108453. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  108454. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  108455. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  108456. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  108457. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  108458. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  108459. areAllEffectsReady(): boolean;
  108460. /**
  108461. * @hidden
  108462. * Get the current error code of the webGL context
  108463. * @returns the error code
  108464. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  108465. */
  108466. getError(): number;
  108467. /** @hidden */
  108468. _getUnpackAlignement(): number;
  108469. /** @hidden */
  108470. _unpackFlipY(value: boolean): void;
  108471. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  108472. /**
  108473. * Updates a dynamic vertex buffer.
  108474. * @param vertexBuffer the vertex buffer to update
  108475. * @param data the data used to update the vertex buffer
  108476. * @param byteOffset the byte offset of the data (optional)
  108477. * @param byteLength the byte length of the data (optional)
  108478. */
  108479. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  108480. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  108481. /** @hidden */
  108482. _bindTexture(channel: number, texture: InternalTexture): void;
  108483. /** @hidden */
  108484. _releaseBuffer(buffer: DataBuffer): boolean;
  108485. releaseEffects(): void;
  108486. displayLoadingUI(): void;
  108487. hideLoadingUI(): void;
  108488. /** @hidden */
  108489. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  108490. /** @hidden */
  108491. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  108492. /** @hidden */
  108493. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  108494. /** @hidden */
  108495. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  108496. }
  108497. }
  108498. declare module BABYLON {
  108499. /** @hidden */
  108500. export class _OcclusionDataStorage {
  108501. /** @hidden */
  108502. occlusionInternalRetryCounter: number;
  108503. /** @hidden */
  108504. isOcclusionQueryInProgress: boolean;
  108505. /** @hidden */
  108506. isOccluded: boolean;
  108507. /** @hidden */
  108508. occlusionRetryCount: number;
  108509. /** @hidden */
  108510. occlusionType: number;
  108511. /** @hidden */
  108512. occlusionQueryAlgorithmType: number;
  108513. }
  108514. interface Engine {
  108515. /**
  108516. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  108517. * @return the new query
  108518. */
  108519. createQuery(): WebGLQuery;
  108520. /**
  108521. * Delete and release a webGL query
  108522. * @param query defines the query to delete
  108523. * @return the current engine
  108524. */
  108525. deleteQuery(query: WebGLQuery): Engine;
  108526. /**
  108527. * Check if a given query has resolved and got its value
  108528. * @param query defines the query to check
  108529. * @returns true if the query got its value
  108530. */
  108531. isQueryResultAvailable(query: WebGLQuery): boolean;
  108532. /**
  108533. * Gets the value of a given query
  108534. * @param query defines the query to check
  108535. * @returns the value of the query
  108536. */
  108537. getQueryResult(query: WebGLQuery): number;
  108538. /**
  108539. * Initiates an occlusion query
  108540. * @param algorithmType defines the algorithm to use
  108541. * @param query defines the query to use
  108542. * @returns the current engine
  108543. * @see http://doc.babylonjs.com/features/occlusionquery
  108544. */
  108545. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  108546. /**
  108547. * Ends an occlusion query
  108548. * @see http://doc.babylonjs.com/features/occlusionquery
  108549. * @param algorithmType defines the algorithm to use
  108550. * @returns the current engine
  108551. */
  108552. endOcclusionQuery(algorithmType: number): Engine;
  108553. /**
  108554. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  108555. * Please note that only one query can be issued at a time
  108556. * @returns a time token used to track the time span
  108557. */
  108558. startTimeQuery(): Nullable<_TimeToken>;
  108559. /**
  108560. * Ends a time query
  108561. * @param token defines the token used to measure the time span
  108562. * @returns the time spent (in ns)
  108563. */
  108564. endTimeQuery(token: _TimeToken): int;
  108565. /** @hidden */
  108566. _currentNonTimestampToken: Nullable<_TimeToken>;
  108567. /** @hidden */
  108568. _createTimeQuery(): WebGLQuery;
  108569. /** @hidden */
  108570. _deleteTimeQuery(query: WebGLQuery): void;
  108571. /** @hidden */
  108572. _getGlAlgorithmType(algorithmType: number): number;
  108573. /** @hidden */
  108574. _getTimeQueryResult(query: WebGLQuery): any;
  108575. /** @hidden */
  108576. _getTimeQueryAvailability(query: WebGLQuery): any;
  108577. }
  108578. interface AbstractMesh {
  108579. /**
  108580. * Backing filed
  108581. * @hidden
  108582. */
  108583. __occlusionDataStorage: _OcclusionDataStorage;
  108584. /**
  108585. * Access property
  108586. * @hidden
  108587. */
  108588. _occlusionDataStorage: _OcclusionDataStorage;
  108589. /**
  108590. * 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.
  108591. * The default value is -1 which means don't break the query and wait till the result
  108592. * @see http://doc.babylonjs.com/features/occlusionquery
  108593. */
  108594. occlusionRetryCount: number;
  108595. /**
  108596. * 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:
  108597. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  108598. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  108599. * * 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.
  108600. * @see http://doc.babylonjs.com/features/occlusionquery
  108601. */
  108602. occlusionType: number;
  108603. /**
  108604. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  108605. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  108606. * * 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.
  108607. * @see http://doc.babylonjs.com/features/occlusionquery
  108608. */
  108609. occlusionQueryAlgorithmType: number;
  108610. /**
  108611. * 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
  108612. * @see http://doc.babylonjs.com/features/occlusionquery
  108613. */
  108614. isOccluded: boolean;
  108615. /**
  108616. * Flag to check the progress status of the query
  108617. * @see http://doc.babylonjs.com/features/occlusionquery
  108618. */
  108619. isOcclusionQueryInProgress: boolean;
  108620. }
  108621. }
  108622. declare module BABYLON {
  108623. /** @hidden */
  108624. export var _forceTransformFeedbackToBundle: boolean;
  108625. interface Engine {
  108626. /**
  108627. * Creates a webGL transform feedback object
  108628. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  108629. * @returns the webGL transform feedback object
  108630. */
  108631. createTransformFeedback(): WebGLTransformFeedback;
  108632. /**
  108633. * Delete a webGL transform feedback object
  108634. * @param value defines the webGL transform feedback object to delete
  108635. */
  108636. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  108637. /**
  108638. * Bind a webGL transform feedback object to the webgl context
  108639. * @param value defines the webGL transform feedback object to bind
  108640. */
  108641. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  108642. /**
  108643. * Begins a transform feedback operation
  108644. * @param usePoints defines if points or triangles must be used
  108645. */
  108646. beginTransformFeedback(usePoints: boolean): void;
  108647. /**
  108648. * Ends a transform feedback operation
  108649. */
  108650. endTransformFeedback(): void;
  108651. /**
  108652. * Specify the varyings to use with transform feedback
  108653. * @param program defines the associated webGL program
  108654. * @param value defines the list of strings representing the varying names
  108655. */
  108656. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  108657. /**
  108658. * Bind a webGL buffer for a transform feedback operation
  108659. * @param value defines the webGL buffer to bind
  108660. */
  108661. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  108662. }
  108663. }
  108664. declare module BABYLON {
  108665. /**
  108666. * Creation options of the multi render target texture.
  108667. */
  108668. export interface IMultiRenderTargetOptions {
  108669. /**
  108670. * Define if the texture needs to create mip maps after render.
  108671. */
  108672. generateMipMaps?: boolean;
  108673. /**
  108674. * Define the types of all the draw buffers we want to create
  108675. */
  108676. types?: number[];
  108677. /**
  108678. * Define the sampling modes of all the draw buffers we want to create
  108679. */
  108680. samplingModes?: number[];
  108681. /**
  108682. * Define if a depth buffer is required
  108683. */
  108684. generateDepthBuffer?: boolean;
  108685. /**
  108686. * Define if a stencil buffer is required
  108687. */
  108688. generateStencilBuffer?: boolean;
  108689. /**
  108690. * Define if a depth texture is required instead of a depth buffer
  108691. */
  108692. generateDepthTexture?: boolean;
  108693. /**
  108694. * Define the number of desired draw buffers
  108695. */
  108696. textureCount?: number;
  108697. /**
  108698. * Define if aspect ratio should be adapted to the texture or stay the scene one
  108699. */
  108700. doNotChangeAspectRatio?: boolean;
  108701. /**
  108702. * Define the default type of the buffers we are creating
  108703. */
  108704. defaultType?: number;
  108705. }
  108706. /**
  108707. * A multi render target, like a render target provides the ability to render to a texture.
  108708. * Unlike the render target, it can render to several draw buffers in one draw.
  108709. * This is specially interesting in deferred rendering or for any effects requiring more than
  108710. * just one color from a single pass.
  108711. */
  108712. export class MultiRenderTarget extends RenderTargetTexture {
  108713. private _internalTextures;
  108714. private _textures;
  108715. private _multiRenderTargetOptions;
  108716. /**
  108717. * Get if draw buffers are currently supported by the used hardware and browser.
  108718. */
  108719. readonly isSupported: boolean;
  108720. /**
  108721. * Get the list of textures generated by the multi render target.
  108722. */
  108723. readonly textures: Texture[];
  108724. /**
  108725. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  108726. */
  108727. readonly depthTexture: Texture;
  108728. /**
  108729. * Set the wrapping mode on U of all the textures we are rendering to.
  108730. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  108731. */
  108732. wrapU: number;
  108733. /**
  108734. * Set the wrapping mode on V of all the textures we are rendering to.
  108735. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  108736. */
  108737. wrapV: number;
  108738. /**
  108739. * Instantiate a new multi render target texture.
  108740. * A multi render target, like a render target provides the ability to render to a texture.
  108741. * Unlike the render target, it can render to several draw buffers in one draw.
  108742. * This is specially interesting in deferred rendering or for any effects requiring more than
  108743. * just one color from a single pass.
  108744. * @param name Define the name of the texture
  108745. * @param size Define the size of the buffers to render to
  108746. * @param count Define the number of target we are rendering into
  108747. * @param scene Define the scene the texture belongs to
  108748. * @param options Define the options used to create the multi render target
  108749. */
  108750. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  108751. /** @hidden */
  108752. _rebuild(): void;
  108753. private _createInternalTextures;
  108754. private _createTextures;
  108755. /**
  108756. * Define the number of samples used if MSAA is enabled.
  108757. */
  108758. samples: number;
  108759. /**
  108760. * Resize all the textures in the multi render target.
  108761. * Be carrefull as it will recreate all the data in the new texture.
  108762. * @param size Define the new size
  108763. */
  108764. resize(size: any): void;
  108765. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  108766. /**
  108767. * Dispose the render targets and their associated resources
  108768. */
  108769. dispose(): void;
  108770. /**
  108771. * Release all the underlying texture used as draw buffers.
  108772. */
  108773. releaseInternalTextures(): void;
  108774. }
  108775. }
  108776. declare module BABYLON {
  108777. interface Engine {
  108778. /**
  108779. * Unbind a list of render target textures from the webGL context
  108780. * This is used only when drawBuffer extension or webGL2 are active
  108781. * @param textures defines the render target textures to unbind
  108782. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  108783. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  108784. */
  108785. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  108786. /**
  108787. * Create a multi render target texture
  108788. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  108789. * @param size defines the size of the texture
  108790. * @param options defines the creation options
  108791. * @returns the cube texture as an InternalTexture
  108792. */
  108793. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  108794. /**
  108795. * Update the sample count for a given multiple render target texture
  108796. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  108797. * @param textures defines the textures to update
  108798. * @param samples defines the sample count to set
  108799. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  108800. */
  108801. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  108802. }
  108803. }
  108804. declare module BABYLON {
  108805. /**
  108806. * Gather the list of clipboard event types as constants.
  108807. */
  108808. export class ClipboardEventTypes {
  108809. /**
  108810. * The clipboard event is fired when a copy command is active (pressed).
  108811. */
  108812. static readonly COPY: number;
  108813. /**
  108814. * The clipboard event is fired when a cut command is active (pressed).
  108815. */
  108816. static readonly CUT: number;
  108817. /**
  108818. * The clipboard event is fired when a paste command is active (pressed).
  108819. */
  108820. static readonly PASTE: number;
  108821. }
  108822. /**
  108823. * This class is used to store clipboard related info for the onClipboardObservable event.
  108824. */
  108825. export class ClipboardInfo {
  108826. /**
  108827. * Defines the type of event (BABYLON.ClipboardEventTypes)
  108828. */
  108829. type: number;
  108830. /**
  108831. * Defines the related dom event
  108832. */
  108833. event: ClipboardEvent;
  108834. /**
  108835. *Creates an instance of ClipboardInfo.
  108836. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  108837. * @param event Defines the related dom event
  108838. */
  108839. constructor(
  108840. /**
  108841. * Defines the type of event (BABYLON.ClipboardEventTypes)
  108842. */
  108843. type: number,
  108844. /**
  108845. * Defines the related dom event
  108846. */
  108847. event: ClipboardEvent);
  108848. /**
  108849. * Get the clipboard event's type from the keycode.
  108850. * @param keyCode Defines the keyCode for the current keyboard event.
  108851. * @return {number}
  108852. */
  108853. static GetTypeFromCharacter(keyCode: number): number;
  108854. }
  108855. }
  108856. declare module BABYLON {
  108857. /**
  108858. * Google Daydream controller
  108859. */
  108860. export class DaydreamController extends WebVRController {
  108861. /**
  108862. * Base Url for the controller model.
  108863. */
  108864. static MODEL_BASE_URL: string;
  108865. /**
  108866. * File name for the controller model.
  108867. */
  108868. static MODEL_FILENAME: string;
  108869. /**
  108870. * Gamepad Id prefix used to identify Daydream Controller.
  108871. */
  108872. static readonly GAMEPAD_ID_PREFIX: string;
  108873. /**
  108874. * Creates a new DaydreamController from a gamepad
  108875. * @param vrGamepad the gamepad that the controller should be created from
  108876. */
  108877. constructor(vrGamepad: any);
  108878. /**
  108879. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  108880. * @param scene scene in which to add meshes
  108881. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  108882. */
  108883. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  108884. /**
  108885. * Called once for each button that changed state since the last frame
  108886. * @param buttonIdx Which button index changed
  108887. * @param state New state of the button
  108888. * @param changes Which properties on the state changed since last frame
  108889. */
  108890. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108891. }
  108892. }
  108893. declare module BABYLON {
  108894. /**
  108895. * Gear VR Controller
  108896. */
  108897. export class GearVRController extends WebVRController {
  108898. /**
  108899. * Base Url for the controller model.
  108900. */
  108901. static MODEL_BASE_URL: string;
  108902. /**
  108903. * File name for the controller model.
  108904. */
  108905. static MODEL_FILENAME: string;
  108906. /**
  108907. * Gamepad Id prefix used to identify this controller.
  108908. */
  108909. static readonly GAMEPAD_ID_PREFIX: string;
  108910. private readonly _buttonIndexToObservableNameMap;
  108911. /**
  108912. * Creates a new GearVRController from a gamepad
  108913. * @param vrGamepad the gamepad that the controller should be created from
  108914. */
  108915. constructor(vrGamepad: any);
  108916. /**
  108917. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  108918. * @param scene scene in which to add meshes
  108919. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  108920. */
  108921. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  108922. /**
  108923. * Called once for each button that changed state since the last frame
  108924. * @param buttonIdx Which button index changed
  108925. * @param state New state of the button
  108926. * @param changes Which properties on the state changed since last frame
  108927. */
  108928. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108929. }
  108930. }
  108931. declare module BABYLON {
  108932. /**
  108933. * Class containing static functions to help procedurally build meshes
  108934. */
  108935. export class PolyhedronBuilder {
  108936. /**
  108937. * Creates a polyhedron mesh
  108938. * * 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
  108939. * * The parameter `size` (positive float, default 1) sets the polygon size
  108940. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  108941. * * 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`
  108942. * * 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
  108943. * * 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)`)
  108944. * * 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
  108945. * * 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
  108946. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108947. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108948. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108949. * @param name defines the name of the mesh
  108950. * @param options defines the options used to create the mesh
  108951. * @param scene defines the hosting scene
  108952. * @returns the polyhedron mesh
  108953. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  108954. */
  108955. static CreatePolyhedron(name: string, options: {
  108956. type?: number;
  108957. size?: number;
  108958. sizeX?: number;
  108959. sizeY?: number;
  108960. sizeZ?: number;
  108961. custom?: any;
  108962. faceUV?: Vector4[];
  108963. faceColors?: Color4[];
  108964. flat?: boolean;
  108965. updatable?: boolean;
  108966. sideOrientation?: number;
  108967. frontUVs?: Vector4;
  108968. backUVs?: Vector4;
  108969. }, scene?: Nullable<Scene>): Mesh;
  108970. }
  108971. }
  108972. declare module BABYLON {
  108973. /**
  108974. * Gizmo that enables scaling a mesh along 3 axis
  108975. */
  108976. export class ScaleGizmo extends Gizmo {
  108977. /**
  108978. * Internal gizmo used for interactions on the x axis
  108979. */
  108980. xGizmo: AxisScaleGizmo;
  108981. /**
  108982. * Internal gizmo used for interactions on the y axis
  108983. */
  108984. yGizmo: AxisScaleGizmo;
  108985. /**
  108986. * Internal gizmo used for interactions on the z axis
  108987. */
  108988. zGizmo: AxisScaleGizmo;
  108989. /**
  108990. * Internal gizmo used to scale all axis equally
  108991. */
  108992. uniformScaleGizmo: AxisScaleGizmo;
  108993. private _meshAttached;
  108994. private _updateGizmoRotationToMatchAttachedMesh;
  108995. private _snapDistance;
  108996. private _scaleRatio;
  108997. private _uniformScalingMesh;
  108998. private _octahedron;
  108999. /** Fires an event when any of it's sub gizmos are dragged */
  109000. onDragStartObservable: Observable<unknown>;
  109001. /** Fires an event when any of it's sub gizmos are released from dragging */
  109002. onDragEndObservable: Observable<unknown>;
  109003. attachedMesh: Nullable<AbstractMesh>;
  109004. /**
  109005. * Creates a ScaleGizmo
  109006. * @param gizmoLayer The utility layer the gizmo will be added to
  109007. */
  109008. constructor(gizmoLayer?: UtilityLayerRenderer);
  109009. updateGizmoRotationToMatchAttachedMesh: boolean;
  109010. /**
  109011. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  109012. */
  109013. snapDistance: number;
  109014. /**
  109015. * Ratio for the scale of the gizmo (Default: 1)
  109016. */
  109017. scaleRatio: number;
  109018. /**
  109019. * Disposes of the gizmo
  109020. */
  109021. dispose(): void;
  109022. }
  109023. }
  109024. declare module BABYLON {
  109025. /**
  109026. * Single axis scale gizmo
  109027. */
  109028. export class AxisScaleGizmo extends Gizmo {
  109029. /**
  109030. * Drag behavior responsible for the gizmos dragging interactions
  109031. */
  109032. dragBehavior: PointerDragBehavior;
  109033. private _pointerObserver;
  109034. /**
  109035. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  109036. */
  109037. snapDistance: number;
  109038. /**
  109039. * Event that fires each time the gizmo snaps to a new location.
  109040. * * snapDistance is the the change in distance
  109041. */
  109042. onSnapObservable: Observable<{
  109043. snapDistance: number;
  109044. }>;
  109045. /**
  109046. * If the scaling operation should be done on all axis (default: false)
  109047. */
  109048. uniformScaling: boolean;
  109049. private _isEnabled;
  109050. private _parent;
  109051. private _arrow;
  109052. private _coloredMaterial;
  109053. private _hoverMaterial;
  109054. /**
  109055. * Creates an AxisScaleGizmo
  109056. * @param gizmoLayer The utility layer the gizmo will be added to
  109057. * @param dragAxis The axis which the gizmo will be able to scale on
  109058. * @param color The color of the gizmo
  109059. */
  109060. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  109061. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  109062. /**
  109063. * If the gizmo is enabled
  109064. */
  109065. isEnabled: boolean;
  109066. /**
  109067. * Disposes of the gizmo
  109068. */
  109069. dispose(): void;
  109070. /**
  109071. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  109072. * @param mesh The mesh to replace the default mesh of the gizmo
  109073. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  109074. */
  109075. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  109076. }
  109077. }
  109078. declare module BABYLON {
  109079. /**
  109080. * Bounding box gizmo
  109081. */
  109082. export class BoundingBoxGizmo extends Gizmo {
  109083. private _lineBoundingBox;
  109084. private _rotateSpheresParent;
  109085. private _scaleBoxesParent;
  109086. private _boundingDimensions;
  109087. private _renderObserver;
  109088. private _pointerObserver;
  109089. private _scaleDragSpeed;
  109090. private _tmpQuaternion;
  109091. private _tmpVector;
  109092. private _tmpRotationMatrix;
  109093. /**
  109094. * 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)
  109095. */
  109096. ignoreChildren: boolean;
  109097. /**
  109098. * 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)
  109099. */
  109100. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  109101. /**
  109102. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  109103. */
  109104. rotationSphereSize: number;
  109105. /**
  109106. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  109107. */
  109108. scaleBoxSize: number;
  109109. /**
  109110. * 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)
  109111. */
  109112. fixedDragMeshScreenSize: boolean;
  109113. /**
  109114. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  109115. */
  109116. fixedDragMeshScreenSizeDistanceFactor: number;
  109117. /**
  109118. * Fired when a rotation sphere or scale box is dragged
  109119. */
  109120. onDragStartObservable: Observable<{}>;
  109121. /**
  109122. * Fired when a scale box is dragged
  109123. */
  109124. onScaleBoxDragObservable: Observable<{}>;
  109125. /**
  109126. * Fired when a scale box drag is ended
  109127. */
  109128. onScaleBoxDragEndObservable: Observable<{}>;
  109129. /**
  109130. * Fired when a rotation sphere is dragged
  109131. */
  109132. onRotationSphereDragObservable: Observable<{}>;
  109133. /**
  109134. * Fired when a rotation sphere drag is ended
  109135. */
  109136. onRotationSphereDragEndObservable: Observable<{}>;
  109137. /**
  109138. * 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)
  109139. */
  109140. scalePivot: Nullable<Vector3>;
  109141. /**
  109142. * Mesh used as a pivot to rotate the attached mesh
  109143. */
  109144. private _anchorMesh;
  109145. private _existingMeshScale;
  109146. private _dragMesh;
  109147. private pointerDragBehavior;
  109148. private coloredMaterial;
  109149. private hoverColoredMaterial;
  109150. /**
  109151. * Sets the color of the bounding box gizmo
  109152. * @param color the color to set
  109153. */
  109154. setColor(color: Color3): void;
  109155. /**
  109156. * Creates an BoundingBoxGizmo
  109157. * @param gizmoLayer The utility layer the gizmo will be added to
  109158. * @param color The color of the gizmo
  109159. */
  109160. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  109161. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  109162. private _selectNode;
  109163. /**
  109164. * Updates the bounding box information for the Gizmo
  109165. */
  109166. updateBoundingBox(): void;
  109167. private _updateRotationSpheres;
  109168. private _updateScaleBoxes;
  109169. /**
  109170. * Enables rotation on the specified axis and disables rotation on the others
  109171. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  109172. */
  109173. setEnabledRotationAxis(axis: string): void;
  109174. /**
  109175. * Enables/disables scaling
  109176. * @param enable if scaling should be enabled
  109177. */
  109178. setEnabledScaling(enable: boolean): void;
  109179. private _updateDummy;
  109180. /**
  109181. * Enables a pointer drag behavior on the bounding box of the gizmo
  109182. */
  109183. enableDragBehavior(): void;
  109184. /**
  109185. * Disposes of the gizmo
  109186. */
  109187. dispose(): void;
  109188. /**
  109189. * 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)
  109190. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  109191. * @returns the bounding box mesh with the passed in mesh as a child
  109192. */
  109193. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  109194. /**
  109195. * CustomMeshes are not supported by this gizmo
  109196. * @param mesh The mesh to replace the default mesh of the gizmo
  109197. */
  109198. setCustomMesh(mesh: Mesh): void;
  109199. }
  109200. }
  109201. declare module BABYLON {
  109202. /**
  109203. * Single plane rotation gizmo
  109204. */
  109205. export class PlaneRotationGizmo extends Gizmo {
  109206. /**
  109207. * Drag behavior responsible for the gizmos dragging interactions
  109208. */
  109209. dragBehavior: PointerDragBehavior;
  109210. private _pointerObserver;
  109211. /**
  109212. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  109213. */
  109214. snapDistance: number;
  109215. /**
  109216. * Event that fires each time the gizmo snaps to a new location.
  109217. * * snapDistance is the the change in distance
  109218. */
  109219. onSnapObservable: Observable<{
  109220. snapDistance: number;
  109221. }>;
  109222. private _isEnabled;
  109223. private _parent;
  109224. /**
  109225. * Creates a PlaneRotationGizmo
  109226. * @param gizmoLayer The utility layer the gizmo will be added to
  109227. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  109228. * @param color The color of the gizmo
  109229. * @param tessellation Amount of tessellation to be used when creating rotation circles
  109230. * @param useEulerRotation Use and update Euler angle instead of quaternion
  109231. */
  109232. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  109233. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  109234. /**
  109235. * If the gizmo is enabled
  109236. */
  109237. isEnabled: boolean;
  109238. /**
  109239. * Disposes of the gizmo
  109240. */
  109241. dispose(): void;
  109242. }
  109243. }
  109244. declare module BABYLON {
  109245. /**
  109246. * Gizmo that enables rotating a mesh along 3 axis
  109247. */
  109248. export class RotationGizmo extends Gizmo {
  109249. /**
  109250. * Internal gizmo used for interactions on the x axis
  109251. */
  109252. xGizmo: PlaneRotationGizmo;
  109253. /**
  109254. * Internal gizmo used for interactions on the y axis
  109255. */
  109256. yGizmo: PlaneRotationGizmo;
  109257. /**
  109258. * Internal gizmo used for interactions on the z axis
  109259. */
  109260. zGizmo: PlaneRotationGizmo;
  109261. /** Fires an event when any of it's sub gizmos are dragged */
  109262. onDragStartObservable: Observable<unknown>;
  109263. /** Fires an event when any of it's sub gizmos are released from dragging */
  109264. onDragEndObservable: Observable<unknown>;
  109265. private _meshAttached;
  109266. attachedMesh: Nullable<AbstractMesh>;
  109267. /**
  109268. * Creates a RotationGizmo
  109269. * @param gizmoLayer The utility layer the gizmo will be added to
  109270. * @param tessellation Amount of tessellation to be used when creating rotation circles
  109271. * @param useEulerRotation Use and update Euler angle instead of quaternion
  109272. */
  109273. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  109274. updateGizmoRotationToMatchAttachedMesh: boolean;
  109275. /**
  109276. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  109277. */
  109278. snapDistance: number;
  109279. /**
  109280. * Ratio for the scale of the gizmo (Default: 1)
  109281. */
  109282. scaleRatio: number;
  109283. /**
  109284. * Disposes of the gizmo
  109285. */
  109286. dispose(): void;
  109287. /**
  109288. * CustomMeshes are not supported by this gizmo
  109289. * @param mesh The mesh to replace the default mesh of the gizmo
  109290. */
  109291. setCustomMesh(mesh: Mesh): void;
  109292. }
  109293. }
  109294. declare module BABYLON {
  109295. /**
  109296. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  109297. */
  109298. export class GizmoManager implements IDisposable {
  109299. private scene;
  109300. /**
  109301. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  109302. */
  109303. gizmos: {
  109304. positionGizmo: Nullable<PositionGizmo>;
  109305. rotationGizmo: Nullable<RotationGizmo>;
  109306. scaleGizmo: Nullable<ScaleGizmo>;
  109307. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  109308. };
  109309. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  109310. clearGizmoOnEmptyPointerEvent: boolean;
  109311. /** Fires an event when the manager is attached to a mesh */
  109312. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  109313. private _gizmosEnabled;
  109314. private _pointerObserver;
  109315. private _attachedMesh;
  109316. private _boundingBoxColor;
  109317. private _defaultUtilityLayer;
  109318. private _defaultKeepDepthUtilityLayer;
  109319. /**
  109320. * When bounding box gizmo is enabled, this can be used to track drag/end events
  109321. */
  109322. boundingBoxDragBehavior: SixDofDragBehavior;
  109323. /**
  109324. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  109325. */
  109326. attachableMeshes: Nullable<Array<AbstractMesh>>;
  109327. /**
  109328. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  109329. */
  109330. usePointerToAttachGizmos: boolean;
  109331. /**
  109332. * Utility layer that the bounding box gizmo belongs to
  109333. */
  109334. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  109335. /**
  109336. * Utility layer that all gizmos besides bounding box belong to
  109337. */
  109338. readonly utilityLayer: UtilityLayerRenderer;
  109339. /**
  109340. * Instatiates a gizmo manager
  109341. * @param scene the scene to overlay the gizmos on top of
  109342. */
  109343. constructor(scene: Scene);
  109344. /**
  109345. * Attaches a set of gizmos to the specified mesh
  109346. * @param mesh The mesh the gizmo's should be attached to
  109347. */
  109348. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  109349. /**
  109350. * If the position gizmo is enabled
  109351. */
  109352. positionGizmoEnabled: boolean;
  109353. /**
  109354. * If the rotation gizmo is enabled
  109355. */
  109356. rotationGizmoEnabled: boolean;
  109357. /**
  109358. * If the scale gizmo is enabled
  109359. */
  109360. scaleGizmoEnabled: boolean;
  109361. /**
  109362. * If the boundingBox gizmo is enabled
  109363. */
  109364. boundingBoxGizmoEnabled: boolean;
  109365. /**
  109366. * Disposes of the gizmo manager
  109367. */
  109368. dispose(): void;
  109369. }
  109370. }
  109371. declare module BABYLON {
  109372. /**
  109373. * A directional light is defined by a direction (what a surprise!).
  109374. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  109375. * 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.
  109376. * Documentation: https://doc.babylonjs.com/babylon101/lights
  109377. */
  109378. export class DirectionalLight extends ShadowLight {
  109379. private _shadowFrustumSize;
  109380. /**
  109381. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  109382. */
  109383. /**
  109384. * Specifies a fix frustum size for the shadow generation.
  109385. */
  109386. shadowFrustumSize: number;
  109387. private _shadowOrthoScale;
  109388. /**
  109389. * Gets the shadow projection scale against the optimal computed one.
  109390. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  109391. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  109392. */
  109393. /**
  109394. * Sets the shadow projection scale against the optimal computed one.
  109395. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  109396. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  109397. */
  109398. shadowOrthoScale: number;
  109399. /**
  109400. * Automatically compute the projection matrix to best fit (including all the casters)
  109401. * on each frame.
  109402. */
  109403. autoUpdateExtends: boolean;
  109404. private _orthoLeft;
  109405. private _orthoRight;
  109406. private _orthoTop;
  109407. private _orthoBottom;
  109408. /**
  109409. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  109410. * The directional light is emitted from everywhere in the given direction.
  109411. * It can cast shadows.
  109412. * Documentation : https://doc.babylonjs.com/babylon101/lights
  109413. * @param name The friendly name of the light
  109414. * @param direction The direction of the light
  109415. * @param scene The scene the light belongs to
  109416. */
  109417. constructor(name: string, direction: Vector3, scene: Scene);
  109418. /**
  109419. * Returns the string "DirectionalLight".
  109420. * @return The class name
  109421. */
  109422. getClassName(): string;
  109423. /**
  109424. * Returns the integer 1.
  109425. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  109426. */
  109427. getTypeID(): number;
  109428. /**
  109429. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  109430. * Returns the DirectionalLight Shadow projection matrix.
  109431. */
  109432. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  109433. /**
  109434. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  109435. * Returns the DirectionalLight Shadow projection matrix.
  109436. */
  109437. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  109438. /**
  109439. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  109440. * Returns the DirectionalLight Shadow projection matrix.
  109441. */
  109442. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  109443. protected _buildUniformLayout(): void;
  109444. /**
  109445. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  109446. * @param effect The effect to update
  109447. * @param lightIndex The index of the light in the effect to update
  109448. * @returns The directional light
  109449. */
  109450. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  109451. /**
  109452. * Gets the minZ used for shadow according to both the scene and the light.
  109453. *
  109454. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  109455. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  109456. * @param activeCamera The camera we are returning the min for
  109457. * @returns the depth min z
  109458. */
  109459. getDepthMinZ(activeCamera: Camera): number;
  109460. /**
  109461. * Gets the maxZ used for shadow according to both the scene and the light.
  109462. *
  109463. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  109464. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  109465. * @param activeCamera The camera we are returning the max for
  109466. * @returns the depth max z
  109467. */
  109468. getDepthMaxZ(activeCamera: Camera): number;
  109469. /**
  109470. * Prepares the list of defines specific to the light type.
  109471. * @param defines the list of defines
  109472. * @param lightIndex defines the index of the light for the effect
  109473. */
  109474. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  109475. }
  109476. }
  109477. declare module BABYLON {
  109478. /**
  109479. * Class containing static functions to help procedurally build meshes
  109480. */
  109481. export class HemisphereBuilder {
  109482. /**
  109483. * Creates a hemisphere mesh
  109484. * @param name defines the name of the mesh
  109485. * @param options defines the options used to create the mesh
  109486. * @param scene defines the hosting scene
  109487. * @returns the hemisphere mesh
  109488. */
  109489. static CreateHemisphere(name: string, options: {
  109490. segments?: number;
  109491. diameter?: number;
  109492. sideOrientation?: number;
  109493. }, scene: any): Mesh;
  109494. }
  109495. }
  109496. declare module BABYLON {
  109497. /**
  109498. * A spot light is defined by a position, a direction, an angle, and an exponent.
  109499. * These values define a cone of light starting from the position, emitting toward the direction.
  109500. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  109501. * and the exponent defines the speed of the decay of the light with distance (reach).
  109502. * Documentation: https://doc.babylonjs.com/babylon101/lights
  109503. */
  109504. export class SpotLight extends ShadowLight {
  109505. private _angle;
  109506. private _innerAngle;
  109507. private _cosHalfAngle;
  109508. private _lightAngleScale;
  109509. private _lightAngleOffset;
  109510. /**
  109511. * Gets the cone angle of the spot light in Radians.
  109512. */
  109513. /**
  109514. * Sets the cone angle of the spot light in Radians.
  109515. */
  109516. angle: number;
  109517. /**
  109518. * Only used in gltf falloff mode, this defines the angle where
  109519. * the directional falloff will start before cutting at angle which could be seen
  109520. * as outer angle.
  109521. */
  109522. /**
  109523. * Only used in gltf falloff mode, this defines the angle where
  109524. * the directional falloff will start before cutting at angle which could be seen
  109525. * as outer angle.
  109526. */
  109527. innerAngle: number;
  109528. private _shadowAngleScale;
  109529. /**
  109530. * Allows scaling the angle of the light for shadow generation only.
  109531. */
  109532. /**
  109533. * Allows scaling the angle of the light for shadow generation only.
  109534. */
  109535. shadowAngleScale: number;
  109536. /**
  109537. * The light decay speed with the distance from the emission spot.
  109538. */
  109539. exponent: number;
  109540. private _projectionTextureMatrix;
  109541. /**
  109542. * Allows reading the projecton texture
  109543. */
  109544. readonly projectionTextureMatrix: Matrix;
  109545. protected _projectionTextureLightNear: number;
  109546. /**
  109547. * Gets the near clip of the Spotlight for texture projection.
  109548. */
  109549. /**
  109550. * Sets the near clip of the Spotlight for texture projection.
  109551. */
  109552. projectionTextureLightNear: number;
  109553. protected _projectionTextureLightFar: number;
  109554. /**
  109555. * Gets the far clip of the Spotlight for texture projection.
  109556. */
  109557. /**
  109558. * Sets the far clip of the Spotlight for texture projection.
  109559. */
  109560. projectionTextureLightFar: number;
  109561. protected _projectionTextureUpDirection: Vector3;
  109562. /**
  109563. * Gets the Up vector of the Spotlight for texture projection.
  109564. */
  109565. /**
  109566. * Sets the Up vector of the Spotlight for texture projection.
  109567. */
  109568. projectionTextureUpDirection: Vector3;
  109569. private _projectionTexture;
  109570. /**
  109571. * Gets the projection texture of the light.
  109572. */
  109573. /**
  109574. * Sets the projection texture of the light.
  109575. */
  109576. projectionTexture: Nullable<BaseTexture>;
  109577. private _projectionTextureViewLightDirty;
  109578. private _projectionTextureProjectionLightDirty;
  109579. private _projectionTextureDirty;
  109580. private _projectionTextureViewTargetVector;
  109581. private _projectionTextureViewLightMatrix;
  109582. private _projectionTextureProjectionLightMatrix;
  109583. private _projectionTextureScalingMatrix;
  109584. /**
  109585. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  109586. * It can cast shadows.
  109587. * Documentation : https://doc.babylonjs.com/babylon101/lights
  109588. * @param name The light friendly name
  109589. * @param position The position of the spot light in the scene
  109590. * @param direction The direction of the light in the scene
  109591. * @param angle The cone angle of the light in Radians
  109592. * @param exponent The light decay speed with the distance from the emission spot
  109593. * @param scene The scene the lights belongs to
  109594. */
  109595. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  109596. /**
  109597. * Returns the string "SpotLight".
  109598. * @returns the class name
  109599. */
  109600. getClassName(): string;
  109601. /**
  109602. * Returns the integer 2.
  109603. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  109604. */
  109605. getTypeID(): number;
  109606. /**
  109607. * Overrides the direction setter to recompute the projection texture view light Matrix.
  109608. */
  109609. protected _setDirection(value: Vector3): void;
  109610. /**
  109611. * Overrides the position setter to recompute the projection texture view light Matrix.
  109612. */
  109613. protected _setPosition(value: Vector3): void;
  109614. /**
  109615. * 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.
  109616. * Returns the SpotLight.
  109617. */
  109618. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  109619. protected _computeProjectionTextureViewLightMatrix(): void;
  109620. protected _computeProjectionTextureProjectionLightMatrix(): void;
  109621. /**
  109622. * Main function for light texture projection matrix computing.
  109623. */
  109624. protected _computeProjectionTextureMatrix(): void;
  109625. protected _buildUniformLayout(): void;
  109626. private _computeAngleValues;
  109627. /**
  109628. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  109629. * @param effect The effect to update
  109630. * @param lightIndex The index of the light in the effect to update
  109631. * @returns The spot light
  109632. */
  109633. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  109634. /**
  109635. * Disposes the light and the associated resources.
  109636. */
  109637. dispose(): void;
  109638. /**
  109639. * Prepares the list of defines specific to the light type.
  109640. * @param defines the list of defines
  109641. * @param lightIndex defines the index of the light for the effect
  109642. */
  109643. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  109644. }
  109645. }
  109646. declare module BABYLON {
  109647. /**
  109648. * Gizmo that enables viewing a light
  109649. */
  109650. export class LightGizmo extends Gizmo {
  109651. private _lightMesh;
  109652. private _material;
  109653. private cachedPosition;
  109654. private cachedForward;
  109655. /**
  109656. * Creates a LightGizmo
  109657. * @param gizmoLayer The utility layer the gizmo will be added to
  109658. */
  109659. constructor(gizmoLayer?: UtilityLayerRenderer);
  109660. private _light;
  109661. /**
  109662. * The light that the gizmo is attached to
  109663. */
  109664. light: Nullable<Light>;
  109665. /**
  109666. * Gets the material used to render the light gizmo
  109667. */
  109668. readonly material: StandardMaterial;
  109669. /**
  109670. * @hidden
  109671. * Updates the gizmo to match the attached mesh's position/rotation
  109672. */
  109673. protected _update(): void;
  109674. private static _Scale;
  109675. /**
  109676. * Creates the lines for a light mesh
  109677. */
  109678. private static _createLightLines;
  109679. /**
  109680. * Disposes of the light gizmo
  109681. */
  109682. dispose(): void;
  109683. private static _CreateHemisphericLightMesh;
  109684. private static _CreatePointLightMesh;
  109685. private static _CreateSpotLightMesh;
  109686. private static _CreateDirectionalLightMesh;
  109687. }
  109688. }
  109689. declare module BABYLON {
  109690. /** @hidden */
  109691. export var backgroundFragmentDeclaration: {
  109692. name: string;
  109693. shader: string;
  109694. };
  109695. }
  109696. declare module BABYLON {
  109697. /** @hidden */
  109698. export var backgroundUboDeclaration: {
  109699. name: string;
  109700. shader: string;
  109701. };
  109702. }
  109703. declare module BABYLON {
  109704. /** @hidden */
  109705. export var backgroundPixelShader: {
  109706. name: string;
  109707. shader: string;
  109708. };
  109709. }
  109710. declare module BABYLON {
  109711. /** @hidden */
  109712. export var backgroundVertexDeclaration: {
  109713. name: string;
  109714. shader: string;
  109715. };
  109716. }
  109717. declare module BABYLON {
  109718. /** @hidden */
  109719. export var backgroundVertexShader: {
  109720. name: string;
  109721. shader: string;
  109722. };
  109723. }
  109724. declare module BABYLON {
  109725. /**
  109726. * Background material used to create an efficient environement around your scene.
  109727. */
  109728. export class BackgroundMaterial extends PushMaterial {
  109729. /**
  109730. * Standard reflectance value at parallel view angle.
  109731. */
  109732. static StandardReflectance0: number;
  109733. /**
  109734. * Standard reflectance value at grazing angle.
  109735. */
  109736. static StandardReflectance90: number;
  109737. protected _primaryColor: Color3;
  109738. /**
  109739. * Key light Color (multiply against the environement texture)
  109740. */
  109741. primaryColor: Color3;
  109742. protected __perceptualColor: Nullable<Color3>;
  109743. /**
  109744. * Experimental Internal Use Only.
  109745. *
  109746. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  109747. * This acts as a helper to set the primary color to a more "human friendly" value.
  109748. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  109749. * output color as close as possible from the chosen value.
  109750. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  109751. * part of lighting setup.)
  109752. */
  109753. _perceptualColor: Nullable<Color3>;
  109754. protected _primaryColorShadowLevel: float;
  109755. /**
  109756. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  109757. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  109758. */
  109759. primaryColorShadowLevel: float;
  109760. protected _primaryColorHighlightLevel: float;
  109761. /**
  109762. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  109763. * The primary color is used at the level chosen to define what the white area would look.
  109764. */
  109765. primaryColorHighlightLevel: float;
  109766. protected _reflectionTexture: Nullable<BaseTexture>;
  109767. /**
  109768. * Reflection Texture used in the material.
  109769. * Should be author in a specific way for the best result (refer to the documentation).
  109770. */
  109771. reflectionTexture: Nullable<BaseTexture>;
  109772. protected _reflectionBlur: float;
  109773. /**
  109774. * Reflection Texture level of blur.
  109775. *
  109776. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  109777. * texture twice.
  109778. */
  109779. reflectionBlur: float;
  109780. protected _diffuseTexture: Nullable<BaseTexture>;
  109781. /**
  109782. * Diffuse Texture used in the material.
  109783. * Should be author in a specific way for the best result (refer to the documentation).
  109784. */
  109785. diffuseTexture: Nullable<BaseTexture>;
  109786. protected _shadowLights: Nullable<IShadowLight[]>;
  109787. /**
  109788. * Specify the list of lights casting shadow on the material.
  109789. * All scene shadow lights will be included if null.
  109790. */
  109791. shadowLights: Nullable<IShadowLight[]>;
  109792. protected _shadowLevel: float;
  109793. /**
  109794. * Helps adjusting the shadow to a softer level if required.
  109795. * 0 means black shadows and 1 means no shadows.
  109796. */
  109797. shadowLevel: float;
  109798. protected _sceneCenter: Vector3;
  109799. /**
  109800. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  109801. * It is usually zero but might be interesting to modify according to your setup.
  109802. */
  109803. sceneCenter: Vector3;
  109804. protected _opacityFresnel: boolean;
  109805. /**
  109806. * This helps specifying that the material is falling off to the sky box at grazing angle.
  109807. * This helps ensuring a nice transition when the camera goes under the ground.
  109808. */
  109809. opacityFresnel: boolean;
  109810. protected _reflectionFresnel: boolean;
  109811. /**
  109812. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  109813. * This helps adding a mirror texture on the ground.
  109814. */
  109815. reflectionFresnel: boolean;
  109816. protected _reflectionFalloffDistance: number;
  109817. /**
  109818. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  109819. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  109820. */
  109821. reflectionFalloffDistance: number;
  109822. protected _reflectionAmount: number;
  109823. /**
  109824. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  109825. */
  109826. reflectionAmount: number;
  109827. protected _reflectionReflectance0: number;
  109828. /**
  109829. * This specifies the weight of the reflection at grazing angle.
  109830. */
  109831. reflectionReflectance0: number;
  109832. protected _reflectionReflectance90: number;
  109833. /**
  109834. * This specifies the weight of the reflection at a perpendicular point of view.
  109835. */
  109836. reflectionReflectance90: number;
  109837. /**
  109838. * Sets the reflection reflectance fresnel values according to the default standard
  109839. * empirically know to work well :-)
  109840. */
  109841. reflectionStandardFresnelWeight: number;
  109842. protected _useRGBColor: boolean;
  109843. /**
  109844. * Helps to directly use the maps channels instead of their level.
  109845. */
  109846. useRGBColor: boolean;
  109847. protected _enableNoise: boolean;
  109848. /**
  109849. * This helps reducing the banding effect that could occur on the background.
  109850. */
  109851. enableNoise: boolean;
  109852. /**
  109853. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  109854. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  109855. * Recommended to be keep at 1.0 except for special cases.
  109856. */
  109857. fovMultiplier: number;
  109858. private _fovMultiplier;
  109859. /**
  109860. * Enable the FOV adjustment feature controlled by fovMultiplier.
  109861. */
  109862. useEquirectangularFOV: boolean;
  109863. private _maxSimultaneousLights;
  109864. /**
  109865. * Number of Simultaneous lights allowed on the material.
  109866. */
  109867. maxSimultaneousLights: int;
  109868. /**
  109869. * Default configuration related to image processing available in the Background Material.
  109870. */
  109871. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  109872. /**
  109873. * Keep track of the image processing observer to allow dispose and replace.
  109874. */
  109875. private _imageProcessingObserver;
  109876. /**
  109877. * Attaches a new image processing configuration to the PBR Material.
  109878. * @param configuration (if null the scene configuration will be use)
  109879. */
  109880. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  109881. /**
  109882. * Gets the image processing configuration used either in this material.
  109883. */
  109884. /**
  109885. * Sets the Default image processing configuration used either in the this material.
  109886. *
  109887. * If sets to null, the scene one is in use.
  109888. */
  109889. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  109890. /**
  109891. * Gets wether the color curves effect is enabled.
  109892. */
  109893. /**
  109894. * Sets wether the color curves effect is enabled.
  109895. */
  109896. cameraColorCurvesEnabled: boolean;
  109897. /**
  109898. * Gets wether the color grading effect is enabled.
  109899. */
  109900. /**
  109901. * Gets wether the color grading effect is enabled.
  109902. */
  109903. cameraColorGradingEnabled: boolean;
  109904. /**
  109905. * Gets wether tonemapping is enabled or not.
  109906. */
  109907. /**
  109908. * Sets wether tonemapping is enabled or not
  109909. */
  109910. cameraToneMappingEnabled: boolean;
  109911. /**
  109912. * The camera exposure used on this material.
  109913. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109914. * This corresponds to a photographic exposure.
  109915. */
  109916. /**
  109917. * The camera exposure used on this material.
  109918. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109919. * This corresponds to a photographic exposure.
  109920. */
  109921. cameraExposure: float;
  109922. /**
  109923. * Gets The camera contrast used on this material.
  109924. */
  109925. /**
  109926. * Sets The camera contrast used on this material.
  109927. */
  109928. cameraContrast: float;
  109929. /**
  109930. * Gets the Color Grading 2D Lookup Texture.
  109931. */
  109932. /**
  109933. * Sets the Color Grading 2D Lookup Texture.
  109934. */
  109935. cameraColorGradingTexture: Nullable<BaseTexture>;
  109936. /**
  109937. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109938. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109939. * 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;
  109940. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109941. */
  109942. /**
  109943. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109944. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109945. * 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;
  109946. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109947. */
  109948. cameraColorCurves: Nullable<ColorCurves>;
  109949. /**
  109950. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  109951. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  109952. */
  109953. switchToBGR: boolean;
  109954. private _renderTargets;
  109955. private _reflectionControls;
  109956. private _white;
  109957. private _primaryShadowColor;
  109958. private _primaryHighlightColor;
  109959. /**
  109960. * Instantiates a Background Material in the given scene
  109961. * @param name The friendly name of the material
  109962. * @param scene The scene to add the material to
  109963. */
  109964. constructor(name: string, scene: Scene);
  109965. /**
  109966. * Gets a boolean indicating that current material needs to register RTT
  109967. */
  109968. readonly hasRenderTargetTextures: boolean;
  109969. /**
  109970. * The entire material has been created in order to prevent overdraw.
  109971. * @returns false
  109972. */
  109973. needAlphaTesting(): boolean;
  109974. /**
  109975. * The entire material has been created in order to prevent overdraw.
  109976. * @returns true if blending is enable
  109977. */
  109978. needAlphaBlending(): boolean;
  109979. /**
  109980. * Checks wether the material is ready to be rendered for a given mesh.
  109981. * @param mesh The mesh to render
  109982. * @param subMesh The submesh to check against
  109983. * @param useInstances Specify wether or not the material is used with instances
  109984. * @returns true if all the dependencies are ready (Textures, Effects...)
  109985. */
  109986. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  109987. /**
  109988. * Compute the primary color according to the chosen perceptual color.
  109989. */
  109990. private _computePrimaryColorFromPerceptualColor;
  109991. /**
  109992. * Compute the highlights and shadow colors according to their chosen levels.
  109993. */
  109994. private _computePrimaryColors;
  109995. /**
  109996. * Build the uniform buffer used in the material.
  109997. */
  109998. buildUniformLayout(): void;
  109999. /**
  110000. * Unbind the material.
  110001. */
  110002. unbind(): void;
  110003. /**
  110004. * Bind only the world matrix to the material.
  110005. * @param world The world matrix to bind.
  110006. */
  110007. bindOnlyWorldMatrix(world: Matrix): void;
  110008. /**
  110009. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  110010. * @param world The world matrix to bind.
  110011. * @param subMesh The submesh to bind for.
  110012. */
  110013. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  110014. /**
  110015. * Checks to see if a texture is used in the material.
  110016. * @param texture - Base texture to use.
  110017. * @returns - Boolean specifying if a texture is used in the material.
  110018. */
  110019. hasTexture(texture: BaseTexture): boolean;
  110020. /**
  110021. * Dispose the material.
  110022. * @param forceDisposeEffect Force disposal of the associated effect.
  110023. * @param forceDisposeTextures Force disposal of the associated textures.
  110024. */
  110025. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  110026. /**
  110027. * Clones the material.
  110028. * @param name The cloned name.
  110029. * @returns The cloned material.
  110030. */
  110031. clone(name: string): BackgroundMaterial;
  110032. /**
  110033. * Serializes the current material to its JSON representation.
  110034. * @returns The JSON representation.
  110035. */
  110036. serialize(): any;
  110037. /**
  110038. * Gets the class name of the material
  110039. * @returns "BackgroundMaterial"
  110040. */
  110041. getClassName(): string;
  110042. /**
  110043. * Parse a JSON input to create back a background material.
  110044. * @param source The JSON data to parse
  110045. * @param scene The scene to create the parsed material in
  110046. * @param rootUrl The root url of the assets the material depends upon
  110047. * @returns the instantiated BackgroundMaterial.
  110048. */
  110049. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  110050. }
  110051. }
  110052. declare module BABYLON {
  110053. /**
  110054. * Represents the different options available during the creation of
  110055. * a Environment helper.
  110056. *
  110057. * This can control the default ground, skybox and image processing setup of your scene.
  110058. */
  110059. export interface IEnvironmentHelperOptions {
  110060. /**
  110061. * Specifies wether or not to create a ground.
  110062. * True by default.
  110063. */
  110064. createGround: boolean;
  110065. /**
  110066. * Specifies the ground size.
  110067. * 15 by default.
  110068. */
  110069. groundSize: number;
  110070. /**
  110071. * The texture used on the ground for the main color.
  110072. * Comes from the BabylonJS CDN by default.
  110073. *
  110074. * Remarks: Can be either a texture or a url.
  110075. */
  110076. groundTexture: string | BaseTexture;
  110077. /**
  110078. * The color mixed in the ground texture by default.
  110079. * BabylonJS clearColor by default.
  110080. */
  110081. groundColor: Color3;
  110082. /**
  110083. * Specifies the ground opacity.
  110084. * 1 by default.
  110085. */
  110086. groundOpacity: number;
  110087. /**
  110088. * Enables the ground to receive shadows.
  110089. * True by default.
  110090. */
  110091. enableGroundShadow: boolean;
  110092. /**
  110093. * Helps preventing the shadow to be fully black on the ground.
  110094. * 0.5 by default.
  110095. */
  110096. groundShadowLevel: number;
  110097. /**
  110098. * Creates a mirror texture attach to the ground.
  110099. * false by default.
  110100. */
  110101. enableGroundMirror: boolean;
  110102. /**
  110103. * Specifies the ground mirror size ratio.
  110104. * 0.3 by default as the default kernel is 64.
  110105. */
  110106. groundMirrorSizeRatio: number;
  110107. /**
  110108. * Specifies the ground mirror blur kernel size.
  110109. * 64 by default.
  110110. */
  110111. groundMirrorBlurKernel: number;
  110112. /**
  110113. * Specifies the ground mirror visibility amount.
  110114. * 1 by default
  110115. */
  110116. groundMirrorAmount: number;
  110117. /**
  110118. * Specifies the ground mirror reflectance weight.
  110119. * This uses the standard weight of the background material to setup the fresnel effect
  110120. * of the mirror.
  110121. * 1 by default.
  110122. */
  110123. groundMirrorFresnelWeight: number;
  110124. /**
  110125. * Specifies the ground mirror Falloff distance.
  110126. * This can helps reducing the size of the reflection.
  110127. * 0 by Default.
  110128. */
  110129. groundMirrorFallOffDistance: number;
  110130. /**
  110131. * Specifies the ground mirror texture type.
  110132. * Unsigned Int by Default.
  110133. */
  110134. groundMirrorTextureType: number;
  110135. /**
  110136. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  110137. * the shown objects.
  110138. */
  110139. groundYBias: number;
  110140. /**
  110141. * Specifies wether or not to create a skybox.
  110142. * True by default.
  110143. */
  110144. createSkybox: boolean;
  110145. /**
  110146. * Specifies the skybox size.
  110147. * 20 by default.
  110148. */
  110149. skyboxSize: number;
  110150. /**
  110151. * The texture used on the skybox for the main color.
  110152. * Comes from the BabylonJS CDN by default.
  110153. *
  110154. * Remarks: Can be either a texture or a url.
  110155. */
  110156. skyboxTexture: string | BaseTexture;
  110157. /**
  110158. * The color mixed in the skybox texture by default.
  110159. * BabylonJS clearColor by default.
  110160. */
  110161. skyboxColor: Color3;
  110162. /**
  110163. * The background rotation around the Y axis of the scene.
  110164. * This helps aligning the key lights of your scene with the background.
  110165. * 0 by default.
  110166. */
  110167. backgroundYRotation: number;
  110168. /**
  110169. * Compute automatically the size of the elements to best fit with the scene.
  110170. */
  110171. sizeAuto: boolean;
  110172. /**
  110173. * Default position of the rootMesh if autoSize is not true.
  110174. */
  110175. rootPosition: Vector3;
  110176. /**
  110177. * Sets up the image processing in the scene.
  110178. * true by default.
  110179. */
  110180. setupImageProcessing: boolean;
  110181. /**
  110182. * The texture used as your environment texture in the scene.
  110183. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  110184. *
  110185. * Remarks: Can be either a texture or a url.
  110186. */
  110187. environmentTexture: string | BaseTexture;
  110188. /**
  110189. * The value of the exposure to apply to the scene.
  110190. * 0.6 by default if setupImageProcessing is true.
  110191. */
  110192. cameraExposure: number;
  110193. /**
  110194. * The value of the contrast to apply to the scene.
  110195. * 1.6 by default if setupImageProcessing is true.
  110196. */
  110197. cameraContrast: number;
  110198. /**
  110199. * Specifies wether or not tonemapping should be enabled in the scene.
  110200. * true by default if setupImageProcessing is true.
  110201. */
  110202. toneMappingEnabled: boolean;
  110203. }
  110204. /**
  110205. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  110206. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  110207. * It also helps with the default setup of your imageProcessing configuration.
  110208. */
  110209. export class EnvironmentHelper {
  110210. /**
  110211. * Default ground texture URL.
  110212. */
  110213. private static _groundTextureCDNUrl;
  110214. /**
  110215. * Default skybox texture URL.
  110216. */
  110217. private static _skyboxTextureCDNUrl;
  110218. /**
  110219. * Default environment texture URL.
  110220. */
  110221. private static _environmentTextureCDNUrl;
  110222. /**
  110223. * Creates the default options for the helper.
  110224. */
  110225. private static _getDefaultOptions;
  110226. private _rootMesh;
  110227. /**
  110228. * Gets the root mesh created by the helper.
  110229. */
  110230. readonly rootMesh: Mesh;
  110231. private _skybox;
  110232. /**
  110233. * Gets the skybox created by the helper.
  110234. */
  110235. readonly skybox: Nullable<Mesh>;
  110236. private _skyboxTexture;
  110237. /**
  110238. * Gets the skybox texture created by the helper.
  110239. */
  110240. readonly skyboxTexture: Nullable<BaseTexture>;
  110241. private _skyboxMaterial;
  110242. /**
  110243. * Gets the skybox material created by the helper.
  110244. */
  110245. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  110246. private _ground;
  110247. /**
  110248. * Gets the ground mesh created by the helper.
  110249. */
  110250. readonly ground: Nullable<Mesh>;
  110251. private _groundTexture;
  110252. /**
  110253. * Gets the ground texture created by the helper.
  110254. */
  110255. readonly groundTexture: Nullable<BaseTexture>;
  110256. private _groundMirror;
  110257. /**
  110258. * Gets the ground mirror created by the helper.
  110259. */
  110260. readonly groundMirror: Nullable<MirrorTexture>;
  110261. /**
  110262. * Gets the ground mirror render list to helps pushing the meshes
  110263. * you wish in the ground reflection.
  110264. */
  110265. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  110266. private _groundMaterial;
  110267. /**
  110268. * Gets the ground material created by the helper.
  110269. */
  110270. readonly groundMaterial: Nullable<BackgroundMaterial>;
  110271. /**
  110272. * Stores the creation options.
  110273. */
  110274. private readonly _scene;
  110275. private _options;
  110276. /**
  110277. * This observable will be notified with any error during the creation of the environment,
  110278. * mainly texture creation errors.
  110279. */
  110280. onErrorObservable: Observable<{
  110281. message?: string;
  110282. exception?: any;
  110283. }>;
  110284. /**
  110285. * constructor
  110286. * @param options Defines the options we want to customize the helper
  110287. * @param scene The scene to add the material to
  110288. */
  110289. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  110290. /**
  110291. * Updates the background according to the new options
  110292. * @param options
  110293. */
  110294. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  110295. /**
  110296. * Sets the primary color of all the available elements.
  110297. * @param color the main color to affect to the ground and the background
  110298. */
  110299. setMainColor(color: Color3): void;
  110300. /**
  110301. * Setup the image processing according to the specified options.
  110302. */
  110303. private _setupImageProcessing;
  110304. /**
  110305. * Setup the environment texture according to the specified options.
  110306. */
  110307. private _setupEnvironmentTexture;
  110308. /**
  110309. * Setup the background according to the specified options.
  110310. */
  110311. private _setupBackground;
  110312. /**
  110313. * Get the scene sizes according to the setup.
  110314. */
  110315. private _getSceneSize;
  110316. /**
  110317. * Setup the ground according to the specified options.
  110318. */
  110319. private _setupGround;
  110320. /**
  110321. * Setup the ground material according to the specified options.
  110322. */
  110323. private _setupGroundMaterial;
  110324. /**
  110325. * Setup the ground diffuse texture according to the specified options.
  110326. */
  110327. private _setupGroundDiffuseTexture;
  110328. /**
  110329. * Setup the ground mirror texture according to the specified options.
  110330. */
  110331. private _setupGroundMirrorTexture;
  110332. /**
  110333. * Setup the ground to receive the mirror texture.
  110334. */
  110335. private _setupMirrorInGroundMaterial;
  110336. /**
  110337. * Setup the skybox according to the specified options.
  110338. */
  110339. private _setupSkybox;
  110340. /**
  110341. * Setup the skybox material according to the specified options.
  110342. */
  110343. private _setupSkyboxMaterial;
  110344. /**
  110345. * Setup the skybox reflection texture according to the specified options.
  110346. */
  110347. private _setupSkyboxReflectionTexture;
  110348. private _errorHandler;
  110349. /**
  110350. * Dispose all the elements created by the Helper.
  110351. */
  110352. dispose(): void;
  110353. }
  110354. }
  110355. declare module BABYLON {
  110356. /**
  110357. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  110358. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  110359. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  110360. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  110361. */
  110362. export class PhotoDome extends TransformNode {
  110363. /**
  110364. * Define the image as a Monoscopic panoramic 360 image.
  110365. */
  110366. static readonly MODE_MONOSCOPIC: number;
  110367. /**
  110368. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  110369. */
  110370. static readonly MODE_TOPBOTTOM: number;
  110371. /**
  110372. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  110373. */
  110374. static readonly MODE_SIDEBYSIDE: number;
  110375. private _useDirectMapping;
  110376. /**
  110377. * The texture being displayed on the sphere
  110378. */
  110379. protected _photoTexture: Texture;
  110380. /**
  110381. * Gets or sets the texture being displayed on the sphere
  110382. */
  110383. photoTexture: Texture;
  110384. /**
  110385. * Observable raised when an error occured while loading the 360 image
  110386. */
  110387. onLoadErrorObservable: Observable<string>;
  110388. /**
  110389. * The skybox material
  110390. */
  110391. protected _material: BackgroundMaterial;
  110392. /**
  110393. * The surface used for the skybox
  110394. */
  110395. protected _mesh: Mesh;
  110396. /**
  110397. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  110398. * Also see the options.resolution property.
  110399. */
  110400. fovMultiplier: number;
  110401. private _imageMode;
  110402. /**
  110403. * Gets or set the current video mode for the video. It can be:
  110404. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  110405. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  110406. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  110407. */
  110408. imageMode: number;
  110409. /**
  110410. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  110411. * @param name Element's name, child elements will append suffixes for their own names.
  110412. * @param urlsOfPhoto defines the url of the photo to display
  110413. * @param options defines an object containing optional or exposed sub element properties
  110414. * @param onError defines a callback called when an error occured while loading the texture
  110415. */
  110416. constructor(name: string, urlOfPhoto: string, options: {
  110417. resolution?: number;
  110418. size?: number;
  110419. useDirectMapping?: boolean;
  110420. faceForward?: boolean;
  110421. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  110422. private _onBeforeCameraRenderObserver;
  110423. private _changeImageMode;
  110424. /**
  110425. * Releases resources associated with this node.
  110426. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  110427. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  110428. */
  110429. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  110430. }
  110431. }
  110432. declare module BABYLON {
  110433. /** @hidden */
  110434. export var rgbdDecodePixelShader: {
  110435. name: string;
  110436. shader: string;
  110437. };
  110438. }
  110439. declare module BABYLON {
  110440. /**
  110441. * Class used to host texture specific utilities
  110442. */
  110443. export class BRDFTextureTools {
  110444. /**
  110445. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  110446. * @param texture the texture to expand.
  110447. */
  110448. private static _ExpandDefaultBRDFTexture;
  110449. /**
  110450. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  110451. * @param scene defines the hosting scene
  110452. * @returns the environment BRDF texture
  110453. */
  110454. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  110455. private static _environmentBRDFBase64Texture;
  110456. }
  110457. }
  110458. declare module BABYLON {
  110459. /**
  110460. * @hidden
  110461. */
  110462. export interface IMaterialClearCoatDefines {
  110463. CLEARCOAT: boolean;
  110464. CLEARCOAT_DEFAULTIOR: boolean;
  110465. CLEARCOAT_TEXTURE: boolean;
  110466. CLEARCOAT_TEXTUREDIRECTUV: number;
  110467. CLEARCOAT_BUMP: boolean;
  110468. CLEARCOAT_BUMPDIRECTUV: number;
  110469. CLEARCOAT_TINT: boolean;
  110470. CLEARCOAT_TINT_TEXTURE: boolean;
  110471. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  110472. /** @hidden */
  110473. _areTexturesDirty: boolean;
  110474. }
  110475. /**
  110476. * Define the code related to the clear coat parameters of the pbr material.
  110477. */
  110478. export class PBRClearCoatConfiguration {
  110479. /**
  110480. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  110481. * The default fits with a polyurethane material.
  110482. */
  110483. private static readonly _DefaultIndexOfRefraction;
  110484. private _isEnabled;
  110485. /**
  110486. * Defines if the clear coat is enabled in the material.
  110487. */
  110488. isEnabled: boolean;
  110489. /**
  110490. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  110491. */
  110492. intensity: number;
  110493. /**
  110494. * Defines the clear coat layer roughness.
  110495. */
  110496. roughness: number;
  110497. private _indexOfRefraction;
  110498. /**
  110499. * Defines the index of refraction of the clear coat.
  110500. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  110501. * The default fits with a polyurethane material.
  110502. * Changing the default value is more performance intensive.
  110503. */
  110504. indexOfRefraction: number;
  110505. private _texture;
  110506. /**
  110507. * Stores the clear coat values in a texture.
  110508. */
  110509. texture: Nullable<BaseTexture>;
  110510. private _bumpTexture;
  110511. /**
  110512. * Define the clear coat specific bump texture.
  110513. */
  110514. bumpTexture: Nullable<BaseTexture>;
  110515. private _isTintEnabled;
  110516. /**
  110517. * Defines if the clear coat tint is enabled in the material.
  110518. */
  110519. isTintEnabled: boolean;
  110520. /**
  110521. * Defines the clear coat tint of the material.
  110522. * This is only use if tint is enabled
  110523. */
  110524. tintColor: Color3;
  110525. /**
  110526. * Defines the distance at which the tint color should be found in the
  110527. * clear coat media.
  110528. * This is only use if tint is enabled
  110529. */
  110530. tintColorAtDistance: number;
  110531. /**
  110532. * Defines the clear coat layer thickness.
  110533. * This is only use if tint is enabled
  110534. */
  110535. tintThickness: number;
  110536. private _tintTexture;
  110537. /**
  110538. * Stores the clear tint values in a texture.
  110539. * rgb is tint
  110540. * a is a thickness factor
  110541. */
  110542. tintTexture: Nullable<BaseTexture>;
  110543. /** @hidden */
  110544. private _internalMarkAllSubMeshesAsTexturesDirty;
  110545. /** @hidden */
  110546. _markAllSubMeshesAsTexturesDirty(): void;
  110547. /**
  110548. * Instantiate a new istance of clear coat configuration.
  110549. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  110550. */
  110551. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  110552. /**
  110553. * Gets wehter the submesh is ready to be used or not.
  110554. * @param defines the list of "defines" to update.
  110555. * @param scene defines the scene the material belongs to.
  110556. * @param engine defines the engine the material belongs to.
  110557. * @param disableBumpMap defines wether the material disables bump or not.
  110558. * @returns - boolean indicating that the submesh is ready or not.
  110559. */
  110560. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  110561. /**
  110562. * Checks to see if a texture is used in the material.
  110563. * @param defines the list of "defines" to update.
  110564. * @param scene defines the scene to the material belongs to.
  110565. */
  110566. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  110567. /**
  110568. * Binds the material data.
  110569. * @param uniformBuffer defines the Uniform buffer to fill in.
  110570. * @param scene defines the scene the material belongs to.
  110571. * @param engine defines the engine the material belongs to.
  110572. * @param disableBumpMap defines wether the material disables bump or not.
  110573. * @param isFrozen defines wether the material is frozen or not.
  110574. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  110575. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  110576. */
  110577. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  110578. /**
  110579. * Checks to see if a texture is used in the material.
  110580. * @param texture - Base texture to use.
  110581. * @returns - Boolean specifying if a texture is used in the material.
  110582. */
  110583. hasTexture(texture: BaseTexture): boolean;
  110584. /**
  110585. * Returns an array of the actively used textures.
  110586. * @param activeTextures Array of BaseTextures
  110587. */
  110588. getActiveTextures(activeTextures: BaseTexture[]): void;
  110589. /**
  110590. * Returns the animatable textures.
  110591. * @param animatables Array of animatable textures.
  110592. */
  110593. getAnimatables(animatables: IAnimatable[]): void;
  110594. /**
  110595. * Disposes the resources of the material.
  110596. * @param forceDisposeTextures - Forces the disposal of all textures.
  110597. */
  110598. dispose(forceDisposeTextures?: boolean): void;
  110599. /**
  110600. * Get the current class name of the texture useful for serialization or dynamic coding.
  110601. * @returns "PBRClearCoatConfiguration"
  110602. */
  110603. getClassName(): string;
  110604. /**
  110605. * Add fallbacks to the effect fallbacks list.
  110606. * @param defines defines the Base texture to use.
  110607. * @param fallbacks defines the current fallback list.
  110608. * @param currentRank defines the current fallback rank.
  110609. * @returns the new fallback rank.
  110610. */
  110611. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  110612. /**
  110613. * Add the required uniforms to the current list.
  110614. * @param uniforms defines the current uniform list.
  110615. */
  110616. static AddUniforms(uniforms: string[]): void;
  110617. /**
  110618. * Add the required samplers to the current list.
  110619. * @param samplers defines the current sampler list.
  110620. */
  110621. static AddSamplers(samplers: string[]): void;
  110622. /**
  110623. * Add the required uniforms to the current buffer.
  110624. * @param uniformBuffer defines the current uniform buffer.
  110625. */
  110626. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  110627. /**
  110628. * Makes a duplicate of the current configuration into another one.
  110629. * @param clearCoatConfiguration define the config where to copy the info
  110630. */
  110631. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  110632. /**
  110633. * Serializes this clear coat configuration.
  110634. * @returns - An object with the serialized config.
  110635. */
  110636. serialize(): any;
  110637. /**
  110638. * Parses a anisotropy Configuration from a serialized object.
  110639. * @param source - Serialized object.
  110640. * @param scene Defines the scene we are parsing for
  110641. * @param rootUrl Defines the rootUrl to load from
  110642. */
  110643. parse(source: any, scene: Scene, rootUrl: string): void;
  110644. }
  110645. }
  110646. declare module BABYLON {
  110647. /**
  110648. * @hidden
  110649. */
  110650. export interface IMaterialAnisotropicDefines {
  110651. ANISOTROPIC: boolean;
  110652. ANISOTROPIC_TEXTURE: boolean;
  110653. ANISOTROPIC_TEXTUREDIRECTUV: number;
  110654. MAINUV1: boolean;
  110655. _areTexturesDirty: boolean;
  110656. _needUVs: boolean;
  110657. }
  110658. /**
  110659. * Define the code related to the anisotropic parameters of the pbr material.
  110660. */
  110661. export class PBRAnisotropicConfiguration {
  110662. private _isEnabled;
  110663. /**
  110664. * Defines if the anisotropy is enabled in the material.
  110665. */
  110666. isEnabled: boolean;
  110667. /**
  110668. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  110669. */
  110670. intensity: number;
  110671. /**
  110672. * Defines if the effect is along the tangents, bitangents or in between.
  110673. * By default, the effect is "strectching" the highlights along the tangents.
  110674. */
  110675. direction: Vector2;
  110676. private _texture;
  110677. /**
  110678. * Stores the anisotropy values in a texture.
  110679. * rg is direction (like normal from -1 to 1)
  110680. * b is a intensity
  110681. */
  110682. texture: Nullable<BaseTexture>;
  110683. /** @hidden */
  110684. private _internalMarkAllSubMeshesAsTexturesDirty;
  110685. /** @hidden */
  110686. _markAllSubMeshesAsTexturesDirty(): void;
  110687. /**
  110688. * Instantiate a new istance of anisotropy configuration.
  110689. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  110690. */
  110691. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  110692. /**
  110693. * Specifies that the submesh is ready to be used.
  110694. * @param defines the list of "defines" to update.
  110695. * @param scene defines the scene the material belongs to.
  110696. * @returns - boolean indicating that the submesh is ready or not.
  110697. */
  110698. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  110699. /**
  110700. * Checks to see if a texture is used in the material.
  110701. * @param defines the list of "defines" to update.
  110702. * @param mesh the mesh we are preparing the defines for.
  110703. * @param scene defines the scene the material belongs to.
  110704. */
  110705. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  110706. /**
  110707. * Binds the material data.
  110708. * @param uniformBuffer defines the Uniform buffer to fill in.
  110709. * @param scene defines the scene the material belongs to.
  110710. * @param isFrozen defines wether the material is frozen or not.
  110711. */
  110712. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  110713. /**
  110714. * Checks to see if a texture is used in the material.
  110715. * @param texture - Base texture to use.
  110716. * @returns - Boolean specifying if a texture is used in the material.
  110717. */
  110718. hasTexture(texture: BaseTexture): boolean;
  110719. /**
  110720. * Returns an array of the actively used textures.
  110721. * @param activeTextures Array of BaseTextures
  110722. */
  110723. getActiveTextures(activeTextures: BaseTexture[]): void;
  110724. /**
  110725. * Returns the animatable textures.
  110726. * @param animatables Array of animatable textures.
  110727. */
  110728. getAnimatables(animatables: IAnimatable[]): void;
  110729. /**
  110730. * Disposes the resources of the material.
  110731. * @param forceDisposeTextures - Forces the disposal of all textures.
  110732. */
  110733. dispose(forceDisposeTextures?: boolean): void;
  110734. /**
  110735. * Get the current class name of the texture useful for serialization or dynamic coding.
  110736. * @returns "PBRAnisotropicConfiguration"
  110737. */
  110738. getClassName(): string;
  110739. /**
  110740. * Add fallbacks to the effect fallbacks list.
  110741. * @param defines defines the Base texture to use.
  110742. * @param fallbacks defines the current fallback list.
  110743. * @param currentRank defines the current fallback rank.
  110744. * @returns the new fallback rank.
  110745. */
  110746. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  110747. /**
  110748. * Add the required uniforms to the current list.
  110749. * @param uniforms defines the current uniform list.
  110750. */
  110751. static AddUniforms(uniforms: string[]): void;
  110752. /**
  110753. * Add the required uniforms to the current buffer.
  110754. * @param uniformBuffer defines the current uniform buffer.
  110755. */
  110756. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  110757. /**
  110758. * Add the required samplers to the current list.
  110759. * @param samplers defines the current sampler list.
  110760. */
  110761. static AddSamplers(samplers: string[]): void;
  110762. /**
  110763. * Makes a duplicate of the current configuration into another one.
  110764. * @param anisotropicConfiguration define the config where to copy the info
  110765. */
  110766. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  110767. /**
  110768. * Serializes this anisotropy configuration.
  110769. * @returns - An object with the serialized config.
  110770. */
  110771. serialize(): any;
  110772. /**
  110773. * Parses a anisotropy Configuration from a serialized object.
  110774. * @param source - Serialized object.
  110775. * @param scene Defines the scene we are parsing for
  110776. * @param rootUrl Defines the rootUrl to load from
  110777. */
  110778. parse(source: any, scene: Scene, rootUrl: string): void;
  110779. }
  110780. }
  110781. declare module BABYLON {
  110782. /**
  110783. * @hidden
  110784. */
  110785. export interface IMaterialBRDFDefines {
  110786. BRDF_V_HEIGHT_CORRELATED: boolean;
  110787. MS_BRDF_ENERGY_CONSERVATION: boolean;
  110788. SPHERICAL_HARMONICS: boolean;
  110789. /** @hidden */
  110790. _areMiscDirty: boolean;
  110791. }
  110792. /**
  110793. * Define the code related to the BRDF parameters of the pbr material.
  110794. */
  110795. export class PBRBRDFConfiguration {
  110796. /**
  110797. * Default value used for the energy conservation.
  110798. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  110799. */
  110800. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  110801. /**
  110802. * Default value used for the Smith Visibility Height Correlated mode.
  110803. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  110804. */
  110805. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  110806. /**
  110807. * Default value used for the IBL diffuse part.
  110808. * This can help switching back to the polynomials mode globally which is a tiny bit
  110809. * less GPU intensive at the drawback of a lower quality.
  110810. */
  110811. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  110812. private _useEnergyConservation;
  110813. /**
  110814. * Defines if the material uses energy conservation.
  110815. */
  110816. useEnergyConservation: boolean;
  110817. private _useSmithVisibilityHeightCorrelated;
  110818. /**
  110819. * LEGACY Mode set to false
  110820. * Defines if the material uses height smith correlated visibility term.
  110821. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  110822. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  110823. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  110824. * Not relying on height correlated will also disable energy conservation.
  110825. */
  110826. useSmithVisibilityHeightCorrelated: boolean;
  110827. private _useSphericalHarmonics;
  110828. /**
  110829. * LEGACY Mode set to false
  110830. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  110831. * diffuse part of the IBL.
  110832. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  110833. * to the ground truth.
  110834. */
  110835. useSphericalHarmonics: boolean;
  110836. /** @hidden */
  110837. private _internalMarkAllSubMeshesAsMiscDirty;
  110838. /** @hidden */
  110839. _markAllSubMeshesAsMiscDirty(): void;
  110840. /**
  110841. * Instantiate a new istance of clear coat configuration.
  110842. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  110843. */
  110844. constructor(markAllSubMeshesAsMiscDirty: () => void);
  110845. /**
  110846. * Checks to see if a texture is used in the material.
  110847. * @param defines the list of "defines" to update.
  110848. */
  110849. prepareDefines(defines: IMaterialBRDFDefines): void;
  110850. /**
  110851. * Get the current class name of the texture useful for serialization or dynamic coding.
  110852. * @returns "PBRClearCoatConfiguration"
  110853. */
  110854. getClassName(): string;
  110855. /**
  110856. * Makes a duplicate of the current configuration into another one.
  110857. * @param brdfConfiguration define the config where to copy the info
  110858. */
  110859. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  110860. /**
  110861. * Serializes this BRDF configuration.
  110862. * @returns - An object with the serialized config.
  110863. */
  110864. serialize(): any;
  110865. /**
  110866. * Parses a anisotropy Configuration from a serialized object.
  110867. * @param source - Serialized object.
  110868. * @param scene Defines the scene we are parsing for
  110869. * @param rootUrl Defines the rootUrl to load from
  110870. */
  110871. parse(source: any, scene: Scene, rootUrl: string): void;
  110872. }
  110873. }
  110874. declare module BABYLON {
  110875. /**
  110876. * @hidden
  110877. */
  110878. export interface IMaterialSheenDefines {
  110879. SHEEN: boolean;
  110880. SHEEN_TEXTURE: boolean;
  110881. SHEEN_TEXTUREDIRECTUV: number;
  110882. SHEEN_LINKWITHALBEDO: boolean;
  110883. /** @hidden */
  110884. _areTexturesDirty: boolean;
  110885. }
  110886. /**
  110887. * Define the code related to the Sheen parameters of the pbr material.
  110888. */
  110889. export class PBRSheenConfiguration {
  110890. private _isEnabled;
  110891. /**
  110892. * Defines if the material uses sheen.
  110893. */
  110894. isEnabled: boolean;
  110895. private _linkSheenWithAlbedo;
  110896. /**
  110897. * Defines if the sheen is linked to the sheen color.
  110898. */
  110899. linkSheenWithAlbedo: boolean;
  110900. /**
  110901. * Defines the sheen intensity.
  110902. */
  110903. intensity: number;
  110904. /**
  110905. * Defines the sheen color.
  110906. */
  110907. color: Color3;
  110908. private _texture;
  110909. /**
  110910. * Stores the sheen tint values in a texture.
  110911. * rgb is tint
  110912. * a is a intensity
  110913. */
  110914. texture: Nullable<BaseTexture>;
  110915. /** @hidden */
  110916. private _internalMarkAllSubMeshesAsTexturesDirty;
  110917. /** @hidden */
  110918. _markAllSubMeshesAsTexturesDirty(): void;
  110919. /**
  110920. * Instantiate a new istance of clear coat configuration.
  110921. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  110922. */
  110923. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  110924. /**
  110925. * Specifies that the submesh is ready to be used.
  110926. * @param defines the list of "defines" to update.
  110927. * @param scene defines the scene the material belongs to.
  110928. * @returns - boolean indicating that the submesh is ready or not.
  110929. */
  110930. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  110931. /**
  110932. * Checks to see if a texture is used in the material.
  110933. * @param defines the list of "defines" to update.
  110934. * @param scene defines the scene the material belongs to.
  110935. */
  110936. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  110937. /**
  110938. * Binds the material data.
  110939. * @param uniformBuffer defines the Uniform buffer to fill in.
  110940. * @param scene defines the scene the material belongs to.
  110941. * @param isFrozen defines wether the material is frozen or not.
  110942. */
  110943. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  110944. /**
  110945. * Checks to see if a texture is used in the material.
  110946. * @param texture - Base texture to use.
  110947. * @returns - Boolean specifying if a texture is used in the material.
  110948. */
  110949. hasTexture(texture: BaseTexture): boolean;
  110950. /**
  110951. * Returns an array of the actively used textures.
  110952. * @param activeTextures Array of BaseTextures
  110953. */
  110954. getActiveTextures(activeTextures: BaseTexture[]): void;
  110955. /**
  110956. * Returns the animatable textures.
  110957. * @param animatables Array of animatable textures.
  110958. */
  110959. getAnimatables(animatables: IAnimatable[]): void;
  110960. /**
  110961. * Disposes the resources of the material.
  110962. * @param forceDisposeTextures - Forces the disposal of all textures.
  110963. */
  110964. dispose(forceDisposeTextures?: boolean): void;
  110965. /**
  110966. * Get the current class name of the texture useful for serialization or dynamic coding.
  110967. * @returns "PBRSheenConfiguration"
  110968. */
  110969. getClassName(): string;
  110970. /**
  110971. * Add fallbacks to the effect fallbacks list.
  110972. * @param defines defines the Base texture to use.
  110973. * @param fallbacks defines the current fallback list.
  110974. * @param currentRank defines the current fallback rank.
  110975. * @returns the new fallback rank.
  110976. */
  110977. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  110978. /**
  110979. * Add the required uniforms to the current list.
  110980. * @param uniforms defines the current uniform list.
  110981. */
  110982. static AddUniforms(uniforms: string[]): void;
  110983. /**
  110984. * Add the required uniforms to the current buffer.
  110985. * @param uniformBuffer defines the current uniform buffer.
  110986. */
  110987. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  110988. /**
  110989. * Add the required samplers to the current list.
  110990. * @param samplers defines the current sampler list.
  110991. */
  110992. static AddSamplers(samplers: string[]): void;
  110993. /**
  110994. * Makes a duplicate of the current configuration into another one.
  110995. * @param sheenConfiguration define the config where to copy the info
  110996. */
  110997. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  110998. /**
  110999. * Serializes this BRDF configuration.
  111000. * @returns - An object with the serialized config.
  111001. */
  111002. serialize(): any;
  111003. /**
  111004. * Parses a anisotropy Configuration from a serialized object.
  111005. * @param source - Serialized object.
  111006. * @param scene Defines the scene we are parsing for
  111007. * @param rootUrl Defines the rootUrl to load from
  111008. */
  111009. parse(source: any, scene: Scene, rootUrl: string): void;
  111010. }
  111011. }
  111012. declare module BABYLON {
  111013. /**
  111014. * @hidden
  111015. */
  111016. export interface IMaterialSubSurfaceDefines {
  111017. SUBSURFACE: boolean;
  111018. SS_REFRACTION: boolean;
  111019. SS_TRANSLUCENCY: boolean;
  111020. SS_SCATERRING: boolean;
  111021. SS_THICKNESSANDMASK_TEXTURE: boolean;
  111022. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  111023. SS_REFRACTIONMAP_3D: boolean;
  111024. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  111025. SS_LODINREFRACTIONALPHA: boolean;
  111026. SS_GAMMAREFRACTION: boolean;
  111027. SS_RGBDREFRACTION: boolean;
  111028. SS_LINEARSPECULARREFRACTION: boolean;
  111029. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  111030. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  111031. /** @hidden */
  111032. _areTexturesDirty: boolean;
  111033. }
  111034. /**
  111035. * Define the code related to the sub surface parameters of the pbr material.
  111036. */
  111037. export class PBRSubSurfaceConfiguration {
  111038. private _isRefractionEnabled;
  111039. /**
  111040. * Defines if the refraction is enabled in the material.
  111041. */
  111042. isRefractionEnabled: boolean;
  111043. private _isTranslucencyEnabled;
  111044. /**
  111045. * Defines if the translucency is enabled in the material.
  111046. */
  111047. isTranslucencyEnabled: boolean;
  111048. private _isScatteringEnabled;
  111049. /**
  111050. * Defines the refraction intensity of the material.
  111051. * The refraction when enabled replaces the Diffuse part of the material.
  111052. * The intensity helps transitionning between diffuse and refraction.
  111053. */
  111054. refractionIntensity: number;
  111055. /**
  111056. * Defines the translucency intensity of the material.
  111057. * When translucency has been enabled, this defines how much of the "translucency"
  111058. * is addded to the diffuse part of the material.
  111059. */
  111060. translucencyIntensity: number;
  111061. /**
  111062. * Defines the scattering intensity of the material.
  111063. * When scattering has been enabled, this defines how much of the "scattered light"
  111064. * is addded to the diffuse part of the material.
  111065. */
  111066. scatteringIntensity: number;
  111067. private _thicknessTexture;
  111068. /**
  111069. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  111070. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  111071. * 0 would mean minimumThickness
  111072. * 1 would mean maximumThickness
  111073. * The other channels might be use as a mask to vary the different effects intensity.
  111074. */
  111075. thicknessTexture: Nullable<BaseTexture>;
  111076. private _refractionTexture;
  111077. /**
  111078. * Defines the texture to use for refraction.
  111079. */
  111080. refractionTexture: Nullable<BaseTexture>;
  111081. private _indexOfRefraction;
  111082. /**
  111083. * Defines the index of refraction used in the material.
  111084. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  111085. */
  111086. indexOfRefraction: number;
  111087. private _invertRefractionY;
  111088. /**
  111089. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  111090. */
  111091. invertRefractionY: boolean;
  111092. private _linkRefractionWithTransparency;
  111093. /**
  111094. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  111095. * Materials half opaque for instance using refraction could benefit from this control.
  111096. */
  111097. linkRefractionWithTransparency: boolean;
  111098. /**
  111099. * Defines the minimum thickness stored in the thickness map.
  111100. * If no thickness map is defined, this value will be used to simulate thickness.
  111101. */
  111102. minimumThickness: number;
  111103. /**
  111104. * Defines the maximum thickness stored in the thickness map.
  111105. */
  111106. maximumThickness: number;
  111107. /**
  111108. * Defines the volume tint of the material.
  111109. * This is used for both translucency and scattering.
  111110. */
  111111. tintColor: Color3;
  111112. /**
  111113. * Defines the distance at which the tint color should be found in the media.
  111114. * This is used for refraction only.
  111115. */
  111116. tintColorAtDistance: number;
  111117. /**
  111118. * Defines how far each channel transmit through the media.
  111119. * It is defined as a color to simplify it selection.
  111120. */
  111121. diffusionDistance: Color3;
  111122. private _useMaskFromThicknessTexture;
  111123. /**
  111124. * Stores the intensity of the different subsurface effects in the thickness texture.
  111125. * * the green channel is the translucency intensity.
  111126. * * the blue channel is the scattering intensity.
  111127. * * the alpha channel is the refraction intensity.
  111128. */
  111129. useMaskFromThicknessTexture: boolean;
  111130. /** @hidden */
  111131. private _internalMarkAllSubMeshesAsTexturesDirty;
  111132. /** @hidden */
  111133. _markAllSubMeshesAsTexturesDirty(): void;
  111134. /**
  111135. * Instantiate a new istance of sub surface configuration.
  111136. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  111137. */
  111138. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  111139. /**
  111140. * Gets wehter the submesh is ready to be used or not.
  111141. * @param defines the list of "defines" to update.
  111142. * @param scene defines the scene the material belongs to.
  111143. * @returns - boolean indicating that the submesh is ready or not.
  111144. */
  111145. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  111146. /**
  111147. * Checks to see if a texture is used in the material.
  111148. * @param defines the list of "defines" to update.
  111149. * @param scene defines the scene to the material belongs to.
  111150. */
  111151. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  111152. /**
  111153. * Binds the material data.
  111154. * @param uniformBuffer defines the Uniform buffer to fill in.
  111155. * @param scene defines the scene the material belongs to.
  111156. * @param engine defines the engine the material belongs to.
  111157. * @param isFrozen defines wether the material is frozen or not.
  111158. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  111159. */
  111160. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  111161. /**
  111162. * Unbinds the material from the mesh.
  111163. * @param activeEffect defines the effect that should be unbound from.
  111164. * @returns true if unbound, otherwise false
  111165. */
  111166. unbind(activeEffect: Effect): boolean;
  111167. /**
  111168. * Returns the texture used for refraction or null if none is used.
  111169. * @param scene defines the scene the material belongs to.
  111170. * @returns - Refraction texture if present. If no refraction texture and refraction
  111171. * is linked with transparency, returns environment texture. Otherwise, returns null.
  111172. */
  111173. private _getRefractionTexture;
  111174. /**
  111175. * Returns true if alpha blending should be disabled.
  111176. */
  111177. readonly disableAlphaBlending: boolean;
  111178. /**
  111179. * Fills the list of render target textures.
  111180. * @param renderTargets the list of render targets to update
  111181. */
  111182. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  111183. /**
  111184. * Checks to see if a texture is used in the material.
  111185. * @param texture - Base texture to use.
  111186. * @returns - Boolean specifying if a texture is used in the material.
  111187. */
  111188. hasTexture(texture: BaseTexture): boolean;
  111189. /**
  111190. * Gets a boolean indicating that current material needs to register RTT
  111191. * @returns true if this uses a render target otherwise false.
  111192. */
  111193. hasRenderTargetTextures(): boolean;
  111194. /**
  111195. * Returns an array of the actively used textures.
  111196. * @param activeTextures Array of BaseTextures
  111197. */
  111198. getActiveTextures(activeTextures: BaseTexture[]): void;
  111199. /**
  111200. * Returns the animatable textures.
  111201. * @param animatables Array of animatable textures.
  111202. */
  111203. getAnimatables(animatables: IAnimatable[]): void;
  111204. /**
  111205. * Disposes the resources of the material.
  111206. * @param forceDisposeTextures - Forces the disposal of all textures.
  111207. */
  111208. dispose(forceDisposeTextures?: boolean): void;
  111209. /**
  111210. * Get the current class name of the texture useful for serialization or dynamic coding.
  111211. * @returns "PBRSubSurfaceConfiguration"
  111212. */
  111213. getClassName(): string;
  111214. /**
  111215. * Add fallbacks to the effect fallbacks list.
  111216. * @param defines defines the Base texture to use.
  111217. * @param fallbacks defines the current fallback list.
  111218. * @param currentRank defines the current fallback rank.
  111219. * @returns the new fallback rank.
  111220. */
  111221. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  111222. /**
  111223. * Add the required uniforms to the current list.
  111224. * @param uniforms defines the current uniform list.
  111225. */
  111226. static AddUniforms(uniforms: string[]): void;
  111227. /**
  111228. * Add the required samplers to the current list.
  111229. * @param samplers defines the current sampler list.
  111230. */
  111231. static AddSamplers(samplers: string[]): void;
  111232. /**
  111233. * Add the required uniforms to the current buffer.
  111234. * @param uniformBuffer defines the current uniform buffer.
  111235. */
  111236. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  111237. /**
  111238. * Makes a duplicate of the current configuration into another one.
  111239. * @param configuration define the config where to copy the info
  111240. */
  111241. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  111242. /**
  111243. * Serializes this Sub Surface configuration.
  111244. * @returns - An object with the serialized config.
  111245. */
  111246. serialize(): any;
  111247. /**
  111248. * Parses a anisotropy Configuration from a serialized object.
  111249. * @param source - Serialized object.
  111250. * @param scene Defines the scene we are parsing for
  111251. * @param rootUrl Defines the rootUrl to load from
  111252. */
  111253. parse(source: any, scene: Scene, rootUrl: string): void;
  111254. }
  111255. }
  111256. declare module BABYLON {
  111257. /** @hidden */
  111258. export var pbrFragmentDeclaration: {
  111259. name: string;
  111260. shader: string;
  111261. };
  111262. }
  111263. declare module BABYLON {
  111264. /** @hidden */
  111265. export var pbrUboDeclaration: {
  111266. name: string;
  111267. shader: string;
  111268. };
  111269. }
  111270. declare module BABYLON {
  111271. /** @hidden */
  111272. export var pbrFragmentExtraDeclaration: {
  111273. name: string;
  111274. shader: string;
  111275. };
  111276. }
  111277. declare module BABYLON {
  111278. /** @hidden */
  111279. export var pbrFragmentSamplersDeclaration: {
  111280. name: string;
  111281. shader: string;
  111282. };
  111283. }
  111284. declare module BABYLON {
  111285. /** @hidden */
  111286. export var pbrHelperFunctions: {
  111287. name: string;
  111288. shader: string;
  111289. };
  111290. }
  111291. declare module BABYLON {
  111292. /** @hidden */
  111293. export var harmonicsFunctions: {
  111294. name: string;
  111295. shader: string;
  111296. };
  111297. }
  111298. declare module BABYLON {
  111299. /** @hidden */
  111300. export var pbrDirectLightingSetupFunctions: {
  111301. name: string;
  111302. shader: string;
  111303. };
  111304. }
  111305. declare module BABYLON {
  111306. /** @hidden */
  111307. export var pbrDirectLightingFalloffFunctions: {
  111308. name: string;
  111309. shader: string;
  111310. };
  111311. }
  111312. declare module BABYLON {
  111313. /** @hidden */
  111314. export var pbrBRDFFunctions: {
  111315. name: string;
  111316. shader: string;
  111317. };
  111318. }
  111319. declare module BABYLON {
  111320. /** @hidden */
  111321. export var pbrDirectLightingFunctions: {
  111322. name: string;
  111323. shader: string;
  111324. };
  111325. }
  111326. declare module BABYLON {
  111327. /** @hidden */
  111328. export var pbrIBLFunctions: {
  111329. name: string;
  111330. shader: string;
  111331. };
  111332. }
  111333. declare module BABYLON {
  111334. /** @hidden */
  111335. export var pbrDebug: {
  111336. name: string;
  111337. shader: string;
  111338. };
  111339. }
  111340. declare module BABYLON {
  111341. /** @hidden */
  111342. export var pbrPixelShader: {
  111343. name: string;
  111344. shader: string;
  111345. };
  111346. }
  111347. declare module BABYLON {
  111348. /** @hidden */
  111349. export var pbrVertexDeclaration: {
  111350. name: string;
  111351. shader: string;
  111352. };
  111353. }
  111354. declare module BABYLON {
  111355. /** @hidden */
  111356. export var pbrVertexShader: {
  111357. name: string;
  111358. shader: string;
  111359. };
  111360. }
  111361. declare module BABYLON {
  111362. /**
  111363. * Manages the defines for the PBR Material.
  111364. * @hidden
  111365. */
  111366. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  111367. PBR: boolean;
  111368. MAINUV1: boolean;
  111369. MAINUV2: boolean;
  111370. UV1: boolean;
  111371. UV2: boolean;
  111372. ALBEDO: boolean;
  111373. ALBEDODIRECTUV: number;
  111374. VERTEXCOLOR: boolean;
  111375. AMBIENT: boolean;
  111376. AMBIENTDIRECTUV: number;
  111377. AMBIENTINGRAYSCALE: boolean;
  111378. OPACITY: boolean;
  111379. VERTEXALPHA: boolean;
  111380. OPACITYDIRECTUV: number;
  111381. OPACITYRGB: boolean;
  111382. ALPHATEST: boolean;
  111383. DEPTHPREPASS: boolean;
  111384. ALPHABLEND: boolean;
  111385. ALPHAFROMALBEDO: boolean;
  111386. ALPHATESTVALUE: string;
  111387. SPECULAROVERALPHA: boolean;
  111388. RADIANCEOVERALPHA: boolean;
  111389. ALPHAFRESNEL: boolean;
  111390. LINEARALPHAFRESNEL: boolean;
  111391. PREMULTIPLYALPHA: boolean;
  111392. EMISSIVE: boolean;
  111393. EMISSIVEDIRECTUV: number;
  111394. REFLECTIVITY: boolean;
  111395. REFLECTIVITYDIRECTUV: number;
  111396. SPECULARTERM: boolean;
  111397. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  111398. MICROSURFACEAUTOMATIC: boolean;
  111399. LODBASEDMICROSFURACE: boolean;
  111400. MICROSURFACEMAP: boolean;
  111401. MICROSURFACEMAPDIRECTUV: number;
  111402. METALLICWORKFLOW: boolean;
  111403. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  111404. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  111405. METALLNESSSTOREINMETALMAPBLUE: boolean;
  111406. AOSTOREINMETALMAPRED: boolean;
  111407. ENVIRONMENTBRDF: boolean;
  111408. ENVIRONMENTBRDF_RGBD: boolean;
  111409. NORMAL: boolean;
  111410. TANGENT: boolean;
  111411. BUMP: boolean;
  111412. BUMPDIRECTUV: number;
  111413. OBJECTSPACE_NORMALMAP: boolean;
  111414. PARALLAX: boolean;
  111415. PARALLAXOCCLUSION: boolean;
  111416. NORMALXYSCALE: boolean;
  111417. LIGHTMAP: boolean;
  111418. LIGHTMAPDIRECTUV: number;
  111419. USELIGHTMAPASSHADOWMAP: boolean;
  111420. GAMMALIGHTMAP: boolean;
  111421. REFLECTION: boolean;
  111422. REFLECTIONMAP_3D: boolean;
  111423. REFLECTIONMAP_SPHERICAL: boolean;
  111424. REFLECTIONMAP_PLANAR: boolean;
  111425. REFLECTIONMAP_CUBIC: boolean;
  111426. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  111427. REFLECTIONMAP_PROJECTION: boolean;
  111428. REFLECTIONMAP_SKYBOX: boolean;
  111429. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  111430. REFLECTIONMAP_EXPLICIT: boolean;
  111431. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  111432. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  111433. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  111434. INVERTCUBICMAP: boolean;
  111435. USESPHERICALFROMREFLECTIONMAP: boolean;
  111436. USEIRRADIANCEMAP: boolean;
  111437. SPHERICAL_HARMONICS: boolean;
  111438. USESPHERICALINVERTEX: boolean;
  111439. REFLECTIONMAP_OPPOSITEZ: boolean;
  111440. LODINREFLECTIONALPHA: boolean;
  111441. GAMMAREFLECTION: boolean;
  111442. RGBDREFLECTION: boolean;
  111443. LINEARSPECULARREFLECTION: boolean;
  111444. RADIANCEOCCLUSION: boolean;
  111445. HORIZONOCCLUSION: boolean;
  111446. INSTANCES: boolean;
  111447. NUM_BONE_INFLUENCERS: number;
  111448. BonesPerMesh: number;
  111449. BONETEXTURE: boolean;
  111450. NONUNIFORMSCALING: boolean;
  111451. MORPHTARGETS: boolean;
  111452. MORPHTARGETS_NORMAL: boolean;
  111453. MORPHTARGETS_TANGENT: boolean;
  111454. MORPHTARGETS_UV: boolean;
  111455. NUM_MORPH_INFLUENCERS: number;
  111456. IMAGEPROCESSING: boolean;
  111457. VIGNETTE: boolean;
  111458. VIGNETTEBLENDMODEMULTIPLY: boolean;
  111459. VIGNETTEBLENDMODEOPAQUE: boolean;
  111460. TONEMAPPING: boolean;
  111461. TONEMAPPING_ACES: boolean;
  111462. CONTRAST: boolean;
  111463. COLORCURVES: boolean;
  111464. COLORGRADING: boolean;
  111465. COLORGRADING3D: boolean;
  111466. SAMPLER3DGREENDEPTH: boolean;
  111467. SAMPLER3DBGRMAP: boolean;
  111468. IMAGEPROCESSINGPOSTPROCESS: boolean;
  111469. EXPOSURE: boolean;
  111470. MULTIVIEW: boolean;
  111471. USEPHYSICALLIGHTFALLOFF: boolean;
  111472. USEGLTFLIGHTFALLOFF: boolean;
  111473. TWOSIDEDLIGHTING: boolean;
  111474. SHADOWFLOAT: boolean;
  111475. CLIPPLANE: boolean;
  111476. CLIPPLANE2: boolean;
  111477. CLIPPLANE3: boolean;
  111478. CLIPPLANE4: boolean;
  111479. POINTSIZE: boolean;
  111480. FOG: boolean;
  111481. LOGARITHMICDEPTH: boolean;
  111482. FORCENORMALFORWARD: boolean;
  111483. SPECULARAA: boolean;
  111484. CLEARCOAT: boolean;
  111485. CLEARCOAT_DEFAULTIOR: boolean;
  111486. CLEARCOAT_TEXTURE: boolean;
  111487. CLEARCOAT_TEXTUREDIRECTUV: number;
  111488. CLEARCOAT_BUMP: boolean;
  111489. CLEARCOAT_BUMPDIRECTUV: number;
  111490. CLEARCOAT_TINT: boolean;
  111491. CLEARCOAT_TINT_TEXTURE: boolean;
  111492. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  111493. ANISOTROPIC: boolean;
  111494. ANISOTROPIC_TEXTURE: boolean;
  111495. ANISOTROPIC_TEXTUREDIRECTUV: number;
  111496. BRDF_V_HEIGHT_CORRELATED: boolean;
  111497. MS_BRDF_ENERGY_CONSERVATION: boolean;
  111498. SHEEN: boolean;
  111499. SHEEN_TEXTURE: boolean;
  111500. SHEEN_TEXTUREDIRECTUV: number;
  111501. SHEEN_LINKWITHALBEDO: boolean;
  111502. SUBSURFACE: boolean;
  111503. SS_REFRACTION: boolean;
  111504. SS_TRANSLUCENCY: boolean;
  111505. SS_SCATERRING: boolean;
  111506. SS_THICKNESSANDMASK_TEXTURE: boolean;
  111507. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  111508. SS_REFRACTIONMAP_3D: boolean;
  111509. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  111510. SS_LODINREFRACTIONALPHA: boolean;
  111511. SS_GAMMAREFRACTION: boolean;
  111512. SS_RGBDREFRACTION: boolean;
  111513. SS_LINEARSPECULARREFRACTION: boolean;
  111514. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  111515. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  111516. UNLIT: boolean;
  111517. DEBUGMODE: number;
  111518. /**
  111519. * Initializes the PBR Material defines.
  111520. */
  111521. constructor();
  111522. /**
  111523. * Resets the PBR Material defines.
  111524. */
  111525. reset(): void;
  111526. }
  111527. /**
  111528. * The Physically based material base class of BJS.
  111529. *
  111530. * This offers the main features of a standard PBR material.
  111531. * For more information, please refer to the documentation :
  111532. * https://doc.babylonjs.com/how_to/physically_based_rendering
  111533. */
  111534. export abstract class PBRBaseMaterial extends PushMaterial {
  111535. /**
  111536. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  111537. */
  111538. static readonly PBRMATERIAL_OPAQUE: number;
  111539. /**
  111540. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  111541. */
  111542. static readonly PBRMATERIAL_ALPHATEST: number;
  111543. /**
  111544. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  111545. */
  111546. static readonly PBRMATERIAL_ALPHABLEND: number;
  111547. /**
  111548. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  111549. * They are also discarded below the alpha cutoff threshold to improve performances.
  111550. */
  111551. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  111552. /**
  111553. * Defines the default value of how much AO map is occluding the analytical lights
  111554. * (point spot...).
  111555. */
  111556. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  111557. /**
  111558. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  111559. */
  111560. static readonly LIGHTFALLOFF_PHYSICAL: number;
  111561. /**
  111562. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  111563. * to enhance interoperability with other engines.
  111564. */
  111565. static readonly LIGHTFALLOFF_GLTF: number;
  111566. /**
  111567. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  111568. * to enhance interoperability with other materials.
  111569. */
  111570. static readonly LIGHTFALLOFF_STANDARD: number;
  111571. /**
  111572. * Intensity of the direct lights e.g. the four lights available in your scene.
  111573. * This impacts both the direct diffuse and specular highlights.
  111574. */
  111575. protected _directIntensity: number;
  111576. /**
  111577. * Intensity of the emissive part of the material.
  111578. * This helps controlling the emissive effect without modifying the emissive color.
  111579. */
  111580. protected _emissiveIntensity: number;
  111581. /**
  111582. * Intensity of the environment e.g. how much the environment will light the object
  111583. * either through harmonics for rough material or through the refelction for shiny ones.
  111584. */
  111585. protected _environmentIntensity: number;
  111586. /**
  111587. * This is a special control allowing the reduction of the specular highlights coming from the
  111588. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  111589. */
  111590. protected _specularIntensity: number;
  111591. /**
  111592. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  111593. */
  111594. private _lightingInfos;
  111595. /**
  111596. * Debug Control allowing disabling the bump map on this material.
  111597. */
  111598. protected _disableBumpMap: boolean;
  111599. /**
  111600. * AKA Diffuse Texture in standard nomenclature.
  111601. */
  111602. protected _albedoTexture: Nullable<BaseTexture>;
  111603. /**
  111604. * AKA Occlusion Texture in other nomenclature.
  111605. */
  111606. protected _ambientTexture: Nullable<BaseTexture>;
  111607. /**
  111608. * AKA Occlusion Texture Intensity in other nomenclature.
  111609. */
  111610. protected _ambientTextureStrength: number;
  111611. /**
  111612. * Defines how much the AO map is occluding the analytical lights (point spot...).
  111613. * 1 means it completely occludes it
  111614. * 0 mean it has no impact
  111615. */
  111616. protected _ambientTextureImpactOnAnalyticalLights: number;
  111617. /**
  111618. * Stores the alpha values in a texture.
  111619. */
  111620. protected _opacityTexture: Nullable<BaseTexture>;
  111621. /**
  111622. * Stores the reflection values in a texture.
  111623. */
  111624. protected _reflectionTexture: Nullable<BaseTexture>;
  111625. /**
  111626. * Stores the emissive values in a texture.
  111627. */
  111628. protected _emissiveTexture: Nullable<BaseTexture>;
  111629. /**
  111630. * AKA Specular texture in other nomenclature.
  111631. */
  111632. protected _reflectivityTexture: Nullable<BaseTexture>;
  111633. /**
  111634. * Used to switch from specular/glossiness to metallic/roughness workflow.
  111635. */
  111636. protected _metallicTexture: Nullable<BaseTexture>;
  111637. /**
  111638. * Specifies the metallic scalar of the metallic/roughness workflow.
  111639. * Can also be used to scale the metalness values of the metallic texture.
  111640. */
  111641. protected _metallic: Nullable<number>;
  111642. /**
  111643. * Specifies the roughness scalar of the metallic/roughness workflow.
  111644. * Can also be used to scale the roughness values of the metallic texture.
  111645. */
  111646. protected _roughness: Nullable<number>;
  111647. /**
  111648. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  111649. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  111650. */
  111651. protected _microSurfaceTexture: Nullable<BaseTexture>;
  111652. /**
  111653. * Stores surface normal data used to displace a mesh in a texture.
  111654. */
  111655. protected _bumpTexture: Nullable<BaseTexture>;
  111656. /**
  111657. * Stores the pre-calculated light information of a mesh in a texture.
  111658. */
  111659. protected _lightmapTexture: Nullable<BaseTexture>;
  111660. /**
  111661. * The color of a material in ambient lighting.
  111662. */
  111663. protected _ambientColor: Color3;
  111664. /**
  111665. * AKA Diffuse Color in other nomenclature.
  111666. */
  111667. protected _albedoColor: Color3;
  111668. /**
  111669. * AKA Specular Color in other nomenclature.
  111670. */
  111671. protected _reflectivityColor: Color3;
  111672. /**
  111673. * The color applied when light is reflected from a material.
  111674. */
  111675. protected _reflectionColor: Color3;
  111676. /**
  111677. * The color applied when light is emitted from a material.
  111678. */
  111679. protected _emissiveColor: Color3;
  111680. /**
  111681. * AKA Glossiness in other nomenclature.
  111682. */
  111683. protected _microSurface: number;
  111684. /**
  111685. * Specifies that the material will use the light map as a show map.
  111686. */
  111687. protected _useLightmapAsShadowmap: boolean;
  111688. /**
  111689. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  111690. * makes the reflect vector face the model (under horizon).
  111691. */
  111692. protected _useHorizonOcclusion: boolean;
  111693. /**
  111694. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  111695. * too much the area relying on ambient texture to define their ambient occlusion.
  111696. */
  111697. protected _useRadianceOcclusion: boolean;
  111698. /**
  111699. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  111700. */
  111701. protected _useAlphaFromAlbedoTexture: boolean;
  111702. /**
  111703. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  111704. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  111705. */
  111706. protected _useSpecularOverAlpha: boolean;
  111707. /**
  111708. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  111709. */
  111710. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  111711. /**
  111712. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  111713. */
  111714. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  111715. /**
  111716. * Specifies if the metallic texture contains the roughness information in its green channel.
  111717. */
  111718. protected _useRoughnessFromMetallicTextureGreen: boolean;
  111719. /**
  111720. * Specifies if the metallic texture contains the metallness information in its blue channel.
  111721. */
  111722. protected _useMetallnessFromMetallicTextureBlue: boolean;
  111723. /**
  111724. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  111725. */
  111726. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  111727. /**
  111728. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  111729. */
  111730. protected _useAmbientInGrayScale: boolean;
  111731. /**
  111732. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  111733. * The material will try to infer what glossiness each pixel should be.
  111734. */
  111735. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  111736. /**
  111737. * Defines the falloff type used in this material.
  111738. * It by default is Physical.
  111739. */
  111740. protected _lightFalloff: number;
  111741. /**
  111742. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  111743. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  111744. */
  111745. protected _useRadianceOverAlpha: boolean;
  111746. /**
  111747. * Allows using an object space normal map (instead of tangent space).
  111748. */
  111749. protected _useObjectSpaceNormalMap: boolean;
  111750. /**
  111751. * Allows using the bump map in parallax mode.
  111752. */
  111753. protected _useParallax: boolean;
  111754. /**
  111755. * Allows using the bump map in parallax occlusion mode.
  111756. */
  111757. protected _useParallaxOcclusion: boolean;
  111758. /**
  111759. * Controls the scale bias of the parallax mode.
  111760. */
  111761. protected _parallaxScaleBias: number;
  111762. /**
  111763. * If sets to true, disables all the lights affecting the material.
  111764. */
  111765. protected _disableLighting: boolean;
  111766. /**
  111767. * Number of Simultaneous lights allowed on the material.
  111768. */
  111769. protected _maxSimultaneousLights: number;
  111770. /**
  111771. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  111772. */
  111773. protected _invertNormalMapX: boolean;
  111774. /**
  111775. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  111776. */
  111777. protected _invertNormalMapY: boolean;
  111778. /**
  111779. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  111780. */
  111781. protected _twoSidedLighting: boolean;
  111782. /**
  111783. * Defines the alpha limits in alpha test mode.
  111784. */
  111785. protected _alphaCutOff: number;
  111786. /**
  111787. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  111788. */
  111789. protected _forceAlphaTest: boolean;
  111790. /**
  111791. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  111792. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  111793. */
  111794. protected _useAlphaFresnel: boolean;
  111795. /**
  111796. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  111797. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  111798. */
  111799. protected _useLinearAlphaFresnel: boolean;
  111800. /**
  111801. * The transparency mode of the material.
  111802. */
  111803. protected _transparencyMode: Nullable<number>;
  111804. /**
  111805. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  111806. * from cos thetav and roughness:
  111807. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  111808. */
  111809. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  111810. /**
  111811. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  111812. */
  111813. protected _forceIrradianceInFragment: boolean;
  111814. /**
  111815. * Force normal to face away from face.
  111816. */
  111817. protected _forceNormalForward: boolean;
  111818. /**
  111819. * Enables specular anti aliasing in the PBR shader.
  111820. * It will both interacts on the Geometry for analytical and IBL lighting.
  111821. * It also prefilter the roughness map based on the bump values.
  111822. */
  111823. protected _enableSpecularAntiAliasing: boolean;
  111824. /**
  111825. * Default configuration related to image processing available in the PBR Material.
  111826. */
  111827. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  111828. /**
  111829. * Keep track of the image processing observer to allow dispose and replace.
  111830. */
  111831. private _imageProcessingObserver;
  111832. /**
  111833. * Attaches a new image processing configuration to the PBR Material.
  111834. * @param configuration
  111835. */
  111836. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  111837. /**
  111838. * Stores the available render targets.
  111839. */
  111840. private _renderTargets;
  111841. /**
  111842. * Sets the global ambient color for the material used in lighting calculations.
  111843. */
  111844. private _globalAmbientColor;
  111845. /**
  111846. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  111847. */
  111848. private _useLogarithmicDepth;
  111849. /**
  111850. * If set to true, no lighting calculations will be applied.
  111851. */
  111852. private _unlit;
  111853. private _debugMode;
  111854. /**
  111855. * @hidden
  111856. * This is reserved for the inspector.
  111857. * Defines the material debug mode.
  111858. * It helps seeing only some components of the material while troubleshooting.
  111859. */
  111860. debugMode: number;
  111861. /**
  111862. * @hidden
  111863. * This is reserved for the inspector.
  111864. * Specify from where on screen the debug mode should start.
  111865. * The value goes from -1 (full screen) to 1 (not visible)
  111866. * It helps with side by side comparison against the final render
  111867. * This defaults to -1
  111868. */
  111869. private debugLimit;
  111870. /**
  111871. * @hidden
  111872. * This is reserved for the inspector.
  111873. * As the default viewing range might not be enough (if the ambient is really small for instance)
  111874. * You can use the factor to better multiply the final value.
  111875. */
  111876. private debugFactor;
  111877. /**
  111878. * Defines the clear coat layer parameters for the material.
  111879. */
  111880. readonly clearCoat: PBRClearCoatConfiguration;
  111881. /**
  111882. * Defines the anisotropic parameters for the material.
  111883. */
  111884. readonly anisotropy: PBRAnisotropicConfiguration;
  111885. /**
  111886. * Defines the BRDF parameters for the material.
  111887. */
  111888. readonly brdf: PBRBRDFConfiguration;
  111889. /**
  111890. * Defines the Sheen parameters for the material.
  111891. */
  111892. readonly sheen: PBRSheenConfiguration;
  111893. /**
  111894. * Defines the SubSurface parameters for the material.
  111895. */
  111896. readonly subSurface: PBRSubSurfaceConfiguration;
  111897. /**
  111898. * Custom callback helping to override the default shader used in the material.
  111899. */
  111900. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  111901. protected _rebuildInParallel: boolean;
  111902. /**
  111903. * Instantiates a new PBRMaterial instance.
  111904. *
  111905. * @param name The material name
  111906. * @param scene The scene the material will be use in.
  111907. */
  111908. constructor(name: string, scene: Scene);
  111909. /**
  111910. * Gets a boolean indicating that current material needs to register RTT
  111911. */
  111912. readonly hasRenderTargetTextures: boolean;
  111913. /**
  111914. * Gets the name of the material class.
  111915. */
  111916. getClassName(): string;
  111917. /**
  111918. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  111919. */
  111920. /**
  111921. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  111922. */
  111923. useLogarithmicDepth: boolean;
  111924. /**
  111925. * Gets the current transparency mode.
  111926. */
  111927. /**
  111928. * Sets the transparency mode of the material.
  111929. *
  111930. * | Value | Type | Description |
  111931. * | ----- | ----------------------------------- | ----------- |
  111932. * | 0 | OPAQUE | |
  111933. * | 1 | ALPHATEST | |
  111934. * | 2 | ALPHABLEND | |
  111935. * | 3 | ALPHATESTANDBLEND | |
  111936. *
  111937. */
  111938. transparencyMode: Nullable<number>;
  111939. /**
  111940. * Returns true if alpha blending should be disabled.
  111941. */
  111942. private readonly _disableAlphaBlending;
  111943. /**
  111944. * Specifies whether or not this material should be rendered in alpha blend mode.
  111945. */
  111946. needAlphaBlending(): boolean;
  111947. /**
  111948. * Specifies if the mesh will require alpha blending.
  111949. * @param mesh - BJS mesh.
  111950. */
  111951. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  111952. /**
  111953. * Specifies whether or not this material should be rendered in alpha test mode.
  111954. */
  111955. needAlphaTesting(): boolean;
  111956. /**
  111957. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  111958. */
  111959. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  111960. /**
  111961. * Gets the texture used for the alpha test.
  111962. */
  111963. getAlphaTestTexture(): Nullable<BaseTexture>;
  111964. /**
  111965. * Specifies that the submesh is ready to be used.
  111966. * @param mesh - BJS mesh.
  111967. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  111968. * @param useInstances - Specifies that instances should be used.
  111969. * @returns - boolean indicating that the submesh is ready or not.
  111970. */
  111971. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  111972. /**
  111973. * Specifies if the material uses metallic roughness workflow.
  111974. * @returns boolean specifiying if the material uses metallic roughness workflow.
  111975. */
  111976. isMetallicWorkflow(): boolean;
  111977. private _prepareEffect;
  111978. private _prepareDefines;
  111979. /**
  111980. * Force shader compilation
  111981. */
  111982. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  111983. clipPlane: boolean;
  111984. }>): void;
  111985. /**
  111986. * Initializes the uniform buffer layout for the shader.
  111987. */
  111988. buildUniformLayout(): void;
  111989. /**
  111990. * Unbinds the material from the mesh
  111991. */
  111992. unbind(): void;
  111993. /**
  111994. * Binds the submesh data.
  111995. * @param world - The world matrix.
  111996. * @param mesh - The BJS mesh.
  111997. * @param subMesh - A submesh of the BJS mesh.
  111998. */
  111999. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  112000. /**
  112001. * Returns the animatable textures.
  112002. * @returns - Array of animatable textures.
  112003. */
  112004. getAnimatables(): IAnimatable[];
  112005. /**
  112006. * Returns the texture used for reflections.
  112007. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  112008. */
  112009. private _getReflectionTexture;
  112010. /**
  112011. * Returns an array of the actively used textures.
  112012. * @returns - Array of BaseTextures
  112013. */
  112014. getActiveTextures(): BaseTexture[];
  112015. /**
  112016. * Checks to see if a texture is used in the material.
  112017. * @param texture - Base texture to use.
  112018. * @returns - Boolean specifying if a texture is used in the material.
  112019. */
  112020. hasTexture(texture: BaseTexture): boolean;
  112021. /**
  112022. * Disposes the resources of the material.
  112023. * @param forceDisposeEffect - Forces the disposal of effects.
  112024. * @param forceDisposeTextures - Forces the disposal of all textures.
  112025. */
  112026. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  112027. }
  112028. }
  112029. declare module BABYLON {
  112030. /**
  112031. * The Physically based material of BJS.
  112032. *
  112033. * This offers the main features of a standard PBR material.
  112034. * For more information, please refer to the documentation :
  112035. * https://doc.babylonjs.com/how_to/physically_based_rendering
  112036. */
  112037. export class PBRMaterial extends PBRBaseMaterial {
  112038. /**
  112039. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  112040. */
  112041. static readonly PBRMATERIAL_OPAQUE: number;
  112042. /**
  112043. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  112044. */
  112045. static readonly PBRMATERIAL_ALPHATEST: number;
  112046. /**
  112047. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  112048. */
  112049. static readonly PBRMATERIAL_ALPHABLEND: number;
  112050. /**
  112051. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  112052. * They are also discarded below the alpha cutoff threshold to improve performances.
  112053. */
  112054. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  112055. /**
  112056. * Defines the default value of how much AO map is occluding the analytical lights
  112057. * (point spot...).
  112058. */
  112059. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  112060. /**
  112061. * Intensity of the direct lights e.g. the four lights available in your scene.
  112062. * This impacts both the direct diffuse and specular highlights.
  112063. */
  112064. directIntensity: number;
  112065. /**
  112066. * Intensity of the emissive part of the material.
  112067. * This helps controlling the emissive effect without modifying the emissive color.
  112068. */
  112069. emissiveIntensity: number;
  112070. /**
  112071. * Intensity of the environment e.g. how much the environment will light the object
  112072. * either through harmonics for rough material or through the refelction for shiny ones.
  112073. */
  112074. environmentIntensity: number;
  112075. /**
  112076. * This is a special control allowing the reduction of the specular highlights coming from the
  112077. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  112078. */
  112079. specularIntensity: number;
  112080. /**
  112081. * Debug Control allowing disabling the bump map on this material.
  112082. */
  112083. disableBumpMap: boolean;
  112084. /**
  112085. * AKA Diffuse Texture in standard nomenclature.
  112086. */
  112087. albedoTexture: BaseTexture;
  112088. /**
  112089. * AKA Occlusion Texture in other nomenclature.
  112090. */
  112091. ambientTexture: BaseTexture;
  112092. /**
  112093. * AKA Occlusion Texture Intensity in other nomenclature.
  112094. */
  112095. ambientTextureStrength: number;
  112096. /**
  112097. * Defines how much the AO map is occluding the analytical lights (point spot...).
  112098. * 1 means it completely occludes it
  112099. * 0 mean it has no impact
  112100. */
  112101. ambientTextureImpactOnAnalyticalLights: number;
  112102. /**
  112103. * Stores the alpha values in a texture.
  112104. */
  112105. opacityTexture: BaseTexture;
  112106. /**
  112107. * Stores the reflection values in a texture.
  112108. */
  112109. reflectionTexture: Nullable<BaseTexture>;
  112110. /**
  112111. * Stores the emissive values in a texture.
  112112. */
  112113. emissiveTexture: BaseTexture;
  112114. /**
  112115. * AKA Specular texture in other nomenclature.
  112116. */
  112117. reflectivityTexture: BaseTexture;
  112118. /**
  112119. * Used to switch from specular/glossiness to metallic/roughness workflow.
  112120. */
  112121. metallicTexture: BaseTexture;
  112122. /**
  112123. * Specifies the metallic scalar of the metallic/roughness workflow.
  112124. * Can also be used to scale the metalness values of the metallic texture.
  112125. */
  112126. metallic: Nullable<number>;
  112127. /**
  112128. * Specifies the roughness scalar of the metallic/roughness workflow.
  112129. * Can also be used to scale the roughness values of the metallic texture.
  112130. */
  112131. roughness: Nullable<number>;
  112132. /**
  112133. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  112134. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  112135. */
  112136. microSurfaceTexture: BaseTexture;
  112137. /**
  112138. * Stores surface normal data used to displace a mesh in a texture.
  112139. */
  112140. bumpTexture: BaseTexture;
  112141. /**
  112142. * Stores the pre-calculated light information of a mesh in a texture.
  112143. */
  112144. lightmapTexture: BaseTexture;
  112145. /**
  112146. * Stores the refracted light information in a texture.
  112147. */
  112148. refractionTexture: Nullable<BaseTexture>;
  112149. /**
  112150. * The color of a material in ambient lighting.
  112151. */
  112152. ambientColor: Color3;
  112153. /**
  112154. * AKA Diffuse Color in other nomenclature.
  112155. */
  112156. albedoColor: Color3;
  112157. /**
  112158. * AKA Specular Color in other nomenclature.
  112159. */
  112160. reflectivityColor: Color3;
  112161. /**
  112162. * The color reflected from the material.
  112163. */
  112164. reflectionColor: Color3;
  112165. /**
  112166. * The color emitted from the material.
  112167. */
  112168. emissiveColor: Color3;
  112169. /**
  112170. * AKA Glossiness in other nomenclature.
  112171. */
  112172. microSurface: number;
  112173. /**
  112174. * source material index of refraction (IOR)' / 'destination material IOR.
  112175. */
  112176. indexOfRefraction: number;
  112177. /**
  112178. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  112179. */
  112180. invertRefractionY: boolean;
  112181. /**
  112182. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  112183. * Materials half opaque for instance using refraction could benefit from this control.
  112184. */
  112185. linkRefractionWithTransparency: boolean;
  112186. /**
  112187. * If true, the light map contains occlusion information instead of lighting info.
  112188. */
  112189. useLightmapAsShadowmap: boolean;
  112190. /**
  112191. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  112192. */
  112193. useAlphaFromAlbedoTexture: boolean;
  112194. /**
  112195. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  112196. */
  112197. forceAlphaTest: boolean;
  112198. /**
  112199. * Defines the alpha limits in alpha test mode.
  112200. */
  112201. alphaCutOff: number;
  112202. /**
  112203. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  112204. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  112205. */
  112206. useSpecularOverAlpha: boolean;
  112207. /**
  112208. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  112209. */
  112210. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  112211. /**
  112212. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  112213. */
  112214. useRoughnessFromMetallicTextureAlpha: boolean;
  112215. /**
  112216. * Specifies if the metallic texture contains the roughness information in its green channel.
  112217. */
  112218. useRoughnessFromMetallicTextureGreen: boolean;
  112219. /**
  112220. * Specifies if the metallic texture contains the metallness information in its blue channel.
  112221. */
  112222. useMetallnessFromMetallicTextureBlue: boolean;
  112223. /**
  112224. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  112225. */
  112226. useAmbientOcclusionFromMetallicTextureRed: boolean;
  112227. /**
  112228. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  112229. */
  112230. useAmbientInGrayScale: boolean;
  112231. /**
  112232. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  112233. * The material will try to infer what glossiness each pixel should be.
  112234. */
  112235. useAutoMicroSurfaceFromReflectivityMap: boolean;
  112236. /**
  112237. * BJS is using an harcoded light falloff based on a manually sets up range.
  112238. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  112239. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  112240. */
  112241. /**
  112242. * BJS is using an harcoded light falloff based on a manually sets up range.
  112243. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  112244. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  112245. */
  112246. usePhysicalLightFalloff: boolean;
  112247. /**
  112248. * In order to support the falloff compatibility with gltf, a special mode has been added
  112249. * to reproduce the gltf light falloff.
  112250. */
  112251. /**
  112252. * In order to support the falloff compatibility with gltf, a special mode has been added
  112253. * to reproduce the gltf light falloff.
  112254. */
  112255. useGLTFLightFalloff: boolean;
  112256. /**
  112257. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  112258. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  112259. */
  112260. useRadianceOverAlpha: boolean;
  112261. /**
  112262. * Allows using an object space normal map (instead of tangent space).
  112263. */
  112264. useObjectSpaceNormalMap: boolean;
  112265. /**
  112266. * Allows using the bump map in parallax mode.
  112267. */
  112268. useParallax: boolean;
  112269. /**
  112270. * Allows using the bump map in parallax occlusion mode.
  112271. */
  112272. useParallaxOcclusion: boolean;
  112273. /**
  112274. * Controls the scale bias of the parallax mode.
  112275. */
  112276. parallaxScaleBias: number;
  112277. /**
  112278. * If sets to true, disables all the lights affecting the material.
  112279. */
  112280. disableLighting: boolean;
  112281. /**
  112282. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  112283. */
  112284. forceIrradianceInFragment: boolean;
  112285. /**
  112286. * Number of Simultaneous lights allowed on the material.
  112287. */
  112288. maxSimultaneousLights: number;
  112289. /**
  112290. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  112291. */
  112292. invertNormalMapX: boolean;
  112293. /**
  112294. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  112295. */
  112296. invertNormalMapY: boolean;
  112297. /**
  112298. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  112299. */
  112300. twoSidedLighting: boolean;
  112301. /**
  112302. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  112303. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  112304. */
  112305. useAlphaFresnel: boolean;
  112306. /**
  112307. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  112308. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  112309. */
  112310. useLinearAlphaFresnel: boolean;
  112311. /**
  112312. * Let user defines the brdf lookup texture used for IBL.
  112313. * A default 8bit version is embedded but you could point at :
  112314. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  112315. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  112316. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  112317. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  112318. */
  112319. environmentBRDFTexture: Nullable<BaseTexture>;
  112320. /**
  112321. * Force normal to face away from face.
  112322. */
  112323. forceNormalForward: boolean;
  112324. /**
  112325. * Enables specular anti aliasing in the PBR shader.
  112326. * It will both interacts on the Geometry for analytical and IBL lighting.
  112327. * It also prefilter the roughness map based on the bump values.
  112328. */
  112329. enableSpecularAntiAliasing: boolean;
  112330. /**
  112331. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  112332. * makes the reflect vector face the model (under horizon).
  112333. */
  112334. useHorizonOcclusion: boolean;
  112335. /**
  112336. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  112337. * too much the area relying on ambient texture to define their ambient occlusion.
  112338. */
  112339. useRadianceOcclusion: boolean;
  112340. /**
  112341. * If set to true, no lighting calculations will be applied.
  112342. */
  112343. unlit: boolean;
  112344. /**
  112345. * Gets the image processing configuration used either in this material.
  112346. */
  112347. /**
  112348. * Sets the Default image processing configuration used either in the this material.
  112349. *
  112350. * If sets to null, the scene one is in use.
  112351. */
  112352. imageProcessingConfiguration: ImageProcessingConfiguration;
  112353. /**
  112354. * Gets wether the color curves effect is enabled.
  112355. */
  112356. /**
  112357. * Sets wether the color curves effect is enabled.
  112358. */
  112359. cameraColorCurvesEnabled: boolean;
  112360. /**
  112361. * Gets wether the color grading effect is enabled.
  112362. */
  112363. /**
  112364. * Gets wether the color grading effect is enabled.
  112365. */
  112366. cameraColorGradingEnabled: boolean;
  112367. /**
  112368. * Gets wether tonemapping is enabled or not.
  112369. */
  112370. /**
  112371. * Sets wether tonemapping is enabled or not
  112372. */
  112373. cameraToneMappingEnabled: boolean;
  112374. /**
  112375. * The camera exposure used on this material.
  112376. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  112377. * This corresponds to a photographic exposure.
  112378. */
  112379. /**
  112380. * The camera exposure used on this material.
  112381. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  112382. * This corresponds to a photographic exposure.
  112383. */
  112384. cameraExposure: number;
  112385. /**
  112386. * Gets The camera contrast used on this material.
  112387. */
  112388. /**
  112389. * Sets The camera contrast used on this material.
  112390. */
  112391. cameraContrast: number;
  112392. /**
  112393. * Gets the Color Grading 2D Lookup Texture.
  112394. */
  112395. /**
  112396. * Sets the Color Grading 2D Lookup Texture.
  112397. */
  112398. cameraColorGradingTexture: Nullable<BaseTexture>;
  112399. /**
  112400. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  112401. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  112402. * 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;
  112403. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  112404. */
  112405. /**
  112406. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  112407. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  112408. * 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;
  112409. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  112410. */
  112411. cameraColorCurves: Nullable<ColorCurves>;
  112412. /**
  112413. * Instantiates a new PBRMaterial instance.
  112414. *
  112415. * @param name The material name
  112416. * @param scene The scene the material will be use in.
  112417. */
  112418. constructor(name: string, scene: Scene);
  112419. /**
  112420. * Returns the name of this material class.
  112421. */
  112422. getClassName(): string;
  112423. /**
  112424. * Makes a duplicate of the current material.
  112425. * @param name - name to use for the new material.
  112426. */
  112427. clone(name: string): PBRMaterial;
  112428. /**
  112429. * Serializes this PBR Material.
  112430. * @returns - An object with the serialized material.
  112431. */
  112432. serialize(): any;
  112433. /**
  112434. * Parses a PBR Material from a serialized object.
  112435. * @param source - Serialized object.
  112436. * @param scene - BJS scene instance.
  112437. * @param rootUrl - url for the scene object
  112438. * @returns - PBRMaterial
  112439. */
  112440. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  112441. }
  112442. }
  112443. declare module BABYLON {
  112444. /**
  112445. * Direct draw surface info
  112446. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  112447. */
  112448. export interface DDSInfo {
  112449. /**
  112450. * Width of the texture
  112451. */
  112452. width: number;
  112453. /**
  112454. * Width of the texture
  112455. */
  112456. height: number;
  112457. /**
  112458. * Number of Mipmaps for the texture
  112459. * @see https://en.wikipedia.org/wiki/Mipmap
  112460. */
  112461. mipmapCount: number;
  112462. /**
  112463. * If the textures format is a known fourCC format
  112464. * @see https://www.fourcc.org/
  112465. */
  112466. isFourCC: boolean;
  112467. /**
  112468. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  112469. */
  112470. isRGB: boolean;
  112471. /**
  112472. * If the texture is a lumincance format
  112473. */
  112474. isLuminance: boolean;
  112475. /**
  112476. * If this is a cube texture
  112477. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  112478. */
  112479. isCube: boolean;
  112480. /**
  112481. * If the texture is a compressed format eg. FOURCC_DXT1
  112482. */
  112483. isCompressed: boolean;
  112484. /**
  112485. * The dxgiFormat of the texture
  112486. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  112487. */
  112488. dxgiFormat: number;
  112489. /**
  112490. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  112491. */
  112492. textureType: number;
  112493. /**
  112494. * Sphericle polynomial created for the dds texture
  112495. */
  112496. sphericalPolynomial?: SphericalPolynomial;
  112497. }
  112498. /**
  112499. * Class used to provide DDS decompression tools
  112500. */
  112501. export class DDSTools {
  112502. /**
  112503. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  112504. */
  112505. static StoreLODInAlphaChannel: boolean;
  112506. /**
  112507. * Gets DDS information from an array buffer
  112508. * @param arrayBuffer defines the array buffer to read data from
  112509. * @returns the DDS information
  112510. */
  112511. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  112512. private static _FloatView;
  112513. private static _Int32View;
  112514. private static _ToHalfFloat;
  112515. private static _FromHalfFloat;
  112516. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  112517. private static _GetHalfFloatRGBAArrayBuffer;
  112518. private static _GetFloatRGBAArrayBuffer;
  112519. private static _GetFloatAsUIntRGBAArrayBuffer;
  112520. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  112521. private static _GetRGBAArrayBuffer;
  112522. private static _ExtractLongWordOrder;
  112523. private static _GetRGBArrayBuffer;
  112524. private static _GetLuminanceArrayBuffer;
  112525. /**
  112526. * Uploads DDS Levels to a Babylon Texture
  112527. * @hidden
  112528. */
  112529. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  112530. }
  112531. interface Engine {
  112532. /**
  112533. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  112534. * @param rootUrl defines the url where the file to load is located
  112535. * @param scene defines the current scene
  112536. * @param lodScale defines scale to apply to the mip map selection
  112537. * @param lodOffset defines offset to apply to the mip map selection
  112538. * @param onLoad defines an optional callback raised when the texture is loaded
  112539. * @param onError defines an optional callback raised if there is an issue to load the texture
  112540. * @param format defines the format of the data
  112541. * @param forcedExtension defines the extension to use to pick the right loader
  112542. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  112543. * @returns the cube texture as an InternalTexture
  112544. */
  112545. 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;
  112546. }
  112547. }
  112548. declare module BABYLON {
  112549. /**
  112550. * Implementation of the DDS Texture Loader.
  112551. * @hidden
  112552. */
  112553. export class _DDSTextureLoader implements IInternalTextureLoader {
  112554. /**
  112555. * Defines wether the loader supports cascade loading the different faces.
  112556. */
  112557. readonly supportCascades: boolean;
  112558. /**
  112559. * This returns if the loader support the current file information.
  112560. * @param extension defines the file extension of the file being loaded
  112561. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112562. * @param fallback defines the fallback internal texture if any
  112563. * @param isBase64 defines whether the texture is encoded as a base64
  112564. * @param isBuffer defines whether the texture data are stored as a buffer
  112565. * @returns true if the loader can load the specified file
  112566. */
  112567. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  112568. /**
  112569. * Transform the url before loading if required.
  112570. * @param rootUrl the url of the texture
  112571. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112572. * @returns the transformed texture
  112573. */
  112574. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  112575. /**
  112576. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  112577. * @param rootUrl the url of the texture
  112578. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112579. * @returns the fallback texture
  112580. */
  112581. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  112582. /**
  112583. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  112584. * @param data contains the texture data
  112585. * @param texture defines the BabylonJS internal texture
  112586. * @param createPolynomials will be true if polynomials have been requested
  112587. * @param onLoad defines the callback to trigger once the texture is ready
  112588. * @param onError defines the callback to trigger in case of error
  112589. */
  112590. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  112591. /**
  112592. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  112593. * @param data contains the texture data
  112594. * @param texture defines the BabylonJS internal texture
  112595. * @param callback defines the method to call once ready to upload
  112596. */
  112597. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  112598. }
  112599. }
  112600. declare module BABYLON {
  112601. /** @hidden */
  112602. export var rgbdEncodePixelShader: {
  112603. name: string;
  112604. shader: string;
  112605. };
  112606. }
  112607. declare module BABYLON {
  112608. /**
  112609. * Raw texture data and descriptor sufficient for WebGL texture upload
  112610. */
  112611. export interface EnvironmentTextureInfo {
  112612. /**
  112613. * Version of the environment map
  112614. */
  112615. version: number;
  112616. /**
  112617. * Width of image
  112618. */
  112619. width: number;
  112620. /**
  112621. * Irradiance information stored in the file.
  112622. */
  112623. irradiance: any;
  112624. /**
  112625. * Specular information stored in the file.
  112626. */
  112627. specular: any;
  112628. }
  112629. /**
  112630. * Sets of helpers addressing the serialization and deserialization of environment texture
  112631. * stored in a BabylonJS env file.
  112632. * Those files are usually stored as .env files.
  112633. */
  112634. export class EnvironmentTextureTools {
  112635. /**
  112636. * Magic number identifying the env file.
  112637. */
  112638. private static _MagicBytes;
  112639. /**
  112640. * Gets the environment info from an env file.
  112641. * @param data The array buffer containing the .env bytes.
  112642. * @returns the environment file info (the json header) if successfully parsed.
  112643. */
  112644. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  112645. /**
  112646. * Creates an environment texture from a loaded cube texture.
  112647. * @param texture defines the cube texture to convert in env file
  112648. * @return a promise containing the environment data if succesfull.
  112649. */
  112650. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  112651. /**
  112652. * Creates a JSON representation of the spherical data.
  112653. * @param texture defines the texture containing the polynomials
  112654. * @return the JSON representation of the spherical info
  112655. */
  112656. private static _CreateEnvTextureIrradiance;
  112657. /**
  112658. * Uploads the texture info contained in the env file to the GPU.
  112659. * @param texture defines the internal texture to upload to
  112660. * @param arrayBuffer defines the buffer cotaining the data to load
  112661. * @param info defines the texture info retrieved through the GetEnvInfo method
  112662. * @returns a promise
  112663. */
  112664. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  112665. /**
  112666. * Uploads the levels of image data to the GPU.
  112667. * @param texture defines the internal texture to upload to
  112668. * @param imageData defines the array buffer views of image data [mipmap][face]
  112669. * @returns a promise
  112670. */
  112671. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  112672. /**
  112673. * Uploads spherical polynomials information to the texture.
  112674. * @param texture defines the texture we are trying to upload the information to
  112675. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  112676. */
  112677. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  112678. /** @hidden */
  112679. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  112680. }
  112681. }
  112682. declare module BABYLON {
  112683. /**
  112684. * Implementation of the ENV Texture Loader.
  112685. * @hidden
  112686. */
  112687. export class _ENVTextureLoader implements IInternalTextureLoader {
  112688. /**
  112689. * Defines wether the loader supports cascade loading the different faces.
  112690. */
  112691. readonly supportCascades: boolean;
  112692. /**
  112693. * This returns if the loader support the current file information.
  112694. * @param extension defines the file extension of the file being loaded
  112695. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112696. * @param fallback defines the fallback internal texture if any
  112697. * @param isBase64 defines whether the texture is encoded as a base64
  112698. * @param isBuffer defines whether the texture data are stored as a buffer
  112699. * @returns true if the loader can load the specified file
  112700. */
  112701. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  112702. /**
  112703. * Transform the url before loading if required.
  112704. * @param rootUrl the url of the texture
  112705. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112706. * @returns the transformed texture
  112707. */
  112708. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  112709. /**
  112710. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  112711. * @param rootUrl the url of the texture
  112712. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112713. * @returns the fallback texture
  112714. */
  112715. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  112716. /**
  112717. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  112718. * @param data contains the texture data
  112719. * @param texture defines the BabylonJS internal texture
  112720. * @param createPolynomials will be true if polynomials have been requested
  112721. * @param onLoad defines the callback to trigger once the texture is ready
  112722. * @param onError defines the callback to trigger in case of error
  112723. */
  112724. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  112725. /**
  112726. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  112727. * @param data contains the texture data
  112728. * @param texture defines the BabylonJS internal texture
  112729. * @param callback defines the method to call once ready to upload
  112730. */
  112731. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  112732. }
  112733. }
  112734. declare module BABYLON {
  112735. /**
  112736. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  112737. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  112738. */
  112739. export class KhronosTextureContainer {
  112740. /** contents of the KTX container file */
  112741. arrayBuffer: any;
  112742. private static HEADER_LEN;
  112743. private static COMPRESSED_2D;
  112744. private static COMPRESSED_3D;
  112745. private static TEX_2D;
  112746. private static TEX_3D;
  112747. /**
  112748. * Gets the openGL type
  112749. */
  112750. glType: number;
  112751. /**
  112752. * Gets the openGL type size
  112753. */
  112754. glTypeSize: number;
  112755. /**
  112756. * Gets the openGL format
  112757. */
  112758. glFormat: number;
  112759. /**
  112760. * Gets the openGL internal format
  112761. */
  112762. glInternalFormat: number;
  112763. /**
  112764. * Gets the base internal format
  112765. */
  112766. glBaseInternalFormat: number;
  112767. /**
  112768. * Gets image width in pixel
  112769. */
  112770. pixelWidth: number;
  112771. /**
  112772. * Gets image height in pixel
  112773. */
  112774. pixelHeight: number;
  112775. /**
  112776. * Gets image depth in pixels
  112777. */
  112778. pixelDepth: number;
  112779. /**
  112780. * Gets the number of array elements
  112781. */
  112782. numberOfArrayElements: number;
  112783. /**
  112784. * Gets the number of faces
  112785. */
  112786. numberOfFaces: number;
  112787. /**
  112788. * Gets the number of mipmap levels
  112789. */
  112790. numberOfMipmapLevels: number;
  112791. /**
  112792. * Gets the bytes of key value data
  112793. */
  112794. bytesOfKeyValueData: number;
  112795. /**
  112796. * Gets the load type
  112797. */
  112798. loadType: number;
  112799. /**
  112800. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  112801. */
  112802. isInvalid: boolean;
  112803. /**
  112804. * Creates a new KhronosTextureContainer
  112805. * @param arrayBuffer contents of the KTX container file
  112806. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  112807. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  112808. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  112809. */
  112810. constructor(
  112811. /** contents of the KTX container file */
  112812. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  112813. /**
  112814. * Uploads KTX content to a Babylon Texture.
  112815. * It is assumed that the texture has already been created & is currently bound
  112816. * @hidden
  112817. */
  112818. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  112819. private _upload2DCompressedLevels;
  112820. }
  112821. }
  112822. declare module BABYLON {
  112823. /**
  112824. * Implementation of the KTX Texture Loader.
  112825. * @hidden
  112826. */
  112827. export class _KTXTextureLoader implements IInternalTextureLoader {
  112828. /**
  112829. * Defines wether the loader supports cascade loading the different faces.
  112830. */
  112831. readonly supportCascades: boolean;
  112832. /**
  112833. * This returns if the loader support the current file information.
  112834. * @param extension defines the file extension of the file being loaded
  112835. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112836. * @param fallback defines the fallback internal texture if any
  112837. * @param isBase64 defines whether the texture is encoded as a base64
  112838. * @param isBuffer defines whether the texture data are stored as a buffer
  112839. * @returns true if the loader can load the specified file
  112840. */
  112841. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  112842. /**
  112843. * Transform the url before loading if required.
  112844. * @param rootUrl the url of the texture
  112845. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112846. * @returns the transformed texture
  112847. */
  112848. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  112849. /**
  112850. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  112851. * @param rootUrl the url of the texture
  112852. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112853. * @returns the fallback texture
  112854. */
  112855. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  112856. /**
  112857. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  112858. * @param data contains the texture data
  112859. * @param texture defines the BabylonJS internal texture
  112860. * @param createPolynomials will be true if polynomials have been requested
  112861. * @param onLoad defines the callback to trigger once the texture is ready
  112862. * @param onError defines the callback to trigger in case of error
  112863. */
  112864. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  112865. /**
  112866. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  112867. * @param data contains the texture data
  112868. * @param texture defines the BabylonJS internal texture
  112869. * @param callback defines the method to call once ready to upload
  112870. */
  112871. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  112872. }
  112873. }
  112874. declare module BABYLON {
  112875. /**
  112876. * Options for the default xr helper
  112877. */
  112878. export class WebXRDefaultExperienceOptions {
  112879. /**
  112880. * Floor meshes that should be used for teleporting
  112881. */
  112882. floorMeshes: Array<AbstractMesh>;
  112883. }
  112884. /**
  112885. * Default experience which provides a similar setup to the previous webVRExperience
  112886. */
  112887. export class WebXRDefaultExperience {
  112888. /**
  112889. * Base experience
  112890. */
  112891. baseExperience: WebXRExperienceHelper;
  112892. /**
  112893. * Input experience extension
  112894. */
  112895. input: WebXRInput;
  112896. /**
  112897. * Loads the controller models
  112898. */
  112899. controllerModelLoader: WebXRControllerModelLoader;
  112900. /**
  112901. * Enables laser pointer and selection
  112902. */
  112903. pointerSelection: WebXRControllerPointerSelection;
  112904. /**
  112905. * Enables teleportation
  112906. */
  112907. teleportation: WebXRControllerTeleportation;
  112908. /**
  112909. * Enables ui for enetering/exiting xr
  112910. */
  112911. enterExitUI: WebXREnterExitUI;
  112912. /**
  112913. * Default output canvas xr should render to
  112914. */
  112915. outputCanvas: WebXRManagedOutputCanvas;
  112916. /**
  112917. * Creates the default xr experience
  112918. * @param scene scene
  112919. * @param options options for basic configuration
  112920. * @returns resulting WebXRDefaultExperience
  112921. */
  112922. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  112923. private constructor();
  112924. /**
  112925. * DIsposes of the experience helper
  112926. */
  112927. dispose(): void;
  112928. }
  112929. }
  112930. declare module BABYLON {
  112931. /** @hidden */
  112932. export var _forceSceneHelpersToBundle: boolean;
  112933. interface Scene {
  112934. /**
  112935. * Creates a default light for the scene.
  112936. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  112937. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  112938. */
  112939. createDefaultLight(replace?: boolean): void;
  112940. /**
  112941. * Creates a default camera for the scene.
  112942. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  112943. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  112944. * @param replace has default false, when true replaces the active camera in the scene
  112945. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  112946. */
  112947. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  112948. /**
  112949. * Creates a default camera and a default light.
  112950. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  112951. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  112952. * @param replace has the default false, when true replaces the active camera/light in the scene
  112953. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  112954. */
  112955. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  112956. /**
  112957. * Creates a new sky box
  112958. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  112959. * @param environmentTexture defines the texture to use as environment texture
  112960. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  112961. * @param scale defines the overall scale of the skybox
  112962. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  112963. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  112964. * @returns a new mesh holding the sky box
  112965. */
  112966. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  112967. /**
  112968. * Creates a new environment
  112969. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  112970. * @param options defines the options you can use to configure the environment
  112971. * @returns the new EnvironmentHelper
  112972. */
  112973. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  112974. /**
  112975. * Creates a new VREXperienceHelper
  112976. * @see http://doc.babylonjs.com/how_to/webvr_helper
  112977. * @param webVROptions defines the options used to create the new VREXperienceHelper
  112978. * @returns a new VREXperienceHelper
  112979. */
  112980. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  112981. /**
  112982. * Creates a new WebXRDefaultExperience
  112983. * @see http://doc.babylonjs.com/how_to/webxr
  112984. * @param options experience options
  112985. * @returns a promise for a new WebXRDefaultExperience
  112986. */
  112987. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  112988. }
  112989. }
  112990. declare module BABYLON {
  112991. /**
  112992. * Contains position and normal vectors for a vertex
  112993. */
  112994. export class PositionNormalVertex {
  112995. /** the position of the vertex (defaut: 0,0,0) */
  112996. position: Vector3;
  112997. /** the normal of the vertex (defaut: 0,1,0) */
  112998. normal: Vector3;
  112999. /**
  113000. * Creates a PositionNormalVertex
  113001. * @param position the position of the vertex (defaut: 0,0,0)
  113002. * @param normal the normal of the vertex (defaut: 0,1,0)
  113003. */
  113004. constructor(
  113005. /** the position of the vertex (defaut: 0,0,0) */
  113006. position?: Vector3,
  113007. /** the normal of the vertex (defaut: 0,1,0) */
  113008. normal?: Vector3);
  113009. /**
  113010. * Clones the PositionNormalVertex
  113011. * @returns the cloned PositionNormalVertex
  113012. */
  113013. clone(): PositionNormalVertex;
  113014. }
  113015. /**
  113016. * Contains position, normal and uv vectors for a vertex
  113017. */
  113018. export class PositionNormalTextureVertex {
  113019. /** the position of the vertex (defaut: 0,0,0) */
  113020. position: Vector3;
  113021. /** the normal of the vertex (defaut: 0,1,0) */
  113022. normal: Vector3;
  113023. /** the uv of the vertex (default: 0,0) */
  113024. uv: Vector2;
  113025. /**
  113026. * Creates a PositionNormalTextureVertex
  113027. * @param position the position of the vertex (defaut: 0,0,0)
  113028. * @param normal the normal of the vertex (defaut: 0,1,0)
  113029. * @param uv the uv of the vertex (default: 0,0)
  113030. */
  113031. constructor(
  113032. /** the position of the vertex (defaut: 0,0,0) */
  113033. position?: Vector3,
  113034. /** the normal of the vertex (defaut: 0,1,0) */
  113035. normal?: Vector3,
  113036. /** the uv of the vertex (default: 0,0) */
  113037. uv?: Vector2);
  113038. /**
  113039. * Clones the PositionNormalTextureVertex
  113040. * @returns the cloned PositionNormalTextureVertex
  113041. */
  113042. clone(): PositionNormalTextureVertex;
  113043. }
  113044. }
  113045. declare module BABYLON {
  113046. /**
  113047. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  113048. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  113049. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  113050. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  113051. */
  113052. export class VideoDome extends TransformNode {
  113053. /**
  113054. * Define the video source as a Monoscopic panoramic 360 video.
  113055. */
  113056. static readonly MODE_MONOSCOPIC: number;
  113057. /**
  113058. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  113059. */
  113060. static readonly MODE_TOPBOTTOM: number;
  113061. /**
  113062. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  113063. */
  113064. static readonly MODE_SIDEBYSIDE: number;
  113065. private _halfDome;
  113066. private _useDirectMapping;
  113067. /**
  113068. * The video texture being displayed on the sphere
  113069. */
  113070. protected _videoTexture: VideoTexture;
  113071. /**
  113072. * Gets the video texture being displayed on the sphere
  113073. */
  113074. readonly videoTexture: VideoTexture;
  113075. /**
  113076. * The skybox material
  113077. */
  113078. protected _material: BackgroundMaterial;
  113079. /**
  113080. * The surface used for the skybox
  113081. */
  113082. protected _mesh: Mesh;
  113083. /**
  113084. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  113085. */
  113086. private _halfDomeMask;
  113087. /**
  113088. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  113089. * Also see the options.resolution property.
  113090. */
  113091. fovMultiplier: number;
  113092. private _videoMode;
  113093. /**
  113094. * Gets or set the current video mode for the video. It can be:
  113095. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  113096. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  113097. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  113098. */
  113099. videoMode: number;
  113100. /**
  113101. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  113102. *
  113103. */
  113104. /**
  113105. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  113106. */
  113107. halfDome: boolean;
  113108. /**
  113109. * Oberserver used in Stereoscopic VR Mode.
  113110. */
  113111. private _onBeforeCameraRenderObserver;
  113112. /**
  113113. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  113114. * @param name Element's name, child elements will append suffixes for their own names.
  113115. * @param urlsOrVideo defines the url(s) or the video element to use
  113116. * @param options An object containing optional or exposed sub element properties
  113117. */
  113118. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  113119. resolution?: number;
  113120. clickToPlay?: boolean;
  113121. autoPlay?: boolean;
  113122. loop?: boolean;
  113123. size?: number;
  113124. poster?: string;
  113125. faceForward?: boolean;
  113126. useDirectMapping?: boolean;
  113127. halfDomeMode?: boolean;
  113128. }, scene: Scene);
  113129. private _changeVideoMode;
  113130. /**
  113131. * Releases resources associated with this node.
  113132. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  113133. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  113134. */
  113135. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  113136. }
  113137. }
  113138. declare module BABYLON {
  113139. /**
  113140. * This class can be used to get instrumentation data from a Babylon engine
  113141. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  113142. */
  113143. export class EngineInstrumentation implements IDisposable {
  113144. /**
  113145. * Define the instrumented engine.
  113146. */
  113147. engine: Engine;
  113148. private _captureGPUFrameTime;
  113149. private _gpuFrameTimeToken;
  113150. private _gpuFrameTime;
  113151. private _captureShaderCompilationTime;
  113152. private _shaderCompilationTime;
  113153. private _onBeginFrameObserver;
  113154. private _onEndFrameObserver;
  113155. private _onBeforeShaderCompilationObserver;
  113156. private _onAfterShaderCompilationObserver;
  113157. /**
  113158. * Gets the perf counter used for GPU frame time
  113159. */
  113160. readonly gpuFrameTimeCounter: PerfCounter;
  113161. /**
  113162. * Gets the GPU frame time capture status
  113163. */
  113164. /**
  113165. * Enable or disable the GPU frame time capture
  113166. */
  113167. captureGPUFrameTime: boolean;
  113168. /**
  113169. * Gets the perf counter used for shader compilation time
  113170. */
  113171. readonly shaderCompilationTimeCounter: PerfCounter;
  113172. /**
  113173. * Gets the shader compilation time capture status
  113174. */
  113175. /**
  113176. * Enable or disable the shader compilation time capture
  113177. */
  113178. captureShaderCompilationTime: boolean;
  113179. /**
  113180. * Instantiates a new engine instrumentation.
  113181. * This class can be used to get instrumentation data from a Babylon engine
  113182. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  113183. * @param engine Defines the engine to instrument
  113184. */
  113185. constructor(
  113186. /**
  113187. * Define the instrumented engine.
  113188. */
  113189. engine: Engine);
  113190. /**
  113191. * Dispose and release associated resources.
  113192. */
  113193. dispose(): void;
  113194. }
  113195. }
  113196. declare module BABYLON {
  113197. /**
  113198. * This class can be used to get instrumentation data from a Babylon engine
  113199. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  113200. */
  113201. export class SceneInstrumentation implements IDisposable {
  113202. /**
  113203. * Defines the scene to instrument
  113204. */
  113205. scene: Scene;
  113206. private _captureActiveMeshesEvaluationTime;
  113207. private _activeMeshesEvaluationTime;
  113208. private _captureRenderTargetsRenderTime;
  113209. private _renderTargetsRenderTime;
  113210. private _captureFrameTime;
  113211. private _frameTime;
  113212. private _captureRenderTime;
  113213. private _renderTime;
  113214. private _captureInterFrameTime;
  113215. private _interFrameTime;
  113216. private _captureParticlesRenderTime;
  113217. private _particlesRenderTime;
  113218. private _captureSpritesRenderTime;
  113219. private _spritesRenderTime;
  113220. private _capturePhysicsTime;
  113221. private _physicsTime;
  113222. private _captureAnimationsTime;
  113223. private _animationsTime;
  113224. private _captureCameraRenderTime;
  113225. private _cameraRenderTime;
  113226. private _onBeforeActiveMeshesEvaluationObserver;
  113227. private _onAfterActiveMeshesEvaluationObserver;
  113228. private _onBeforeRenderTargetsRenderObserver;
  113229. private _onAfterRenderTargetsRenderObserver;
  113230. private _onAfterRenderObserver;
  113231. private _onBeforeDrawPhaseObserver;
  113232. private _onAfterDrawPhaseObserver;
  113233. private _onBeforeAnimationsObserver;
  113234. private _onBeforeParticlesRenderingObserver;
  113235. private _onAfterParticlesRenderingObserver;
  113236. private _onBeforeSpritesRenderingObserver;
  113237. private _onAfterSpritesRenderingObserver;
  113238. private _onBeforePhysicsObserver;
  113239. private _onAfterPhysicsObserver;
  113240. private _onAfterAnimationsObserver;
  113241. private _onBeforeCameraRenderObserver;
  113242. private _onAfterCameraRenderObserver;
  113243. /**
  113244. * Gets the perf counter used for active meshes evaluation time
  113245. */
  113246. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  113247. /**
  113248. * Gets the active meshes evaluation time capture status
  113249. */
  113250. /**
  113251. * Enable or disable the active meshes evaluation time capture
  113252. */
  113253. captureActiveMeshesEvaluationTime: boolean;
  113254. /**
  113255. * Gets the perf counter used for render targets render time
  113256. */
  113257. readonly renderTargetsRenderTimeCounter: PerfCounter;
  113258. /**
  113259. * Gets the render targets render time capture status
  113260. */
  113261. /**
  113262. * Enable or disable the render targets render time capture
  113263. */
  113264. captureRenderTargetsRenderTime: boolean;
  113265. /**
  113266. * Gets the perf counter used for particles render time
  113267. */
  113268. readonly particlesRenderTimeCounter: PerfCounter;
  113269. /**
  113270. * Gets the particles render time capture status
  113271. */
  113272. /**
  113273. * Enable or disable the particles render time capture
  113274. */
  113275. captureParticlesRenderTime: boolean;
  113276. /**
  113277. * Gets the perf counter used for sprites render time
  113278. */
  113279. readonly spritesRenderTimeCounter: PerfCounter;
  113280. /**
  113281. * Gets the sprites render time capture status
  113282. */
  113283. /**
  113284. * Enable or disable the sprites render time capture
  113285. */
  113286. captureSpritesRenderTime: boolean;
  113287. /**
  113288. * Gets the perf counter used for physics time
  113289. */
  113290. readonly physicsTimeCounter: PerfCounter;
  113291. /**
  113292. * Gets the physics time capture status
  113293. */
  113294. /**
  113295. * Enable or disable the physics time capture
  113296. */
  113297. capturePhysicsTime: boolean;
  113298. /**
  113299. * Gets the perf counter used for animations time
  113300. */
  113301. readonly animationsTimeCounter: PerfCounter;
  113302. /**
  113303. * Gets the animations time capture status
  113304. */
  113305. /**
  113306. * Enable or disable the animations time capture
  113307. */
  113308. captureAnimationsTime: boolean;
  113309. /**
  113310. * Gets the perf counter used for frame time capture
  113311. */
  113312. readonly frameTimeCounter: PerfCounter;
  113313. /**
  113314. * Gets the frame time capture status
  113315. */
  113316. /**
  113317. * Enable or disable the frame time capture
  113318. */
  113319. captureFrameTime: boolean;
  113320. /**
  113321. * Gets the perf counter used for inter-frames time capture
  113322. */
  113323. readonly interFrameTimeCounter: PerfCounter;
  113324. /**
  113325. * Gets the inter-frames time capture status
  113326. */
  113327. /**
  113328. * Enable or disable the inter-frames time capture
  113329. */
  113330. captureInterFrameTime: boolean;
  113331. /**
  113332. * Gets the perf counter used for render time capture
  113333. */
  113334. readonly renderTimeCounter: PerfCounter;
  113335. /**
  113336. * Gets the render time capture status
  113337. */
  113338. /**
  113339. * Enable or disable the render time capture
  113340. */
  113341. captureRenderTime: boolean;
  113342. /**
  113343. * Gets the perf counter used for camera render time capture
  113344. */
  113345. readonly cameraRenderTimeCounter: PerfCounter;
  113346. /**
  113347. * Gets the camera render time capture status
  113348. */
  113349. /**
  113350. * Enable or disable the camera render time capture
  113351. */
  113352. captureCameraRenderTime: boolean;
  113353. /**
  113354. * Gets the perf counter used for draw calls
  113355. */
  113356. readonly drawCallsCounter: PerfCounter;
  113357. /**
  113358. * Instantiates a new scene instrumentation.
  113359. * This class can be used to get instrumentation data from a Babylon engine
  113360. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  113361. * @param scene Defines the scene to instrument
  113362. */
  113363. constructor(
  113364. /**
  113365. * Defines the scene to instrument
  113366. */
  113367. scene: Scene);
  113368. /**
  113369. * Dispose and release associated resources.
  113370. */
  113371. dispose(): void;
  113372. }
  113373. }
  113374. declare module BABYLON {
  113375. /** @hidden */
  113376. export var glowMapGenerationPixelShader: {
  113377. name: string;
  113378. shader: string;
  113379. };
  113380. }
  113381. declare module BABYLON {
  113382. /** @hidden */
  113383. export var glowMapGenerationVertexShader: {
  113384. name: string;
  113385. shader: string;
  113386. };
  113387. }
  113388. declare module BABYLON {
  113389. /**
  113390. * Effect layer options. This helps customizing the behaviour
  113391. * of the effect layer.
  113392. */
  113393. export interface IEffectLayerOptions {
  113394. /**
  113395. * Multiplication factor apply to the canvas size to compute the render target size
  113396. * used to generated the objects (the smaller the faster).
  113397. */
  113398. mainTextureRatio: number;
  113399. /**
  113400. * Enforces a fixed size texture to ensure effect stability across devices.
  113401. */
  113402. mainTextureFixedSize?: number;
  113403. /**
  113404. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  113405. */
  113406. alphaBlendingMode: number;
  113407. /**
  113408. * The camera attached to the layer.
  113409. */
  113410. camera: Nullable<Camera>;
  113411. /**
  113412. * The rendering group to draw the layer in.
  113413. */
  113414. renderingGroupId: number;
  113415. }
  113416. /**
  113417. * The effect layer Helps adding post process effect blended with the main pass.
  113418. *
  113419. * This can be for instance use to generate glow or higlight effects on the scene.
  113420. *
  113421. * The effect layer class can not be used directly and is intented to inherited from to be
  113422. * customized per effects.
  113423. */
  113424. export abstract class EffectLayer {
  113425. private _vertexBuffers;
  113426. private _indexBuffer;
  113427. private _cachedDefines;
  113428. private _effectLayerMapGenerationEffect;
  113429. private _effectLayerOptions;
  113430. private _mergeEffect;
  113431. protected _scene: Scene;
  113432. protected _engine: Engine;
  113433. protected _maxSize: number;
  113434. protected _mainTextureDesiredSize: ISize;
  113435. protected _mainTexture: RenderTargetTexture;
  113436. protected _shouldRender: boolean;
  113437. protected _postProcesses: PostProcess[];
  113438. protected _textures: BaseTexture[];
  113439. protected _emissiveTextureAndColor: {
  113440. texture: Nullable<BaseTexture>;
  113441. color: Color4;
  113442. };
  113443. /**
  113444. * The name of the layer
  113445. */
  113446. name: string;
  113447. /**
  113448. * The clear color of the texture used to generate the glow map.
  113449. */
  113450. neutralColor: Color4;
  113451. /**
  113452. * Specifies wether the highlight layer is enabled or not.
  113453. */
  113454. isEnabled: boolean;
  113455. /**
  113456. * Gets the camera attached to the layer.
  113457. */
  113458. readonly camera: Nullable<Camera>;
  113459. /**
  113460. * Gets the rendering group id the layer should render in.
  113461. */
  113462. renderingGroupId: number;
  113463. /**
  113464. * An event triggered when the effect layer has been disposed.
  113465. */
  113466. onDisposeObservable: Observable<EffectLayer>;
  113467. /**
  113468. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  113469. */
  113470. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  113471. /**
  113472. * An event triggered when the generated texture is being merged in the scene.
  113473. */
  113474. onBeforeComposeObservable: Observable<EffectLayer>;
  113475. /**
  113476. * An event triggered when the generated texture has been merged in the scene.
  113477. */
  113478. onAfterComposeObservable: Observable<EffectLayer>;
  113479. /**
  113480. * An event triggered when the efffect layer changes its size.
  113481. */
  113482. onSizeChangedObservable: Observable<EffectLayer>;
  113483. /** @hidden */
  113484. static _SceneComponentInitialization: (scene: Scene) => void;
  113485. /**
  113486. * Instantiates a new effect Layer and references it in the scene.
  113487. * @param name The name of the layer
  113488. * @param scene The scene to use the layer in
  113489. */
  113490. constructor(
  113491. /** The Friendly of the effect in the scene */
  113492. name: string, scene: Scene);
  113493. /**
  113494. * Get the effect name of the layer.
  113495. * @return The effect name
  113496. */
  113497. abstract getEffectName(): string;
  113498. /**
  113499. * Checks for the readiness of the element composing the layer.
  113500. * @param subMesh the mesh to check for
  113501. * @param useInstances specify wether or not to use instances to render the mesh
  113502. * @return true if ready otherwise, false
  113503. */
  113504. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  113505. /**
  113506. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  113507. * @returns true if the effect requires stencil during the main canvas render pass.
  113508. */
  113509. abstract needStencil(): boolean;
  113510. /**
  113511. * Create the merge effect. This is the shader use to blit the information back
  113512. * to the main canvas at the end of the scene rendering.
  113513. * @returns The effect containing the shader used to merge the effect on the main canvas
  113514. */
  113515. protected abstract _createMergeEffect(): Effect;
  113516. /**
  113517. * Creates the render target textures and post processes used in the effect layer.
  113518. */
  113519. protected abstract _createTextureAndPostProcesses(): void;
  113520. /**
  113521. * Implementation specific of rendering the generating effect on the main canvas.
  113522. * @param effect The effect used to render through
  113523. */
  113524. protected abstract _internalRender(effect: Effect): void;
  113525. /**
  113526. * Sets the required values for both the emissive texture and and the main color.
  113527. */
  113528. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  113529. /**
  113530. * Free any resources and references associated to a mesh.
  113531. * Internal use
  113532. * @param mesh The mesh to free.
  113533. */
  113534. abstract _disposeMesh(mesh: Mesh): void;
  113535. /**
  113536. * Serializes this layer (Glow or Highlight for example)
  113537. * @returns a serialized layer object
  113538. */
  113539. abstract serialize?(): any;
  113540. /**
  113541. * Initializes the effect layer with the required options.
  113542. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  113543. */
  113544. protected _init(options: Partial<IEffectLayerOptions>): void;
  113545. /**
  113546. * Generates the index buffer of the full screen quad blending to the main canvas.
  113547. */
  113548. private _generateIndexBuffer;
  113549. /**
  113550. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  113551. */
  113552. private _generateVertexBuffer;
  113553. /**
  113554. * Sets the main texture desired size which is the closest power of two
  113555. * of the engine canvas size.
  113556. */
  113557. private _setMainTextureSize;
  113558. /**
  113559. * Creates the main texture for the effect layer.
  113560. */
  113561. protected _createMainTexture(): void;
  113562. /**
  113563. * Adds specific effects defines.
  113564. * @param defines The defines to add specifics to.
  113565. */
  113566. protected _addCustomEffectDefines(defines: string[]): void;
  113567. /**
  113568. * Checks for the readiness of the element composing the layer.
  113569. * @param subMesh the mesh to check for
  113570. * @param useInstances specify wether or not to use instances to render the mesh
  113571. * @param emissiveTexture the associated emissive texture used to generate the glow
  113572. * @return true if ready otherwise, false
  113573. */
  113574. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  113575. /**
  113576. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  113577. */
  113578. render(): void;
  113579. /**
  113580. * Determine if a given mesh will be used in the current effect.
  113581. * @param mesh mesh to test
  113582. * @returns true if the mesh will be used
  113583. */
  113584. hasMesh(mesh: AbstractMesh): boolean;
  113585. /**
  113586. * Returns true if the layer contains information to display, otherwise false.
  113587. * @returns true if the glow layer should be rendered
  113588. */
  113589. shouldRender(): boolean;
  113590. /**
  113591. * Returns true if the mesh should render, otherwise false.
  113592. * @param mesh The mesh to render
  113593. * @returns true if it should render otherwise false
  113594. */
  113595. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  113596. /**
  113597. * Returns true if the mesh can be rendered, otherwise false.
  113598. * @param mesh The mesh to render
  113599. * @param material The material used on the mesh
  113600. * @returns true if it can be rendered otherwise false
  113601. */
  113602. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  113603. /**
  113604. * Returns true if the mesh should render, otherwise false.
  113605. * @param mesh The mesh to render
  113606. * @returns true if it should render otherwise false
  113607. */
  113608. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  113609. /**
  113610. * Renders the submesh passed in parameter to the generation map.
  113611. */
  113612. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  113613. /**
  113614. * Rebuild the required buffers.
  113615. * @hidden Internal use only.
  113616. */
  113617. _rebuild(): void;
  113618. /**
  113619. * Dispose only the render target textures and post process.
  113620. */
  113621. private _disposeTextureAndPostProcesses;
  113622. /**
  113623. * Dispose the highlight layer and free resources.
  113624. */
  113625. dispose(): void;
  113626. /**
  113627. * Gets the class name of the effect layer
  113628. * @returns the string with the class name of the effect layer
  113629. */
  113630. getClassName(): string;
  113631. /**
  113632. * Creates an effect layer from parsed effect layer data
  113633. * @param parsedEffectLayer defines effect layer data
  113634. * @param scene defines the current scene
  113635. * @param rootUrl defines the root URL containing the effect layer information
  113636. * @returns a parsed effect Layer
  113637. */
  113638. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  113639. }
  113640. }
  113641. declare module BABYLON {
  113642. interface AbstractScene {
  113643. /**
  113644. * The list of effect layers (highlights/glow) added to the scene
  113645. * @see http://doc.babylonjs.com/how_to/highlight_layer
  113646. * @see http://doc.babylonjs.com/how_to/glow_layer
  113647. */
  113648. effectLayers: Array<EffectLayer>;
  113649. /**
  113650. * Removes the given effect layer from this scene.
  113651. * @param toRemove defines the effect layer to remove
  113652. * @returns the index of the removed effect layer
  113653. */
  113654. removeEffectLayer(toRemove: EffectLayer): number;
  113655. /**
  113656. * Adds the given effect layer to this scene
  113657. * @param newEffectLayer defines the effect layer to add
  113658. */
  113659. addEffectLayer(newEffectLayer: EffectLayer): void;
  113660. }
  113661. /**
  113662. * Defines the layer scene component responsible to manage any effect layers
  113663. * in a given scene.
  113664. */
  113665. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  113666. /**
  113667. * The component name helpfull to identify the component in the list of scene components.
  113668. */
  113669. readonly name: string;
  113670. /**
  113671. * The scene the component belongs to.
  113672. */
  113673. scene: Scene;
  113674. private _engine;
  113675. private _renderEffects;
  113676. private _needStencil;
  113677. private _previousStencilState;
  113678. /**
  113679. * Creates a new instance of the component for the given scene
  113680. * @param scene Defines the scene to register the component in
  113681. */
  113682. constructor(scene: Scene);
  113683. /**
  113684. * Registers the component in a given scene
  113685. */
  113686. register(): void;
  113687. /**
  113688. * Rebuilds the elements related to this component in case of
  113689. * context lost for instance.
  113690. */
  113691. rebuild(): void;
  113692. /**
  113693. * Serializes the component data to the specified json object
  113694. * @param serializationObject The object to serialize to
  113695. */
  113696. serialize(serializationObject: any): void;
  113697. /**
  113698. * Adds all the elements from the container to the scene
  113699. * @param container the container holding the elements
  113700. */
  113701. addFromContainer(container: AbstractScene): void;
  113702. /**
  113703. * Removes all the elements in the container from the scene
  113704. * @param container contains the elements to remove
  113705. * @param dispose if the removed element should be disposed (default: false)
  113706. */
  113707. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  113708. /**
  113709. * Disposes the component and the associated ressources.
  113710. */
  113711. dispose(): void;
  113712. private _isReadyForMesh;
  113713. private _renderMainTexture;
  113714. private _setStencil;
  113715. private _setStencilBack;
  113716. private _draw;
  113717. private _drawCamera;
  113718. private _drawRenderingGroup;
  113719. }
  113720. }
  113721. declare module BABYLON {
  113722. /** @hidden */
  113723. export var glowMapMergePixelShader: {
  113724. name: string;
  113725. shader: string;
  113726. };
  113727. }
  113728. declare module BABYLON {
  113729. /** @hidden */
  113730. export var glowMapMergeVertexShader: {
  113731. name: string;
  113732. shader: string;
  113733. };
  113734. }
  113735. declare module BABYLON {
  113736. interface AbstractScene {
  113737. /**
  113738. * Return a the first highlight layer of the scene with a given name.
  113739. * @param name The name of the highlight layer to look for.
  113740. * @return The highlight layer if found otherwise null.
  113741. */
  113742. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  113743. }
  113744. /**
  113745. * Glow layer options. This helps customizing the behaviour
  113746. * of the glow layer.
  113747. */
  113748. export interface IGlowLayerOptions {
  113749. /**
  113750. * Multiplication factor apply to the canvas size to compute the render target size
  113751. * used to generated the glowing objects (the smaller the faster).
  113752. */
  113753. mainTextureRatio: number;
  113754. /**
  113755. * Enforces a fixed size texture to ensure resize independant blur.
  113756. */
  113757. mainTextureFixedSize?: number;
  113758. /**
  113759. * How big is the kernel of the blur texture.
  113760. */
  113761. blurKernelSize: number;
  113762. /**
  113763. * The camera attached to the layer.
  113764. */
  113765. camera: Nullable<Camera>;
  113766. /**
  113767. * Enable MSAA by chosing the number of samples.
  113768. */
  113769. mainTextureSamples?: number;
  113770. /**
  113771. * The rendering group to draw the layer in.
  113772. */
  113773. renderingGroupId: number;
  113774. }
  113775. /**
  113776. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  113777. *
  113778. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  113779. * glowy meshes to your scene.
  113780. *
  113781. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  113782. */
  113783. export class GlowLayer extends EffectLayer {
  113784. /**
  113785. * Effect Name of the layer.
  113786. */
  113787. static readonly EffectName: string;
  113788. /**
  113789. * The default blur kernel size used for the glow.
  113790. */
  113791. static DefaultBlurKernelSize: number;
  113792. /**
  113793. * The default texture size ratio used for the glow.
  113794. */
  113795. static DefaultTextureRatio: number;
  113796. /**
  113797. * Sets the kernel size of the blur.
  113798. */
  113799. /**
  113800. * Gets the kernel size of the blur.
  113801. */
  113802. blurKernelSize: number;
  113803. /**
  113804. * Sets the glow intensity.
  113805. */
  113806. /**
  113807. * Gets the glow intensity.
  113808. */
  113809. intensity: number;
  113810. private _options;
  113811. private _intensity;
  113812. private _horizontalBlurPostprocess1;
  113813. private _verticalBlurPostprocess1;
  113814. private _horizontalBlurPostprocess2;
  113815. private _verticalBlurPostprocess2;
  113816. private _blurTexture1;
  113817. private _blurTexture2;
  113818. private _postProcesses1;
  113819. private _postProcesses2;
  113820. private _includedOnlyMeshes;
  113821. private _excludedMeshes;
  113822. /**
  113823. * Callback used to let the user override the color selection on a per mesh basis
  113824. */
  113825. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  113826. /**
  113827. * Callback used to let the user override the texture selection on a per mesh basis
  113828. */
  113829. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  113830. /**
  113831. * Instantiates a new glow Layer and references it to the scene.
  113832. * @param name The name of the layer
  113833. * @param scene The scene to use the layer in
  113834. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  113835. */
  113836. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  113837. /**
  113838. * Get the effect name of the layer.
  113839. * @return The effect name
  113840. */
  113841. getEffectName(): string;
  113842. /**
  113843. * Create the merge effect. This is the shader use to blit the information back
  113844. * to the main canvas at the end of the scene rendering.
  113845. */
  113846. protected _createMergeEffect(): Effect;
  113847. /**
  113848. * Creates the render target textures and post processes used in the glow layer.
  113849. */
  113850. protected _createTextureAndPostProcesses(): void;
  113851. /**
  113852. * Checks for the readiness of the element composing the layer.
  113853. * @param subMesh the mesh to check for
  113854. * @param useInstances specify wether or not to use instances to render the mesh
  113855. * @param emissiveTexture the associated emissive texture used to generate the glow
  113856. * @return true if ready otherwise, false
  113857. */
  113858. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  113859. /**
  113860. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  113861. */
  113862. needStencil(): boolean;
  113863. /**
  113864. * Returns true if the mesh can be rendered, otherwise false.
  113865. * @param mesh The mesh to render
  113866. * @param material The material used on the mesh
  113867. * @returns true if it can be rendered otherwise false
  113868. */
  113869. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  113870. /**
  113871. * Implementation specific of rendering the generating effect on the main canvas.
  113872. * @param effect The effect used to render through
  113873. */
  113874. protected _internalRender(effect: Effect): void;
  113875. /**
  113876. * Sets the required values for both the emissive texture and and the main color.
  113877. */
  113878. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  113879. /**
  113880. * Returns true if the mesh should render, otherwise false.
  113881. * @param mesh The mesh to render
  113882. * @returns true if it should render otherwise false
  113883. */
  113884. protected _shouldRenderMesh(mesh: Mesh): boolean;
  113885. /**
  113886. * Adds specific effects defines.
  113887. * @param defines The defines to add specifics to.
  113888. */
  113889. protected _addCustomEffectDefines(defines: string[]): void;
  113890. /**
  113891. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  113892. * @param mesh The mesh to exclude from the glow layer
  113893. */
  113894. addExcludedMesh(mesh: Mesh): void;
  113895. /**
  113896. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  113897. * @param mesh The mesh to remove
  113898. */
  113899. removeExcludedMesh(mesh: Mesh): void;
  113900. /**
  113901. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  113902. * @param mesh The mesh to include in the glow layer
  113903. */
  113904. addIncludedOnlyMesh(mesh: Mesh): void;
  113905. /**
  113906. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  113907. * @param mesh The mesh to remove
  113908. */
  113909. removeIncludedOnlyMesh(mesh: Mesh): void;
  113910. /**
  113911. * Determine if a given mesh will be used in the glow layer
  113912. * @param mesh The mesh to test
  113913. * @returns true if the mesh will be highlighted by the current glow layer
  113914. */
  113915. hasMesh(mesh: AbstractMesh): boolean;
  113916. /**
  113917. * Free any resources and references associated to a mesh.
  113918. * Internal use
  113919. * @param mesh The mesh to free.
  113920. * @hidden
  113921. */
  113922. _disposeMesh(mesh: Mesh): void;
  113923. /**
  113924. * Gets the class name of the effect layer
  113925. * @returns the string with the class name of the effect layer
  113926. */
  113927. getClassName(): string;
  113928. /**
  113929. * Serializes this glow layer
  113930. * @returns a serialized glow layer object
  113931. */
  113932. serialize(): any;
  113933. /**
  113934. * Creates a Glow Layer from parsed glow layer data
  113935. * @param parsedGlowLayer defines glow layer data
  113936. * @param scene defines the current scene
  113937. * @param rootUrl defines the root URL containing the glow layer information
  113938. * @returns a parsed Glow Layer
  113939. */
  113940. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  113941. }
  113942. }
  113943. declare module BABYLON {
  113944. /** @hidden */
  113945. export var glowBlurPostProcessPixelShader: {
  113946. name: string;
  113947. shader: string;
  113948. };
  113949. }
  113950. declare module BABYLON {
  113951. interface AbstractScene {
  113952. /**
  113953. * Return a the first highlight layer of the scene with a given name.
  113954. * @param name The name of the highlight layer to look for.
  113955. * @return The highlight layer if found otherwise null.
  113956. */
  113957. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  113958. }
  113959. /**
  113960. * Highlight layer options. This helps customizing the behaviour
  113961. * of the highlight layer.
  113962. */
  113963. export interface IHighlightLayerOptions {
  113964. /**
  113965. * Multiplication factor apply to the canvas size to compute the render target size
  113966. * used to generated the glowing objects (the smaller the faster).
  113967. */
  113968. mainTextureRatio: number;
  113969. /**
  113970. * Enforces a fixed size texture to ensure resize independant blur.
  113971. */
  113972. mainTextureFixedSize?: number;
  113973. /**
  113974. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  113975. * of the picture to blur (the smaller the faster).
  113976. */
  113977. blurTextureSizeRatio: number;
  113978. /**
  113979. * How big in texel of the blur texture is the vertical blur.
  113980. */
  113981. blurVerticalSize: number;
  113982. /**
  113983. * How big in texel of the blur texture is the horizontal blur.
  113984. */
  113985. blurHorizontalSize: number;
  113986. /**
  113987. * Alpha blending mode used to apply the blur. Default is combine.
  113988. */
  113989. alphaBlendingMode: number;
  113990. /**
  113991. * The camera attached to the layer.
  113992. */
  113993. camera: Nullable<Camera>;
  113994. /**
  113995. * Should we display highlight as a solid stroke?
  113996. */
  113997. isStroke?: boolean;
  113998. /**
  113999. * The rendering group to draw the layer in.
  114000. */
  114001. renderingGroupId: number;
  114002. }
  114003. /**
  114004. * The highlight layer Helps adding a glow effect around a mesh.
  114005. *
  114006. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  114007. * glowy meshes to your scene.
  114008. *
  114009. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  114010. */
  114011. export class HighlightLayer extends EffectLayer {
  114012. name: string;
  114013. /**
  114014. * Effect Name of the highlight layer.
  114015. */
  114016. static readonly EffectName: string;
  114017. /**
  114018. * The neutral color used during the preparation of the glow effect.
  114019. * This is black by default as the blend operation is a blend operation.
  114020. */
  114021. static NeutralColor: Color4;
  114022. /**
  114023. * Stencil value used for glowing meshes.
  114024. */
  114025. static GlowingMeshStencilReference: number;
  114026. /**
  114027. * Stencil value used for the other meshes in the scene.
  114028. */
  114029. static NormalMeshStencilReference: number;
  114030. /**
  114031. * Specifies whether or not the inner glow is ACTIVE in the layer.
  114032. */
  114033. innerGlow: boolean;
  114034. /**
  114035. * Specifies whether or not the outer glow is ACTIVE in the layer.
  114036. */
  114037. outerGlow: boolean;
  114038. /**
  114039. * Specifies the horizontal size of the blur.
  114040. */
  114041. /**
  114042. * Gets the horizontal size of the blur.
  114043. */
  114044. blurHorizontalSize: number;
  114045. /**
  114046. * Specifies the vertical size of the blur.
  114047. */
  114048. /**
  114049. * Gets the vertical size of the blur.
  114050. */
  114051. blurVerticalSize: number;
  114052. /**
  114053. * An event triggered when the highlight layer is being blurred.
  114054. */
  114055. onBeforeBlurObservable: Observable<HighlightLayer>;
  114056. /**
  114057. * An event triggered when the highlight layer has been blurred.
  114058. */
  114059. onAfterBlurObservable: Observable<HighlightLayer>;
  114060. private _instanceGlowingMeshStencilReference;
  114061. private _options;
  114062. private _downSamplePostprocess;
  114063. private _horizontalBlurPostprocess;
  114064. private _verticalBlurPostprocess;
  114065. private _blurTexture;
  114066. private _meshes;
  114067. private _excludedMeshes;
  114068. /**
  114069. * Instantiates a new highlight Layer and references it to the scene..
  114070. * @param name The name of the layer
  114071. * @param scene The scene to use the layer in
  114072. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  114073. */
  114074. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  114075. /**
  114076. * Get the effect name of the layer.
  114077. * @return The effect name
  114078. */
  114079. getEffectName(): string;
  114080. /**
  114081. * Create the merge effect. This is the shader use to blit the information back
  114082. * to the main canvas at the end of the scene rendering.
  114083. */
  114084. protected _createMergeEffect(): Effect;
  114085. /**
  114086. * Creates the render target textures and post processes used in the highlight layer.
  114087. */
  114088. protected _createTextureAndPostProcesses(): void;
  114089. /**
  114090. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  114091. */
  114092. needStencil(): boolean;
  114093. /**
  114094. * Checks for the readiness of the element composing the layer.
  114095. * @param subMesh the mesh to check for
  114096. * @param useInstances specify wether or not to use instances to render the mesh
  114097. * @param emissiveTexture the associated emissive texture used to generate the glow
  114098. * @return true if ready otherwise, false
  114099. */
  114100. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  114101. /**
  114102. * Implementation specific of rendering the generating effect on the main canvas.
  114103. * @param effect The effect used to render through
  114104. */
  114105. protected _internalRender(effect: Effect): void;
  114106. /**
  114107. * Returns true if the layer contains information to display, otherwise false.
  114108. */
  114109. shouldRender(): boolean;
  114110. /**
  114111. * Returns true if the mesh should render, otherwise false.
  114112. * @param mesh The mesh to render
  114113. * @returns true if it should render otherwise false
  114114. */
  114115. protected _shouldRenderMesh(mesh: Mesh): boolean;
  114116. /**
  114117. * Sets the required values for both the emissive texture and and the main color.
  114118. */
  114119. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  114120. /**
  114121. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  114122. * @param mesh The mesh to exclude from the highlight layer
  114123. */
  114124. addExcludedMesh(mesh: Mesh): void;
  114125. /**
  114126. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  114127. * @param mesh The mesh to highlight
  114128. */
  114129. removeExcludedMesh(mesh: Mesh): void;
  114130. /**
  114131. * Determine if a given mesh will be highlighted by the current HighlightLayer
  114132. * @param mesh mesh to test
  114133. * @returns true if the mesh will be highlighted by the current HighlightLayer
  114134. */
  114135. hasMesh(mesh: AbstractMesh): boolean;
  114136. /**
  114137. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  114138. * @param mesh The mesh to highlight
  114139. * @param color The color of the highlight
  114140. * @param glowEmissiveOnly Extract the glow from the emissive texture
  114141. */
  114142. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  114143. /**
  114144. * Remove a mesh from the highlight layer in order to make it stop glowing.
  114145. * @param mesh The mesh to highlight
  114146. */
  114147. removeMesh(mesh: Mesh): void;
  114148. /**
  114149. * Force the stencil to the normal expected value for none glowing parts
  114150. */
  114151. private _defaultStencilReference;
  114152. /**
  114153. * Free any resources and references associated to a mesh.
  114154. * Internal use
  114155. * @param mesh The mesh to free.
  114156. * @hidden
  114157. */
  114158. _disposeMesh(mesh: Mesh): void;
  114159. /**
  114160. * Dispose the highlight layer and free resources.
  114161. */
  114162. dispose(): void;
  114163. /**
  114164. * Gets the class name of the effect layer
  114165. * @returns the string with the class name of the effect layer
  114166. */
  114167. getClassName(): string;
  114168. /**
  114169. * Serializes this Highlight layer
  114170. * @returns a serialized Highlight layer object
  114171. */
  114172. serialize(): any;
  114173. /**
  114174. * Creates a Highlight layer from parsed Highlight layer data
  114175. * @param parsedHightlightLayer defines the Highlight layer data
  114176. * @param scene defines the current scene
  114177. * @param rootUrl defines the root URL containing the Highlight layer information
  114178. * @returns a parsed Highlight layer
  114179. */
  114180. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  114181. }
  114182. }
  114183. declare module BABYLON {
  114184. interface AbstractScene {
  114185. /**
  114186. * The list of layers (background and foreground) of the scene
  114187. */
  114188. layers: Array<Layer>;
  114189. }
  114190. /**
  114191. * Defines the layer scene component responsible to manage any layers
  114192. * in a given scene.
  114193. */
  114194. export class LayerSceneComponent implements ISceneComponent {
  114195. /**
  114196. * The component name helpfull to identify the component in the list of scene components.
  114197. */
  114198. readonly name: string;
  114199. /**
  114200. * The scene the component belongs to.
  114201. */
  114202. scene: Scene;
  114203. private _engine;
  114204. /**
  114205. * Creates a new instance of the component for the given scene
  114206. * @param scene Defines the scene to register the component in
  114207. */
  114208. constructor(scene: Scene);
  114209. /**
  114210. * Registers the component in a given scene
  114211. */
  114212. register(): void;
  114213. /**
  114214. * Rebuilds the elements related to this component in case of
  114215. * context lost for instance.
  114216. */
  114217. rebuild(): void;
  114218. /**
  114219. * Disposes the component and the associated ressources.
  114220. */
  114221. dispose(): void;
  114222. private _draw;
  114223. private _drawCameraPredicate;
  114224. private _drawCameraBackground;
  114225. private _drawCameraForeground;
  114226. private _drawRenderTargetPredicate;
  114227. private _drawRenderTargetBackground;
  114228. private _drawRenderTargetForeground;
  114229. /**
  114230. * Adds all the elements from the container to the scene
  114231. * @param container the container holding the elements
  114232. */
  114233. addFromContainer(container: AbstractScene): void;
  114234. /**
  114235. * Removes all the elements in the container from the scene
  114236. * @param container contains the elements to remove
  114237. * @param dispose if the removed element should be disposed (default: false)
  114238. */
  114239. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  114240. }
  114241. }
  114242. declare module BABYLON {
  114243. /** @hidden */
  114244. export var layerPixelShader: {
  114245. name: string;
  114246. shader: string;
  114247. };
  114248. }
  114249. declare module BABYLON {
  114250. /** @hidden */
  114251. export var layerVertexShader: {
  114252. name: string;
  114253. shader: string;
  114254. };
  114255. }
  114256. declare module BABYLON {
  114257. /**
  114258. * This represents a full screen 2d layer.
  114259. * This can be useful to display a picture in the background of your scene for instance.
  114260. * @see https://www.babylonjs-playground.com/#08A2BS#1
  114261. */
  114262. export class Layer {
  114263. /**
  114264. * Define the name of the layer.
  114265. */
  114266. name: string;
  114267. /**
  114268. * Define the texture the layer should display.
  114269. */
  114270. texture: Nullable<Texture>;
  114271. /**
  114272. * Is the layer in background or foreground.
  114273. */
  114274. isBackground: boolean;
  114275. /**
  114276. * Define the color of the layer (instead of texture).
  114277. */
  114278. color: Color4;
  114279. /**
  114280. * Define the scale of the layer in order to zoom in out of the texture.
  114281. */
  114282. scale: Vector2;
  114283. /**
  114284. * Define an offset for the layer in order to shift the texture.
  114285. */
  114286. offset: Vector2;
  114287. /**
  114288. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  114289. */
  114290. alphaBlendingMode: number;
  114291. /**
  114292. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  114293. * Alpha test will not mix with the background color in case of transparency.
  114294. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  114295. */
  114296. alphaTest: boolean;
  114297. /**
  114298. * Define a mask to restrict the layer to only some of the scene cameras.
  114299. */
  114300. layerMask: number;
  114301. /**
  114302. * Define the list of render target the layer is visible into.
  114303. */
  114304. renderTargetTextures: RenderTargetTexture[];
  114305. /**
  114306. * Define if the layer is only used in renderTarget or if it also
  114307. * renders in the main frame buffer of the canvas.
  114308. */
  114309. renderOnlyInRenderTargetTextures: boolean;
  114310. private _scene;
  114311. private _vertexBuffers;
  114312. private _indexBuffer;
  114313. private _effect;
  114314. private _alphaTestEffect;
  114315. /**
  114316. * An event triggered when the layer is disposed.
  114317. */
  114318. onDisposeObservable: Observable<Layer>;
  114319. private _onDisposeObserver;
  114320. /**
  114321. * Back compatibility with callback before the onDisposeObservable existed.
  114322. * The set callback will be triggered when the layer has been disposed.
  114323. */
  114324. onDispose: () => void;
  114325. /**
  114326. * An event triggered before rendering the scene
  114327. */
  114328. onBeforeRenderObservable: Observable<Layer>;
  114329. private _onBeforeRenderObserver;
  114330. /**
  114331. * Back compatibility with callback before the onBeforeRenderObservable existed.
  114332. * The set callback will be triggered just before rendering the layer.
  114333. */
  114334. onBeforeRender: () => void;
  114335. /**
  114336. * An event triggered after rendering the scene
  114337. */
  114338. onAfterRenderObservable: Observable<Layer>;
  114339. private _onAfterRenderObserver;
  114340. /**
  114341. * Back compatibility with callback before the onAfterRenderObservable existed.
  114342. * The set callback will be triggered just after rendering the layer.
  114343. */
  114344. onAfterRender: () => void;
  114345. /**
  114346. * Instantiates a new layer.
  114347. * This represents a full screen 2d layer.
  114348. * This can be useful to display a picture in the background of your scene for instance.
  114349. * @see https://www.babylonjs-playground.com/#08A2BS#1
  114350. * @param name Define the name of the layer in the scene
  114351. * @param imgUrl Define the url of the texture to display in the layer
  114352. * @param scene Define the scene the layer belongs to
  114353. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  114354. * @param color Defines a color for the layer
  114355. */
  114356. constructor(
  114357. /**
  114358. * Define the name of the layer.
  114359. */
  114360. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  114361. private _createIndexBuffer;
  114362. /** @hidden */
  114363. _rebuild(): void;
  114364. /**
  114365. * Renders the layer in the scene.
  114366. */
  114367. render(): void;
  114368. /**
  114369. * Disposes and releases the associated ressources.
  114370. */
  114371. dispose(): void;
  114372. }
  114373. }
  114374. declare module BABYLON {
  114375. /** @hidden */
  114376. export var lensFlarePixelShader: {
  114377. name: string;
  114378. shader: string;
  114379. };
  114380. }
  114381. declare module BABYLON {
  114382. /** @hidden */
  114383. export var lensFlareVertexShader: {
  114384. name: string;
  114385. shader: string;
  114386. };
  114387. }
  114388. declare module BABYLON {
  114389. /**
  114390. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  114391. * It is usually composed of several `lensFlare`.
  114392. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  114393. */
  114394. export class LensFlareSystem {
  114395. /**
  114396. * Define the name of the lens flare system
  114397. */
  114398. name: string;
  114399. /**
  114400. * List of lens flares used in this system.
  114401. */
  114402. lensFlares: LensFlare[];
  114403. /**
  114404. * Define a limit from the border the lens flare can be visible.
  114405. */
  114406. borderLimit: number;
  114407. /**
  114408. * Define a viewport border we do not want to see the lens flare in.
  114409. */
  114410. viewportBorder: number;
  114411. /**
  114412. * Define a predicate which could limit the list of meshes able to occlude the effect.
  114413. */
  114414. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  114415. /**
  114416. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  114417. */
  114418. layerMask: number;
  114419. /**
  114420. * Define the id of the lens flare system in the scene.
  114421. * (equal to name by default)
  114422. */
  114423. id: string;
  114424. private _scene;
  114425. private _emitter;
  114426. private _vertexBuffers;
  114427. private _indexBuffer;
  114428. private _effect;
  114429. private _positionX;
  114430. private _positionY;
  114431. private _isEnabled;
  114432. /** @hidden */
  114433. static _SceneComponentInitialization: (scene: Scene) => void;
  114434. /**
  114435. * Instantiates a lens flare system.
  114436. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  114437. * It is usually composed of several `lensFlare`.
  114438. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  114439. * @param name Define the name of the lens flare system in the scene
  114440. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  114441. * @param scene Define the scene the lens flare system belongs to
  114442. */
  114443. constructor(
  114444. /**
  114445. * Define the name of the lens flare system
  114446. */
  114447. name: string, emitter: any, scene: Scene);
  114448. /**
  114449. * Define if the lens flare system is enabled.
  114450. */
  114451. isEnabled: boolean;
  114452. /**
  114453. * Get the scene the effects belongs to.
  114454. * @returns the scene holding the lens flare system
  114455. */
  114456. getScene(): Scene;
  114457. /**
  114458. * Get the emitter of the lens flare system.
  114459. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  114460. * @returns the emitter of the lens flare system
  114461. */
  114462. getEmitter(): any;
  114463. /**
  114464. * Set the emitter of the lens flare system.
  114465. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  114466. * @param newEmitter Define the new emitter of the system
  114467. */
  114468. setEmitter(newEmitter: any): void;
  114469. /**
  114470. * Get the lens flare system emitter position.
  114471. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  114472. * @returns the position
  114473. */
  114474. getEmitterPosition(): Vector3;
  114475. /**
  114476. * @hidden
  114477. */
  114478. computeEffectivePosition(globalViewport: Viewport): boolean;
  114479. /** @hidden */
  114480. _isVisible(): boolean;
  114481. /**
  114482. * @hidden
  114483. */
  114484. render(): boolean;
  114485. /**
  114486. * Dispose and release the lens flare with its associated resources.
  114487. */
  114488. dispose(): void;
  114489. /**
  114490. * Parse a lens flare system from a JSON repressentation
  114491. * @param parsedLensFlareSystem Define the JSON to parse
  114492. * @param scene Define the scene the parsed system should be instantiated in
  114493. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  114494. * @returns the parsed system
  114495. */
  114496. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  114497. /**
  114498. * Serialize the current Lens Flare System into a JSON representation.
  114499. * @returns the serialized JSON
  114500. */
  114501. serialize(): any;
  114502. }
  114503. }
  114504. declare module BABYLON {
  114505. /**
  114506. * This represents one of the lens effect in a `lensFlareSystem`.
  114507. * It controls one of the indiviual texture used in the effect.
  114508. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  114509. */
  114510. export class LensFlare {
  114511. /**
  114512. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  114513. */
  114514. size: number;
  114515. /**
  114516. * 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.
  114517. */
  114518. position: number;
  114519. /**
  114520. * Define the lens color.
  114521. */
  114522. color: Color3;
  114523. /**
  114524. * Define the lens texture.
  114525. */
  114526. texture: Nullable<Texture>;
  114527. /**
  114528. * Define the alpha mode to render this particular lens.
  114529. */
  114530. alphaMode: number;
  114531. private _system;
  114532. /**
  114533. * Creates a new Lens Flare.
  114534. * This represents one of the lens effect in a `lensFlareSystem`.
  114535. * It controls one of the indiviual texture used in the effect.
  114536. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  114537. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  114538. * @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.
  114539. * @param color Define the lens color
  114540. * @param imgUrl Define the lens texture url
  114541. * @param system Define the `lensFlareSystem` this flare is part of
  114542. * @returns The newly created Lens Flare
  114543. */
  114544. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  114545. /**
  114546. * Instantiates a new Lens Flare.
  114547. * This represents one of the lens effect in a `lensFlareSystem`.
  114548. * It controls one of the indiviual texture used in the effect.
  114549. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  114550. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  114551. * @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.
  114552. * @param color Define the lens color
  114553. * @param imgUrl Define the lens texture url
  114554. * @param system Define the `lensFlareSystem` this flare is part of
  114555. */
  114556. constructor(
  114557. /**
  114558. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  114559. */
  114560. size: number,
  114561. /**
  114562. * 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.
  114563. */
  114564. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  114565. /**
  114566. * Dispose and release the lens flare with its associated resources.
  114567. */
  114568. dispose(): void;
  114569. }
  114570. }
  114571. declare module BABYLON {
  114572. interface AbstractScene {
  114573. /**
  114574. * The list of lens flare system added to the scene
  114575. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  114576. */
  114577. lensFlareSystems: Array<LensFlareSystem>;
  114578. /**
  114579. * Removes the given lens flare system from this scene.
  114580. * @param toRemove The lens flare system to remove
  114581. * @returns The index of the removed lens flare system
  114582. */
  114583. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  114584. /**
  114585. * Adds the given lens flare system to this scene
  114586. * @param newLensFlareSystem The lens flare system to add
  114587. */
  114588. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  114589. /**
  114590. * Gets a lens flare system using its name
  114591. * @param name defines the name to look for
  114592. * @returns the lens flare system or null if not found
  114593. */
  114594. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  114595. /**
  114596. * Gets a lens flare system using its id
  114597. * @param id defines the id to look for
  114598. * @returns the lens flare system or null if not found
  114599. */
  114600. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  114601. }
  114602. /**
  114603. * Defines the lens flare scene component responsible to manage any lens flares
  114604. * in a given scene.
  114605. */
  114606. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  114607. /**
  114608. * The component name helpfull to identify the component in the list of scene components.
  114609. */
  114610. readonly name: string;
  114611. /**
  114612. * The scene the component belongs to.
  114613. */
  114614. scene: Scene;
  114615. /**
  114616. * Creates a new instance of the component for the given scene
  114617. * @param scene Defines the scene to register the component in
  114618. */
  114619. constructor(scene: Scene);
  114620. /**
  114621. * Registers the component in a given scene
  114622. */
  114623. register(): void;
  114624. /**
  114625. * Rebuilds the elements related to this component in case of
  114626. * context lost for instance.
  114627. */
  114628. rebuild(): void;
  114629. /**
  114630. * Adds all the elements from the container to the scene
  114631. * @param container the container holding the elements
  114632. */
  114633. addFromContainer(container: AbstractScene): void;
  114634. /**
  114635. * Removes all the elements in the container from the scene
  114636. * @param container contains the elements to remove
  114637. * @param dispose if the removed element should be disposed (default: false)
  114638. */
  114639. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  114640. /**
  114641. * Serializes the component data to the specified json object
  114642. * @param serializationObject The object to serialize to
  114643. */
  114644. serialize(serializationObject: any): void;
  114645. /**
  114646. * Disposes the component and the associated ressources.
  114647. */
  114648. dispose(): void;
  114649. private _draw;
  114650. }
  114651. }
  114652. declare module BABYLON {
  114653. /**
  114654. * Defines the shadow generator component responsible to manage any shadow generators
  114655. * in a given scene.
  114656. */
  114657. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  114658. /**
  114659. * The component name helpfull to identify the component in the list of scene components.
  114660. */
  114661. readonly name: string;
  114662. /**
  114663. * The scene the component belongs to.
  114664. */
  114665. scene: Scene;
  114666. /**
  114667. * Creates a new instance of the component for the given scene
  114668. * @param scene Defines the scene to register the component in
  114669. */
  114670. constructor(scene: Scene);
  114671. /**
  114672. * Registers the component in a given scene
  114673. */
  114674. register(): void;
  114675. /**
  114676. * Rebuilds the elements related to this component in case of
  114677. * context lost for instance.
  114678. */
  114679. rebuild(): void;
  114680. /**
  114681. * Serializes the component data to the specified json object
  114682. * @param serializationObject The object to serialize to
  114683. */
  114684. serialize(serializationObject: any): void;
  114685. /**
  114686. * Adds all the elements from the container to the scene
  114687. * @param container the container holding the elements
  114688. */
  114689. addFromContainer(container: AbstractScene): void;
  114690. /**
  114691. * Removes all the elements in the container from the scene
  114692. * @param container contains the elements to remove
  114693. * @param dispose if the removed element should be disposed (default: false)
  114694. */
  114695. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  114696. /**
  114697. * Rebuilds the elements related to this component in case of
  114698. * context lost for instance.
  114699. */
  114700. dispose(): void;
  114701. private _gatherRenderTargets;
  114702. }
  114703. }
  114704. declare module BABYLON {
  114705. /**
  114706. * A point light is a light defined by an unique point in world space.
  114707. * The light is emitted in every direction from this point.
  114708. * A good example of a point light is a standard light bulb.
  114709. * Documentation: https://doc.babylonjs.com/babylon101/lights
  114710. */
  114711. export class PointLight extends ShadowLight {
  114712. private _shadowAngle;
  114713. /**
  114714. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  114715. * This specifies what angle the shadow will use to be created.
  114716. *
  114717. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  114718. */
  114719. /**
  114720. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  114721. * This specifies what angle the shadow will use to be created.
  114722. *
  114723. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  114724. */
  114725. shadowAngle: number;
  114726. /**
  114727. * Gets the direction if it has been set.
  114728. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  114729. */
  114730. /**
  114731. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  114732. */
  114733. direction: Vector3;
  114734. /**
  114735. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  114736. * A PointLight emits the light in every direction.
  114737. * It can cast shadows.
  114738. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  114739. * ```javascript
  114740. * var pointLight = new PointLight("pl", camera.position, scene);
  114741. * ```
  114742. * Documentation : https://doc.babylonjs.com/babylon101/lights
  114743. * @param name The light friendly name
  114744. * @param position The position of the point light in the scene
  114745. * @param scene The scene the lights belongs to
  114746. */
  114747. constructor(name: string, position: Vector3, scene: Scene);
  114748. /**
  114749. * Returns the string "PointLight"
  114750. * @returns the class name
  114751. */
  114752. getClassName(): string;
  114753. /**
  114754. * Returns the integer 0.
  114755. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  114756. */
  114757. getTypeID(): number;
  114758. /**
  114759. * Specifies wether or not the shadowmap should be a cube texture.
  114760. * @returns true if the shadowmap needs to be a cube texture.
  114761. */
  114762. needCube(): boolean;
  114763. /**
  114764. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  114765. * @param faceIndex The index of the face we are computed the direction to generate shadow
  114766. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  114767. */
  114768. getShadowDirection(faceIndex?: number): Vector3;
  114769. /**
  114770. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  114771. * - fov = PI / 2
  114772. * - aspect ratio : 1.0
  114773. * - z-near and far equal to the active camera minZ and maxZ.
  114774. * Returns the PointLight.
  114775. */
  114776. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  114777. protected _buildUniformLayout(): void;
  114778. /**
  114779. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  114780. * @param effect The effect to update
  114781. * @param lightIndex The index of the light in the effect to update
  114782. * @returns The point light
  114783. */
  114784. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  114785. /**
  114786. * Prepares the list of defines specific to the light type.
  114787. * @param defines the list of defines
  114788. * @param lightIndex defines the index of the light for the effect
  114789. */
  114790. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  114791. }
  114792. }
  114793. declare module BABYLON {
  114794. /**
  114795. * Header information of HDR texture files.
  114796. */
  114797. export interface HDRInfo {
  114798. /**
  114799. * The height of the texture in pixels.
  114800. */
  114801. height: number;
  114802. /**
  114803. * The width of the texture in pixels.
  114804. */
  114805. width: number;
  114806. /**
  114807. * The index of the beginning of the data in the binary file.
  114808. */
  114809. dataPosition: number;
  114810. }
  114811. /**
  114812. * This groups tools to convert HDR texture to native colors array.
  114813. */
  114814. export class HDRTools {
  114815. private static Ldexp;
  114816. private static Rgbe2float;
  114817. private static readStringLine;
  114818. /**
  114819. * Reads header information from an RGBE texture stored in a native array.
  114820. * More information on this format are available here:
  114821. * https://en.wikipedia.org/wiki/RGBE_image_format
  114822. *
  114823. * @param uint8array The binary file stored in native array.
  114824. * @return The header information.
  114825. */
  114826. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  114827. /**
  114828. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  114829. * This RGBE texture needs to store the information as a panorama.
  114830. *
  114831. * More information on this format are available here:
  114832. * https://en.wikipedia.org/wiki/RGBE_image_format
  114833. *
  114834. * @param buffer The binary file stored in an array buffer.
  114835. * @param size The expected size of the extracted cubemap.
  114836. * @return The Cube Map information.
  114837. */
  114838. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  114839. /**
  114840. * Returns the pixels data extracted from an RGBE texture.
  114841. * This pixels will be stored left to right up to down in the R G B order in one array.
  114842. *
  114843. * More information on this format are available here:
  114844. * https://en.wikipedia.org/wiki/RGBE_image_format
  114845. *
  114846. * @param uint8array The binary file stored in an array buffer.
  114847. * @param hdrInfo The header information of the file.
  114848. * @return The pixels data in RGB right to left up to down order.
  114849. */
  114850. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  114851. private static RGBE_ReadPixels_RLE;
  114852. }
  114853. }
  114854. declare module BABYLON {
  114855. /**
  114856. * This represents a texture coming from an HDR input.
  114857. *
  114858. * The only supported format is currently panorama picture stored in RGBE format.
  114859. * Example of such files can be found on HDRLib: http://hdrlib.com/
  114860. */
  114861. export class HDRCubeTexture extends BaseTexture {
  114862. private static _facesMapping;
  114863. private _generateHarmonics;
  114864. private _noMipmap;
  114865. private _textureMatrix;
  114866. private _size;
  114867. private _onLoad;
  114868. private _onError;
  114869. /**
  114870. * The texture URL.
  114871. */
  114872. url: string;
  114873. /**
  114874. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  114875. */
  114876. coordinatesMode: number;
  114877. protected _isBlocking: boolean;
  114878. /**
  114879. * Sets wether or not the texture is blocking during loading.
  114880. */
  114881. /**
  114882. * Gets wether or not the texture is blocking during loading.
  114883. */
  114884. isBlocking: boolean;
  114885. protected _rotationY: number;
  114886. /**
  114887. * Sets texture matrix rotation angle around Y axis in radians.
  114888. */
  114889. /**
  114890. * Gets texture matrix rotation angle around Y axis radians.
  114891. */
  114892. rotationY: number;
  114893. /**
  114894. * Gets or sets the center of the bounding box associated with the cube texture
  114895. * It must define where the camera used to render the texture was set
  114896. */
  114897. boundingBoxPosition: Vector3;
  114898. private _boundingBoxSize;
  114899. /**
  114900. * Gets or sets the size of the bounding box associated with the cube texture
  114901. * When defined, the cubemap will switch to local mode
  114902. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  114903. * @example https://www.babylonjs-playground.com/#RNASML
  114904. */
  114905. boundingBoxSize: Vector3;
  114906. /**
  114907. * Instantiates an HDRTexture from the following parameters.
  114908. *
  114909. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  114910. * @param scene The scene the texture will be used in
  114911. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  114912. * @param noMipmap Forces to not generate the mipmap if true
  114913. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  114914. * @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)
  114915. * @param reserved Reserved flag for internal use.
  114916. */
  114917. 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>);
  114918. /**
  114919. * Get the current class name of the texture useful for serialization or dynamic coding.
  114920. * @returns "HDRCubeTexture"
  114921. */
  114922. getClassName(): string;
  114923. /**
  114924. * Occurs when the file is raw .hdr file.
  114925. */
  114926. private loadTexture;
  114927. clone(): HDRCubeTexture;
  114928. delayLoad(): void;
  114929. /**
  114930. * Get the texture reflection matrix used to rotate/transform the reflection.
  114931. * @returns the reflection matrix
  114932. */
  114933. getReflectionTextureMatrix(): Matrix;
  114934. /**
  114935. * Set the texture reflection matrix used to rotate/transform the reflection.
  114936. * @param value Define the reflection matrix to set
  114937. */
  114938. setReflectionTextureMatrix(value: Matrix): void;
  114939. /**
  114940. * Parses a JSON representation of an HDR Texture in order to create the texture
  114941. * @param parsedTexture Define the JSON representation
  114942. * @param scene Define the scene the texture should be created in
  114943. * @param rootUrl Define the root url in case we need to load relative dependencies
  114944. * @returns the newly created texture after parsing
  114945. */
  114946. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  114947. serialize(): any;
  114948. }
  114949. }
  114950. declare module BABYLON {
  114951. /**
  114952. * Class used to control physics engine
  114953. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  114954. */
  114955. export class PhysicsEngine implements IPhysicsEngine {
  114956. private _physicsPlugin;
  114957. /**
  114958. * Global value used to control the smallest number supported by the simulation
  114959. */
  114960. static Epsilon: number;
  114961. private _impostors;
  114962. private _joints;
  114963. /**
  114964. * Gets the gravity vector used by the simulation
  114965. */
  114966. gravity: Vector3;
  114967. /**
  114968. * Factory used to create the default physics plugin.
  114969. * @returns The default physics plugin
  114970. */
  114971. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  114972. /**
  114973. * Creates a new Physics Engine
  114974. * @param gravity defines the gravity vector used by the simulation
  114975. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  114976. */
  114977. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  114978. /**
  114979. * Sets the gravity vector used by the simulation
  114980. * @param gravity defines the gravity vector to use
  114981. */
  114982. setGravity(gravity: Vector3): void;
  114983. /**
  114984. * Set the time step of the physics engine.
  114985. * Default is 1/60.
  114986. * To slow it down, enter 1/600 for example.
  114987. * To speed it up, 1/30
  114988. * @param newTimeStep defines the new timestep to apply to this world.
  114989. */
  114990. setTimeStep(newTimeStep?: number): void;
  114991. /**
  114992. * Get the time step of the physics engine.
  114993. * @returns the current time step
  114994. */
  114995. getTimeStep(): number;
  114996. /**
  114997. * Release all resources
  114998. */
  114999. dispose(): void;
  115000. /**
  115001. * Gets the name of the current physics plugin
  115002. * @returns the name of the plugin
  115003. */
  115004. getPhysicsPluginName(): string;
  115005. /**
  115006. * Adding a new impostor for the impostor tracking.
  115007. * This will be done by the impostor itself.
  115008. * @param impostor the impostor to add
  115009. */
  115010. addImpostor(impostor: PhysicsImpostor): void;
  115011. /**
  115012. * Remove an impostor from the engine.
  115013. * This impostor and its mesh will not longer be updated by the physics engine.
  115014. * @param impostor the impostor to remove
  115015. */
  115016. removeImpostor(impostor: PhysicsImpostor): void;
  115017. /**
  115018. * Add a joint to the physics engine
  115019. * @param mainImpostor defines the main impostor to which the joint is added.
  115020. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  115021. * @param joint defines the joint that will connect both impostors.
  115022. */
  115023. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  115024. /**
  115025. * Removes a joint from the simulation
  115026. * @param mainImpostor defines the impostor used with the joint
  115027. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  115028. * @param joint defines the joint to remove
  115029. */
  115030. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  115031. /**
  115032. * Called by the scene. No need to call it.
  115033. * @param delta defines the timespam between frames
  115034. */
  115035. _step(delta: number): void;
  115036. /**
  115037. * Gets the current plugin used to run the simulation
  115038. * @returns current plugin
  115039. */
  115040. getPhysicsPlugin(): IPhysicsEnginePlugin;
  115041. /**
  115042. * Gets the list of physic impostors
  115043. * @returns an array of PhysicsImpostor
  115044. */
  115045. getImpostors(): Array<PhysicsImpostor>;
  115046. /**
  115047. * Gets the impostor for a physics enabled object
  115048. * @param object defines the object impersonated by the impostor
  115049. * @returns the PhysicsImpostor or null if not found
  115050. */
  115051. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  115052. /**
  115053. * Gets the impostor for a physics body object
  115054. * @param body defines physics body used by the impostor
  115055. * @returns the PhysicsImpostor or null if not found
  115056. */
  115057. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  115058. /**
  115059. * Does a raycast in the physics world
  115060. * @param from when should the ray start?
  115061. * @param to when should the ray end?
  115062. * @returns PhysicsRaycastResult
  115063. */
  115064. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  115065. }
  115066. }
  115067. declare module BABYLON {
  115068. /** @hidden */
  115069. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  115070. private _useDeltaForWorldStep;
  115071. world: any;
  115072. name: string;
  115073. private _physicsMaterials;
  115074. private _fixedTimeStep;
  115075. private _cannonRaycastResult;
  115076. private _raycastResult;
  115077. private _physicsBodysToRemoveAfterStep;
  115078. BJSCANNON: any;
  115079. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  115080. setGravity(gravity: Vector3): void;
  115081. setTimeStep(timeStep: number): void;
  115082. getTimeStep(): number;
  115083. executeStep(delta: number): void;
  115084. private _removeMarkedPhysicsBodiesFromWorld;
  115085. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  115086. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  115087. generatePhysicsBody(impostor: PhysicsImpostor): void;
  115088. private _processChildMeshes;
  115089. removePhysicsBody(impostor: PhysicsImpostor): void;
  115090. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  115091. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  115092. private _addMaterial;
  115093. private _checkWithEpsilon;
  115094. private _createShape;
  115095. private _createHeightmap;
  115096. private _minus90X;
  115097. private _plus90X;
  115098. private _tmpPosition;
  115099. private _tmpDeltaPosition;
  115100. private _tmpUnityRotation;
  115101. private _updatePhysicsBodyTransformation;
  115102. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  115103. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  115104. isSupported(): boolean;
  115105. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  115106. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  115107. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  115108. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  115109. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  115110. getBodyMass(impostor: PhysicsImpostor): number;
  115111. getBodyFriction(impostor: PhysicsImpostor): number;
  115112. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  115113. getBodyRestitution(impostor: PhysicsImpostor): number;
  115114. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  115115. sleepBody(impostor: PhysicsImpostor): void;
  115116. wakeUpBody(impostor: PhysicsImpostor): void;
  115117. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  115118. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  115119. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  115120. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  115121. getRadius(impostor: PhysicsImpostor): number;
  115122. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  115123. dispose(): void;
  115124. private _extendNamespace;
  115125. /**
  115126. * Does a raycast in the physics world
  115127. * @param from when should the ray start?
  115128. * @param to when should the ray end?
  115129. * @returns PhysicsRaycastResult
  115130. */
  115131. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  115132. }
  115133. }
  115134. declare module BABYLON {
  115135. /** @hidden */
  115136. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  115137. world: any;
  115138. name: string;
  115139. BJSOIMO: any;
  115140. private _raycastResult;
  115141. constructor(iterations?: number, oimoInjection?: any);
  115142. setGravity(gravity: Vector3): void;
  115143. setTimeStep(timeStep: number): void;
  115144. getTimeStep(): number;
  115145. private _tmpImpostorsArray;
  115146. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  115147. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  115148. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  115149. generatePhysicsBody(impostor: PhysicsImpostor): void;
  115150. private _tmpPositionVector;
  115151. removePhysicsBody(impostor: PhysicsImpostor): void;
  115152. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  115153. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  115154. isSupported(): boolean;
  115155. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  115156. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  115157. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  115158. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  115159. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  115160. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  115161. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  115162. getBodyMass(impostor: PhysicsImpostor): number;
  115163. getBodyFriction(impostor: PhysicsImpostor): number;
  115164. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  115165. getBodyRestitution(impostor: PhysicsImpostor): number;
  115166. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  115167. sleepBody(impostor: PhysicsImpostor): void;
  115168. wakeUpBody(impostor: PhysicsImpostor): void;
  115169. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  115170. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  115171. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  115172. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  115173. getRadius(impostor: PhysicsImpostor): number;
  115174. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  115175. dispose(): void;
  115176. /**
  115177. * Does a raycast in the physics world
  115178. * @param from when should the ray start?
  115179. * @param to when should the ray end?
  115180. * @returns PhysicsRaycastResult
  115181. */
  115182. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  115183. }
  115184. }
  115185. declare module BABYLON {
  115186. /**
  115187. * Class containing static functions to help procedurally build meshes
  115188. */
  115189. export class RibbonBuilder {
  115190. /**
  115191. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  115192. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  115193. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  115194. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  115195. * * 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
  115196. * * 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
  115197. * * 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
  115198. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115199. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115200. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  115201. * * 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
  115202. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  115203. * * 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
  115204. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  115205. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115206. * @param name defines the name of the mesh
  115207. * @param options defines the options used to create the mesh
  115208. * @param scene defines the hosting scene
  115209. * @returns the ribbon mesh
  115210. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  115211. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  115212. */
  115213. static CreateRibbon(name: string, options: {
  115214. pathArray: Vector3[][];
  115215. closeArray?: boolean;
  115216. closePath?: boolean;
  115217. offset?: number;
  115218. updatable?: boolean;
  115219. sideOrientation?: number;
  115220. frontUVs?: Vector4;
  115221. backUVs?: Vector4;
  115222. instance?: Mesh;
  115223. invertUV?: boolean;
  115224. uvs?: Vector2[];
  115225. colors?: Color4[];
  115226. }, scene?: Nullable<Scene>): Mesh;
  115227. }
  115228. }
  115229. declare module BABYLON {
  115230. /**
  115231. * Class containing static functions to help procedurally build meshes
  115232. */
  115233. export class ShapeBuilder {
  115234. /**
  115235. * 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.
  115236. * * 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.
  115237. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  115238. * * 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.
  115239. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  115240. * * 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
  115241. * * 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
  115242. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  115243. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115244. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115245. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  115246. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115247. * @param name defines the name of the mesh
  115248. * @param options defines the options used to create the mesh
  115249. * @param scene defines the hosting scene
  115250. * @returns the extruded shape mesh
  115251. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  115252. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  115253. */
  115254. static ExtrudeShape(name: string, options: {
  115255. shape: Vector3[];
  115256. path: Vector3[];
  115257. scale?: number;
  115258. rotation?: number;
  115259. cap?: number;
  115260. updatable?: boolean;
  115261. sideOrientation?: number;
  115262. frontUVs?: Vector4;
  115263. backUVs?: Vector4;
  115264. instance?: Mesh;
  115265. invertUV?: boolean;
  115266. }, scene?: Nullable<Scene>): Mesh;
  115267. /**
  115268. * Creates an custom extruded shape mesh.
  115269. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  115270. * * 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.
  115271. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  115272. * * 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
  115273. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  115274. * * 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
  115275. * * It must returns a float value that will be the scale value applied to the shape on each path point
  115276. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  115277. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  115278. * * 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
  115279. * * 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
  115280. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  115281. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115282. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115283. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  115284. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115285. * @param name defines the name of the mesh
  115286. * @param options defines the options used to create the mesh
  115287. * @param scene defines the hosting scene
  115288. * @returns the custom extruded shape mesh
  115289. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  115290. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  115291. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  115292. */
  115293. static ExtrudeShapeCustom(name: string, options: {
  115294. shape: Vector3[];
  115295. path: Vector3[];
  115296. scaleFunction?: any;
  115297. rotationFunction?: any;
  115298. ribbonCloseArray?: boolean;
  115299. ribbonClosePath?: boolean;
  115300. cap?: number;
  115301. updatable?: boolean;
  115302. sideOrientation?: number;
  115303. frontUVs?: Vector4;
  115304. backUVs?: Vector4;
  115305. instance?: Mesh;
  115306. invertUV?: boolean;
  115307. }, scene?: Nullable<Scene>): Mesh;
  115308. private static _ExtrudeShapeGeneric;
  115309. }
  115310. }
  115311. declare module BABYLON {
  115312. /**
  115313. * AmmoJS Physics plugin
  115314. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  115315. * @see https://github.com/kripken/ammo.js/
  115316. */
  115317. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  115318. private _useDeltaForWorldStep;
  115319. /**
  115320. * Reference to the Ammo library
  115321. */
  115322. bjsAMMO: any;
  115323. /**
  115324. * Created ammoJS world which physics bodies are added to
  115325. */
  115326. world: any;
  115327. /**
  115328. * Name of the plugin
  115329. */
  115330. name: string;
  115331. private _timeStep;
  115332. private _fixedTimeStep;
  115333. private _maxSteps;
  115334. private _tmpQuaternion;
  115335. private _tmpAmmoTransform;
  115336. private _tmpAmmoQuaternion;
  115337. private _tmpAmmoConcreteContactResultCallback;
  115338. private _collisionConfiguration;
  115339. private _dispatcher;
  115340. private _overlappingPairCache;
  115341. private _solver;
  115342. private _softBodySolver;
  115343. private _tmpAmmoVectorA;
  115344. private _tmpAmmoVectorB;
  115345. private _tmpAmmoVectorC;
  115346. private _tmpAmmoVectorD;
  115347. private _tmpContactCallbackResult;
  115348. private _tmpAmmoVectorRCA;
  115349. private _tmpAmmoVectorRCB;
  115350. private _raycastResult;
  115351. private static readonly DISABLE_COLLISION_FLAG;
  115352. private static readonly KINEMATIC_FLAG;
  115353. private static readonly DISABLE_DEACTIVATION_FLAG;
  115354. /**
  115355. * Initializes the ammoJS plugin
  115356. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  115357. * @param ammoInjection can be used to inject your own ammo reference
  115358. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  115359. */
  115360. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  115361. /**
  115362. * Sets the gravity of the physics world (m/(s^2))
  115363. * @param gravity Gravity to set
  115364. */
  115365. setGravity(gravity: Vector3): void;
  115366. /**
  115367. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  115368. * @param timeStep timestep to use in seconds
  115369. */
  115370. setTimeStep(timeStep: number): void;
  115371. /**
  115372. * 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)
  115373. * @param fixedTimeStep fixedTimeStep to use in seconds
  115374. */
  115375. setFixedTimeStep(fixedTimeStep: number): void;
  115376. /**
  115377. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  115378. * @param maxSteps the maximum number of steps by the physics engine per frame
  115379. */
  115380. setMaxSteps(maxSteps: number): void;
  115381. /**
  115382. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  115383. * @returns the current timestep in seconds
  115384. */
  115385. getTimeStep(): number;
  115386. private _isImpostorInContact;
  115387. private _isImpostorPairInContact;
  115388. private _stepSimulation;
  115389. /**
  115390. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  115391. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  115392. * After the step the babylon meshes are set to the position of the physics imposters
  115393. * @param delta amount of time to step forward
  115394. * @param impostors array of imposters to update before/after the step
  115395. */
  115396. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  115397. /**
  115398. * Update babylon mesh to match physics world object
  115399. * @param impostor imposter to match
  115400. */
  115401. private _afterSoftStep;
  115402. /**
  115403. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  115404. * @param impostor imposter to match
  115405. */
  115406. private _ropeStep;
  115407. /**
  115408. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  115409. * @param impostor imposter to match
  115410. */
  115411. private _softbodyOrClothStep;
  115412. private _tmpVector;
  115413. private _tmpMatrix;
  115414. /**
  115415. * Applies an impulse on the imposter
  115416. * @param impostor imposter to apply impulse to
  115417. * @param force amount of force to be applied to the imposter
  115418. * @param contactPoint the location to apply the impulse on the imposter
  115419. */
  115420. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  115421. /**
  115422. * Applies a force on the imposter
  115423. * @param impostor imposter to apply force
  115424. * @param force amount of force to be applied to the imposter
  115425. * @param contactPoint the location to apply the force on the imposter
  115426. */
  115427. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  115428. /**
  115429. * Creates a physics body using the plugin
  115430. * @param impostor the imposter to create the physics body on
  115431. */
  115432. generatePhysicsBody(impostor: PhysicsImpostor): void;
  115433. /**
  115434. * Removes the physics body from the imposter and disposes of the body's memory
  115435. * @param impostor imposter to remove the physics body from
  115436. */
  115437. removePhysicsBody(impostor: PhysicsImpostor): void;
  115438. /**
  115439. * Generates a joint
  115440. * @param impostorJoint the imposter joint to create the joint with
  115441. */
  115442. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  115443. /**
  115444. * Removes a joint
  115445. * @param impostorJoint the imposter joint to remove the joint from
  115446. */
  115447. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  115448. private _addMeshVerts;
  115449. /**
  115450. * Initialise the soft body vertices to match its object's (mesh) vertices
  115451. * Softbody vertices (nodes) are in world space and to match this
  115452. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  115453. * @param impostor to create the softbody for
  115454. */
  115455. private _softVertexData;
  115456. /**
  115457. * Create an impostor's soft body
  115458. * @param impostor to create the softbody for
  115459. */
  115460. private _createSoftbody;
  115461. /**
  115462. * Create cloth for an impostor
  115463. * @param impostor to create the softbody for
  115464. */
  115465. private _createCloth;
  115466. /**
  115467. * Create rope for an impostor
  115468. * @param impostor to create the softbody for
  115469. */
  115470. private _createRope;
  115471. private _addHullVerts;
  115472. private _createShape;
  115473. /**
  115474. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  115475. * @param impostor imposter containing the physics body and babylon object
  115476. */
  115477. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  115478. /**
  115479. * Sets the babylon object's position/rotation from the physics body's position/rotation
  115480. * @param impostor imposter containing the physics body and babylon object
  115481. * @param newPosition new position
  115482. * @param newRotation new rotation
  115483. */
  115484. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  115485. /**
  115486. * If this plugin is supported
  115487. * @returns true if its supported
  115488. */
  115489. isSupported(): boolean;
  115490. /**
  115491. * Sets the linear velocity of the physics body
  115492. * @param impostor imposter to set the velocity on
  115493. * @param velocity velocity to set
  115494. */
  115495. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  115496. /**
  115497. * Sets the angular velocity of the physics body
  115498. * @param impostor imposter to set the velocity on
  115499. * @param velocity velocity to set
  115500. */
  115501. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  115502. /**
  115503. * gets the linear velocity
  115504. * @param impostor imposter to get linear velocity from
  115505. * @returns linear velocity
  115506. */
  115507. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  115508. /**
  115509. * gets the angular velocity
  115510. * @param impostor imposter to get angular velocity from
  115511. * @returns angular velocity
  115512. */
  115513. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  115514. /**
  115515. * Sets the mass of physics body
  115516. * @param impostor imposter to set the mass on
  115517. * @param mass mass to set
  115518. */
  115519. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  115520. /**
  115521. * Gets the mass of the physics body
  115522. * @param impostor imposter to get the mass from
  115523. * @returns mass
  115524. */
  115525. getBodyMass(impostor: PhysicsImpostor): number;
  115526. /**
  115527. * Gets friction of the impostor
  115528. * @param impostor impostor to get friction from
  115529. * @returns friction value
  115530. */
  115531. getBodyFriction(impostor: PhysicsImpostor): number;
  115532. /**
  115533. * Sets friction of the impostor
  115534. * @param impostor impostor to set friction on
  115535. * @param friction friction value
  115536. */
  115537. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  115538. /**
  115539. * Gets restitution of the impostor
  115540. * @param impostor impostor to get restitution from
  115541. * @returns restitution value
  115542. */
  115543. getBodyRestitution(impostor: PhysicsImpostor): number;
  115544. /**
  115545. * Sets resitution of the impostor
  115546. * @param impostor impostor to set resitution on
  115547. * @param restitution resitution value
  115548. */
  115549. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  115550. /**
  115551. * Gets pressure inside the impostor
  115552. * @param impostor impostor to get pressure from
  115553. * @returns pressure value
  115554. */
  115555. getBodyPressure(impostor: PhysicsImpostor): number;
  115556. /**
  115557. * Sets pressure inside a soft body impostor
  115558. * Cloth and rope must remain 0 pressure
  115559. * @param impostor impostor to set pressure on
  115560. * @param pressure pressure value
  115561. */
  115562. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  115563. /**
  115564. * Gets stiffness of the impostor
  115565. * @param impostor impostor to get stiffness from
  115566. * @returns pressure value
  115567. */
  115568. getBodyStiffness(impostor: PhysicsImpostor): number;
  115569. /**
  115570. * Sets stiffness of the impostor
  115571. * @param impostor impostor to set stiffness on
  115572. * @param stiffness stiffness value from 0 to 1
  115573. */
  115574. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  115575. /**
  115576. * Gets velocityIterations of the impostor
  115577. * @param impostor impostor to get velocity iterations from
  115578. * @returns velocityIterations value
  115579. */
  115580. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  115581. /**
  115582. * Sets velocityIterations of the impostor
  115583. * @param impostor impostor to set velocity iterations on
  115584. * @param velocityIterations velocityIterations value
  115585. */
  115586. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  115587. /**
  115588. * Gets positionIterations of the impostor
  115589. * @param impostor impostor to get position iterations from
  115590. * @returns positionIterations value
  115591. */
  115592. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  115593. /**
  115594. * Sets positionIterations of the impostor
  115595. * @param impostor impostor to set position on
  115596. * @param positionIterations positionIterations value
  115597. */
  115598. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  115599. /**
  115600. * Append an anchor to a cloth object
  115601. * @param impostor is the cloth impostor to add anchor to
  115602. * @param otherImpostor is the rigid impostor to anchor to
  115603. * @param width ratio across width from 0 to 1
  115604. * @param height ratio up height from 0 to 1
  115605. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  115606. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  115607. */
  115608. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  115609. /**
  115610. * Append an hook to a rope object
  115611. * @param impostor is the rope impostor to add hook to
  115612. * @param otherImpostor is the rigid impostor to hook to
  115613. * @param length ratio along the rope from 0 to 1
  115614. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  115615. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  115616. */
  115617. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  115618. /**
  115619. * Sleeps the physics body and stops it from being active
  115620. * @param impostor impostor to sleep
  115621. */
  115622. sleepBody(impostor: PhysicsImpostor): void;
  115623. /**
  115624. * Activates the physics body
  115625. * @param impostor impostor to activate
  115626. */
  115627. wakeUpBody(impostor: PhysicsImpostor): void;
  115628. /**
  115629. * Updates the distance parameters of the joint
  115630. * @param joint joint to update
  115631. * @param maxDistance maximum distance of the joint
  115632. * @param minDistance minimum distance of the joint
  115633. */
  115634. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  115635. /**
  115636. * Sets a motor on the joint
  115637. * @param joint joint to set motor on
  115638. * @param speed speed of the motor
  115639. * @param maxForce maximum force of the motor
  115640. * @param motorIndex index of the motor
  115641. */
  115642. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  115643. /**
  115644. * Sets the motors limit
  115645. * @param joint joint to set limit on
  115646. * @param upperLimit upper limit
  115647. * @param lowerLimit lower limit
  115648. */
  115649. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  115650. /**
  115651. * Syncs the position and rotation of a mesh with the impostor
  115652. * @param mesh mesh to sync
  115653. * @param impostor impostor to update the mesh with
  115654. */
  115655. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  115656. /**
  115657. * Gets the radius of the impostor
  115658. * @param impostor impostor to get radius from
  115659. * @returns the radius
  115660. */
  115661. getRadius(impostor: PhysicsImpostor): number;
  115662. /**
  115663. * Gets the box size of the impostor
  115664. * @param impostor impostor to get box size from
  115665. * @param result the resulting box size
  115666. */
  115667. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  115668. /**
  115669. * Disposes of the impostor
  115670. */
  115671. dispose(): void;
  115672. /**
  115673. * Does a raycast in the physics world
  115674. * @param from when should the ray start?
  115675. * @param to when should the ray end?
  115676. * @returns PhysicsRaycastResult
  115677. */
  115678. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  115679. }
  115680. }
  115681. declare module BABYLON {
  115682. interface AbstractScene {
  115683. /**
  115684. * The list of reflection probes added to the scene
  115685. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  115686. */
  115687. reflectionProbes: Array<ReflectionProbe>;
  115688. /**
  115689. * Removes the given reflection probe from this scene.
  115690. * @param toRemove The reflection probe to remove
  115691. * @returns The index of the removed reflection probe
  115692. */
  115693. removeReflectionProbe(toRemove: ReflectionProbe): number;
  115694. /**
  115695. * Adds the given reflection probe to this scene.
  115696. * @param newReflectionProbe The reflection probe to add
  115697. */
  115698. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  115699. }
  115700. /**
  115701. * Class used to generate realtime reflection / refraction cube textures
  115702. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  115703. */
  115704. export class ReflectionProbe {
  115705. /** defines the name of the probe */
  115706. name: string;
  115707. private _scene;
  115708. private _renderTargetTexture;
  115709. private _projectionMatrix;
  115710. private _viewMatrix;
  115711. private _target;
  115712. private _add;
  115713. private _attachedMesh;
  115714. private _invertYAxis;
  115715. /** Gets or sets probe position (center of the cube map) */
  115716. position: Vector3;
  115717. /**
  115718. * Creates a new reflection probe
  115719. * @param name defines the name of the probe
  115720. * @param size defines the texture resolution (for each face)
  115721. * @param scene defines the hosting scene
  115722. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  115723. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  115724. */
  115725. constructor(
  115726. /** defines the name of the probe */
  115727. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  115728. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  115729. samples: number;
  115730. /** Gets or sets the refresh rate to use (on every frame by default) */
  115731. refreshRate: number;
  115732. /**
  115733. * Gets the hosting scene
  115734. * @returns a Scene
  115735. */
  115736. getScene(): Scene;
  115737. /** Gets the internal CubeTexture used to render to */
  115738. readonly cubeTexture: RenderTargetTexture;
  115739. /** Gets the list of meshes to render */
  115740. readonly renderList: Nullable<AbstractMesh[]>;
  115741. /**
  115742. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  115743. * @param mesh defines the mesh to attach to
  115744. */
  115745. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  115746. /**
  115747. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  115748. * @param renderingGroupId The rendering group id corresponding to its index
  115749. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  115750. */
  115751. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  115752. /**
  115753. * Clean all associated resources
  115754. */
  115755. dispose(): void;
  115756. /**
  115757. * Converts the reflection probe information to a readable string for debug purpose.
  115758. * @param fullDetails Supports for multiple levels of logging within scene loading
  115759. * @returns the human readable reflection probe info
  115760. */
  115761. toString(fullDetails?: boolean): string;
  115762. /**
  115763. * Get the class name of the relfection probe.
  115764. * @returns "ReflectionProbe"
  115765. */
  115766. getClassName(): string;
  115767. /**
  115768. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  115769. * @returns The JSON representation of the texture
  115770. */
  115771. serialize(): any;
  115772. /**
  115773. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  115774. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  115775. * @param scene Define the scene the parsed reflection probe should be instantiated in
  115776. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  115777. * @returns The parsed reflection probe if successful
  115778. */
  115779. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  115780. }
  115781. }
  115782. declare module BABYLON {
  115783. /** @hidden */
  115784. export var _BabylonLoaderRegistered: boolean;
  115785. }
  115786. declare module BABYLON {
  115787. /**
  115788. * The Physically based simple base material of BJS.
  115789. *
  115790. * This enables better naming and convention enforcements on top of the pbrMaterial.
  115791. * It is used as the base class for both the specGloss and metalRough conventions.
  115792. */
  115793. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  115794. /**
  115795. * Number of Simultaneous lights allowed on the material.
  115796. */
  115797. maxSimultaneousLights: number;
  115798. /**
  115799. * If sets to true, disables all the lights affecting the material.
  115800. */
  115801. disableLighting: boolean;
  115802. /**
  115803. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  115804. */
  115805. environmentTexture: BaseTexture;
  115806. /**
  115807. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  115808. */
  115809. invertNormalMapX: boolean;
  115810. /**
  115811. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  115812. */
  115813. invertNormalMapY: boolean;
  115814. /**
  115815. * Normal map used in the model.
  115816. */
  115817. normalTexture: BaseTexture;
  115818. /**
  115819. * Emissivie color used to self-illuminate the model.
  115820. */
  115821. emissiveColor: Color3;
  115822. /**
  115823. * Emissivie texture used to self-illuminate the model.
  115824. */
  115825. emissiveTexture: BaseTexture;
  115826. /**
  115827. * Occlusion Channel Strenght.
  115828. */
  115829. occlusionStrength: number;
  115830. /**
  115831. * Occlusion Texture of the material (adding extra occlusion effects).
  115832. */
  115833. occlusionTexture: BaseTexture;
  115834. /**
  115835. * Defines the alpha limits in alpha test mode.
  115836. */
  115837. alphaCutOff: number;
  115838. /**
  115839. * Gets the current double sided mode.
  115840. */
  115841. /**
  115842. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  115843. */
  115844. doubleSided: boolean;
  115845. /**
  115846. * Stores the pre-calculated light information of a mesh in a texture.
  115847. */
  115848. lightmapTexture: BaseTexture;
  115849. /**
  115850. * If true, the light map contains occlusion information instead of lighting info.
  115851. */
  115852. useLightmapAsShadowmap: boolean;
  115853. /**
  115854. * Instantiates a new PBRMaterial instance.
  115855. *
  115856. * @param name The material name
  115857. * @param scene The scene the material will be use in.
  115858. */
  115859. constructor(name: string, scene: Scene);
  115860. getClassName(): string;
  115861. }
  115862. }
  115863. declare module BABYLON {
  115864. /**
  115865. * The PBR material of BJS following the metal roughness convention.
  115866. *
  115867. * This fits to the PBR convention in the GLTF definition:
  115868. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  115869. */
  115870. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  115871. /**
  115872. * The base color has two different interpretations depending on the value of metalness.
  115873. * When the material is a metal, the base color is the specific measured reflectance value
  115874. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  115875. * of the material.
  115876. */
  115877. baseColor: Color3;
  115878. /**
  115879. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  115880. * well as opacity information in the alpha channel.
  115881. */
  115882. baseTexture: BaseTexture;
  115883. /**
  115884. * Specifies the metallic scalar value of the material.
  115885. * Can also be used to scale the metalness values of the metallic texture.
  115886. */
  115887. metallic: number;
  115888. /**
  115889. * Specifies the roughness scalar value of the material.
  115890. * Can also be used to scale the roughness values of the metallic texture.
  115891. */
  115892. roughness: number;
  115893. /**
  115894. * Texture containing both the metallic value in the B channel and the
  115895. * roughness value in the G channel to keep better precision.
  115896. */
  115897. metallicRoughnessTexture: BaseTexture;
  115898. /**
  115899. * Instantiates a new PBRMetalRoughnessMaterial instance.
  115900. *
  115901. * @param name The material name
  115902. * @param scene The scene the material will be use in.
  115903. */
  115904. constructor(name: string, scene: Scene);
  115905. /**
  115906. * Return the currrent class name of the material.
  115907. */
  115908. getClassName(): string;
  115909. /**
  115910. * Makes a duplicate of the current material.
  115911. * @param name - name to use for the new material.
  115912. */
  115913. clone(name: string): PBRMetallicRoughnessMaterial;
  115914. /**
  115915. * Serialize the material to a parsable JSON object.
  115916. */
  115917. serialize(): any;
  115918. /**
  115919. * Parses a JSON object correponding to the serialize function.
  115920. */
  115921. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  115922. }
  115923. }
  115924. declare module BABYLON {
  115925. /**
  115926. * The PBR material of BJS following the specular glossiness convention.
  115927. *
  115928. * This fits to the PBR convention in the GLTF definition:
  115929. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  115930. */
  115931. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  115932. /**
  115933. * Specifies the diffuse color of the material.
  115934. */
  115935. diffuseColor: Color3;
  115936. /**
  115937. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  115938. * channel.
  115939. */
  115940. diffuseTexture: BaseTexture;
  115941. /**
  115942. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  115943. */
  115944. specularColor: Color3;
  115945. /**
  115946. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  115947. */
  115948. glossiness: number;
  115949. /**
  115950. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  115951. */
  115952. specularGlossinessTexture: BaseTexture;
  115953. /**
  115954. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  115955. *
  115956. * @param name The material name
  115957. * @param scene The scene the material will be use in.
  115958. */
  115959. constructor(name: string, scene: Scene);
  115960. /**
  115961. * Return the currrent class name of the material.
  115962. */
  115963. getClassName(): string;
  115964. /**
  115965. * Makes a duplicate of the current material.
  115966. * @param name - name to use for the new material.
  115967. */
  115968. clone(name: string): PBRSpecularGlossinessMaterial;
  115969. /**
  115970. * Serialize the material to a parsable JSON object.
  115971. */
  115972. serialize(): any;
  115973. /**
  115974. * Parses a JSON object correponding to the serialize function.
  115975. */
  115976. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  115977. }
  115978. }
  115979. declare module BABYLON {
  115980. /**
  115981. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  115982. * It can help converting any input color in a desired output one. This can then be used to create effects
  115983. * from sepia, black and white to sixties or futuristic rendering...
  115984. *
  115985. * The only supported format is currently 3dl.
  115986. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  115987. */
  115988. export class ColorGradingTexture extends BaseTexture {
  115989. /**
  115990. * The current texture matrix. (will always be identity in color grading texture)
  115991. */
  115992. private _textureMatrix;
  115993. /**
  115994. * The texture URL.
  115995. */
  115996. url: string;
  115997. /**
  115998. * Empty line regex stored for GC.
  115999. */
  116000. private static _noneEmptyLineRegex;
  116001. private _engine;
  116002. /**
  116003. * Instantiates a ColorGradingTexture from the following parameters.
  116004. *
  116005. * @param url The location of the color gradind data (currently only supporting 3dl)
  116006. * @param scene The scene the texture will be used in
  116007. */
  116008. constructor(url: string, scene: Scene);
  116009. /**
  116010. * Returns the texture matrix used in most of the material.
  116011. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  116012. */
  116013. getTextureMatrix(): Matrix;
  116014. /**
  116015. * Occurs when the file being loaded is a .3dl LUT file.
  116016. */
  116017. private load3dlTexture;
  116018. /**
  116019. * Starts the loading process of the texture.
  116020. */
  116021. private loadTexture;
  116022. /**
  116023. * Clones the color gradind texture.
  116024. */
  116025. clone(): ColorGradingTexture;
  116026. /**
  116027. * Called during delayed load for textures.
  116028. */
  116029. delayLoad(): void;
  116030. /**
  116031. * Parses a color grading texture serialized by Babylon.
  116032. * @param parsedTexture The texture information being parsedTexture
  116033. * @param scene The scene to load the texture in
  116034. * @param rootUrl The root url of the data assets to load
  116035. * @return A color gradind texture
  116036. */
  116037. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  116038. /**
  116039. * Serializes the LUT texture to json format.
  116040. */
  116041. serialize(): any;
  116042. }
  116043. }
  116044. declare module BABYLON {
  116045. /**
  116046. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  116047. */
  116048. export class EquiRectangularCubeTexture extends BaseTexture {
  116049. /** The six faces of the cube. */
  116050. private static _FacesMapping;
  116051. private _noMipmap;
  116052. private _onLoad;
  116053. private _onError;
  116054. /** The size of the cubemap. */
  116055. private _size;
  116056. /** The buffer of the image. */
  116057. private _buffer;
  116058. /** The width of the input image. */
  116059. private _width;
  116060. /** The height of the input image. */
  116061. private _height;
  116062. /** The URL to the image. */
  116063. url: string;
  116064. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  116065. coordinatesMode: number;
  116066. /**
  116067. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  116068. * @param url The location of the image
  116069. * @param scene The scene the texture will be used in
  116070. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  116071. * @param noMipmap Forces to not generate the mipmap if true
  116072. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  116073. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  116074. * @param onLoad — defines a callback called when texture is loaded
  116075. * @param onError — defines a callback called if there is an error
  116076. */
  116077. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  116078. /**
  116079. * Load the image data, by putting the image on a canvas and extracting its buffer.
  116080. */
  116081. private loadImage;
  116082. /**
  116083. * Convert the image buffer into a cubemap and create a CubeTexture.
  116084. */
  116085. private loadTexture;
  116086. /**
  116087. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  116088. * @param buffer The ArrayBuffer that should be converted.
  116089. * @returns The buffer as Float32Array.
  116090. */
  116091. private getFloat32ArrayFromArrayBuffer;
  116092. /**
  116093. * Get the current class name of the texture useful for serialization or dynamic coding.
  116094. * @returns "EquiRectangularCubeTexture"
  116095. */
  116096. getClassName(): string;
  116097. /**
  116098. * Create a clone of the current EquiRectangularCubeTexture and return it.
  116099. * @returns A clone of the current EquiRectangularCubeTexture.
  116100. */
  116101. clone(): EquiRectangularCubeTexture;
  116102. }
  116103. }
  116104. declare module BABYLON {
  116105. /**
  116106. * Based on jsTGALoader - Javascript loader for TGA file
  116107. * By Vincent Thibault
  116108. * @see http://blog.robrowser.com/javascript-tga-loader.html
  116109. */
  116110. export class TGATools {
  116111. private static _TYPE_INDEXED;
  116112. private static _TYPE_RGB;
  116113. private static _TYPE_GREY;
  116114. private static _TYPE_RLE_INDEXED;
  116115. private static _TYPE_RLE_RGB;
  116116. private static _TYPE_RLE_GREY;
  116117. private static _ORIGIN_MASK;
  116118. private static _ORIGIN_SHIFT;
  116119. private static _ORIGIN_BL;
  116120. private static _ORIGIN_BR;
  116121. private static _ORIGIN_UL;
  116122. private static _ORIGIN_UR;
  116123. /**
  116124. * Gets the header of a TGA file
  116125. * @param data defines the TGA data
  116126. * @returns the header
  116127. */
  116128. static GetTGAHeader(data: Uint8Array): any;
  116129. /**
  116130. * Uploads TGA content to a Babylon Texture
  116131. * @hidden
  116132. */
  116133. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  116134. /** @hidden */
  116135. 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;
  116136. /** @hidden */
  116137. 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;
  116138. /** @hidden */
  116139. 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;
  116140. /** @hidden */
  116141. 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;
  116142. /** @hidden */
  116143. 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;
  116144. /** @hidden */
  116145. 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;
  116146. }
  116147. }
  116148. declare module BABYLON {
  116149. /**
  116150. * Implementation of the TGA Texture Loader.
  116151. * @hidden
  116152. */
  116153. export class _TGATextureLoader implements IInternalTextureLoader {
  116154. /**
  116155. * Defines wether the loader supports cascade loading the different faces.
  116156. */
  116157. readonly supportCascades: boolean;
  116158. /**
  116159. * This returns if the loader support the current file information.
  116160. * @param extension defines the file extension of the file being loaded
  116161. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116162. * @param fallback defines the fallback internal texture if any
  116163. * @param isBase64 defines whether the texture is encoded as a base64
  116164. * @param isBuffer defines whether the texture data are stored as a buffer
  116165. * @returns true if the loader can load the specified file
  116166. */
  116167. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  116168. /**
  116169. * Transform the url before loading if required.
  116170. * @param rootUrl the url of the texture
  116171. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116172. * @returns the transformed texture
  116173. */
  116174. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  116175. /**
  116176. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  116177. * @param rootUrl the url of the texture
  116178. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116179. * @returns the fallback texture
  116180. */
  116181. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  116182. /**
  116183. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  116184. * @param data contains the texture data
  116185. * @param texture defines the BabylonJS internal texture
  116186. * @param createPolynomials will be true if polynomials have been requested
  116187. * @param onLoad defines the callback to trigger once the texture is ready
  116188. * @param onError defines the callback to trigger in case of error
  116189. */
  116190. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  116191. /**
  116192. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  116193. * @param data contains the texture data
  116194. * @param texture defines the BabylonJS internal texture
  116195. * @param callback defines the method to call once ready to upload
  116196. */
  116197. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  116198. }
  116199. }
  116200. declare module BABYLON {
  116201. /**
  116202. * Info about the .basis files
  116203. */
  116204. class BasisFileInfo {
  116205. /**
  116206. * If the file has alpha
  116207. */
  116208. hasAlpha: boolean;
  116209. /**
  116210. * Info about each image of the basis file
  116211. */
  116212. images: Array<{
  116213. levels: Array<{
  116214. width: number;
  116215. height: number;
  116216. transcodedPixels: ArrayBufferView;
  116217. }>;
  116218. }>;
  116219. }
  116220. /**
  116221. * Result of transcoding a basis file
  116222. */
  116223. class TranscodeResult {
  116224. /**
  116225. * Info about the .basis file
  116226. */
  116227. fileInfo: BasisFileInfo;
  116228. /**
  116229. * Format to use when loading the file
  116230. */
  116231. format: number;
  116232. }
  116233. /**
  116234. * Configuration options for the Basis transcoder
  116235. */
  116236. export class BasisTranscodeConfiguration {
  116237. /**
  116238. * Supported compression formats used to determine the supported output format of the transcoder
  116239. */
  116240. supportedCompressionFormats?: {
  116241. /**
  116242. * etc1 compression format
  116243. */
  116244. etc1?: boolean;
  116245. /**
  116246. * s3tc compression format
  116247. */
  116248. s3tc?: boolean;
  116249. /**
  116250. * pvrtc compression format
  116251. */
  116252. pvrtc?: boolean;
  116253. /**
  116254. * etc2 compression format
  116255. */
  116256. etc2?: boolean;
  116257. };
  116258. /**
  116259. * If mipmap levels should be loaded for transcoded images (Default: true)
  116260. */
  116261. loadMipmapLevels?: boolean;
  116262. /**
  116263. * Index of a single image to load (Default: all images)
  116264. */
  116265. loadSingleImage?: number;
  116266. }
  116267. /**
  116268. * Used to load .Basis files
  116269. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  116270. */
  116271. export class BasisTools {
  116272. private static _IgnoreSupportedFormats;
  116273. /**
  116274. * URL to use when loading the basis transcoder
  116275. */
  116276. static JSModuleURL: string;
  116277. /**
  116278. * URL to use when loading the wasm module for the transcoder
  116279. */
  116280. static WasmModuleURL: string;
  116281. /**
  116282. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  116283. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  116284. * @returns internal format corresponding to the Basis format
  116285. */
  116286. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  116287. private static _WorkerPromise;
  116288. private static _Worker;
  116289. private static _actionId;
  116290. private static _CreateWorkerAsync;
  116291. /**
  116292. * Transcodes a loaded image file to compressed pixel data
  116293. * @param imageData image data to transcode
  116294. * @param config configuration options for the transcoding
  116295. * @returns a promise resulting in the transcoded image
  116296. */
  116297. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  116298. /**
  116299. * Loads a texture from the transcode result
  116300. * @param texture texture load to
  116301. * @param transcodeResult the result of transcoding the basis file to load from
  116302. */
  116303. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  116304. }
  116305. }
  116306. declare module BABYLON {
  116307. /**
  116308. * Loader for .basis file format
  116309. */
  116310. export class _BasisTextureLoader implements IInternalTextureLoader {
  116311. /**
  116312. * Defines whether the loader supports cascade loading the different faces.
  116313. */
  116314. readonly supportCascades: boolean;
  116315. /**
  116316. * This returns if the loader support the current file information.
  116317. * @param extension defines the file extension of the file being loaded
  116318. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116319. * @param fallback defines the fallback internal texture if any
  116320. * @param isBase64 defines whether the texture is encoded as a base64
  116321. * @param isBuffer defines whether the texture data are stored as a buffer
  116322. * @returns true if the loader can load the specified file
  116323. */
  116324. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  116325. /**
  116326. * Transform the url before loading if required.
  116327. * @param rootUrl the url of the texture
  116328. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116329. * @returns the transformed texture
  116330. */
  116331. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  116332. /**
  116333. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  116334. * @param rootUrl the url of the texture
  116335. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116336. * @returns the fallback texture
  116337. */
  116338. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  116339. /**
  116340. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  116341. * @param data contains the texture data
  116342. * @param texture defines the BabylonJS internal texture
  116343. * @param createPolynomials will be true if polynomials have been requested
  116344. * @param onLoad defines the callback to trigger once the texture is ready
  116345. * @param onError defines the callback to trigger in case of error
  116346. */
  116347. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  116348. /**
  116349. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  116350. * @param data contains the texture data
  116351. * @param texture defines the BabylonJS internal texture
  116352. * @param callback defines the method to call once ready to upload
  116353. */
  116354. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  116355. }
  116356. }
  116357. declare module BABYLON {
  116358. /**
  116359. * 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.
  116360. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  116361. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  116362. */
  116363. export class CustomProceduralTexture extends ProceduralTexture {
  116364. private _animate;
  116365. private _time;
  116366. private _config;
  116367. private _texturePath;
  116368. /**
  116369. * Instantiates a new Custom Procedural Texture.
  116370. * 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.
  116371. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  116372. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  116373. * @param name Define the name of the texture
  116374. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  116375. * @param size Define the size of the texture to create
  116376. * @param scene Define the scene the texture belongs to
  116377. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  116378. * @param generateMipMaps Define if the texture should creates mip maps or not
  116379. */
  116380. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  116381. private _loadJson;
  116382. /**
  116383. * Is the texture ready to be used ? (rendered at least once)
  116384. * @returns true if ready, otherwise, false.
  116385. */
  116386. isReady(): boolean;
  116387. /**
  116388. * Render the texture to its associated render target.
  116389. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  116390. */
  116391. render(useCameraPostProcess?: boolean): void;
  116392. /**
  116393. * Update the list of dependant textures samplers in the shader.
  116394. */
  116395. updateTextures(): void;
  116396. /**
  116397. * Update the uniform values of the procedural texture in the shader.
  116398. */
  116399. updateShaderUniforms(): void;
  116400. /**
  116401. * Define if the texture animates or not.
  116402. */
  116403. animate: boolean;
  116404. }
  116405. }
  116406. declare module BABYLON {
  116407. /** @hidden */
  116408. export var noisePixelShader: {
  116409. name: string;
  116410. shader: string;
  116411. };
  116412. }
  116413. declare module BABYLON {
  116414. /**
  116415. * Class used to generate noise procedural textures
  116416. */
  116417. export class NoiseProceduralTexture extends ProceduralTexture {
  116418. private _time;
  116419. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  116420. brightness: number;
  116421. /** Defines the number of octaves to process */
  116422. octaves: number;
  116423. /** Defines the level of persistence (0.8 by default) */
  116424. persistence: number;
  116425. /** Gets or sets animation speed factor (default is 1) */
  116426. animationSpeedFactor: number;
  116427. /**
  116428. * Creates a new NoiseProceduralTexture
  116429. * @param name defines the name fo the texture
  116430. * @param size defines the size of the texture (default is 256)
  116431. * @param scene defines the hosting scene
  116432. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  116433. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  116434. */
  116435. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  116436. private _updateShaderUniforms;
  116437. protected _getDefines(): string;
  116438. /** Generate the current state of the procedural texture */
  116439. render(useCameraPostProcess?: boolean): void;
  116440. /**
  116441. * Serializes this noise procedural texture
  116442. * @returns a serialized noise procedural texture object
  116443. */
  116444. serialize(): any;
  116445. /**
  116446. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  116447. * @param parsedTexture defines parsed texture data
  116448. * @param scene defines the current scene
  116449. * @param rootUrl defines the root URL containing noise procedural texture information
  116450. * @returns a parsed NoiseProceduralTexture
  116451. */
  116452. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  116453. }
  116454. }
  116455. declare module BABYLON {
  116456. /**
  116457. * Raw cube texture where the raw buffers are passed in
  116458. */
  116459. export class RawCubeTexture extends CubeTexture {
  116460. /**
  116461. * Creates a cube texture where the raw buffers are passed in.
  116462. * @param scene defines the scene the texture is attached to
  116463. * @param data defines the array of data to use to create each face
  116464. * @param size defines the size of the textures
  116465. * @param format defines the format of the data
  116466. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  116467. * @param generateMipMaps defines if the engine should generate the mip levels
  116468. * @param invertY defines if data must be stored with Y axis inverted
  116469. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  116470. * @param compression defines the compression used (null by default)
  116471. */
  116472. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  116473. /**
  116474. * Updates the raw cube texture.
  116475. * @param data defines the data to store
  116476. * @param format defines the data format
  116477. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  116478. * @param invertY defines if data must be stored with Y axis inverted
  116479. * @param compression defines the compression used (null by default)
  116480. * @param level defines which level of the texture to update
  116481. */
  116482. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  116483. /**
  116484. * Updates a raw cube texture with RGBD encoded data.
  116485. * @param data defines the array of data [mipmap][face] to use to create each face
  116486. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  116487. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  116488. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  116489. * @returns a promsie that resolves when the operation is complete
  116490. */
  116491. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  116492. /**
  116493. * Clones the raw cube texture.
  116494. * @return a new cube texture
  116495. */
  116496. clone(): CubeTexture;
  116497. /** @hidden */
  116498. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  116499. }
  116500. }
  116501. declare module BABYLON {
  116502. /**
  116503. * Class used to store 3D textures containing user data
  116504. */
  116505. export class RawTexture3D extends Texture {
  116506. /** Gets or sets the texture format to use */
  116507. format: number;
  116508. private _engine;
  116509. /**
  116510. * Create a new RawTexture3D
  116511. * @param data defines the data of the texture
  116512. * @param width defines the width of the texture
  116513. * @param height defines the height of the texture
  116514. * @param depth defines the depth of the texture
  116515. * @param format defines the texture format to use
  116516. * @param scene defines the hosting scene
  116517. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  116518. * @param invertY defines if texture must be stored with Y axis inverted
  116519. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  116520. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  116521. */
  116522. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  116523. /** Gets or sets the texture format to use */
  116524. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  116525. /**
  116526. * Update the texture with new data
  116527. * @param data defines the data to store in the texture
  116528. */
  116529. update(data: ArrayBufferView): void;
  116530. }
  116531. }
  116532. declare module BABYLON {
  116533. /**
  116534. * Creates a refraction texture used by refraction channel of the standard material.
  116535. * It is like a mirror but to see through a material.
  116536. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  116537. */
  116538. export class RefractionTexture extends RenderTargetTexture {
  116539. /**
  116540. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  116541. * 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.
  116542. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  116543. */
  116544. refractionPlane: Plane;
  116545. /**
  116546. * Define how deep under the surface we should see.
  116547. */
  116548. depth: number;
  116549. /**
  116550. * Creates a refraction texture used by refraction channel of the standard material.
  116551. * It is like a mirror but to see through a material.
  116552. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  116553. * @param name Define the texture name
  116554. * @param size Define the size of the underlying texture
  116555. * @param scene Define the scene the refraction belongs to
  116556. * @param generateMipMaps Define if we need to generate mips level for the refraction
  116557. */
  116558. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  116559. /**
  116560. * Clone the refraction texture.
  116561. * @returns the cloned texture
  116562. */
  116563. clone(): RefractionTexture;
  116564. /**
  116565. * Serialize the texture to a JSON representation you could use in Parse later on
  116566. * @returns the serialized JSON representation
  116567. */
  116568. serialize(): any;
  116569. }
  116570. }
  116571. declare module BABYLON {
  116572. /**
  116573. * Defines the options related to the creation of an HtmlElementTexture
  116574. */
  116575. export interface IHtmlElementTextureOptions {
  116576. /**
  116577. * Defines wether mip maps should be created or not.
  116578. */
  116579. generateMipMaps?: boolean;
  116580. /**
  116581. * Defines the sampling mode of the texture.
  116582. */
  116583. samplingMode?: number;
  116584. /**
  116585. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  116586. */
  116587. engine: Nullable<Engine>;
  116588. /**
  116589. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  116590. */
  116591. scene: Nullable<Scene>;
  116592. }
  116593. /**
  116594. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  116595. * To be as efficient as possible depending on your constraints nothing aside the first upload
  116596. * is automatically managed.
  116597. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  116598. * in your application.
  116599. *
  116600. * As the update is not automatic, you need to call them manually.
  116601. */
  116602. export class HtmlElementTexture extends BaseTexture {
  116603. /**
  116604. * The texture URL.
  116605. */
  116606. element: HTMLVideoElement | HTMLCanvasElement;
  116607. private static readonly DefaultOptions;
  116608. private _textureMatrix;
  116609. private _engine;
  116610. private _isVideo;
  116611. private _generateMipMaps;
  116612. private _samplingMode;
  116613. /**
  116614. * Instantiates a HtmlElementTexture from the following parameters.
  116615. *
  116616. * @param name Defines the name of the texture
  116617. * @param element Defines the video or canvas the texture is filled with
  116618. * @param options Defines the other none mandatory texture creation options
  116619. */
  116620. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  116621. private _createInternalTexture;
  116622. /**
  116623. * Returns the texture matrix used in most of the material.
  116624. */
  116625. getTextureMatrix(): Matrix;
  116626. /**
  116627. * Updates the content of the texture.
  116628. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  116629. */
  116630. update(invertY?: Nullable<boolean>): void;
  116631. }
  116632. }
  116633. declare module BABYLON {
  116634. /**
  116635. * Enum used to define the target of a block
  116636. */
  116637. export enum NodeMaterialBlockTargets {
  116638. /** Vertex shader */
  116639. Vertex = 1,
  116640. /** Fragment shader */
  116641. Fragment = 2,
  116642. /** Neutral */
  116643. Neutral = 4,
  116644. /** Vertex and Fragment */
  116645. VertexAndFragment = 3
  116646. }
  116647. }
  116648. declare module BABYLON {
  116649. /**
  116650. * Defines the kind of connection point for node based material
  116651. */
  116652. export enum NodeMaterialBlockConnectionPointTypes {
  116653. /** Float */
  116654. Float = 1,
  116655. /** Int */
  116656. Int = 2,
  116657. /** Vector2 */
  116658. Vector2 = 4,
  116659. /** Vector3 */
  116660. Vector3 = 8,
  116661. /** Vector4 */
  116662. Vector4 = 16,
  116663. /** Color3 */
  116664. Color3 = 32,
  116665. /** Color4 */
  116666. Color4 = 64,
  116667. /** Matrix */
  116668. Matrix = 128,
  116669. /** Detect type based on connection */
  116670. AutoDetect = 1024,
  116671. /** Output type that will be defined by input type */
  116672. BasedOnInput = 2048
  116673. }
  116674. }
  116675. declare module BABYLON {
  116676. /**
  116677. * Root class for all node material optimizers
  116678. */
  116679. export class NodeMaterialOptimizer {
  116680. /**
  116681. * Function used to optimize a NodeMaterial graph
  116682. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  116683. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  116684. */
  116685. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  116686. }
  116687. }
  116688. declare module BABYLON {
  116689. /**
  116690. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  116691. */
  116692. export class TransformBlock extends NodeMaterialBlock {
  116693. /**
  116694. * Defines the value to use to complement W value to transform it to a Vector4
  116695. */
  116696. complementW: number;
  116697. /**
  116698. * Defines the value to use to complement z value to transform it to a Vector4
  116699. */
  116700. complementZ: number;
  116701. /**
  116702. * Creates a new TransformBlock
  116703. * @param name defines the block name
  116704. */
  116705. constructor(name: string);
  116706. /**
  116707. * Gets the current class name
  116708. * @returns the class name
  116709. */
  116710. getClassName(): string;
  116711. /**
  116712. * Gets the vector input
  116713. */
  116714. readonly vector: NodeMaterialConnectionPoint;
  116715. /**
  116716. * Gets the output component
  116717. */
  116718. readonly output: NodeMaterialConnectionPoint;
  116719. /**
  116720. * Gets the matrix transform input
  116721. */
  116722. readonly transform: NodeMaterialConnectionPoint;
  116723. protected _buildBlock(state: NodeMaterialBuildState): this;
  116724. serialize(): any;
  116725. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  116726. protected _dumpPropertiesCode(): string;
  116727. }
  116728. }
  116729. declare module BABYLON {
  116730. /**
  116731. * Block used to output the vertex position
  116732. */
  116733. export class VertexOutputBlock extends NodeMaterialBlock {
  116734. /**
  116735. * Creates a new VertexOutputBlock
  116736. * @param name defines the block name
  116737. */
  116738. constructor(name: string);
  116739. /**
  116740. * Gets the current class name
  116741. * @returns the class name
  116742. */
  116743. getClassName(): string;
  116744. /**
  116745. * Gets the vector input component
  116746. */
  116747. readonly vector: NodeMaterialConnectionPoint;
  116748. protected _buildBlock(state: NodeMaterialBuildState): this;
  116749. }
  116750. }
  116751. declare module BABYLON {
  116752. /**
  116753. * Block used to output the final color
  116754. */
  116755. export class FragmentOutputBlock extends NodeMaterialBlock {
  116756. /**
  116757. * Create a new FragmentOutputBlock
  116758. * @param name defines the block name
  116759. */
  116760. constructor(name: string);
  116761. /**
  116762. * Gets the current class name
  116763. * @returns the class name
  116764. */
  116765. getClassName(): string;
  116766. /**
  116767. * Gets the rgba input component
  116768. */
  116769. readonly rgba: NodeMaterialConnectionPoint;
  116770. /**
  116771. * Gets the rgb input component
  116772. */
  116773. readonly rgb: NodeMaterialConnectionPoint;
  116774. /**
  116775. * Gets the a input component
  116776. */
  116777. readonly a: NodeMaterialConnectionPoint;
  116778. protected _buildBlock(state: NodeMaterialBuildState): this;
  116779. }
  116780. }
  116781. declare module BABYLON {
  116782. /**
  116783. * Enum used to define well known values e.g. values automatically provided by the system
  116784. */
  116785. export enum NodeMaterialWellKnownValues {
  116786. /** World */
  116787. World = 1,
  116788. /** View */
  116789. View = 2,
  116790. /** Projection */
  116791. Projection = 3,
  116792. /** ViewProjection */
  116793. ViewProjection = 4,
  116794. /** WorldView */
  116795. WorldView = 5,
  116796. /** WorldViewProjection */
  116797. WorldViewProjection = 6,
  116798. /** CameraPosition */
  116799. CameraPosition = 7,
  116800. /** Fog Color */
  116801. FogColor = 8
  116802. }
  116803. }
  116804. declare module BABYLON {
  116805. /**
  116806. * Block used to read a reflection texture from a sampler
  116807. */
  116808. export class ReflectionTextureBlock extends NodeMaterialBlock {
  116809. private _define3DName;
  116810. private _defineCubicName;
  116811. private _defineExplicitName;
  116812. private _defineProjectionName;
  116813. private _defineLocalCubicName;
  116814. private _defineSphericalName;
  116815. private _definePlanarName;
  116816. private _defineEquirectangularName;
  116817. private _defineMirroredEquirectangularFixedName;
  116818. private _defineEquirectangularFixedName;
  116819. private _defineSkyboxName;
  116820. private _cubeSamplerName;
  116821. private _2DSamplerName;
  116822. private _positionUVWName;
  116823. private _directionWName;
  116824. private _reflectionCoordsName;
  116825. private _reflection2DCoordsName;
  116826. private _reflectionColorName;
  116827. private _reflectionMatrixName;
  116828. /**
  116829. * Gets or sets the texture associated with the node
  116830. */
  116831. texture: Nullable<BaseTexture>;
  116832. /**
  116833. * Create a new TextureBlock
  116834. * @param name defines the block name
  116835. */
  116836. constructor(name: string);
  116837. /**
  116838. * Gets the current class name
  116839. * @returns the class name
  116840. */
  116841. getClassName(): string;
  116842. /**
  116843. * Gets the world position input component
  116844. */
  116845. readonly position: NodeMaterialConnectionPoint;
  116846. /**
  116847. * Gets the world position input component
  116848. */
  116849. readonly worldPosition: NodeMaterialConnectionPoint;
  116850. /**
  116851. * Gets the world normal input component
  116852. */
  116853. readonly worldNormal: NodeMaterialConnectionPoint;
  116854. /**
  116855. * Gets the world input component
  116856. */
  116857. readonly world: NodeMaterialConnectionPoint;
  116858. /**
  116859. * Gets the camera (or eye) position component
  116860. */
  116861. readonly cameraPosition: NodeMaterialConnectionPoint;
  116862. /**
  116863. * Gets the view input component
  116864. */
  116865. readonly view: NodeMaterialConnectionPoint;
  116866. /**
  116867. * Gets the rgb output component
  116868. */
  116869. readonly rgb: NodeMaterialConnectionPoint;
  116870. /**
  116871. * Gets the r output component
  116872. */
  116873. readonly r: NodeMaterialConnectionPoint;
  116874. /**
  116875. * Gets the g output component
  116876. */
  116877. readonly g: NodeMaterialConnectionPoint;
  116878. /**
  116879. * Gets the b output component
  116880. */
  116881. readonly b: NodeMaterialConnectionPoint;
  116882. autoConfigure(material: NodeMaterial): void;
  116883. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  116884. isReady(): boolean;
  116885. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  116886. private _injectVertexCode;
  116887. private _writeOutput;
  116888. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  116889. serialize(): any;
  116890. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  116891. }
  116892. }
  116893. declare module BABYLON {
  116894. /**
  116895. * Interface used to configure the node material editor
  116896. */
  116897. export interface INodeMaterialEditorOptions {
  116898. /** Define the URl to load node editor script */
  116899. editorURL?: string;
  116900. }
  116901. /** @hidden */
  116902. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  116903. /** BONES */
  116904. NUM_BONE_INFLUENCERS: number;
  116905. BonesPerMesh: number;
  116906. BONETEXTURE: boolean;
  116907. /** MORPH TARGETS */
  116908. MORPHTARGETS: boolean;
  116909. MORPHTARGETS_NORMAL: boolean;
  116910. MORPHTARGETS_TANGENT: boolean;
  116911. MORPHTARGETS_UV: boolean;
  116912. NUM_MORPH_INFLUENCERS: number;
  116913. /** IMAGE PROCESSING */
  116914. IMAGEPROCESSING: boolean;
  116915. VIGNETTE: boolean;
  116916. VIGNETTEBLENDMODEMULTIPLY: boolean;
  116917. VIGNETTEBLENDMODEOPAQUE: boolean;
  116918. TONEMAPPING: boolean;
  116919. TONEMAPPING_ACES: boolean;
  116920. CONTRAST: boolean;
  116921. EXPOSURE: boolean;
  116922. COLORCURVES: boolean;
  116923. COLORGRADING: boolean;
  116924. COLORGRADING3D: boolean;
  116925. SAMPLER3DGREENDEPTH: boolean;
  116926. SAMPLER3DBGRMAP: boolean;
  116927. IMAGEPROCESSINGPOSTPROCESS: boolean;
  116928. constructor();
  116929. setValue(name: string, value: boolean): void;
  116930. }
  116931. /**
  116932. * Class used to configure NodeMaterial
  116933. */
  116934. export interface INodeMaterialOptions {
  116935. /**
  116936. * Defines if blocks should emit comments
  116937. */
  116938. emitComments: boolean;
  116939. }
  116940. /**
  116941. * Class used to create a node based material built by assembling shader blocks
  116942. */
  116943. export class NodeMaterial extends PushMaterial {
  116944. private static _BuildIdGenerator;
  116945. private _options;
  116946. private _vertexCompilationState;
  116947. private _fragmentCompilationState;
  116948. private _sharedData;
  116949. private _buildId;
  116950. private _buildWasSuccessful;
  116951. private _cachedWorldViewMatrix;
  116952. private _cachedWorldViewProjectionMatrix;
  116953. private _optimizers;
  116954. private _animationFrame;
  116955. /** Define the URl to load node editor script */
  116956. static EditorURL: string;
  116957. private BJSNODEMATERIALEDITOR;
  116958. /** Get the inspector from bundle or global */
  116959. private _getGlobalNodeMaterialEditor;
  116960. /**
  116961. * 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)
  116962. */
  116963. ignoreAlpha: boolean;
  116964. /**
  116965. * Defines the maximum number of lights that can be used in the material
  116966. */
  116967. maxSimultaneousLights: number;
  116968. /**
  116969. * Observable raised when the material is built
  116970. */
  116971. onBuildObservable: Observable<NodeMaterial>;
  116972. /**
  116973. * Gets or sets the root nodes of the material vertex shader
  116974. */
  116975. _vertexOutputNodes: NodeMaterialBlock[];
  116976. /**
  116977. * Gets or sets the root nodes of the material fragment (pixel) shader
  116978. */
  116979. _fragmentOutputNodes: NodeMaterialBlock[];
  116980. /** Gets or sets options to control the node material overall behavior */
  116981. options: INodeMaterialOptions;
  116982. /**
  116983. * Default configuration related to image processing available in the standard Material.
  116984. */
  116985. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  116986. /**
  116987. * Gets the image processing configuration used either in this material.
  116988. */
  116989. /**
  116990. * Sets the Default image processing configuration used either in the this material.
  116991. *
  116992. * If sets to null, the scene one is in use.
  116993. */
  116994. imageProcessingConfiguration: ImageProcessingConfiguration;
  116995. /**
  116996. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  116997. */
  116998. attachedBlocks: NodeMaterialBlock[];
  116999. /**
  117000. * Create a new node based material
  117001. * @param name defines the material name
  117002. * @param scene defines the hosting scene
  117003. * @param options defines creation option
  117004. */
  117005. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  117006. /**
  117007. * Gets the current class name of the material e.g. "NodeMaterial"
  117008. * @returns the class name
  117009. */
  117010. getClassName(): string;
  117011. /**
  117012. * Keep track of the image processing observer to allow dispose and replace.
  117013. */
  117014. private _imageProcessingObserver;
  117015. /**
  117016. * Attaches a new image processing configuration to the Standard Material.
  117017. * @param configuration
  117018. */
  117019. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  117020. /**
  117021. * Get a block by its name
  117022. * @param name defines the name of the block to retrieve
  117023. * @returns the required block or null if not found
  117024. */
  117025. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  117026. /**
  117027. * Get a block by its name
  117028. * @param predicate defines the predicate used to find the good candidate
  117029. * @returns the required block or null if not found
  117030. */
  117031. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  117032. /**
  117033. * Get an input block by its name
  117034. * @param predicate defines the predicate used to find the good candidate
  117035. * @returns the required input block or null if not found
  117036. */
  117037. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  117038. /**
  117039. * Gets the list of input blocks attached to this material
  117040. * @returns an array of InputBlocks
  117041. */
  117042. getInputBlocks(): InputBlock[];
  117043. /**
  117044. * Adds a new optimizer to the list of optimizers
  117045. * @param optimizer defines the optimizers to add
  117046. * @returns the current material
  117047. */
  117048. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  117049. /**
  117050. * Remove an optimizer from the list of optimizers
  117051. * @param optimizer defines the optimizers to remove
  117052. * @returns the current material
  117053. */
  117054. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  117055. /**
  117056. * Add a new block to the list of output nodes
  117057. * @param node defines the node to add
  117058. * @returns the current material
  117059. */
  117060. addOutputNode(node: NodeMaterialBlock): this;
  117061. /**
  117062. * Remove a block from the list of root nodes
  117063. * @param node defines the node to remove
  117064. * @returns the current material
  117065. */
  117066. removeOutputNode(node: NodeMaterialBlock): this;
  117067. private _addVertexOutputNode;
  117068. private _removeVertexOutputNode;
  117069. private _addFragmentOutputNode;
  117070. private _removeFragmentOutputNode;
  117071. /**
  117072. * Specifies if the material will require alpha blending
  117073. * @returns a boolean specifying if alpha blending is needed
  117074. */
  117075. needAlphaBlending(): boolean;
  117076. /**
  117077. * Specifies if this material should be rendered in alpha test mode
  117078. * @returns a boolean specifying if an alpha test is needed.
  117079. */
  117080. needAlphaTesting(): boolean;
  117081. private _initializeBlock;
  117082. private _resetDualBlocks;
  117083. /**
  117084. * Build the material and generates the inner effect
  117085. * @param verbose defines if the build should log activity
  117086. */
  117087. build(verbose?: boolean): void;
  117088. /**
  117089. * Runs an otpimization phase to try to improve the shader code
  117090. */
  117091. optimize(): void;
  117092. private _prepareDefinesForAttributes;
  117093. /**
  117094. * Get if the submesh is ready to be used and all its information available.
  117095. * Child classes can use it to update shaders
  117096. * @param mesh defines the mesh to check
  117097. * @param subMesh defines which submesh to check
  117098. * @param useInstances specifies that instances should be used
  117099. * @returns a boolean indicating that the submesh is ready or not
  117100. */
  117101. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  117102. /**
  117103. * Get a string representing the shaders built by the current node graph
  117104. */
  117105. readonly compiledShaders: string;
  117106. /**
  117107. * Binds the world matrix to the material
  117108. * @param world defines the world transformation matrix
  117109. */
  117110. bindOnlyWorldMatrix(world: Matrix): void;
  117111. /**
  117112. * Binds the submesh to this material by preparing the effect and shader to draw
  117113. * @param world defines the world transformation matrix
  117114. * @param mesh defines the mesh containing the submesh
  117115. * @param subMesh defines the submesh to bind the material to
  117116. */
  117117. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  117118. /**
  117119. * Gets the active textures from the material
  117120. * @returns an array of textures
  117121. */
  117122. getActiveTextures(): BaseTexture[];
  117123. /**
  117124. * Gets the list of texture blocks
  117125. * @returns an array of texture blocks
  117126. */
  117127. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  117128. /**
  117129. * Specifies if the material uses a texture
  117130. * @param texture defines the texture to check against the material
  117131. * @returns a boolean specifying if the material uses the texture
  117132. */
  117133. hasTexture(texture: BaseTexture): boolean;
  117134. /**
  117135. * Disposes the material
  117136. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  117137. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  117138. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  117139. */
  117140. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  117141. /** Creates the node editor window. */
  117142. private _createNodeEditor;
  117143. /**
  117144. * Launch the node material editor
  117145. * @param config Define the configuration of the editor
  117146. * @return a promise fulfilled when the node editor is visible
  117147. */
  117148. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  117149. /**
  117150. * Clear the current material
  117151. */
  117152. clear(): void;
  117153. /**
  117154. * Clear the current material and set it to a default state
  117155. */
  117156. setToDefault(): void;
  117157. /**
  117158. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  117159. * @param url defines the url to load from
  117160. * @returns a promise that will fullfil when the material is fully loaded
  117161. */
  117162. loadAsync(url: string): Promise<unknown>;
  117163. private _gatherBlocks;
  117164. /**
  117165. * Generate a string containing the code declaration required to create an equivalent of this material
  117166. * @returns a string
  117167. */
  117168. generateCode(): string;
  117169. /**
  117170. * Serializes this material in a JSON representation
  117171. * @returns the serialized material object
  117172. */
  117173. serialize(): any;
  117174. private _restoreConnections;
  117175. /**
  117176. * Clear the current graph and load a new one from a serialization object
  117177. * @param source defines the JSON representation of the material
  117178. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  117179. */
  117180. loadFromSerialization(source: any, rootUrl?: string): void;
  117181. /**
  117182. * Creates a node material from parsed material data
  117183. * @param source defines the JSON representation of the material
  117184. * @param scene defines the hosting scene
  117185. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  117186. * @returns a new node material
  117187. */
  117188. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  117189. /**
  117190. * Creates a new node material set to default basic configuration
  117191. * @param name defines the name of the material
  117192. * @param scene defines the hosting scene
  117193. * @returns a new NodeMaterial
  117194. */
  117195. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  117196. }
  117197. }
  117198. declare module BABYLON {
  117199. /**
  117200. * Block used to read a texture from a sampler
  117201. */
  117202. export class TextureBlock extends NodeMaterialBlock {
  117203. private _defineName;
  117204. private _samplerName;
  117205. private _transformedUVName;
  117206. private _textureTransformName;
  117207. private _textureInfoName;
  117208. private _mainUVName;
  117209. private _mainUVDefineName;
  117210. /**
  117211. * Gets or sets the texture associated with the node
  117212. */
  117213. texture: Nullable<BaseTexture>;
  117214. /**
  117215. * Create a new TextureBlock
  117216. * @param name defines the block name
  117217. */
  117218. constructor(name: string);
  117219. /**
  117220. * Gets the current class name
  117221. * @returns the class name
  117222. */
  117223. getClassName(): string;
  117224. /**
  117225. * Gets the uv input component
  117226. */
  117227. readonly uv: NodeMaterialConnectionPoint;
  117228. /**
  117229. * Gets the rgba output component
  117230. */
  117231. readonly rgba: NodeMaterialConnectionPoint;
  117232. /**
  117233. * Gets the rgb output component
  117234. */
  117235. readonly rgb: NodeMaterialConnectionPoint;
  117236. /**
  117237. * Gets the r output component
  117238. */
  117239. readonly r: NodeMaterialConnectionPoint;
  117240. /**
  117241. * Gets the g output component
  117242. */
  117243. readonly g: NodeMaterialConnectionPoint;
  117244. /**
  117245. * Gets the b output component
  117246. */
  117247. readonly b: NodeMaterialConnectionPoint;
  117248. /**
  117249. * Gets the a output component
  117250. */
  117251. readonly a: NodeMaterialConnectionPoint;
  117252. readonly target: NodeMaterialBlockTargets;
  117253. autoConfigure(material: NodeMaterial): void;
  117254. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  117255. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  117256. isReady(): boolean;
  117257. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  117258. private readonly _isMixed;
  117259. private _injectVertexCode;
  117260. private _writeOutput;
  117261. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  117262. protected _dumpPropertiesCode(): string;
  117263. serialize(): any;
  117264. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  117265. }
  117266. }
  117267. declare module BABYLON {
  117268. /**
  117269. * Class used to store shared data between 2 NodeMaterialBuildState
  117270. */
  117271. export class NodeMaterialBuildStateSharedData {
  117272. /**
  117273. * Gets the list of emitted varyings
  117274. */
  117275. temps: string[];
  117276. /**
  117277. * Gets the list of emitted varyings
  117278. */
  117279. varyings: string[];
  117280. /**
  117281. * Gets the varying declaration string
  117282. */
  117283. varyingDeclaration: string;
  117284. /**
  117285. * Input blocks
  117286. */
  117287. inputBlocks: InputBlock[];
  117288. /**
  117289. * Input blocks
  117290. */
  117291. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  117292. /**
  117293. * Bindable blocks (Blocks that need to set data to the effect)
  117294. */
  117295. bindableBlocks: NodeMaterialBlock[];
  117296. /**
  117297. * List of blocks that can provide a compilation fallback
  117298. */
  117299. blocksWithFallbacks: NodeMaterialBlock[];
  117300. /**
  117301. * List of blocks that can provide a define update
  117302. */
  117303. blocksWithDefines: NodeMaterialBlock[];
  117304. /**
  117305. * List of blocks that can provide a repeatable content
  117306. */
  117307. repeatableContentBlocks: NodeMaterialBlock[];
  117308. /**
  117309. * List of blocks that can provide a dynamic list of uniforms
  117310. */
  117311. dynamicUniformBlocks: NodeMaterialBlock[];
  117312. /**
  117313. * List of blocks that can block the isReady function for the material
  117314. */
  117315. blockingBlocks: NodeMaterialBlock[];
  117316. /**
  117317. * Gets the list of animated inputs
  117318. */
  117319. animatedInputs: InputBlock[];
  117320. /**
  117321. * Build Id used to avoid multiple recompilations
  117322. */
  117323. buildId: number;
  117324. /** List of emitted variables */
  117325. variableNames: {
  117326. [key: string]: number;
  117327. };
  117328. /** List of emitted defines */
  117329. defineNames: {
  117330. [key: string]: number;
  117331. };
  117332. /** Should emit comments? */
  117333. emitComments: boolean;
  117334. /** Emit build activity */
  117335. verbose: boolean;
  117336. /**
  117337. * Gets the compilation hints emitted at compilation time
  117338. */
  117339. hints: {
  117340. needWorldViewMatrix: boolean;
  117341. needWorldViewProjectionMatrix: boolean;
  117342. needAlphaBlending: boolean;
  117343. needAlphaTesting: boolean;
  117344. };
  117345. /**
  117346. * List of compilation checks
  117347. */
  117348. checks: {
  117349. emitVertex: boolean;
  117350. emitFragment: boolean;
  117351. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  117352. };
  117353. /** Creates a new shared data */
  117354. constructor();
  117355. /**
  117356. * Emits console errors and exceptions if there is a failing check
  117357. */
  117358. emitErrors(): void;
  117359. }
  117360. }
  117361. declare module BABYLON {
  117362. /**
  117363. * Class used to store node based material build state
  117364. */
  117365. export class NodeMaterialBuildState {
  117366. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  117367. supportUniformBuffers: boolean;
  117368. /**
  117369. * Gets the list of emitted attributes
  117370. */
  117371. attributes: string[];
  117372. /**
  117373. * Gets the list of emitted uniforms
  117374. */
  117375. uniforms: string[];
  117376. /**
  117377. * Gets the list of emitted uniform buffers
  117378. */
  117379. uniformBuffers: string[];
  117380. /**
  117381. * Gets the list of emitted samplers
  117382. */
  117383. samplers: string[];
  117384. /**
  117385. * Gets the list of emitted functions
  117386. */
  117387. functions: {
  117388. [key: string]: string;
  117389. };
  117390. /**
  117391. * Gets the target of the compilation state
  117392. */
  117393. target: NodeMaterialBlockTargets;
  117394. /**
  117395. * Gets the list of emitted counters
  117396. */
  117397. counters: {
  117398. [key: string]: number;
  117399. };
  117400. /**
  117401. * Shared data between multiple NodeMaterialBuildState instances
  117402. */
  117403. sharedData: NodeMaterialBuildStateSharedData;
  117404. /** @hidden */
  117405. _vertexState: NodeMaterialBuildState;
  117406. /** @hidden */
  117407. _attributeDeclaration: string;
  117408. /** @hidden */
  117409. _uniformDeclaration: string;
  117410. /** @hidden */
  117411. _samplerDeclaration: string;
  117412. /** @hidden */
  117413. _varyingTransfer: string;
  117414. private _repeatableContentAnchorIndex;
  117415. /** @hidden */
  117416. _builtCompilationString: string;
  117417. /**
  117418. * Gets the emitted compilation strings
  117419. */
  117420. compilationString: string;
  117421. /**
  117422. * Finalize the compilation strings
  117423. * @param state defines the current compilation state
  117424. */
  117425. finalize(state: NodeMaterialBuildState): void;
  117426. /** @hidden */
  117427. readonly _repeatableContentAnchor: string;
  117428. /** @hidden */
  117429. _getFreeVariableName(prefix: string): string;
  117430. /** @hidden */
  117431. _getFreeDefineName(prefix: string): string;
  117432. /** @hidden */
  117433. _excludeVariableName(name: string): void;
  117434. /** @hidden */
  117435. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  117436. /** @hidden */
  117437. _emitFunction(name: string, code: string, comments: string): void;
  117438. /** @hidden */
  117439. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  117440. replaceStrings?: {
  117441. search: RegExp;
  117442. replace: string;
  117443. }[];
  117444. repeatKey?: string;
  117445. }): string;
  117446. /** @hidden */
  117447. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  117448. repeatKey?: string;
  117449. removeAttributes?: boolean;
  117450. removeUniforms?: boolean;
  117451. removeVaryings?: boolean;
  117452. removeIfDef?: boolean;
  117453. replaceStrings?: {
  117454. search: RegExp;
  117455. replace: string;
  117456. }[];
  117457. }, storeKey?: string): void;
  117458. /** @hidden */
  117459. _registerTempVariable(name: string): boolean;
  117460. /** @hidden */
  117461. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  117462. /** @hidden */
  117463. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  117464. }
  117465. }
  117466. declare module BABYLON {
  117467. /**
  117468. * Defines a block that can be used inside a node based material
  117469. */
  117470. export class NodeMaterialBlock {
  117471. private _buildId;
  117472. private _buildTarget;
  117473. private _target;
  117474. private _isFinalMerger;
  117475. private _isInput;
  117476. /** @hidden */
  117477. _codeVariableName: string;
  117478. /** @hidden */
  117479. _inputs: NodeMaterialConnectionPoint[];
  117480. /** @hidden */
  117481. _outputs: NodeMaterialConnectionPoint[];
  117482. /**
  117483. * Gets or sets the name of the block
  117484. */
  117485. name: string;
  117486. /**
  117487. * Gets or sets the unique id of the node
  117488. */
  117489. uniqueId: number;
  117490. /**
  117491. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  117492. */
  117493. readonly isFinalMerger: boolean;
  117494. /**
  117495. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  117496. */
  117497. readonly isInput: boolean;
  117498. /**
  117499. * Gets or sets the build Id
  117500. */
  117501. buildId: number;
  117502. /**
  117503. * Gets or sets the target of the block
  117504. */
  117505. target: NodeMaterialBlockTargets;
  117506. /**
  117507. * Gets the list of input points
  117508. */
  117509. readonly inputs: NodeMaterialConnectionPoint[];
  117510. /** Gets the list of output points */
  117511. readonly outputs: NodeMaterialConnectionPoint[];
  117512. /**
  117513. * Find an input by its name
  117514. * @param name defines the name of the input to look for
  117515. * @returns the input or null if not found
  117516. */
  117517. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  117518. /**
  117519. * Find an output by its name
  117520. * @param name defines the name of the outputto look for
  117521. * @returns the output or null if not found
  117522. */
  117523. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  117524. /**
  117525. * Creates a new NodeMaterialBlock
  117526. * @param name defines the block name
  117527. * @param target defines the target of that block (Vertex by default)
  117528. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  117529. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  117530. */
  117531. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  117532. /**
  117533. * Initialize the block and prepare the context for build
  117534. * @param state defines the state that will be used for the build
  117535. */
  117536. initialize(state: NodeMaterialBuildState): void;
  117537. /**
  117538. * Bind data to effect. Will only be called for blocks with isBindable === true
  117539. * @param effect defines the effect to bind data to
  117540. * @param nodeMaterial defines the hosting NodeMaterial
  117541. * @param mesh defines the mesh that will be rendered
  117542. */
  117543. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  117544. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  117545. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  117546. protected _writeFloat(value: number): string;
  117547. /**
  117548. * Gets the current class name e.g. "NodeMaterialBlock"
  117549. * @returns the class name
  117550. */
  117551. getClassName(): string;
  117552. /**
  117553. * Register a new input. Must be called inside a block constructor
  117554. * @param name defines the connection point name
  117555. * @param type defines the connection point type
  117556. * @param isOptional defines a boolean indicating that this input can be omitted
  117557. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  117558. * @returns the current block
  117559. */
  117560. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  117561. /**
  117562. * Register a new output. Must be called inside a block constructor
  117563. * @param name defines the connection point name
  117564. * @param type defines the connection point type
  117565. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  117566. * @returns the current block
  117567. */
  117568. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  117569. /**
  117570. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  117571. * @param forOutput defines an optional connection point to check compatibility with
  117572. * @returns the first available input or null
  117573. */
  117574. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  117575. /**
  117576. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  117577. * @param forBlock defines an optional block to check compatibility with
  117578. * @returns the first available input or null
  117579. */
  117580. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  117581. /**
  117582. * Gets the sibling of the given output
  117583. * @param current defines the current output
  117584. * @returns the next output in the list or null
  117585. */
  117586. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  117587. /**
  117588. * Connect current block with another block
  117589. * @param other defines the block to connect with
  117590. * @param options define the various options to help pick the right connections
  117591. * @returns the current block
  117592. */
  117593. connectTo(other: NodeMaterialBlock, options?: {
  117594. input?: string;
  117595. output?: string;
  117596. outputSwizzle?: string;
  117597. }): this | undefined;
  117598. protected _buildBlock(state: NodeMaterialBuildState): void;
  117599. /**
  117600. * Add uniforms, samplers and uniform buffers at compilation time
  117601. * @param state defines the state to update
  117602. * @param nodeMaterial defines the node material requesting the update
  117603. * @param defines defines the material defines to update
  117604. */
  117605. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  117606. /**
  117607. * Add potential fallbacks if shader compilation fails
  117608. * @param mesh defines the mesh to be rendered
  117609. * @param fallbacks defines the current prioritized list of fallbacks
  117610. */
  117611. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  117612. /**
  117613. * Update defines for shader compilation
  117614. * @param mesh defines the mesh to be rendered
  117615. * @param nodeMaterial defines the node material requesting the update
  117616. * @param defines defines the material defines to update
  117617. * @param useInstances specifies that instances should be used
  117618. */
  117619. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  117620. /**
  117621. * Initialize defines for shader compilation
  117622. * @param mesh defines the mesh to be rendered
  117623. * @param nodeMaterial defines the node material requesting the update
  117624. * @param defines defines the material defines to be prepared
  117625. * @param useInstances specifies that instances should be used
  117626. */
  117627. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  117628. /**
  117629. * Lets the block try to connect some inputs automatically
  117630. * @param material defines the hosting NodeMaterial
  117631. */
  117632. autoConfigure(material: NodeMaterial): void;
  117633. /**
  117634. * Function called when a block is declared as repeatable content generator
  117635. * @param vertexShaderState defines the current compilation state for the vertex shader
  117636. * @param fragmentShaderState defines the current compilation state for the fragment shader
  117637. * @param mesh defines the mesh to be rendered
  117638. * @param defines defines the material defines to update
  117639. */
  117640. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  117641. /**
  117642. * Checks if the block is ready
  117643. * @param mesh defines the mesh to be rendered
  117644. * @param nodeMaterial defines the node material requesting the update
  117645. * @param defines defines the material defines to update
  117646. * @param useInstances specifies that instances should be used
  117647. * @returns true if the block is ready
  117648. */
  117649. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  117650. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  117651. private _processBuild;
  117652. /**
  117653. * Compile the current node and generate the shader code
  117654. * @param state defines the current compilation state (uniforms, samplers, current string)
  117655. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  117656. * @returns true if already built
  117657. */
  117658. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  117659. protected _inputRename(name: string): string;
  117660. protected _outputRename(name: string): string;
  117661. protected _dumpPropertiesCode(): string;
  117662. /** @hidden */
  117663. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  117664. /**
  117665. * Clone the current block to a new identical block
  117666. * @param scene defines the hosting scene
  117667. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  117668. * @returns a copy of the current block
  117669. */
  117670. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  117671. /**
  117672. * Serializes this block in a JSON representation
  117673. * @returns the serialized block object
  117674. */
  117675. serialize(): any;
  117676. /** @hidden */
  117677. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  117678. }
  117679. }
  117680. declare module BABYLON {
  117681. /**
  117682. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  117683. */
  117684. export enum NodeMaterialBlockConnectionPointMode {
  117685. /** Value is an uniform */
  117686. Uniform = 0,
  117687. /** Value is a mesh attribute */
  117688. Attribute = 1,
  117689. /** Value is a varying between vertex and fragment shaders */
  117690. Varying = 2,
  117691. /** Mode is undefined */
  117692. Undefined = 3
  117693. }
  117694. }
  117695. declare module BABYLON {
  117696. /**
  117697. * Enum defining the type of animations supported by InputBlock
  117698. */
  117699. export enum AnimatedInputBlockTypes {
  117700. /** No animation */
  117701. None = 0,
  117702. /** Time based animation. Will only work for floats */
  117703. Time = 1
  117704. }
  117705. }
  117706. declare module BABYLON {
  117707. /**
  117708. * Block used to expose an input value
  117709. */
  117710. export class InputBlock extends NodeMaterialBlock {
  117711. private _mode;
  117712. private _associatedVariableName;
  117713. private _storedValue;
  117714. private _valueCallback;
  117715. private _type;
  117716. private _animationType;
  117717. /** @hidden */
  117718. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  117719. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  117720. visibleInInspector: boolean;
  117721. /**
  117722. * Gets or sets the connection point type (default is float)
  117723. */
  117724. readonly type: NodeMaterialBlockConnectionPointTypes;
  117725. /**
  117726. * Creates a new InputBlock
  117727. * @param name defines the block name
  117728. * @param target defines the target of that block (Vertex by default)
  117729. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  117730. */
  117731. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  117732. /**
  117733. * Gets the output component
  117734. */
  117735. readonly output: NodeMaterialConnectionPoint;
  117736. /**
  117737. * Set the source of this connection point to a vertex attribute
  117738. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  117739. * @returns the current connection point
  117740. */
  117741. setAsAttribute(attributeName?: string): InputBlock;
  117742. /**
  117743. * Set the source of this connection point to a well known value
  117744. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  117745. * @returns the current connection point
  117746. */
  117747. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): InputBlock;
  117748. /**
  117749. * Gets or sets the value of that point.
  117750. * Please note that this value will be ignored if valueCallback is defined
  117751. */
  117752. value: any;
  117753. /**
  117754. * Gets or sets a callback used to get the value of that point.
  117755. * Please note that setting this value will force the connection point to ignore the value property
  117756. */
  117757. valueCallback: () => any;
  117758. /**
  117759. * Gets or sets the associated variable name in the shader
  117760. */
  117761. associatedVariableName: string;
  117762. /** Gets or sets the type of animation applied to the input */
  117763. animationType: AnimatedInputBlockTypes;
  117764. /**
  117765. * Gets a boolean indicating that this connection point not defined yet
  117766. */
  117767. readonly isUndefined: boolean;
  117768. /**
  117769. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  117770. * In this case the connection point name must be the name of the uniform to use.
  117771. * Can only be set on inputs
  117772. */
  117773. isUniform: boolean;
  117774. /**
  117775. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  117776. * In this case the connection point name must be the name of the attribute to use
  117777. * Can only be set on inputs
  117778. */
  117779. isAttribute: boolean;
  117780. /**
  117781. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  117782. * Can only be set on exit points
  117783. */
  117784. isVarying: boolean;
  117785. /**
  117786. * Gets a boolean indicating that the current connection point is a well known value
  117787. */
  117788. readonly isWellKnownValue: boolean;
  117789. /**
  117790. * Gets or sets the current well known value or null if not defined as well know value
  117791. */
  117792. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  117793. /**
  117794. * Gets the current class name
  117795. * @returns the class name
  117796. */
  117797. getClassName(): string;
  117798. /**
  117799. * Animate the input if animationType !== None
  117800. * @param scene defines the rendering scene
  117801. */
  117802. animate(scene: Scene): void;
  117803. private _emitDefine;
  117804. /**
  117805. * Set the input block to its default value (based on its type)
  117806. */
  117807. setDefaultValue(): void;
  117808. protected _dumpPropertiesCode(): string;
  117809. private _emit;
  117810. /** @hidden */
  117811. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  117812. /** @hidden */
  117813. _transmit(effect: Effect, scene: Scene): void;
  117814. protected _buildBlock(state: NodeMaterialBuildState): void;
  117815. serialize(): any;
  117816. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  117817. }
  117818. }
  117819. declare module BABYLON {
  117820. /**
  117821. * Defines a connection point for a block
  117822. */
  117823. export class NodeMaterialConnectionPoint {
  117824. /** @hidden */
  117825. _ownerBlock: NodeMaterialBlock;
  117826. /** @hidden */
  117827. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  117828. private _endpoints;
  117829. private _associatedVariableName;
  117830. /** @hidden */
  117831. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  117832. /** @hidden */
  117833. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  117834. private _type;
  117835. /** @hidden */
  117836. _enforceAssociatedVariableName: boolean;
  117837. /**
  117838. * Gets or sets the additional types supported byt this connection point
  117839. */
  117840. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  117841. /**
  117842. * Gets or sets the associated variable name in the shader
  117843. */
  117844. associatedVariableName: string;
  117845. /**
  117846. * Gets or sets the connection point type (default is float)
  117847. */
  117848. type: NodeMaterialBlockConnectionPointTypes;
  117849. /**
  117850. * Gets or sets the connection point name
  117851. */
  117852. name: string;
  117853. /**
  117854. * Gets or sets a boolean indicating that this connection point can be omitted
  117855. */
  117856. isOptional: boolean;
  117857. /**
  117858. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  117859. */
  117860. define: string;
  117861. /** Gets or sets the target of that connection point */
  117862. target: NodeMaterialBlockTargets;
  117863. /**
  117864. * Gets a boolean indicating that the current point is connected
  117865. */
  117866. readonly isConnected: boolean;
  117867. /**
  117868. * Gets a boolean indicating that the current point is connected to an input block
  117869. */
  117870. readonly isConnectedToInputBlock: boolean;
  117871. /**
  117872. * Gets a the connected input block (if any)
  117873. */
  117874. readonly connectInputBlock: Nullable<InputBlock>;
  117875. /** Get the other side of the connection (if any) */
  117876. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  117877. /** Get the block that owns this connection point */
  117878. readonly ownerBlock: NodeMaterialBlock;
  117879. /** Get the block connected on the other side of this connection (if any) */
  117880. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  117881. /** Get the block connected on the endpoints of this connection (if any) */
  117882. readonly connectedBlocks: Array<NodeMaterialBlock>;
  117883. /** Gets the list of connected endpoints */
  117884. readonly endpoints: NodeMaterialConnectionPoint[];
  117885. /** Gets a boolean indicating if that output point is connected to at least one input */
  117886. readonly hasEndpoints: boolean;
  117887. /**
  117888. * Creates a new connection point
  117889. * @param name defines the connection point name
  117890. * @param ownerBlock defines the block hosting this connection point
  117891. */
  117892. constructor(name: string, ownerBlock: NodeMaterialBlock);
  117893. /**
  117894. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  117895. * @returns the class name
  117896. */
  117897. getClassName(): string;
  117898. /**
  117899. * Gets an boolean indicating if the current point can be connected to another point
  117900. * @param connectionPoint defines the other connection point
  117901. * @returns true if the connection is possible
  117902. */
  117903. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  117904. /**
  117905. * Connect this point to another connection point
  117906. * @param connectionPoint defines the other connection point
  117907. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  117908. * @returns the current connection point
  117909. */
  117910. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  117911. /**
  117912. * Disconnect this point from one of his endpoint
  117913. * @param endpoint defines the other connection point
  117914. * @returns the current connection point
  117915. */
  117916. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  117917. /**
  117918. * Serializes this point in a JSON representation
  117919. * @returns the serialized point object
  117920. */
  117921. serialize(): any;
  117922. }
  117923. }
  117924. declare module BABYLON {
  117925. /**
  117926. * Block used to add support for vertex skinning (bones)
  117927. */
  117928. export class BonesBlock extends NodeMaterialBlock {
  117929. /**
  117930. * Creates a new BonesBlock
  117931. * @param name defines the block name
  117932. */
  117933. constructor(name: string);
  117934. /**
  117935. * Initialize the block and prepare the context for build
  117936. * @param state defines the state that will be used for the build
  117937. */
  117938. initialize(state: NodeMaterialBuildState): void;
  117939. /**
  117940. * Gets the current class name
  117941. * @returns the class name
  117942. */
  117943. getClassName(): string;
  117944. /**
  117945. * Gets the matrix indices input component
  117946. */
  117947. readonly matricesIndices: NodeMaterialConnectionPoint;
  117948. /**
  117949. * Gets the matrix weights input component
  117950. */
  117951. readonly matricesWeights: NodeMaterialConnectionPoint;
  117952. /**
  117953. * Gets the extra matrix indices input component
  117954. */
  117955. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  117956. /**
  117957. * Gets the extra matrix weights input component
  117958. */
  117959. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  117960. /**
  117961. * Gets the world input component
  117962. */
  117963. readonly world: NodeMaterialConnectionPoint;
  117964. /**
  117965. * Gets the output component
  117966. */
  117967. readonly output: NodeMaterialConnectionPoint;
  117968. autoConfigure(material: NodeMaterial): void;
  117969. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  117970. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  117971. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  117972. protected _buildBlock(state: NodeMaterialBuildState): this;
  117973. }
  117974. }
  117975. declare module BABYLON {
  117976. /**
  117977. * Block used to add support for instances
  117978. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  117979. */
  117980. export class InstancesBlock extends NodeMaterialBlock {
  117981. /**
  117982. * Creates a new InstancesBlock
  117983. * @param name defines the block name
  117984. */
  117985. constructor(name: string);
  117986. /**
  117987. * Gets the current class name
  117988. * @returns the class name
  117989. */
  117990. getClassName(): string;
  117991. /**
  117992. * Gets the first world row input component
  117993. */
  117994. readonly world0: NodeMaterialConnectionPoint;
  117995. /**
  117996. * Gets the second world row input component
  117997. */
  117998. readonly world1: NodeMaterialConnectionPoint;
  117999. /**
  118000. * Gets the third world row input component
  118001. */
  118002. readonly world2: NodeMaterialConnectionPoint;
  118003. /**
  118004. * Gets the forth world row input component
  118005. */
  118006. readonly world3: NodeMaterialConnectionPoint;
  118007. /**
  118008. * Gets the world input component
  118009. */
  118010. readonly world: NodeMaterialConnectionPoint;
  118011. /**
  118012. * Gets the output component
  118013. */
  118014. readonly output: NodeMaterialConnectionPoint;
  118015. autoConfigure(material: NodeMaterial): void;
  118016. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  118017. protected _buildBlock(state: NodeMaterialBuildState): this;
  118018. }
  118019. }
  118020. declare module BABYLON {
  118021. /**
  118022. * Block used to add morph targets support to vertex shader
  118023. */
  118024. export class MorphTargetsBlock extends NodeMaterialBlock {
  118025. private _repeatableContentAnchor;
  118026. private _repeatebleContentGenerated;
  118027. /**
  118028. * Create a new MorphTargetsBlock
  118029. * @param name defines the block name
  118030. */
  118031. constructor(name: string);
  118032. /**
  118033. * Gets the current class name
  118034. * @returns the class name
  118035. */
  118036. getClassName(): string;
  118037. /**
  118038. * Gets the position input component
  118039. */
  118040. readonly position: NodeMaterialConnectionPoint;
  118041. /**
  118042. * Gets the normal input component
  118043. */
  118044. readonly normal: NodeMaterialConnectionPoint;
  118045. /**
  118046. * Gets the tangent input component
  118047. */
  118048. readonly tangent: NodeMaterialConnectionPoint;
  118049. /**
  118050. * Gets the tangent input component
  118051. */
  118052. readonly uv: NodeMaterialConnectionPoint;
  118053. /**
  118054. * Gets the position output component
  118055. */
  118056. readonly positionOutput: NodeMaterialConnectionPoint;
  118057. /**
  118058. * Gets the normal output component
  118059. */
  118060. readonly normalOutput: NodeMaterialConnectionPoint;
  118061. /**
  118062. * Gets the tangent output component
  118063. */
  118064. readonly tangentOutput: NodeMaterialConnectionPoint;
  118065. /**
  118066. * Gets the tangent output component
  118067. */
  118068. readonly uvOutput: NodeMaterialConnectionPoint;
  118069. initialize(state: NodeMaterialBuildState): void;
  118070. autoConfigure(material: NodeMaterial): void;
  118071. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  118072. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  118073. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  118074. protected _buildBlock(state: NodeMaterialBuildState): this;
  118075. }
  118076. }
  118077. declare module BABYLON {
  118078. /**
  118079. * Block used to add an alpha test in the fragment shader
  118080. */
  118081. export class AlphaTestBlock extends NodeMaterialBlock {
  118082. /**
  118083. * Gets or sets the alpha value where alpha testing happens
  118084. */
  118085. alphaCutOff: number;
  118086. /**
  118087. * Create a new AlphaTestBlock
  118088. * @param name defines the block name
  118089. */
  118090. constructor(name: string);
  118091. /**
  118092. * Gets the current class name
  118093. * @returns the class name
  118094. */
  118095. getClassName(): string;
  118096. /**
  118097. * Gets the color input component
  118098. */
  118099. readonly color: NodeMaterialConnectionPoint;
  118100. /**
  118101. * Gets the alpha input component
  118102. */
  118103. readonly alpha: NodeMaterialConnectionPoint;
  118104. protected _buildBlock(state: NodeMaterialBuildState): this;
  118105. protected _dumpPropertiesCode(): string;
  118106. serialize(): any;
  118107. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118108. }
  118109. }
  118110. declare module BABYLON {
  118111. /**
  118112. * Block used to add image processing support to fragment shader
  118113. */
  118114. export class ImageProcessingBlock extends NodeMaterialBlock {
  118115. /**
  118116. * Create a new ImageProcessingBlock
  118117. * @param name defines the block name
  118118. */
  118119. constructor(name: string);
  118120. /**
  118121. * Gets the current class name
  118122. * @returns the class name
  118123. */
  118124. getClassName(): string;
  118125. /**
  118126. * Gets the color input component
  118127. */
  118128. readonly color: NodeMaterialConnectionPoint;
  118129. /**
  118130. * Gets the output component
  118131. */
  118132. readonly output: NodeMaterialConnectionPoint;
  118133. /**
  118134. * Initialize the block and prepare the context for build
  118135. * @param state defines the state that will be used for the build
  118136. */
  118137. initialize(state: NodeMaterialBuildState): void;
  118138. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  118139. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  118140. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  118141. protected _buildBlock(state: NodeMaterialBuildState): this;
  118142. }
  118143. }
  118144. declare module BABYLON {
  118145. /**
  118146. * Block used to add support for scene fog
  118147. */
  118148. export class FogBlock extends NodeMaterialBlock {
  118149. private _fogDistanceName;
  118150. private _fogParameters;
  118151. /**
  118152. * Create a new FogBlock
  118153. * @param name defines the block name
  118154. */
  118155. constructor(name: string);
  118156. /**
  118157. * Gets the current class name
  118158. * @returns the class name
  118159. */
  118160. getClassName(): string;
  118161. /**
  118162. * Gets the world position input component
  118163. */
  118164. readonly worldPosition: NodeMaterialConnectionPoint;
  118165. /**
  118166. * Gets the view input component
  118167. */
  118168. readonly view: NodeMaterialConnectionPoint;
  118169. /**
  118170. * Gets the color input component
  118171. */
  118172. readonly input: NodeMaterialConnectionPoint;
  118173. /**
  118174. * Gets the fog color input component
  118175. */
  118176. readonly fogColor: NodeMaterialConnectionPoint;
  118177. /**
  118178. * Gets the output component
  118179. */
  118180. readonly output: NodeMaterialConnectionPoint;
  118181. autoConfigure(material: NodeMaterial): void;
  118182. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  118183. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  118184. protected _buildBlock(state: NodeMaterialBuildState): this;
  118185. }
  118186. }
  118187. declare module BABYLON {
  118188. /**
  118189. * Block used to add light in the fragment shader
  118190. */
  118191. export class LightBlock extends NodeMaterialBlock {
  118192. private _lightId;
  118193. /**
  118194. * Gets or sets the light associated with this block
  118195. */
  118196. light: Nullable<Light>;
  118197. /**
  118198. * Create a new LightBlock
  118199. * @param name defines the block name
  118200. */
  118201. constructor(name: string);
  118202. /**
  118203. * Gets the current class name
  118204. * @returns the class name
  118205. */
  118206. getClassName(): string;
  118207. /**
  118208. * Gets the world position input component
  118209. */
  118210. readonly worldPosition: NodeMaterialConnectionPoint;
  118211. /**
  118212. * Gets the world normal input component
  118213. */
  118214. readonly worldNormal: NodeMaterialConnectionPoint;
  118215. /**
  118216. * Gets the camera (or eye) position component
  118217. */
  118218. readonly cameraPosition: NodeMaterialConnectionPoint;
  118219. /**
  118220. * Gets the diffuse output component
  118221. */
  118222. readonly diffuseOutput: NodeMaterialConnectionPoint;
  118223. /**
  118224. * Gets the specular output component
  118225. */
  118226. readonly specularOutput: NodeMaterialConnectionPoint;
  118227. autoConfigure(material: NodeMaterial): void;
  118228. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  118229. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  118230. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  118231. private _injectVertexCode;
  118232. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  118233. serialize(): any;
  118234. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118235. }
  118236. }
  118237. declare module BABYLON {
  118238. /**
  118239. * Block used to multiply 2 values
  118240. */
  118241. export class MultiplyBlock extends NodeMaterialBlock {
  118242. /**
  118243. * Creates a new MultiplyBlock
  118244. * @param name defines the block name
  118245. */
  118246. constructor(name: string);
  118247. /**
  118248. * Gets the current class name
  118249. * @returns the class name
  118250. */
  118251. getClassName(): string;
  118252. /**
  118253. * Gets the left operand input component
  118254. */
  118255. readonly left: NodeMaterialConnectionPoint;
  118256. /**
  118257. * Gets the right operand input component
  118258. */
  118259. readonly right: NodeMaterialConnectionPoint;
  118260. /**
  118261. * Gets the output component
  118262. */
  118263. readonly output: NodeMaterialConnectionPoint;
  118264. protected _buildBlock(state: NodeMaterialBuildState): this;
  118265. }
  118266. }
  118267. declare module BABYLON {
  118268. /**
  118269. * Block used to add 2 vectors
  118270. */
  118271. export class AddBlock extends NodeMaterialBlock {
  118272. /**
  118273. * Creates a new AddBlock
  118274. * @param name defines the block name
  118275. */
  118276. constructor(name: string);
  118277. /**
  118278. * Gets the current class name
  118279. * @returns the class name
  118280. */
  118281. getClassName(): string;
  118282. /**
  118283. * Gets the left operand input component
  118284. */
  118285. readonly left: NodeMaterialConnectionPoint;
  118286. /**
  118287. * Gets the right operand input component
  118288. */
  118289. readonly right: NodeMaterialConnectionPoint;
  118290. /**
  118291. * Gets the output component
  118292. */
  118293. readonly output: NodeMaterialConnectionPoint;
  118294. protected _buildBlock(state: NodeMaterialBuildState): this;
  118295. }
  118296. }
  118297. declare module BABYLON {
  118298. /**
  118299. * Block used to scale a vector by a float
  118300. */
  118301. export class ScaleBlock extends NodeMaterialBlock {
  118302. /**
  118303. * Creates a new ScaleBlock
  118304. * @param name defines the block name
  118305. */
  118306. constructor(name: string);
  118307. /**
  118308. * Gets the current class name
  118309. * @returns the class name
  118310. */
  118311. getClassName(): string;
  118312. /**
  118313. * Gets the input component
  118314. */
  118315. readonly input: NodeMaterialConnectionPoint;
  118316. /**
  118317. * Gets the factor input component
  118318. */
  118319. readonly factor: NodeMaterialConnectionPoint;
  118320. /**
  118321. * Gets the output component
  118322. */
  118323. readonly output: NodeMaterialConnectionPoint;
  118324. protected _buildBlock(state: NodeMaterialBuildState): this;
  118325. }
  118326. }
  118327. declare module BABYLON {
  118328. /**
  118329. * Block used to clamp a float
  118330. */
  118331. export class ClampBlock extends NodeMaterialBlock {
  118332. /** Gets or sets the minimum range */
  118333. minimum: number;
  118334. /** Gets or sets the maximum range */
  118335. maximum: number;
  118336. /**
  118337. * Creates a new ClampBlock
  118338. * @param name defines the block name
  118339. */
  118340. constructor(name: string);
  118341. /**
  118342. * Gets the current class name
  118343. * @returns the class name
  118344. */
  118345. getClassName(): string;
  118346. /**
  118347. * Gets the value input component
  118348. */
  118349. readonly value: NodeMaterialConnectionPoint;
  118350. /**
  118351. * Gets the output component
  118352. */
  118353. readonly output: NodeMaterialConnectionPoint;
  118354. protected _buildBlock(state: NodeMaterialBuildState): this;
  118355. protected _dumpPropertiesCode(): string;
  118356. serialize(): any;
  118357. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118358. }
  118359. }
  118360. declare module BABYLON {
  118361. /**
  118362. * Block used to apply a cross product between 2 vectors
  118363. */
  118364. export class CrossBlock extends NodeMaterialBlock {
  118365. /**
  118366. * Creates a new CrossBlock
  118367. * @param name defines the block name
  118368. */
  118369. constructor(name: string);
  118370. /**
  118371. * Gets the current class name
  118372. * @returns the class name
  118373. */
  118374. getClassName(): string;
  118375. /**
  118376. * Gets the left operand input component
  118377. */
  118378. readonly left: NodeMaterialConnectionPoint;
  118379. /**
  118380. * Gets the right operand input component
  118381. */
  118382. readonly right: NodeMaterialConnectionPoint;
  118383. /**
  118384. * Gets the output component
  118385. */
  118386. readonly output: NodeMaterialConnectionPoint;
  118387. protected _buildBlock(state: NodeMaterialBuildState): this;
  118388. }
  118389. }
  118390. declare module BABYLON {
  118391. /**
  118392. * Block used to apply a dot product between 2 vectors
  118393. */
  118394. export class DotBlock extends NodeMaterialBlock {
  118395. /**
  118396. * Creates a new DotBlock
  118397. * @param name defines the block name
  118398. */
  118399. constructor(name: string);
  118400. /**
  118401. * Gets the current class name
  118402. * @returns the class name
  118403. */
  118404. getClassName(): string;
  118405. /**
  118406. * Gets the left operand input component
  118407. */
  118408. readonly left: NodeMaterialConnectionPoint;
  118409. /**
  118410. * Gets the right operand input component
  118411. */
  118412. readonly right: NodeMaterialConnectionPoint;
  118413. /**
  118414. * Gets the output component
  118415. */
  118416. readonly output: NodeMaterialConnectionPoint;
  118417. protected _buildBlock(state: NodeMaterialBuildState): this;
  118418. }
  118419. }
  118420. declare module BABYLON {
  118421. /**
  118422. * Block used to remap a float from a range to a new one
  118423. */
  118424. export class RemapBlock extends NodeMaterialBlock {
  118425. /**
  118426. * Gets or sets the source range
  118427. */
  118428. sourceRange: Vector2;
  118429. /**
  118430. * Gets or sets the target range
  118431. */
  118432. targetRange: Vector2;
  118433. /**
  118434. * Creates a new RemapBlock
  118435. * @param name defines the block name
  118436. */
  118437. constructor(name: string);
  118438. /**
  118439. * Gets the current class name
  118440. * @returns the class name
  118441. */
  118442. getClassName(): string;
  118443. /**
  118444. * Gets the input component
  118445. */
  118446. readonly input: NodeMaterialConnectionPoint;
  118447. /**
  118448. * Gets the output component
  118449. */
  118450. readonly output: NodeMaterialConnectionPoint;
  118451. protected _buildBlock(state: NodeMaterialBuildState): this;
  118452. protected _dumpPropertiesCode(): string;
  118453. serialize(): any;
  118454. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118455. }
  118456. }
  118457. declare module BABYLON {
  118458. /**
  118459. * Block used to normalize a vector
  118460. */
  118461. export class NormalizeBlock extends NodeMaterialBlock {
  118462. /**
  118463. * Creates a new NormalizeBlock
  118464. * @param name defines the block name
  118465. */
  118466. constructor(name: string);
  118467. /**
  118468. * Gets the current class name
  118469. * @returns the class name
  118470. */
  118471. getClassName(): string;
  118472. /**
  118473. * Gets the input component
  118474. */
  118475. readonly input: NodeMaterialConnectionPoint;
  118476. /**
  118477. * Gets the output component
  118478. */
  118479. readonly output: NodeMaterialConnectionPoint;
  118480. protected _buildBlock(state: NodeMaterialBuildState): this;
  118481. }
  118482. }
  118483. declare module BABYLON {
  118484. /**
  118485. * Operations supported by the Trigonometry block
  118486. */
  118487. export enum TrigonometryBlockOperations {
  118488. /** Cos */
  118489. Cos = 0,
  118490. /** Sin */
  118491. Sin = 1,
  118492. /** Abs */
  118493. Abs = 2,
  118494. /** Exp */
  118495. Exp = 3,
  118496. /** Exp2 */
  118497. Exp2 = 4,
  118498. /** Round */
  118499. Round = 5,
  118500. /** Floor */
  118501. Floor = 6,
  118502. /** Ceiling */
  118503. Ceiling = 7
  118504. }
  118505. /**
  118506. * Block used to apply trigonometry operation to floats
  118507. */
  118508. export class TrigonometryBlock extends NodeMaterialBlock {
  118509. /**
  118510. * Gets or sets the operation applied by the block
  118511. */
  118512. operation: TrigonometryBlockOperations;
  118513. /**
  118514. * Creates a new TrigonometryBlock
  118515. * @param name defines the block name
  118516. */
  118517. constructor(name: string);
  118518. /**
  118519. * Gets the current class name
  118520. * @returns the class name
  118521. */
  118522. getClassName(): string;
  118523. /**
  118524. * Gets the input component
  118525. */
  118526. readonly input: NodeMaterialConnectionPoint;
  118527. /**
  118528. * Gets the output component
  118529. */
  118530. readonly output: NodeMaterialConnectionPoint;
  118531. protected _buildBlock(state: NodeMaterialBuildState): this;
  118532. }
  118533. }
  118534. declare module BABYLON {
  118535. /**
  118536. * Block used to create a Color3/4 out of individual inputs (one for each component)
  118537. */
  118538. export class ColorMergerBlock extends NodeMaterialBlock {
  118539. /**
  118540. * Create a new ColorMergerBlock
  118541. * @param name defines the block name
  118542. */
  118543. constructor(name: string);
  118544. /**
  118545. * Gets the current class name
  118546. * @returns the class name
  118547. */
  118548. getClassName(): string;
  118549. /**
  118550. * Gets the r component (input)
  118551. */
  118552. readonly r: NodeMaterialConnectionPoint;
  118553. /**
  118554. * Gets the g component (input)
  118555. */
  118556. readonly g: NodeMaterialConnectionPoint;
  118557. /**
  118558. * Gets the b component (input)
  118559. */
  118560. readonly b: NodeMaterialConnectionPoint;
  118561. /**
  118562. * Gets the a component (input)
  118563. */
  118564. readonly a: NodeMaterialConnectionPoint;
  118565. /**
  118566. * Gets the rgba component (output)
  118567. */
  118568. readonly rgba: NodeMaterialConnectionPoint;
  118569. /**
  118570. * Gets the rgb component (output)
  118571. */
  118572. readonly rgb: NodeMaterialConnectionPoint;
  118573. protected _buildBlock(state: NodeMaterialBuildState): this;
  118574. }
  118575. }
  118576. declare module BABYLON {
  118577. /**
  118578. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  118579. */
  118580. export class VectorMergerBlock extends NodeMaterialBlock {
  118581. /**
  118582. * Create a new VectorMergerBlock
  118583. * @param name defines the block name
  118584. */
  118585. constructor(name: string);
  118586. /**
  118587. * Gets the current class name
  118588. * @returns the class name
  118589. */
  118590. getClassName(): string;
  118591. /**
  118592. * Gets the x component (input)
  118593. */
  118594. readonly x: NodeMaterialConnectionPoint;
  118595. /**
  118596. * Gets the y component (input)
  118597. */
  118598. readonly y: NodeMaterialConnectionPoint;
  118599. /**
  118600. * Gets the z component (input)
  118601. */
  118602. readonly z: NodeMaterialConnectionPoint;
  118603. /**
  118604. * Gets the w component (input)
  118605. */
  118606. readonly w: NodeMaterialConnectionPoint;
  118607. /**
  118608. * Gets the xyzw component (output)
  118609. */
  118610. readonly xyzw: NodeMaterialConnectionPoint;
  118611. /**
  118612. * Gets the xyz component (output)
  118613. */
  118614. readonly xyz: NodeMaterialConnectionPoint;
  118615. /**
  118616. * Gets the xy component (output)
  118617. */
  118618. readonly xy: NodeMaterialConnectionPoint;
  118619. protected _buildBlock(state: NodeMaterialBuildState): this;
  118620. }
  118621. }
  118622. declare module BABYLON {
  118623. /**
  118624. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  118625. */
  118626. export class ColorSplitterBlock extends NodeMaterialBlock {
  118627. /**
  118628. * Create a new ColorSplitterBlock
  118629. * @param name defines the block name
  118630. */
  118631. constructor(name: string);
  118632. /**
  118633. * Gets the current class name
  118634. * @returns the class name
  118635. */
  118636. getClassName(): string;
  118637. /**
  118638. * Gets the rgba component (input)
  118639. */
  118640. readonly rgba: NodeMaterialConnectionPoint;
  118641. /**
  118642. * Gets the rgb component (input)
  118643. */
  118644. readonly rgbIn: NodeMaterialConnectionPoint;
  118645. /**
  118646. * Gets the rgb component (output)
  118647. */
  118648. readonly rgbOut: NodeMaterialConnectionPoint;
  118649. /**
  118650. * Gets the r component (output)
  118651. */
  118652. readonly r: NodeMaterialConnectionPoint;
  118653. /**
  118654. * Gets the g component (output)
  118655. */
  118656. readonly g: NodeMaterialConnectionPoint;
  118657. /**
  118658. * Gets the b component (output)
  118659. */
  118660. readonly b: NodeMaterialConnectionPoint;
  118661. /**
  118662. * Gets the a component (output)
  118663. */
  118664. readonly a: NodeMaterialConnectionPoint;
  118665. protected _inputRename(name: string): string;
  118666. protected _outputRename(name: string): string;
  118667. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  118668. }
  118669. }
  118670. declare module BABYLON {
  118671. /**
  118672. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  118673. */
  118674. export class VectorSplitterBlock extends NodeMaterialBlock {
  118675. /**
  118676. * Create a new VectorSplitterBlock
  118677. * @param name defines the block name
  118678. */
  118679. constructor(name: string);
  118680. /**
  118681. * Gets the current class name
  118682. * @returns the class name
  118683. */
  118684. getClassName(): string;
  118685. /**
  118686. * Gets the xyzw component (input)
  118687. */
  118688. readonly xyzw: NodeMaterialConnectionPoint;
  118689. /**
  118690. * Gets the xyz component (input)
  118691. */
  118692. readonly xyzIn: NodeMaterialConnectionPoint;
  118693. /**
  118694. * Gets the xy component (input)
  118695. */
  118696. readonly xyIn: NodeMaterialConnectionPoint;
  118697. /**
  118698. * Gets the xyz component (output)
  118699. */
  118700. readonly xyzOut: NodeMaterialConnectionPoint;
  118701. /**
  118702. * Gets the xy component (output)
  118703. */
  118704. readonly xyOut: NodeMaterialConnectionPoint;
  118705. /**
  118706. * Gets the x component (output)
  118707. */
  118708. readonly x: NodeMaterialConnectionPoint;
  118709. /**
  118710. * Gets the y component (output)
  118711. */
  118712. readonly y: NodeMaterialConnectionPoint;
  118713. /**
  118714. * Gets the z component (output)
  118715. */
  118716. readonly z: NodeMaterialConnectionPoint;
  118717. /**
  118718. * Gets the w component (output)
  118719. */
  118720. readonly w: NodeMaterialConnectionPoint;
  118721. protected _inputRename(name: string): string;
  118722. protected _outputRename(name: string): string;
  118723. protected _buildBlock(state: NodeMaterialBuildState): this;
  118724. }
  118725. }
  118726. declare module BABYLON {
  118727. /**
  118728. * Block used to lerp 2 values
  118729. */
  118730. export class LerpBlock extends NodeMaterialBlock {
  118731. /**
  118732. * Creates a new LerpBlock
  118733. * @param name defines the block name
  118734. */
  118735. constructor(name: string);
  118736. /**
  118737. * Gets the current class name
  118738. * @returns the class name
  118739. */
  118740. getClassName(): string;
  118741. /**
  118742. * Gets the left operand input component
  118743. */
  118744. readonly left: NodeMaterialConnectionPoint;
  118745. /**
  118746. * Gets the right operand input component
  118747. */
  118748. readonly right: NodeMaterialConnectionPoint;
  118749. /**
  118750. * Gets the gradient operand input component
  118751. */
  118752. readonly gradient: NodeMaterialConnectionPoint;
  118753. /**
  118754. * Gets the output component
  118755. */
  118756. readonly output: NodeMaterialConnectionPoint;
  118757. protected _buildBlock(state: NodeMaterialBuildState): this;
  118758. }
  118759. }
  118760. declare module BABYLON {
  118761. /**
  118762. * Block used to divide 2 vectors
  118763. */
  118764. export class DivideBlock extends NodeMaterialBlock {
  118765. /**
  118766. * Creates a new DivideBlock
  118767. * @param name defines the block name
  118768. */
  118769. constructor(name: string);
  118770. /**
  118771. * Gets the current class name
  118772. * @returns the class name
  118773. */
  118774. getClassName(): string;
  118775. /**
  118776. * Gets the left operand input component
  118777. */
  118778. readonly left: NodeMaterialConnectionPoint;
  118779. /**
  118780. * Gets the right operand input component
  118781. */
  118782. readonly right: NodeMaterialConnectionPoint;
  118783. /**
  118784. * Gets the output component
  118785. */
  118786. readonly output: NodeMaterialConnectionPoint;
  118787. protected _buildBlock(state: NodeMaterialBuildState): this;
  118788. }
  118789. }
  118790. declare module BABYLON {
  118791. /**
  118792. * Block used to subtract 2 vectors
  118793. */
  118794. export class SubtractBlock extends NodeMaterialBlock {
  118795. /**
  118796. * Creates a new SubtractBlock
  118797. * @param name defines the block name
  118798. */
  118799. constructor(name: string);
  118800. /**
  118801. * Gets the current class name
  118802. * @returns the class name
  118803. */
  118804. getClassName(): string;
  118805. /**
  118806. * Gets the left operand input component
  118807. */
  118808. readonly left: NodeMaterialConnectionPoint;
  118809. /**
  118810. * Gets the right operand input component
  118811. */
  118812. readonly right: NodeMaterialConnectionPoint;
  118813. /**
  118814. * Gets the output component
  118815. */
  118816. readonly output: NodeMaterialConnectionPoint;
  118817. protected _buildBlock(state: NodeMaterialBuildState): this;
  118818. }
  118819. }
  118820. declare module BABYLON {
  118821. /**
  118822. * Block used to step a value
  118823. */
  118824. export class StepBlock extends NodeMaterialBlock {
  118825. /**
  118826. * Creates a new AddBlock
  118827. * @param name defines the block name
  118828. */
  118829. constructor(name: string);
  118830. /**
  118831. * Gets the current class name
  118832. * @returns the class name
  118833. */
  118834. getClassName(): string;
  118835. /**
  118836. * Gets the value operand input component
  118837. */
  118838. readonly value: NodeMaterialConnectionPoint;
  118839. /**
  118840. * Gets the edge operand input component
  118841. */
  118842. readonly edge: NodeMaterialConnectionPoint;
  118843. /**
  118844. * Gets the output component
  118845. */
  118846. readonly output: NodeMaterialConnectionPoint;
  118847. protected _buildBlock(state: NodeMaterialBuildState): this;
  118848. }
  118849. }
  118850. declare module BABYLON {
  118851. /**
  118852. * Block used to get the opposite of a value
  118853. */
  118854. export class OppositeBlock extends NodeMaterialBlock {
  118855. /**
  118856. * Creates a new OppositeBlock
  118857. * @param name defines the block name
  118858. */
  118859. constructor(name: string);
  118860. /**
  118861. * Gets the current class name
  118862. * @returns the class name
  118863. */
  118864. getClassName(): string;
  118865. /**
  118866. * Gets the input component
  118867. */
  118868. readonly input: NodeMaterialConnectionPoint;
  118869. /**
  118870. * Gets the output component
  118871. */
  118872. readonly output: NodeMaterialConnectionPoint;
  118873. protected _buildBlock(state: NodeMaterialBuildState): this;
  118874. }
  118875. }
  118876. declare module BABYLON {
  118877. /**
  118878. * Block used to get the view direction
  118879. */
  118880. export class ViewDirectionBlock extends NodeMaterialBlock {
  118881. /**
  118882. * Creates a new ViewDirectionBlock
  118883. * @param name defines the block name
  118884. */
  118885. constructor(name: string);
  118886. /**
  118887. * Gets the current class name
  118888. * @returns the class name
  118889. */
  118890. getClassName(): string;
  118891. /**
  118892. * Gets the world position component
  118893. */
  118894. readonly worldPosition: NodeMaterialConnectionPoint;
  118895. /**
  118896. * Gets the camera position component
  118897. */
  118898. readonly cameraPosition: NodeMaterialConnectionPoint;
  118899. /**
  118900. * Gets the output component
  118901. */
  118902. readonly output: NodeMaterialConnectionPoint;
  118903. autoConfigure(material: NodeMaterial): void;
  118904. protected _buildBlock(state: NodeMaterialBuildState): this;
  118905. }
  118906. }
  118907. declare module BABYLON {
  118908. /**
  118909. * Block used to compute fresnel value
  118910. */
  118911. export class FresnelBlock extends NodeMaterialBlock {
  118912. /**
  118913. * Create a new FresnelBlock
  118914. * @param name defines the block name
  118915. */
  118916. constructor(name: string);
  118917. /**
  118918. * Gets the current class name
  118919. * @returns the class name
  118920. */
  118921. getClassName(): string;
  118922. /**
  118923. * Gets the world normal input component
  118924. */
  118925. readonly worldNormal: NodeMaterialConnectionPoint;
  118926. /**
  118927. * Gets the view direction input component
  118928. */
  118929. readonly viewDirection: NodeMaterialConnectionPoint;
  118930. /**
  118931. * Gets the bias input component
  118932. */
  118933. readonly bias: NodeMaterialConnectionPoint;
  118934. /**
  118935. * Gets the camera (or eye) position component
  118936. */
  118937. readonly power: NodeMaterialConnectionPoint;
  118938. /**
  118939. * Gets the fresnel output component
  118940. */
  118941. readonly fresnel: NodeMaterialConnectionPoint;
  118942. autoConfigure(material: NodeMaterial): void;
  118943. protected _buildBlock(state: NodeMaterialBuildState): this;
  118944. }
  118945. }
  118946. declare module BABYLON {
  118947. /**
  118948. * Effect Render Options
  118949. */
  118950. export interface IEffectRendererOptions {
  118951. /**
  118952. * Defines the vertices positions.
  118953. */
  118954. positions?: number[];
  118955. /**
  118956. * Defines the indices.
  118957. */
  118958. indices?: number[];
  118959. }
  118960. /**
  118961. * Helper class to render one or more effects
  118962. */
  118963. export class EffectRenderer {
  118964. private engine;
  118965. private static _DefaultOptions;
  118966. private _vertexBuffers;
  118967. private _indexBuffer;
  118968. private _ringBufferIndex;
  118969. private _ringScreenBuffer;
  118970. private _fullscreenViewport;
  118971. private _getNextFrameBuffer;
  118972. /**
  118973. * Creates an effect renderer
  118974. * @param engine the engine to use for rendering
  118975. * @param options defines the options of the effect renderer
  118976. */
  118977. constructor(engine: Engine, options?: IEffectRendererOptions);
  118978. /**
  118979. * Sets the current viewport in normalized coordinates 0-1
  118980. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  118981. */
  118982. setViewport(viewport?: Viewport): void;
  118983. /**
  118984. * Sets the current effect wrapper to use during draw.
  118985. * The effect needs to be ready before calling this api.
  118986. * This also sets the default full screen position attribute.
  118987. * @param effectWrapper Defines the effect to draw with
  118988. */
  118989. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  118990. /**
  118991. * Draws a full screen quad.
  118992. */
  118993. draw(): void;
  118994. /**
  118995. * renders one or more effects to a specified texture
  118996. * @param effectWrappers list of effects to renderer
  118997. * @param outputTexture texture to draw to, if null it will render to the screen
  118998. */
  118999. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  119000. /**
  119001. * Disposes of the effect renderer
  119002. */
  119003. dispose(): void;
  119004. }
  119005. /**
  119006. * Options to create an EffectWrapper
  119007. */
  119008. interface EffectWrapperCreationOptions {
  119009. /**
  119010. * Engine to use to create the effect
  119011. */
  119012. engine: Engine;
  119013. /**
  119014. * Fragment shader for the effect
  119015. */
  119016. fragmentShader: string;
  119017. /**
  119018. * Vertex shader for the effect
  119019. */
  119020. vertexShader?: string;
  119021. /**
  119022. * Attributes to use in the shader
  119023. */
  119024. attributeNames?: Array<string>;
  119025. /**
  119026. * Uniforms to use in the shader
  119027. */
  119028. uniformNames?: Array<string>;
  119029. /**
  119030. * Texture sampler names to use in the shader
  119031. */
  119032. samplerNames?: Array<string>;
  119033. /**
  119034. * The friendly name of the effect displayed in Spector.
  119035. */
  119036. name?: string;
  119037. }
  119038. /**
  119039. * Wraps an effect to be used for rendering
  119040. */
  119041. export class EffectWrapper {
  119042. /**
  119043. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  119044. */
  119045. onApplyObservable: Observable<{}>;
  119046. /**
  119047. * The underlying effect
  119048. */
  119049. effect: Effect;
  119050. /**
  119051. * Creates an effect to be renderer
  119052. * @param creationOptions options to create the effect
  119053. */
  119054. constructor(creationOptions: EffectWrapperCreationOptions);
  119055. /**
  119056. * Disposes of the effect wrapper
  119057. */
  119058. dispose(): void;
  119059. }
  119060. }
  119061. declare module BABYLON {
  119062. /**
  119063. * Helper class to push actions to a pool of workers.
  119064. */
  119065. export class WorkerPool implements IDisposable {
  119066. private _workerInfos;
  119067. private _pendingActions;
  119068. /**
  119069. * Constructor
  119070. * @param workers Array of workers to use for actions
  119071. */
  119072. constructor(workers: Array<Worker>);
  119073. /**
  119074. * Terminates all workers and clears any pending actions.
  119075. */
  119076. dispose(): void;
  119077. /**
  119078. * Pushes an action to the worker pool. If all the workers are active, the action will be
  119079. * pended until a worker has completed its action.
  119080. * @param action The action to perform. Call onComplete when the action is complete.
  119081. */
  119082. push(action: (worker: Worker, onComplete: () => void) => void): void;
  119083. private _execute;
  119084. }
  119085. }
  119086. declare module BABYLON {
  119087. /**
  119088. * Configuration for Draco compression
  119089. */
  119090. export interface IDracoCompressionConfiguration {
  119091. /**
  119092. * Configuration for the decoder.
  119093. */
  119094. decoder: {
  119095. /**
  119096. * The url to the WebAssembly module.
  119097. */
  119098. wasmUrl?: string;
  119099. /**
  119100. * The url to the WebAssembly binary.
  119101. */
  119102. wasmBinaryUrl?: string;
  119103. /**
  119104. * The url to the fallback JavaScript module.
  119105. */
  119106. fallbackUrl?: string;
  119107. };
  119108. }
  119109. /**
  119110. * Draco compression (https://google.github.io/draco/)
  119111. *
  119112. * This class wraps the Draco module.
  119113. *
  119114. * **Encoder**
  119115. *
  119116. * The encoder is not currently implemented.
  119117. *
  119118. * **Decoder**
  119119. *
  119120. * 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.
  119121. *
  119122. * To update the configuration, use the following code:
  119123. * ```javascript
  119124. * DracoCompression.Configuration = {
  119125. * decoder: {
  119126. * wasmUrl: "<url to the WebAssembly library>",
  119127. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  119128. * fallbackUrl: "<url to the fallback JavaScript library>",
  119129. * }
  119130. * };
  119131. * ```
  119132. *
  119133. * 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.
  119134. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  119135. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  119136. *
  119137. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  119138. * ```javascript
  119139. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  119140. * ```
  119141. *
  119142. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  119143. */
  119144. export class DracoCompression implements IDisposable {
  119145. private _workerPoolPromise?;
  119146. private _decoderModulePromise?;
  119147. /**
  119148. * The configuration. Defaults to the following urls:
  119149. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  119150. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  119151. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  119152. */
  119153. static Configuration: IDracoCompressionConfiguration;
  119154. /**
  119155. * Returns true if the decoder configuration is available.
  119156. */
  119157. static readonly DecoderAvailable: boolean;
  119158. /**
  119159. * Default number of workers to create when creating the draco compression object.
  119160. */
  119161. static DefaultNumWorkers: number;
  119162. private static GetDefaultNumWorkers;
  119163. private static _Default;
  119164. /**
  119165. * Default instance for the draco compression object.
  119166. */
  119167. static readonly Default: DracoCompression;
  119168. /**
  119169. * Constructor
  119170. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  119171. */
  119172. constructor(numWorkers?: number);
  119173. /**
  119174. * Stop all async operations and release resources.
  119175. */
  119176. dispose(): void;
  119177. /**
  119178. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  119179. * @returns a promise that resolves when ready
  119180. */
  119181. whenReadyAsync(): Promise<void>;
  119182. /**
  119183. * Decode Draco compressed mesh data to vertex data.
  119184. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  119185. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  119186. * @returns A promise that resolves with the decoded vertex data
  119187. */
  119188. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  119189. [kind: string]: number;
  119190. }): Promise<VertexData>;
  119191. }
  119192. }
  119193. declare module BABYLON {
  119194. /**
  119195. * Class for building Constructive Solid Geometry
  119196. */
  119197. export class CSG {
  119198. private polygons;
  119199. /**
  119200. * The world matrix
  119201. */
  119202. matrix: Matrix;
  119203. /**
  119204. * Stores the position
  119205. */
  119206. position: Vector3;
  119207. /**
  119208. * Stores the rotation
  119209. */
  119210. rotation: Vector3;
  119211. /**
  119212. * Stores the rotation quaternion
  119213. */
  119214. rotationQuaternion: Nullable<Quaternion>;
  119215. /**
  119216. * Stores the scaling vector
  119217. */
  119218. scaling: Vector3;
  119219. /**
  119220. * Convert the Mesh to CSG
  119221. * @param mesh The Mesh to convert to CSG
  119222. * @returns A new CSG from the Mesh
  119223. */
  119224. static FromMesh(mesh: Mesh): CSG;
  119225. /**
  119226. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  119227. * @param polygons Polygons used to construct a CSG solid
  119228. */
  119229. private static FromPolygons;
  119230. /**
  119231. * Clones, or makes a deep copy, of the CSG
  119232. * @returns A new CSG
  119233. */
  119234. clone(): CSG;
  119235. /**
  119236. * Unions this CSG with another CSG
  119237. * @param csg The CSG to union against this CSG
  119238. * @returns The unioned CSG
  119239. */
  119240. union(csg: CSG): CSG;
  119241. /**
  119242. * Unions this CSG with another CSG in place
  119243. * @param csg The CSG to union against this CSG
  119244. */
  119245. unionInPlace(csg: CSG): void;
  119246. /**
  119247. * Subtracts this CSG with another CSG
  119248. * @param csg The CSG to subtract against this CSG
  119249. * @returns A new CSG
  119250. */
  119251. subtract(csg: CSG): CSG;
  119252. /**
  119253. * Subtracts this CSG with another CSG in place
  119254. * @param csg The CSG to subtact against this CSG
  119255. */
  119256. subtractInPlace(csg: CSG): void;
  119257. /**
  119258. * Intersect this CSG with another CSG
  119259. * @param csg The CSG to intersect against this CSG
  119260. * @returns A new CSG
  119261. */
  119262. intersect(csg: CSG): CSG;
  119263. /**
  119264. * Intersects this CSG with another CSG in place
  119265. * @param csg The CSG to intersect against this CSG
  119266. */
  119267. intersectInPlace(csg: CSG): void;
  119268. /**
  119269. * Return a new CSG solid with solid and empty space switched. This solid is
  119270. * not modified.
  119271. * @returns A new CSG solid with solid and empty space switched
  119272. */
  119273. inverse(): CSG;
  119274. /**
  119275. * Inverses the CSG in place
  119276. */
  119277. inverseInPlace(): void;
  119278. /**
  119279. * This is used to keep meshes transformations so they can be restored
  119280. * when we build back a Babylon Mesh
  119281. * NB : All CSG operations are performed in world coordinates
  119282. * @param csg The CSG to copy the transform attributes from
  119283. * @returns This CSG
  119284. */
  119285. copyTransformAttributes(csg: CSG): CSG;
  119286. /**
  119287. * Build Raw mesh from CSG
  119288. * Coordinates here are in world space
  119289. * @param name The name of the mesh geometry
  119290. * @param scene The Scene
  119291. * @param keepSubMeshes Specifies if the submeshes should be kept
  119292. * @returns A new Mesh
  119293. */
  119294. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  119295. /**
  119296. * Build Mesh from CSG taking material and transforms into account
  119297. * @param name The name of the Mesh
  119298. * @param material The material of the Mesh
  119299. * @param scene The Scene
  119300. * @param keepSubMeshes Specifies if submeshes should be kept
  119301. * @returns The new Mesh
  119302. */
  119303. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  119304. }
  119305. }
  119306. declare module BABYLON {
  119307. /**
  119308. * Class used to create a trail following a mesh
  119309. */
  119310. export class TrailMesh extends Mesh {
  119311. private _generator;
  119312. private _autoStart;
  119313. private _running;
  119314. private _diameter;
  119315. private _length;
  119316. private _sectionPolygonPointsCount;
  119317. private _sectionVectors;
  119318. private _sectionNormalVectors;
  119319. private _beforeRenderObserver;
  119320. /**
  119321. * @constructor
  119322. * @param name The value used by scene.getMeshByName() to do a lookup.
  119323. * @param generator The mesh to generate a trail.
  119324. * @param scene The scene to add this mesh to.
  119325. * @param diameter Diameter of trailing mesh. Default is 1.
  119326. * @param length Length of trailing mesh. Default is 60.
  119327. * @param autoStart Automatically start trailing mesh. Default true.
  119328. */
  119329. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  119330. /**
  119331. * "TrailMesh"
  119332. * @returns "TrailMesh"
  119333. */
  119334. getClassName(): string;
  119335. private _createMesh;
  119336. /**
  119337. * Start trailing mesh.
  119338. */
  119339. start(): void;
  119340. /**
  119341. * Stop trailing mesh.
  119342. */
  119343. stop(): void;
  119344. /**
  119345. * Update trailing mesh geometry.
  119346. */
  119347. update(): void;
  119348. /**
  119349. * Returns a new TrailMesh object.
  119350. * @param name is a string, the name given to the new mesh
  119351. * @param newGenerator use new generator object for cloned trail mesh
  119352. * @returns a new mesh
  119353. */
  119354. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  119355. /**
  119356. * Serializes this trail mesh
  119357. * @param serializationObject object to write serialization to
  119358. */
  119359. serialize(serializationObject: any): void;
  119360. /**
  119361. * Parses a serialized trail mesh
  119362. * @param parsedMesh the serialized mesh
  119363. * @param scene the scene to create the trail mesh in
  119364. * @returns the created trail mesh
  119365. */
  119366. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  119367. }
  119368. }
  119369. declare module BABYLON {
  119370. /**
  119371. * Class containing static functions to help procedurally build meshes
  119372. */
  119373. export class TiledBoxBuilder {
  119374. /**
  119375. * Creates a box mesh
  119376. * 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)
  119377. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  119378. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119379. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119380. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119381. * @param name defines the name of the mesh
  119382. * @param options defines the options used to create the mesh
  119383. * @param scene defines the hosting scene
  119384. * @returns the box mesh
  119385. */
  119386. static CreateTiledBox(name: string, options: {
  119387. pattern?: number;
  119388. width?: number;
  119389. height?: number;
  119390. depth?: number;
  119391. tileSize?: number;
  119392. tileWidth?: number;
  119393. tileHeight?: number;
  119394. alignHorizontal?: number;
  119395. alignVertical?: number;
  119396. faceUV?: Vector4[];
  119397. faceColors?: Color4[];
  119398. sideOrientation?: number;
  119399. updatable?: boolean;
  119400. }, scene?: Nullable<Scene>): Mesh;
  119401. }
  119402. }
  119403. declare module BABYLON {
  119404. /**
  119405. * Class containing static functions to help procedurally build meshes
  119406. */
  119407. export class TorusKnotBuilder {
  119408. /**
  119409. * Creates a torus knot mesh
  119410. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  119411. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  119412. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  119413. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  119414. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119415. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119416. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  119417. * @param name defines the name of the mesh
  119418. * @param options defines the options used to create the mesh
  119419. * @param scene defines the hosting scene
  119420. * @returns the torus knot mesh
  119421. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  119422. */
  119423. static CreateTorusKnot(name: string, options: {
  119424. radius?: number;
  119425. tube?: number;
  119426. radialSegments?: number;
  119427. tubularSegments?: number;
  119428. p?: number;
  119429. q?: number;
  119430. updatable?: boolean;
  119431. sideOrientation?: number;
  119432. frontUVs?: Vector4;
  119433. backUVs?: Vector4;
  119434. }, scene: any): Mesh;
  119435. }
  119436. }
  119437. declare module BABYLON {
  119438. /**
  119439. * Polygon
  119440. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  119441. */
  119442. export class Polygon {
  119443. /**
  119444. * Creates a rectangle
  119445. * @param xmin bottom X coord
  119446. * @param ymin bottom Y coord
  119447. * @param xmax top X coord
  119448. * @param ymax top Y coord
  119449. * @returns points that make the resulting rectation
  119450. */
  119451. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  119452. /**
  119453. * Creates a circle
  119454. * @param radius radius of circle
  119455. * @param cx scale in x
  119456. * @param cy scale in y
  119457. * @param numberOfSides number of sides that make up the circle
  119458. * @returns points that make the resulting circle
  119459. */
  119460. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  119461. /**
  119462. * Creates a polygon from input string
  119463. * @param input Input polygon data
  119464. * @returns the parsed points
  119465. */
  119466. static Parse(input: string): Vector2[];
  119467. /**
  119468. * Starts building a polygon from x and y coordinates
  119469. * @param x x coordinate
  119470. * @param y y coordinate
  119471. * @returns the started path2
  119472. */
  119473. static StartingAt(x: number, y: number): Path2;
  119474. }
  119475. /**
  119476. * Builds a polygon
  119477. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  119478. */
  119479. export class PolygonMeshBuilder {
  119480. private _points;
  119481. private _outlinepoints;
  119482. private _holes;
  119483. private _name;
  119484. private _scene;
  119485. private _epoints;
  119486. private _eholes;
  119487. private _addToepoint;
  119488. /**
  119489. * Babylon reference to the earcut plugin.
  119490. */
  119491. bjsEarcut: any;
  119492. /**
  119493. * Creates a PolygonMeshBuilder
  119494. * @param name name of the builder
  119495. * @param contours Path of the polygon
  119496. * @param scene scene to add to when creating the mesh
  119497. * @param earcutInjection can be used to inject your own earcut reference
  119498. */
  119499. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  119500. /**
  119501. * Adds a whole within the polygon
  119502. * @param hole Array of points defining the hole
  119503. * @returns this
  119504. */
  119505. addHole(hole: Vector2[]): PolygonMeshBuilder;
  119506. /**
  119507. * Creates the polygon
  119508. * @param updatable If the mesh should be updatable
  119509. * @param depth The depth of the mesh created
  119510. * @returns the created mesh
  119511. */
  119512. build(updatable?: boolean, depth?: number): Mesh;
  119513. /**
  119514. * Creates the polygon
  119515. * @param depth The depth of the mesh created
  119516. * @returns the created VertexData
  119517. */
  119518. buildVertexData(depth?: number): VertexData;
  119519. /**
  119520. * Adds a side to the polygon
  119521. * @param positions points that make the polygon
  119522. * @param normals normals of the polygon
  119523. * @param uvs uvs of the polygon
  119524. * @param indices indices of the polygon
  119525. * @param bounds bounds of the polygon
  119526. * @param points points of the polygon
  119527. * @param depth depth of the polygon
  119528. * @param flip flip of the polygon
  119529. */
  119530. private addSide;
  119531. }
  119532. }
  119533. declare module BABYLON {
  119534. /**
  119535. * Class containing static functions to help procedurally build meshes
  119536. */
  119537. export class PolygonBuilder {
  119538. /**
  119539. * Creates a polygon mesh
  119540. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  119541. * * 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
  119542. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  119543. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119544. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  119545. * * Remember you can only change the shape positions, not their number when updating a polygon
  119546. * @param name defines the name of the mesh
  119547. * @param options defines the options used to create the mesh
  119548. * @param scene defines the hosting scene
  119549. * @param earcutInjection can be used to inject your own earcut reference
  119550. * @returns the polygon mesh
  119551. */
  119552. static CreatePolygon(name: string, options: {
  119553. shape: Vector3[];
  119554. holes?: Vector3[][];
  119555. depth?: number;
  119556. faceUV?: Vector4[];
  119557. faceColors?: Color4[];
  119558. updatable?: boolean;
  119559. sideOrientation?: number;
  119560. frontUVs?: Vector4;
  119561. backUVs?: Vector4;
  119562. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  119563. /**
  119564. * Creates an extruded polygon mesh, with depth in the Y direction.
  119565. * * 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)
  119566. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  119567. * @param name defines the name of the mesh
  119568. * @param options defines the options used to create the mesh
  119569. * @param scene defines the hosting scene
  119570. * @param earcutInjection can be used to inject your own earcut reference
  119571. * @returns the polygon mesh
  119572. */
  119573. static ExtrudePolygon(name: string, options: {
  119574. shape: Vector3[];
  119575. holes?: Vector3[][];
  119576. depth?: number;
  119577. faceUV?: Vector4[];
  119578. faceColors?: Color4[];
  119579. updatable?: boolean;
  119580. sideOrientation?: number;
  119581. frontUVs?: Vector4;
  119582. backUVs?: Vector4;
  119583. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  119584. }
  119585. }
  119586. declare module BABYLON {
  119587. /**
  119588. * Class containing static functions to help procedurally build meshes
  119589. */
  119590. export class LatheBuilder {
  119591. /**
  119592. * Creates lathe mesh.
  119593. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  119594. * * 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
  119595. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  119596. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  119597. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  119598. * * 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
  119599. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  119600. * * 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
  119601. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119602. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119603. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  119604. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119605. * @param name defines the name of the mesh
  119606. * @param options defines the options used to create the mesh
  119607. * @param scene defines the hosting scene
  119608. * @returns the lathe mesh
  119609. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  119610. */
  119611. static CreateLathe(name: string, options: {
  119612. shape: Vector3[];
  119613. radius?: number;
  119614. tessellation?: number;
  119615. clip?: number;
  119616. arc?: number;
  119617. closed?: boolean;
  119618. updatable?: boolean;
  119619. sideOrientation?: number;
  119620. frontUVs?: Vector4;
  119621. backUVs?: Vector4;
  119622. cap?: number;
  119623. invertUV?: boolean;
  119624. }, scene?: Nullable<Scene>): Mesh;
  119625. }
  119626. }
  119627. declare module BABYLON {
  119628. /**
  119629. * Class containing static functions to help procedurally build meshes
  119630. */
  119631. export class TiledPlaneBuilder {
  119632. /**
  119633. * Creates a tiled plane mesh
  119634. * * The parameter `pattern` will, depending on value, do nothing or
  119635. * * * flip (reflect about central vertical) alternate tiles across and up
  119636. * * * flip every tile on alternate rows
  119637. * * * rotate (180 degs) alternate tiles across and up
  119638. * * * rotate every tile on alternate rows
  119639. * * * flip and rotate alternate tiles across and up
  119640. * * * flip and rotate every tile on alternate rows
  119641. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  119642. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  119643. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119644. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  119645. * * 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)
  119646. * * 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)
  119647. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  119648. * @param name defines the name of the mesh
  119649. * @param options defines the options used to create the mesh
  119650. * @param scene defines the hosting scene
  119651. * @returns the box mesh
  119652. */
  119653. static CreateTiledPlane(name: string, options: {
  119654. pattern?: number;
  119655. tileSize?: number;
  119656. tileWidth?: number;
  119657. tileHeight?: number;
  119658. size?: number;
  119659. width?: number;
  119660. height?: number;
  119661. alignHorizontal?: number;
  119662. alignVertical?: number;
  119663. sideOrientation?: number;
  119664. frontUVs?: Vector4;
  119665. backUVs?: Vector4;
  119666. updatable?: boolean;
  119667. }, scene?: Nullable<Scene>): Mesh;
  119668. }
  119669. }
  119670. declare module BABYLON {
  119671. /**
  119672. * Class containing static functions to help procedurally build meshes
  119673. */
  119674. export class TubeBuilder {
  119675. /**
  119676. * Creates a tube mesh.
  119677. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  119678. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  119679. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  119680. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  119681. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  119682. * * 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)
  119683. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  119684. * * 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
  119685. * * 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
  119686. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119687. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119688. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  119689. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119690. * @param name defines the name of the mesh
  119691. * @param options defines the options used to create the mesh
  119692. * @param scene defines the hosting scene
  119693. * @returns the tube mesh
  119694. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  119695. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  119696. */
  119697. static CreateTube(name: string, options: {
  119698. path: Vector3[];
  119699. radius?: number;
  119700. tessellation?: number;
  119701. radiusFunction?: {
  119702. (i: number, distance: number): number;
  119703. };
  119704. cap?: number;
  119705. arc?: number;
  119706. updatable?: boolean;
  119707. sideOrientation?: number;
  119708. frontUVs?: Vector4;
  119709. backUVs?: Vector4;
  119710. instance?: Mesh;
  119711. invertUV?: boolean;
  119712. }, scene?: Nullable<Scene>): Mesh;
  119713. }
  119714. }
  119715. declare module BABYLON {
  119716. /**
  119717. * Class containing static functions to help procedurally build meshes
  119718. */
  119719. export class IcoSphereBuilder {
  119720. /**
  119721. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  119722. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  119723. * * 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`)
  119724. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  119725. * * 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
  119726. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119727. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119728. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119729. * @param name defines the name of the mesh
  119730. * @param options defines the options used to create the mesh
  119731. * @param scene defines the hosting scene
  119732. * @returns the icosahedron mesh
  119733. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  119734. */
  119735. static CreateIcoSphere(name: string, options: {
  119736. radius?: number;
  119737. radiusX?: number;
  119738. radiusY?: number;
  119739. radiusZ?: number;
  119740. flat?: boolean;
  119741. subdivisions?: number;
  119742. sideOrientation?: number;
  119743. frontUVs?: Vector4;
  119744. backUVs?: Vector4;
  119745. updatable?: boolean;
  119746. }, scene?: Nullable<Scene>): Mesh;
  119747. }
  119748. }
  119749. declare module BABYLON {
  119750. /**
  119751. * Class containing static functions to help procedurally build meshes
  119752. */
  119753. export class DecalBuilder {
  119754. /**
  119755. * Creates a decal mesh.
  119756. * 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
  119757. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  119758. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  119759. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  119760. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  119761. * @param name defines the name of the mesh
  119762. * @param sourceMesh defines the mesh where the decal must be applied
  119763. * @param options defines the options used to create the mesh
  119764. * @param scene defines the hosting scene
  119765. * @returns the decal mesh
  119766. * @see https://doc.babylonjs.com/how_to/decals
  119767. */
  119768. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  119769. position?: Vector3;
  119770. normal?: Vector3;
  119771. size?: Vector3;
  119772. angle?: number;
  119773. }): Mesh;
  119774. }
  119775. }
  119776. declare module BABYLON {
  119777. /**
  119778. * Class containing static functions to help procedurally build meshes
  119779. */
  119780. export class MeshBuilder {
  119781. /**
  119782. * Creates a box mesh
  119783. * * The parameter `size` sets the size (float) of each box side (default 1)
  119784. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  119785. * * 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)
  119786. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  119787. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119788. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119789. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119790. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  119791. * @param name defines the name of the mesh
  119792. * @param options defines the options used to create the mesh
  119793. * @param scene defines the hosting scene
  119794. * @returns the box mesh
  119795. */
  119796. static CreateBox(name: string, options: {
  119797. size?: number;
  119798. width?: number;
  119799. height?: number;
  119800. depth?: number;
  119801. faceUV?: Vector4[];
  119802. faceColors?: Color4[];
  119803. sideOrientation?: number;
  119804. frontUVs?: Vector4;
  119805. backUVs?: Vector4;
  119806. updatable?: boolean;
  119807. }, scene?: Nullable<Scene>): Mesh;
  119808. /**
  119809. * Creates a tiled box mesh
  119810. * * faceTiles sets the pattern, tile size and number of tiles for a face
  119811. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119812. * @param name defines the name of the mesh
  119813. * @param options defines the options used to create the mesh
  119814. * @param scene defines the hosting scene
  119815. * @returns the tiled box mesh
  119816. */
  119817. static CreateTiledBox(name: string, options: {
  119818. pattern?: number;
  119819. size?: number;
  119820. width?: number;
  119821. height?: number;
  119822. depth: number;
  119823. tileSize?: number;
  119824. tileWidth?: number;
  119825. tileHeight?: number;
  119826. faceUV?: Vector4[];
  119827. faceColors?: Color4[];
  119828. alignHorizontal?: number;
  119829. alignVertical?: number;
  119830. sideOrientation?: number;
  119831. updatable?: boolean;
  119832. }, scene?: Nullable<Scene>): Mesh;
  119833. /**
  119834. * Creates a sphere mesh
  119835. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  119836. * * 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`)
  119837. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  119838. * * 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
  119839. * * 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)
  119840. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119841. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119842. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119843. * @param name defines the name of the mesh
  119844. * @param options defines the options used to create the mesh
  119845. * @param scene defines the hosting scene
  119846. * @returns the sphere mesh
  119847. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  119848. */
  119849. static CreateSphere(name: string, options: {
  119850. segments?: number;
  119851. diameter?: number;
  119852. diameterX?: number;
  119853. diameterY?: number;
  119854. diameterZ?: number;
  119855. arc?: number;
  119856. slice?: number;
  119857. sideOrientation?: number;
  119858. frontUVs?: Vector4;
  119859. backUVs?: Vector4;
  119860. updatable?: boolean;
  119861. }, scene?: Nullable<Scene>): Mesh;
  119862. /**
  119863. * Creates a plane polygonal mesh. By default, this is a disc
  119864. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  119865. * * 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
  119866. * * 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
  119867. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119868. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119869. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119870. * @param name defines the name of the mesh
  119871. * @param options defines the options used to create the mesh
  119872. * @param scene defines the hosting scene
  119873. * @returns the plane polygonal mesh
  119874. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  119875. */
  119876. static CreateDisc(name: string, options: {
  119877. radius?: number;
  119878. tessellation?: number;
  119879. arc?: number;
  119880. updatable?: boolean;
  119881. sideOrientation?: number;
  119882. frontUVs?: Vector4;
  119883. backUVs?: Vector4;
  119884. }, scene?: Nullable<Scene>): Mesh;
  119885. /**
  119886. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  119887. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  119888. * * 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`)
  119889. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  119890. * * 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
  119891. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119892. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119893. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119894. * @param name defines the name of the mesh
  119895. * @param options defines the options used to create the mesh
  119896. * @param scene defines the hosting scene
  119897. * @returns the icosahedron mesh
  119898. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  119899. */
  119900. static CreateIcoSphere(name: string, options: {
  119901. radius?: number;
  119902. radiusX?: number;
  119903. radiusY?: number;
  119904. radiusZ?: number;
  119905. flat?: boolean;
  119906. subdivisions?: number;
  119907. sideOrientation?: number;
  119908. frontUVs?: Vector4;
  119909. backUVs?: Vector4;
  119910. updatable?: boolean;
  119911. }, scene?: Nullable<Scene>): Mesh;
  119912. /**
  119913. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  119914. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  119915. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  119916. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  119917. * * 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
  119918. * * 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
  119919. * * 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
  119920. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119921. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119922. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  119923. * * 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
  119924. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  119925. * * 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
  119926. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  119927. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119928. * @param name defines the name of the mesh
  119929. * @param options defines the options used to create the mesh
  119930. * @param scene defines the hosting scene
  119931. * @returns the ribbon mesh
  119932. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  119933. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  119934. */
  119935. static CreateRibbon(name: string, options: {
  119936. pathArray: Vector3[][];
  119937. closeArray?: boolean;
  119938. closePath?: boolean;
  119939. offset?: number;
  119940. updatable?: boolean;
  119941. sideOrientation?: number;
  119942. frontUVs?: Vector4;
  119943. backUVs?: Vector4;
  119944. instance?: Mesh;
  119945. invertUV?: boolean;
  119946. uvs?: Vector2[];
  119947. colors?: Color4[];
  119948. }, scene?: Nullable<Scene>): Mesh;
  119949. /**
  119950. * Creates a cylinder or a cone mesh
  119951. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  119952. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  119953. * * 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.
  119954. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  119955. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  119956. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  119957. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  119958. * * 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).
  119959. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  119960. * * 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).
  119961. * * 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
  119962. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  119963. * * 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
  119964. * * 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.
  119965. * * If `enclose` is false, a ring surface is one element.
  119966. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  119967. * * 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
  119968. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119969. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119970. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  119971. * @param name defines the name of the mesh
  119972. * @param options defines the options used to create the mesh
  119973. * @param scene defines the hosting scene
  119974. * @returns the cylinder mesh
  119975. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  119976. */
  119977. static CreateCylinder(name: string, options: {
  119978. height?: number;
  119979. diameterTop?: number;
  119980. diameterBottom?: number;
  119981. diameter?: number;
  119982. tessellation?: number;
  119983. subdivisions?: number;
  119984. arc?: number;
  119985. faceColors?: Color4[];
  119986. faceUV?: Vector4[];
  119987. updatable?: boolean;
  119988. hasRings?: boolean;
  119989. enclose?: boolean;
  119990. cap?: number;
  119991. sideOrientation?: number;
  119992. frontUVs?: Vector4;
  119993. backUVs?: Vector4;
  119994. }, scene?: Nullable<Scene>): Mesh;
  119995. /**
  119996. * Creates a torus mesh
  119997. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  119998. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  119999. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  120000. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120001. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120002. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  120003. * @param name defines the name of the mesh
  120004. * @param options defines the options used to create the mesh
  120005. * @param scene defines the hosting scene
  120006. * @returns the torus mesh
  120007. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  120008. */
  120009. static CreateTorus(name: string, options: {
  120010. diameter?: number;
  120011. thickness?: number;
  120012. tessellation?: number;
  120013. updatable?: boolean;
  120014. sideOrientation?: number;
  120015. frontUVs?: Vector4;
  120016. backUVs?: Vector4;
  120017. }, scene?: Nullable<Scene>): Mesh;
  120018. /**
  120019. * Creates a torus knot mesh
  120020. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  120021. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  120022. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  120023. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  120024. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120025. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120026. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  120027. * @param name defines the name of the mesh
  120028. * @param options defines the options used to create the mesh
  120029. * @param scene defines the hosting scene
  120030. * @returns the torus knot mesh
  120031. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  120032. */
  120033. static CreateTorusKnot(name: string, options: {
  120034. radius?: number;
  120035. tube?: number;
  120036. radialSegments?: number;
  120037. tubularSegments?: number;
  120038. p?: number;
  120039. q?: number;
  120040. updatable?: boolean;
  120041. sideOrientation?: number;
  120042. frontUVs?: Vector4;
  120043. backUVs?: Vector4;
  120044. }, scene?: Nullable<Scene>): Mesh;
  120045. /**
  120046. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  120047. * * 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
  120048. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  120049. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  120050. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  120051. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  120052. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  120053. * * 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
  120054. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  120055. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120056. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  120057. * @param name defines the name of the new line system
  120058. * @param options defines the options used to create the line system
  120059. * @param scene defines the hosting scene
  120060. * @returns a new line system mesh
  120061. */
  120062. static CreateLineSystem(name: string, options: {
  120063. lines: Vector3[][];
  120064. updatable?: boolean;
  120065. instance?: Nullable<LinesMesh>;
  120066. colors?: Nullable<Color4[][]>;
  120067. useVertexAlpha?: boolean;
  120068. }, scene: Nullable<Scene>): LinesMesh;
  120069. /**
  120070. * Creates a line mesh
  120071. * 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
  120072. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  120073. * * The parameter `points` is an array successive Vector3
  120074. * * 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
  120075. * * The optional parameter `colors` is an array of successive Color4, one per line point
  120076. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  120077. * * When updating an instance, remember that only point positions can change, not the number of points
  120078. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120079. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  120080. * @param name defines the name of the new line system
  120081. * @param options defines the options used to create the line system
  120082. * @param scene defines the hosting scene
  120083. * @returns a new line mesh
  120084. */
  120085. static CreateLines(name: string, options: {
  120086. points: Vector3[];
  120087. updatable?: boolean;
  120088. instance?: Nullable<LinesMesh>;
  120089. colors?: Color4[];
  120090. useVertexAlpha?: boolean;
  120091. }, scene?: Nullable<Scene>): LinesMesh;
  120092. /**
  120093. * Creates a dashed line mesh
  120094. * * 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
  120095. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  120096. * * The parameter `points` is an array successive Vector3
  120097. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  120098. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  120099. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  120100. * * 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
  120101. * * When updating an instance, remember that only point positions can change, not the number of points
  120102. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120103. * @param name defines the name of the mesh
  120104. * @param options defines the options used to create the mesh
  120105. * @param scene defines the hosting scene
  120106. * @returns the dashed line mesh
  120107. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  120108. */
  120109. static CreateDashedLines(name: string, options: {
  120110. points: Vector3[];
  120111. dashSize?: number;
  120112. gapSize?: number;
  120113. dashNb?: number;
  120114. updatable?: boolean;
  120115. instance?: LinesMesh;
  120116. }, scene?: Nullable<Scene>): LinesMesh;
  120117. /**
  120118. * 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.
  120119. * * 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.
  120120. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  120121. * * 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.
  120122. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  120123. * * 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
  120124. * * 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
  120125. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  120126. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120127. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120128. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  120129. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  120130. * @param name defines the name of the mesh
  120131. * @param options defines the options used to create the mesh
  120132. * @param scene defines the hosting scene
  120133. * @returns the extruded shape mesh
  120134. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  120135. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  120136. */
  120137. static ExtrudeShape(name: string, options: {
  120138. shape: Vector3[];
  120139. path: Vector3[];
  120140. scale?: number;
  120141. rotation?: number;
  120142. cap?: number;
  120143. updatable?: boolean;
  120144. sideOrientation?: number;
  120145. frontUVs?: Vector4;
  120146. backUVs?: Vector4;
  120147. instance?: Mesh;
  120148. invertUV?: boolean;
  120149. }, scene?: Nullable<Scene>): Mesh;
  120150. /**
  120151. * Creates an custom extruded shape mesh.
  120152. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  120153. * * 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.
  120154. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  120155. * * 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
  120156. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  120157. * * 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
  120158. * * It must returns a float value that will be the scale value applied to the shape on each path point
  120159. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  120160. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  120161. * * 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
  120162. * * 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
  120163. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  120164. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120165. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120166. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  120167. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120168. * @param name defines the name of the mesh
  120169. * @param options defines the options used to create the mesh
  120170. * @param scene defines the hosting scene
  120171. * @returns the custom extruded shape mesh
  120172. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  120173. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  120174. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  120175. */
  120176. static ExtrudeShapeCustom(name: string, options: {
  120177. shape: Vector3[];
  120178. path: Vector3[];
  120179. scaleFunction?: any;
  120180. rotationFunction?: any;
  120181. ribbonCloseArray?: boolean;
  120182. ribbonClosePath?: boolean;
  120183. cap?: number;
  120184. updatable?: boolean;
  120185. sideOrientation?: number;
  120186. frontUVs?: Vector4;
  120187. backUVs?: Vector4;
  120188. instance?: Mesh;
  120189. invertUV?: boolean;
  120190. }, scene?: Nullable<Scene>): Mesh;
  120191. /**
  120192. * Creates lathe mesh.
  120193. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  120194. * * 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
  120195. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  120196. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  120197. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  120198. * * 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
  120199. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  120200. * * 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
  120201. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120202. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120203. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  120204. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120205. * @param name defines the name of the mesh
  120206. * @param options defines the options used to create the mesh
  120207. * @param scene defines the hosting scene
  120208. * @returns the lathe mesh
  120209. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  120210. */
  120211. static CreateLathe(name: string, options: {
  120212. shape: Vector3[];
  120213. radius?: number;
  120214. tessellation?: number;
  120215. clip?: number;
  120216. arc?: number;
  120217. closed?: boolean;
  120218. updatable?: boolean;
  120219. sideOrientation?: number;
  120220. frontUVs?: Vector4;
  120221. backUVs?: Vector4;
  120222. cap?: number;
  120223. invertUV?: boolean;
  120224. }, scene?: Nullable<Scene>): Mesh;
  120225. /**
  120226. * Creates a tiled plane mesh
  120227. * * You can set a limited pattern arrangement with the tiles
  120228. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120229. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120230. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120231. * @param name defines the name of the mesh
  120232. * @param options defines the options used to create the mesh
  120233. * @param scene defines the hosting scene
  120234. * @returns the plane mesh
  120235. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  120236. */
  120237. static CreateTiledPlane(name: string, options: {
  120238. pattern?: number;
  120239. tileSize?: number;
  120240. tileWidth?: number;
  120241. tileHeight?: number;
  120242. size?: number;
  120243. width?: number;
  120244. height?: number;
  120245. alignHorizontal?: number;
  120246. alignVertical?: number;
  120247. sideOrientation?: number;
  120248. frontUVs?: Vector4;
  120249. backUVs?: Vector4;
  120250. updatable?: boolean;
  120251. }, scene?: Nullable<Scene>): Mesh;
  120252. /**
  120253. * Creates a plane mesh
  120254. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  120255. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  120256. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  120257. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120258. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120259. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120260. * @param name defines the name of the mesh
  120261. * @param options defines the options used to create the mesh
  120262. * @param scene defines the hosting scene
  120263. * @returns the plane mesh
  120264. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  120265. */
  120266. static CreatePlane(name: string, options: {
  120267. size?: number;
  120268. width?: number;
  120269. height?: number;
  120270. sideOrientation?: number;
  120271. frontUVs?: Vector4;
  120272. backUVs?: Vector4;
  120273. updatable?: boolean;
  120274. sourcePlane?: Plane;
  120275. }, scene?: Nullable<Scene>): Mesh;
  120276. /**
  120277. * Creates a ground mesh
  120278. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  120279. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  120280. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120281. * @param name defines the name of the mesh
  120282. * @param options defines the options used to create the mesh
  120283. * @param scene defines the hosting scene
  120284. * @returns the ground mesh
  120285. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  120286. */
  120287. static CreateGround(name: string, options: {
  120288. width?: number;
  120289. height?: number;
  120290. subdivisions?: number;
  120291. subdivisionsX?: number;
  120292. subdivisionsY?: number;
  120293. updatable?: boolean;
  120294. }, scene?: Nullable<Scene>): Mesh;
  120295. /**
  120296. * Creates a tiled ground mesh
  120297. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  120298. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  120299. * * 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
  120300. * * 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
  120301. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  120302. * @param name defines the name of the mesh
  120303. * @param options defines the options used to create the mesh
  120304. * @param scene defines the hosting scene
  120305. * @returns the tiled ground mesh
  120306. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  120307. */
  120308. static CreateTiledGround(name: string, options: {
  120309. xmin: number;
  120310. zmin: number;
  120311. xmax: number;
  120312. zmax: number;
  120313. subdivisions?: {
  120314. w: number;
  120315. h: number;
  120316. };
  120317. precision?: {
  120318. w: number;
  120319. h: number;
  120320. };
  120321. updatable?: boolean;
  120322. }, scene?: Nullable<Scene>): Mesh;
  120323. /**
  120324. * Creates a ground mesh from a height map
  120325. * * The parameter `url` sets the URL of the height map image resource.
  120326. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  120327. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  120328. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  120329. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  120330. * * 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.
  120331. * * 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).
  120332. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  120333. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  120334. * @param name defines the name of the mesh
  120335. * @param url defines the url to the height map
  120336. * @param options defines the options used to create the mesh
  120337. * @param scene defines the hosting scene
  120338. * @returns the ground mesh
  120339. * @see https://doc.babylonjs.com/babylon101/height_map
  120340. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  120341. */
  120342. static CreateGroundFromHeightMap(name: string, url: string, options: {
  120343. width?: number;
  120344. height?: number;
  120345. subdivisions?: number;
  120346. minHeight?: number;
  120347. maxHeight?: number;
  120348. colorFilter?: Color3;
  120349. alphaFilter?: number;
  120350. updatable?: boolean;
  120351. onReady?: (mesh: GroundMesh) => void;
  120352. }, scene?: Nullable<Scene>): GroundMesh;
  120353. /**
  120354. * Creates a polygon mesh
  120355. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  120356. * * 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
  120357. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  120358. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120359. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  120360. * * Remember you can only change the shape positions, not their number when updating a polygon
  120361. * @param name defines the name of the mesh
  120362. * @param options defines the options used to create the mesh
  120363. * @param scene defines the hosting scene
  120364. * @param earcutInjection can be used to inject your own earcut reference
  120365. * @returns the polygon mesh
  120366. */
  120367. static CreatePolygon(name: string, options: {
  120368. shape: Vector3[];
  120369. holes?: Vector3[][];
  120370. depth?: number;
  120371. faceUV?: Vector4[];
  120372. faceColors?: Color4[];
  120373. updatable?: boolean;
  120374. sideOrientation?: number;
  120375. frontUVs?: Vector4;
  120376. backUVs?: Vector4;
  120377. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  120378. /**
  120379. * Creates an extruded polygon mesh, with depth in the Y direction.
  120380. * * 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)
  120381. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  120382. * @param name defines the name of the mesh
  120383. * @param options defines the options used to create the mesh
  120384. * @param scene defines the hosting scene
  120385. * @param earcutInjection can be used to inject your own earcut reference
  120386. * @returns the polygon mesh
  120387. */
  120388. static ExtrudePolygon(name: string, options: {
  120389. shape: Vector3[];
  120390. holes?: Vector3[][];
  120391. depth?: number;
  120392. faceUV?: Vector4[];
  120393. faceColors?: Color4[];
  120394. updatable?: boolean;
  120395. sideOrientation?: number;
  120396. frontUVs?: Vector4;
  120397. backUVs?: Vector4;
  120398. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  120399. /**
  120400. * Creates a tube mesh.
  120401. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  120402. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  120403. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  120404. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  120405. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  120406. * * 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)
  120407. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  120408. * * 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
  120409. * * 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
  120410. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120411. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120412. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  120413. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120414. * @param name defines the name of the mesh
  120415. * @param options defines the options used to create the mesh
  120416. * @param scene defines the hosting scene
  120417. * @returns the tube mesh
  120418. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  120419. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  120420. */
  120421. static CreateTube(name: string, options: {
  120422. path: Vector3[];
  120423. radius?: number;
  120424. tessellation?: number;
  120425. radiusFunction?: {
  120426. (i: number, distance: number): number;
  120427. };
  120428. cap?: number;
  120429. arc?: number;
  120430. updatable?: boolean;
  120431. sideOrientation?: number;
  120432. frontUVs?: Vector4;
  120433. backUVs?: Vector4;
  120434. instance?: Mesh;
  120435. invertUV?: boolean;
  120436. }, scene?: Nullable<Scene>): Mesh;
  120437. /**
  120438. * Creates a polyhedron mesh
  120439. * * 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
  120440. * * The parameter `size` (positive float, default 1) sets the polygon size
  120441. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  120442. * * 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`
  120443. * * 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
  120444. * * 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)`)
  120445. * * 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
  120446. * * 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
  120447. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120448. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120449. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120450. * @param name defines the name of the mesh
  120451. * @param options defines the options used to create the mesh
  120452. * @param scene defines the hosting scene
  120453. * @returns the polyhedron mesh
  120454. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  120455. */
  120456. static CreatePolyhedron(name: string, options: {
  120457. type?: number;
  120458. size?: number;
  120459. sizeX?: number;
  120460. sizeY?: number;
  120461. sizeZ?: number;
  120462. custom?: any;
  120463. faceUV?: Vector4[];
  120464. faceColors?: Color4[];
  120465. flat?: boolean;
  120466. updatable?: boolean;
  120467. sideOrientation?: number;
  120468. frontUVs?: Vector4;
  120469. backUVs?: Vector4;
  120470. }, scene?: Nullable<Scene>): Mesh;
  120471. /**
  120472. * Creates a decal mesh.
  120473. * 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
  120474. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  120475. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  120476. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  120477. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  120478. * @param name defines the name of the mesh
  120479. * @param sourceMesh defines the mesh where the decal must be applied
  120480. * @param options defines the options used to create the mesh
  120481. * @param scene defines the hosting scene
  120482. * @returns the decal mesh
  120483. * @see https://doc.babylonjs.com/how_to/decals
  120484. */
  120485. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  120486. position?: Vector3;
  120487. normal?: Vector3;
  120488. size?: Vector3;
  120489. angle?: number;
  120490. }): Mesh;
  120491. }
  120492. }
  120493. declare module BABYLON {
  120494. /**
  120495. * A simplifier interface for future simplification implementations
  120496. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  120497. */
  120498. export interface ISimplifier {
  120499. /**
  120500. * Simplification of a given mesh according to the given settings.
  120501. * Since this requires computation, it is assumed that the function runs async.
  120502. * @param settings The settings of the simplification, including quality and distance
  120503. * @param successCallback A callback that will be called after the mesh was simplified.
  120504. * @param errorCallback in case of an error, this callback will be called. optional.
  120505. */
  120506. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  120507. }
  120508. /**
  120509. * Expected simplification settings.
  120510. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  120511. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  120512. */
  120513. export interface ISimplificationSettings {
  120514. /**
  120515. * Gets or sets the expected quality
  120516. */
  120517. quality: number;
  120518. /**
  120519. * Gets or sets the distance when this optimized version should be used
  120520. */
  120521. distance: number;
  120522. /**
  120523. * Gets an already optimized mesh
  120524. */
  120525. optimizeMesh?: boolean;
  120526. }
  120527. /**
  120528. * Class used to specify simplification options
  120529. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  120530. */
  120531. export class SimplificationSettings implements ISimplificationSettings {
  120532. /** expected quality */
  120533. quality: number;
  120534. /** distance when this optimized version should be used */
  120535. distance: number;
  120536. /** already optimized mesh */
  120537. optimizeMesh?: boolean | undefined;
  120538. /**
  120539. * Creates a SimplificationSettings
  120540. * @param quality expected quality
  120541. * @param distance distance when this optimized version should be used
  120542. * @param optimizeMesh already optimized mesh
  120543. */
  120544. constructor(
  120545. /** expected quality */
  120546. quality: number,
  120547. /** distance when this optimized version should be used */
  120548. distance: number,
  120549. /** already optimized mesh */
  120550. optimizeMesh?: boolean | undefined);
  120551. }
  120552. /**
  120553. * Interface used to define a simplification task
  120554. */
  120555. export interface ISimplificationTask {
  120556. /**
  120557. * Array of settings
  120558. */
  120559. settings: Array<ISimplificationSettings>;
  120560. /**
  120561. * Simplification type
  120562. */
  120563. simplificationType: SimplificationType;
  120564. /**
  120565. * Mesh to simplify
  120566. */
  120567. mesh: Mesh;
  120568. /**
  120569. * Callback called on success
  120570. */
  120571. successCallback?: () => void;
  120572. /**
  120573. * Defines if parallel processing can be used
  120574. */
  120575. parallelProcessing: boolean;
  120576. }
  120577. /**
  120578. * Queue used to order the simplification tasks
  120579. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  120580. */
  120581. export class SimplificationQueue {
  120582. private _simplificationArray;
  120583. /**
  120584. * Gets a boolean indicating that the process is still running
  120585. */
  120586. running: boolean;
  120587. /**
  120588. * Creates a new queue
  120589. */
  120590. constructor();
  120591. /**
  120592. * Adds a new simplification task
  120593. * @param task defines a task to add
  120594. */
  120595. addTask(task: ISimplificationTask): void;
  120596. /**
  120597. * Execute next task
  120598. */
  120599. executeNext(): void;
  120600. /**
  120601. * Execute a simplification task
  120602. * @param task defines the task to run
  120603. */
  120604. runSimplification(task: ISimplificationTask): void;
  120605. private getSimplifier;
  120606. }
  120607. /**
  120608. * The implemented types of simplification
  120609. * At the moment only Quadratic Error Decimation is implemented
  120610. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  120611. */
  120612. export enum SimplificationType {
  120613. /** Quadratic error decimation */
  120614. QUADRATIC = 0
  120615. }
  120616. }
  120617. declare module BABYLON {
  120618. interface Scene {
  120619. /** @hidden (Backing field) */
  120620. _simplificationQueue: SimplificationQueue;
  120621. /**
  120622. * Gets or sets the simplification queue attached to the scene
  120623. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  120624. */
  120625. simplificationQueue: SimplificationQueue;
  120626. }
  120627. interface Mesh {
  120628. /**
  120629. * Simplify the mesh according to the given array of settings.
  120630. * Function will return immediately and will simplify async
  120631. * @param settings a collection of simplification settings
  120632. * @param parallelProcessing should all levels calculate parallel or one after the other
  120633. * @param simplificationType the type of simplification to run
  120634. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  120635. * @returns the current mesh
  120636. */
  120637. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  120638. }
  120639. /**
  120640. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  120641. * created in a scene
  120642. */
  120643. export class SimplicationQueueSceneComponent implements ISceneComponent {
  120644. /**
  120645. * The component name helpfull to identify the component in the list of scene components.
  120646. */
  120647. readonly name: string;
  120648. /**
  120649. * The scene the component belongs to.
  120650. */
  120651. scene: Scene;
  120652. /**
  120653. * Creates a new instance of the component for the given scene
  120654. * @param scene Defines the scene to register the component in
  120655. */
  120656. constructor(scene: Scene);
  120657. /**
  120658. * Registers the component in a given scene
  120659. */
  120660. register(): void;
  120661. /**
  120662. * Rebuilds the elements related to this component in case of
  120663. * context lost for instance.
  120664. */
  120665. rebuild(): void;
  120666. /**
  120667. * Disposes the component and the associated ressources
  120668. */
  120669. dispose(): void;
  120670. private _beforeCameraUpdate;
  120671. }
  120672. }
  120673. declare module BABYLON {
  120674. /**
  120675. * Navigation plugin interface to add navigation constrained by a navigation mesh
  120676. */
  120677. export interface INavigationEnginePlugin {
  120678. /**
  120679. * plugin name
  120680. */
  120681. name: string;
  120682. /**
  120683. * Creates a navigation mesh
  120684. * @param meshes array of all the geometry used to compute the navigatio mesh
  120685. * @param parameters bunch of parameters used to filter geometry
  120686. */
  120687. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  120688. /**
  120689. * Create a navigation mesh debug mesh
  120690. * @param scene is where the mesh will be added
  120691. * @returns debug display mesh
  120692. */
  120693. createDebugNavMesh(scene: Scene): Mesh;
  120694. /**
  120695. * Get a navigation mesh constrained position, closest to the parameter position
  120696. * @param position world position
  120697. * @returns the closest point to position constrained by the navigation mesh
  120698. */
  120699. getClosestPoint(position: Vector3): Vector3;
  120700. /**
  120701. * Get a navigation mesh constrained position, within a particular radius
  120702. * @param position world position
  120703. * @param maxRadius the maximum distance to the constrained world position
  120704. * @returns the closest point to position constrained by the navigation mesh
  120705. */
  120706. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  120707. /**
  120708. * Compute the final position from a segment made of destination-position
  120709. * @param position world position
  120710. * @param destination world position
  120711. * @returns the resulting point along the navmesh
  120712. */
  120713. moveAlong(position: Vector3, destination: Vector3): Vector3;
  120714. /**
  120715. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  120716. * @param start world position
  120717. * @param end world position
  120718. * @returns array containing world position composing the path
  120719. */
  120720. computePath(start: Vector3, end: Vector3): Vector3[];
  120721. /**
  120722. * If this plugin is supported
  120723. * @returns true if plugin is supported
  120724. */
  120725. isSupported(): boolean;
  120726. /**
  120727. * Create a new Crowd so you can add agents
  120728. * @param maxAgents the maximum agent count in the crowd
  120729. * @param maxAgentRadius the maximum radius an agent can have
  120730. * @param scene to attach the crowd to
  120731. * @returns the crowd you can add agents to
  120732. */
  120733. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  120734. /**
  120735. * Release all resources
  120736. */
  120737. dispose(): void;
  120738. }
  120739. /**
  120740. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  120741. */
  120742. export interface ICrowd {
  120743. /**
  120744. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  120745. * You can attach anything to that node. The node position is updated in the scene update tick.
  120746. * @param pos world position that will be constrained by the navigation mesh
  120747. * @param parameters agent parameters
  120748. * @param transform hooked to the agent that will be update by the scene
  120749. * @returns agent index
  120750. */
  120751. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  120752. /**
  120753. * Returns the agent position in world space
  120754. * @param index agent index returned by addAgent
  120755. * @returns world space position
  120756. */
  120757. getAgentPosition(index: number): Vector3;
  120758. /**
  120759. * Gets the agent velocity in world space
  120760. * @param index agent index returned by addAgent
  120761. * @returns world space velocity
  120762. */
  120763. getAgentVelocity(index: number): Vector3;
  120764. /**
  120765. * remove a particular agent previously created
  120766. * @param index agent index returned by addAgent
  120767. */
  120768. removeAgent(index: number): void;
  120769. /**
  120770. * get the list of all agents attached to this crowd
  120771. * @returns list of agent indices
  120772. */
  120773. getAgents(): number[];
  120774. /**
  120775. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  120776. * @param deltaTime in seconds
  120777. */
  120778. update(deltaTime: number): void;
  120779. /**
  120780. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  120781. * @param index agent index returned by addAgent
  120782. * @param destination targeted world position
  120783. */
  120784. agentGoto(index: number, destination: Vector3): void;
  120785. /**
  120786. * Release all resources
  120787. */
  120788. dispose(): void;
  120789. }
  120790. /**
  120791. * Configures an agent
  120792. */
  120793. export interface IAgentParameters {
  120794. /**
  120795. * Agent radius. [Limit: >= 0]
  120796. */
  120797. radius: number;
  120798. /**
  120799. * Agent height. [Limit: > 0]
  120800. */
  120801. height: number;
  120802. /**
  120803. * Maximum allowed acceleration. [Limit: >= 0]
  120804. */
  120805. maxAcceleration: number;
  120806. /**
  120807. * Maximum allowed speed. [Limit: >= 0]
  120808. */
  120809. maxSpeed: number;
  120810. /**
  120811. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  120812. */
  120813. collisionQueryRange: number;
  120814. /**
  120815. * The path visibility optimization range. [Limit: > 0]
  120816. */
  120817. pathOptimizationRange: number;
  120818. /**
  120819. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  120820. */
  120821. separationWeight: number;
  120822. }
  120823. /**
  120824. * Configures the navigation mesh creation
  120825. */
  120826. export interface INavMeshParameters {
  120827. /**
  120828. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  120829. */
  120830. cs: number;
  120831. /**
  120832. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  120833. */
  120834. ch: number;
  120835. /**
  120836. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  120837. */
  120838. walkableSlopeAngle: number;
  120839. /**
  120840. * Minimum floor to 'ceiling' height that will still allow the floor area to
  120841. * be considered walkable. [Limit: >= 3] [Units: vx]
  120842. */
  120843. walkableHeight: number;
  120844. /**
  120845. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  120846. */
  120847. walkableClimb: number;
  120848. /**
  120849. * The distance to erode/shrink the walkable area of the heightfield away from
  120850. * obstructions. [Limit: >=0] [Units: vx]
  120851. */
  120852. walkableRadius: number;
  120853. /**
  120854. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  120855. */
  120856. maxEdgeLen: number;
  120857. /**
  120858. * The maximum distance a simplfied contour's border edges should deviate
  120859. * the original raw contour. [Limit: >=0] [Units: vx]
  120860. */
  120861. maxSimplificationError: number;
  120862. /**
  120863. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  120864. */
  120865. minRegionArea: number;
  120866. /**
  120867. * Any regions with a span count smaller than this value will, if possible,
  120868. * be merged with larger regions. [Limit: >=0] [Units: vx]
  120869. */
  120870. mergeRegionArea: number;
  120871. /**
  120872. * The maximum number of vertices allowed for polygons generated during the
  120873. * contour to polygon conversion process. [Limit: >= 3]
  120874. */
  120875. maxVertsPerPoly: number;
  120876. /**
  120877. * Sets the sampling distance to use when generating the detail mesh.
  120878. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  120879. */
  120880. detailSampleDist: number;
  120881. /**
  120882. * The maximum distance the detail mesh surface should deviate from heightfield
  120883. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  120884. */
  120885. detailSampleMaxError: number;
  120886. }
  120887. }
  120888. declare module BABYLON {
  120889. /**
  120890. * RecastJS navigation plugin
  120891. */
  120892. export class RecastJSPlugin implements INavigationEnginePlugin {
  120893. /**
  120894. * Reference to the Recast library
  120895. */
  120896. bjsRECAST: any;
  120897. /**
  120898. * plugin name
  120899. */
  120900. name: string;
  120901. /**
  120902. * the first navmesh created. We might extend this to support multiple navmeshes
  120903. */
  120904. navMesh: any;
  120905. /**
  120906. * Initializes the recastJS plugin
  120907. * @param recastInjection can be used to inject your own recast reference
  120908. */
  120909. constructor(recastInjection?: any);
  120910. /**
  120911. * Creates a navigation mesh
  120912. * @param meshes array of all the geometry used to compute the navigatio mesh
  120913. * @param parameters bunch of parameters used to filter geometry
  120914. */
  120915. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  120916. /**
  120917. * Create a navigation mesh debug mesh
  120918. * @param scene is where the mesh will be added
  120919. * @returns debug display mesh
  120920. */
  120921. createDebugNavMesh(scene: Scene): Mesh;
  120922. /**
  120923. * Get a navigation mesh constrained position, closest to the parameter position
  120924. * @param position world position
  120925. * @returns the closest point to position constrained by the navigation mesh
  120926. */
  120927. getClosestPoint(position: Vector3): Vector3;
  120928. /**
  120929. * Get a navigation mesh constrained position, within a particular radius
  120930. * @param position world position
  120931. * @param maxRadius the maximum distance to the constrained world position
  120932. * @returns the closest point to position constrained by the navigation mesh
  120933. */
  120934. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  120935. /**
  120936. * Compute the final position from a segment made of destination-position
  120937. * @param position world position
  120938. * @param destination world position
  120939. * @returns the resulting point along the navmesh
  120940. */
  120941. moveAlong(position: Vector3, destination: Vector3): Vector3;
  120942. /**
  120943. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  120944. * @param start world position
  120945. * @param end world position
  120946. * @returns array containing world position composing the path
  120947. */
  120948. computePath(start: Vector3, end: Vector3): Vector3[];
  120949. /**
  120950. * Create a new Crowd so you can add agents
  120951. * @param maxAgents the maximum agent count in the crowd
  120952. * @param maxAgentRadius the maximum radius an agent can have
  120953. * @param scene to attach the crowd to
  120954. * @returns the crowd you can add agents to
  120955. */
  120956. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  120957. /**
  120958. * Disposes
  120959. */
  120960. dispose(): void;
  120961. /**
  120962. * If this plugin is supported
  120963. * @returns true if plugin is supported
  120964. */
  120965. isSupported(): boolean;
  120966. }
  120967. /**
  120968. * Recast detour crowd implementation
  120969. */
  120970. export class RecastJSCrowd implements ICrowd {
  120971. /**
  120972. * Recast/detour plugin
  120973. */
  120974. bjsRECASTPlugin: RecastJSPlugin;
  120975. /**
  120976. * Link to the detour crowd
  120977. */
  120978. recastCrowd: any;
  120979. /**
  120980. * One transform per agent
  120981. */
  120982. transforms: TransformNode[];
  120983. /**
  120984. * All agents created
  120985. */
  120986. agents: number[];
  120987. /**
  120988. * Link to the scene is kept to unregister the crowd from the scene
  120989. */
  120990. private _scene;
  120991. /**
  120992. * Observer for crowd updates
  120993. */
  120994. private _onBeforeAnimationsObserver;
  120995. /**
  120996. * Constructor
  120997. * @param plugin recastJS plugin
  120998. * @param maxAgents the maximum agent count in the crowd
  120999. * @param maxAgentRadius the maximum radius an agent can have
  121000. * @param scene to attach the crowd to
  121001. * @returns the crowd you can add agents to
  121002. */
  121003. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  121004. /**
  121005. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  121006. * You can attach anything to that node. The node position is updated in the scene update tick.
  121007. * @param pos world position that will be constrained by the navigation mesh
  121008. * @param parameters agent parameters
  121009. * @param transform hooked to the agent that will be update by the scene
  121010. * @returns agent index
  121011. */
  121012. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  121013. /**
  121014. * Returns the agent position in world space
  121015. * @param index agent index returned by addAgent
  121016. * @returns world space position
  121017. */
  121018. getAgentPosition(index: number): Vector3;
  121019. /**
  121020. * Returns the agent velocity in world space
  121021. * @param index agent index returned by addAgent
  121022. * @returns world space velocity
  121023. */
  121024. getAgentVelocity(index: number): Vector3;
  121025. /**
  121026. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  121027. * @param index agent index returned by addAgent
  121028. * @param destination targeted world position
  121029. */
  121030. agentGoto(index: number, destination: Vector3): void;
  121031. /**
  121032. * remove a particular agent previously created
  121033. * @param index agent index returned by addAgent
  121034. */
  121035. removeAgent(index: number): void;
  121036. /**
  121037. * get the list of all agents attached to this crowd
  121038. * @returns list of agent indices
  121039. */
  121040. getAgents(): number[];
  121041. /**
  121042. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  121043. * @param deltaTime in seconds
  121044. */
  121045. update(deltaTime: number): void;
  121046. /**
  121047. * Release all resources
  121048. */
  121049. dispose(): void;
  121050. }
  121051. }
  121052. declare module BABYLON {
  121053. /**
  121054. * Class used to enable access to IndexedDB
  121055. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  121056. */
  121057. export class Database implements IOfflineProvider {
  121058. private _callbackManifestChecked;
  121059. private _currentSceneUrl;
  121060. private _db;
  121061. private _enableSceneOffline;
  121062. private _enableTexturesOffline;
  121063. private _manifestVersionFound;
  121064. private _mustUpdateRessources;
  121065. private _hasReachedQuota;
  121066. private _isSupported;
  121067. private _idbFactory;
  121068. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  121069. private static IsUASupportingBlobStorage;
  121070. /**
  121071. * Gets a boolean indicating if Database storate is enabled (off by default)
  121072. */
  121073. static IDBStorageEnabled: boolean;
  121074. /**
  121075. * Gets a boolean indicating if scene must be saved in the database
  121076. */
  121077. readonly enableSceneOffline: boolean;
  121078. /**
  121079. * Gets a boolean indicating if textures must be saved in the database
  121080. */
  121081. readonly enableTexturesOffline: boolean;
  121082. /**
  121083. * Creates a new Database
  121084. * @param urlToScene defines the url to load the scene
  121085. * @param callbackManifestChecked defines the callback to use when manifest is checked
  121086. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  121087. */
  121088. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  121089. private static _ParseURL;
  121090. private static _ReturnFullUrlLocation;
  121091. private _checkManifestFile;
  121092. /**
  121093. * Open the database and make it available
  121094. * @param successCallback defines the callback to call on success
  121095. * @param errorCallback defines the callback to call on error
  121096. */
  121097. open(successCallback: () => void, errorCallback: () => void): void;
  121098. /**
  121099. * Loads an image from the database
  121100. * @param url defines the url to load from
  121101. * @param image defines the target DOM image
  121102. */
  121103. loadImage(url: string, image: HTMLImageElement): void;
  121104. private _loadImageFromDBAsync;
  121105. private _saveImageIntoDBAsync;
  121106. private _checkVersionFromDB;
  121107. private _loadVersionFromDBAsync;
  121108. private _saveVersionIntoDBAsync;
  121109. /**
  121110. * Loads a file from database
  121111. * @param url defines the URL to load from
  121112. * @param sceneLoaded defines a callback to call on success
  121113. * @param progressCallBack defines a callback to call when progress changed
  121114. * @param errorCallback defines a callback to call on error
  121115. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  121116. */
  121117. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  121118. private _loadFileAsync;
  121119. private _saveFileAsync;
  121120. /**
  121121. * Validates if xhr data is correct
  121122. * @param xhr defines the request to validate
  121123. * @param dataType defines the expected data type
  121124. * @returns true if data is correct
  121125. */
  121126. private static _ValidateXHRData;
  121127. }
  121128. }
  121129. declare module BABYLON {
  121130. /** @hidden */
  121131. export var gpuUpdateParticlesPixelShader: {
  121132. name: string;
  121133. shader: string;
  121134. };
  121135. }
  121136. declare module BABYLON {
  121137. /** @hidden */
  121138. export var gpuUpdateParticlesVertexShader: {
  121139. name: string;
  121140. shader: string;
  121141. };
  121142. }
  121143. declare module BABYLON {
  121144. /** @hidden */
  121145. export var clipPlaneFragmentDeclaration2: {
  121146. name: string;
  121147. shader: string;
  121148. };
  121149. }
  121150. declare module BABYLON {
  121151. /** @hidden */
  121152. export var gpuRenderParticlesPixelShader: {
  121153. name: string;
  121154. shader: string;
  121155. };
  121156. }
  121157. declare module BABYLON {
  121158. /** @hidden */
  121159. export var clipPlaneVertexDeclaration2: {
  121160. name: string;
  121161. shader: string;
  121162. };
  121163. }
  121164. declare module BABYLON {
  121165. /** @hidden */
  121166. export var gpuRenderParticlesVertexShader: {
  121167. name: string;
  121168. shader: string;
  121169. };
  121170. }
  121171. declare module BABYLON {
  121172. /**
  121173. * This represents a GPU particle system in Babylon
  121174. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  121175. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  121176. */
  121177. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  121178. /**
  121179. * The layer mask we are rendering the particles through.
  121180. */
  121181. layerMask: number;
  121182. private _capacity;
  121183. private _activeCount;
  121184. private _currentActiveCount;
  121185. private _accumulatedCount;
  121186. private _renderEffect;
  121187. private _updateEffect;
  121188. private _buffer0;
  121189. private _buffer1;
  121190. private _spriteBuffer;
  121191. private _updateVAO;
  121192. private _renderVAO;
  121193. private _targetIndex;
  121194. private _sourceBuffer;
  121195. private _targetBuffer;
  121196. private _engine;
  121197. private _currentRenderId;
  121198. private _started;
  121199. private _stopped;
  121200. private _timeDelta;
  121201. private _randomTexture;
  121202. private _randomTexture2;
  121203. private _attributesStrideSize;
  121204. private _updateEffectOptions;
  121205. private _randomTextureSize;
  121206. private _actualFrame;
  121207. private readonly _rawTextureWidth;
  121208. /**
  121209. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  121210. */
  121211. static readonly IsSupported: boolean;
  121212. /**
  121213. * An event triggered when the system is disposed.
  121214. */
  121215. onDisposeObservable: Observable<GPUParticleSystem>;
  121216. /**
  121217. * Gets the maximum number of particles active at the same time.
  121218. * @returns The max number of active particles.
  121219. */
  121220. getCapacity(): number;
  121221. /**
  121222. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  121223. * to override the particles.
  121224. */
  121225. forceDepthWrite: boolean;
  121226. /**
  121227. * Gets or set the number of active particles
  121228. */
  121229. activeParticleCount: number;
  121230. private _preWarmDone;
  121231. /**
  121232. * Is this system ready to be used/rendered
  121233. * @return true if the system is ready
  121234. */
  121235. isReady(): boolean;
  121236. /**
  121237. * Gets if the system has been started. (Note: this will still be true after stop is called)
  121238. * @returns True if it has been started, otherwise false.
  121239. */
  121240. isStarted(): boolean;
  121241. /**
  121242. * Starts the particle system and begins to emit
  121243. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  121244. */
  121245. start(delay?: number): void;
  121246. /**
  121247. * Stops the particle system.
  121248. */
  121249. stop(): void;
  121250. /**
  121251. * Remove all active particles
  121252. */
  121253. reset(): void;
  121254. /**
  121255. * Returns the string "GPUParticleSystem"
  121256. * @returns a string containing the class name
  121257. */
  121258. getClassName(): string;
  121259. private _colorGradientsTexture;
  121260. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  121261. /**
  121262. * Adds a new color gradient
  121263. * @param gradient defines the gradient to use (between 0 and 1)
  121264. * @param color1 defines the color to affect to the specified gradient
  121265. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  121266. * @returns the current particle system
  121267. */
  121268. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  121269. /**
  121270. * Remove a specific color gradient
  121271. * @param gradient defines the gradient to remove
  121272. * @returns the current particle system
  121273. */
  121274. removeColorGradient(gradient: number): GPUParticleSystem;
  121275. private _angularSpeedGradientsTexture;
  121276. private _sizeGradientsTexture;
  121277. private _velocityGradientsTexture;
  121278. private _limitVelocityGradientsTexture;
  121279. private _dragGradientsTexture;
  121280. private _addFactorGradient;
  121281. /**
  121282. * Adds a new size gradient
  121283. * @param gradient defines the gradient to use (between 0 and 1)
  121284. * @param factor defines the size factor to affect to the specified gradient
  121285. * @returns the current particle system
  121286. */
  121287. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  121288. /**
  121289. * Remove a specific size gradient
  121290. * @param gradient defines the gradient to remove
  121291. * @returns the current particle system
  121292. */
  121293. removeSizeGradient(gradient: number): GPUParticleSystem;
  121294. /**
  121295. * Adds a new angular speed gradient
  121296. * @param gradient defines the gradient to use (between 0 and 1)
  121297. * @param factor defines the angular speed to affect to the specified gradient
  121298. * @returns the current particle system
  121299. */
  121300. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  121301. /**
  121302. * Remove a specific angular speed gradient
  121303. * @param gradient defines the gradient to remove
  121304. * @returns the current particle system
  121305. */
  121306. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  121307. /**
  121308. * Adds a new velocity gradient
  121309. * @param gradient defines the gradient to use (between 0 and 1)
  121310. * @param factor defines the velocity to affect to the specified gradient
  121311. * @returns the current particle system
  121312. */
  121313. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  121314. /**
  121315. * Remove a specific velocity gradient
  121316. * @param gradient defines the gradient to remove
  121317. * @returns the current particle system
  121318. */
  121319. removeVelocityGradient(gradient: number): GPUParticleSystem;
  121320. /**
  121321. * Adds a new limit velocity gradient
  121322. * @param gradient defines the gradient to use (between 0 and 1)
  121323. * @param factor defines the limit velocity value to affect to the specified gradient
  121324. * @returns the current particle system
  121325. */
  121326. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  121327. /**
  121328. * Remove a specific limit velocity gradient
  121329. * @param gradient defines the gradient to remove
  121330. * @returns the current particle system
  121331. */
  121332. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  121333. /**
  121334. * Adds a new drag gradient
  121335. * @param gradient defines the gradient to use (between 0 and 1)
  121336. * @param factor defines the drag value to affect to the specified gradient
  121337. * @returns the current particle system
  121338. */
  121339. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  121340. /**
  121341. * Remove a specific drag gradient
  121342. * @param gradient defines the gradient to remove
  121343. * @returns the current particle system
  121344. */
  121345. removeDragGradient(gradient: number): GPUParticleSystem;
  121346. /**
  121347. * Not supported by GPUParticleSystem
  121348. * @param gradient defines the gradient to use (between 0 and 1)
  121349. * @param factor defines the emit rate value to affect to the specified gradient
  121350. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  121351. * @returns the current particle system
  121352. */
  121353. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  121354. /**
  121355. * Not supported by GPUParticleSystem
  121356. * @param gradient defines the gradient to remove
  121357. * @returns the current particle system
  121358. */
  121359. removeEmitRateGradient(gradient: number): IParticleSystem;
  121360. /**
  121361. * Not supported by GPUParticleSystem
  121362. * @param gradient defines the gradient to use (between 0 and 1)
  121363. * @param factor defines the start size value to affect to the specified gradient
  121364. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  121365. * @returns the current particle system
  121366. */
  121367. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  121368. /**
  121369. * Not supported by GPUParticleSystem
  121370. * @param gradient defines the gradient to remove
  121371. * @returns the current particle system
  121372. */
  121373. removeStartSizeGradient(gradient: number): IParticleSystem;
  121374. /**
  121375. * Not supported by GPUParticleSystem
  121376. * @param gradient defines the gradient to use (between 0 and 1)
  121377. * @param min defines the color remap minimal range
  121378. * @param max defines the color remap maximal range
  121379. * @returns the current particle system
  121380. */
  121381. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  121382. /**
  121383. * Not supported by GPUParticleSystem
  121384. * @param gradient defines the gradient to remove
  121385. * @returns the current particle system
  121386. */
  121387. removeColorRemapGradient(): IParticleSystem;
  121388. /**
  121389. * Not supported by GPUParticleSystem
  121390. * @param gradient defines the gradient to use (between 0 and 1)
  121391. * @param min defines the alpha remap minimal range
  121392. * @param max defines the alpha remap maximal range
  121393. * @returns the current particle system
  121394. */
  121395. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  121396. /**
  121397. * Not supported by GPUParticleSystem
  121398. * @param gradient defines the gradient to remove
  121399. * @returns the current particle system
  121400. */
  121401. removeAlphaRemapGradient(): IParticleSystem;
  121402. /**
  121403. * Not supported by GPUParticleSystem
  121404. * @param gradient defines the gradient to use (between 0 and 1)
  121405. * @param color defines the color to affect to the specified gradient
  121406. * @returns the current particle system
  121407. */
  121408. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  121409. /**
  121410. * Not supported by GPUParticleSystem
  121411. * @param gradient defines the gradient to remove
  121412. * @returns the current particle system
  121413. */
  121414. removeRampGradient(): IParticleSystem;
  121415. /**
  121416. * Not supported by GPUParticleSystem
  121417. * @returns the list of ramp gradients
  121418. */
  121419. getRampGradients(): Nullable<Array<Color3Gradient>>;
  121420. /**
  121421. * Not supported by GPUParticleSystem
  121422. * Gets or sets a boolean indicating that ramp gradients must be used
  121423. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  121424. */
  121425. useRampGradients: boolean;
  121426. /**
  121427. * Not supported by GPUParticleSystem
  121428. * @param gradient defines the gradient to use (between 0 and 1)
  121429. * @param factor defines the life time factor to affect to the specified gradient
  121430. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  121431. * @returns the current particle system
  121432. */
  121433. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  121434. /**
  121435. * Not supported by GPUParticleSystem
  121436. * @param gradient defines the gradient to remove
  121437. * @returns the current particle system
  121438. */
  121439. removeLifeTimeGradient(gradient: number): IParticleSystem;
  121440. /**
  121441. * Instantiates a GPU particle system.
  121442. * 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.
  121443. * @param name The name of the particle system
  121444. * @param options The options used to create the system
  121445. * @param scene The scene the particle system belongs to
  121446. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  121447. */
  121448. constructor(name: string, options: Partial<{
  121449. capacity: number;
  121450. randomTextureSize: number;
  121451. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  121452. protected _reset(): void;
  121453. private _createUpdateVAO;
  121454. private _createRenderVAO;
  121455. private _initialize;
  121456. /** @hidden */
  121457. _recreateUpdateEffect(): void;
  121458. /** @hidden */
  121459. _recreateRenderEffect(): void;
  121460. /**
  121461. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  121462. * @param preWarm defines if we are in the pre-warmimg phase
  121463. */
  121464. animate(preWarm?: boolean): void;
  121465. private _createFactorGradientTexture;
  121466. private _createSizeGradientTexture;
  121467. private _createAngularSpeedGradientTexture;
  121468. private _createVelocityGradientTexture;
  121469. private _createLimitVelocityGradientTexture;
  121470. private _createDragGradientTexture;
  121471. private _createColorGradientTexture;
  121472. /**
  121473. * Renders the particle system in its current state
  121474. * @param preWarm defines if the system should only update the particles but not render them
  121475. * @returns the current number of particles
  121476. */
  121477. render(preWarm?: boolean): number;
  121478. /**
  121479. * Rebuilds the particle system
  121480. */
  121481. rebuild(): void;
  121482. private _releaseBuffers;
  121483. private _releaseVAOs;
  121484. /**
  121485. * Disposes the particle system and free the associated resources
  121486. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  121487. */
  121488. dispose(disposeTexture?: boolean): void;
  121489. /**
  121490. * Clones the particle system.
  121491. * @param name The name of the cloned object
  121492. * @param newEmitter The new emitter to use
  121493. * @returns the cloned particle system
  121494. */
  121495. clone(name: string, newEmitter: any): GPUParticleSystem;
  121496. /**
  121497. * Serializes the particle system to a JSON object.
  121498. * @returns the JSON object
  121499. */
  121500. serialize(): any;
  121501. /**
  121502. * Parses a JSON object to create a GPU particle system.
  121503. * @param parsedParticleSystem The JSON object to parse
  121504. * @param scene The scene to create the particle system in
  121505. * @param rootUrl The root url to use to load external dependencies like texture
  121506. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  121507. * @returns the parsed GPU particle system
  121508. */
  121509. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  121510. }
  121511. }
  121512. declare module BABYLON {
  121513. /**
  121514. * Represents a set of particle systems working together to create a specific effect
  121515. */
  121516. export class ParticleSystemSet implements IDisposable {
  121517. private _emitterCreationOptions;
  121518. private _emitterNode;
  121519. /**
  121520. * Gets the particle system list
  121521. */
  121522. systems: IParticleSystem[];
  121523. /**
  121524. * Gets the emitter node used with this set
  121525. */
  121526. readonly emitterNode: Nullable<TransformNode>;
  121527. /**
  121528. * Creates a new emitter mesh as a sphere
  121529. * @param options defines the options used to create the sphere
  121530. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  121531. * @param scene defines the hosting scene
  121532. */
  121533. setEmitterAsSphere(options: {
  121534. diameter: number;
  121535. segments: number;
  121536. color: Color3;
  121537. }, renderingGroupId: number, scene: Scene): void;
  121538. /**
  121539. * Starts all particle systems of the set
  121540. * @param emitter defines an optional mesh to use as emitter for the particle systems
  121541. */
  121542. start(emitter?: AbstractMesh): void;
  121543. /**
  121544. * Release all associated resources
  121545. */
  121546. dispose(): void;
  121547. /**
  121548. * Serialize the set into a JSON compatible object
  121549. * @returns a JSON compatible representation of the set
  121550. */
  121551. serialize(): any;
  121552. /**
  121553. * Parse a new ParticleSystemSet from a serialized source
  121554. * @param data defines a JSON compatible representation of the set
  121555. * @param scene defines the hosting scene
  121556. * @param gpu defines if we want GPU particles or CPU particles
  121557. * @returns a new ParticleSystemSet
  121558. */
  121559. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  121560. }
  121561. }
  121562. declare module BABYLON {
  121563. /**
  121564. * This class is made for on one-liner static method to help creating particle system set.
  121565. */
  121566. export class ParticleHelper {
  121567. /**
  121568. * Gets or sets base Assets URL
  121569. */
  121570. static BaseAssetsUrl: string;
  121571. /**
  121572. * Create a default particle system that you can tweak
  121573. * @param emitter defines the emitter to use
  121574. * @param capacity defines the system capacity (default is 500 particles)
  121575. * @param scene defines the hosting scene
  121576. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  121577. * @returns the new Particle system
  121578. */
  121579. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  121580. /**
  121581. * This is the main static method (one-liner) of this helper to create different particle systems
  121582. * @param type This string represents the type to the particle system to create
  121583. * @param scene The scene where the particle system should live
  121584. * @param gpu If the system will use gpu
  121585. * @returns the ParticleSystemSet created
  121586. */
  121587. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  121588. /**
  121589. * Static function used to export a particle system to a ParticleSystemSet variable.
  121590. * Please note that the emitter shape is not exported
  121591. * @param systems defines the particle systems to export
  121592. * @returns the created particle system set
  121593. */
  121594. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  121595. }
  121596. }
  121597. declare module BABYLON {
  121598. interface Engine {
  121599. /**
  121600. * Create an effect to use with particle systems.
  121601. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  121602. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  121603. * @param uniformsNames defines a list of attribute names
  121604. * @param samplers defines an array of string used to represent textures
  121605. * @param defines defines the string containing the defines to use to compile the shaders
  121606. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  121607. * @param onCompiled defines a function to call when the effect creation is successful
  121608. * @param onError defines a function to call when the effect creation has failed
  121609. * @returns the new Effect
  121610. */
  121611. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  121612. }
  121613. interface Mesh {
  121614. /**
  121615. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  121616. * @returns an array of IParticleSystem
  121617. */
  121618. getEmittedParticleSystems(): IParticleSystem[];
  121619. /**
  121620. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  121621. * @returns an array of IParticleSystem
  121622. */
  121623. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  121624. }
  121625. /**
  121626. * @hidden
  121627. */
  121628. export var _IDoNeedToBeInTheBuild: number;
  121629. }
  121630. declare module BABYLON {
  121631. interface Scene {
  121632. /** @hidden (Backing field) */
  121633. _physicsEngine: Nullable<IPhysicsEngine>;
  121634. /**
  121635. * Gets the current physics engine
  121636. * @returns a IPhysicsEngine or null if none attached
  121637. */
  121638. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  121639. /**
  121640. * Enables physics to the current scene
  121641. * @param gravity defines the scene's gravity for the physics engine
  121642. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  121643. * @return a boolean indicating if the physics engine was initialized
  121644. */
  121645. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  121646. /**
  121647. * Disables and disposes the physics engine associated with the scene
  121648. */
  121649. disablePhysicsEngine(): void;
  121650. /**
  121651. * Gets a boolean indicating if there is an active physics engine
  121652. * @returns a boolean indicating if there is an active physics engine
  121653. */
  121654. isPhysicsEnabled(): boolean;
  121655. /**
  121656. * Deletes a physics compound impostor
  121657. * @param compound defines the compound to delete
  121658. */
  121659. deleteCompoundImpostor(compound: any): void;
  121660. /**
  121661. * An event triggered when physic simulation is about to be run
  121662. */
  121663. onBeforePhysicsObservable: Observable<Scene>;
  121664. /**
  121665. * An event triggered when physic simulation has been done
  121666. */
  121667. onAfterPhysicsObservable: Observable<Scene>;
  121668. }
  121669. interface AbstractMesh {
  121670. /** @hidden */
  121671. _physicsImpostor: Nullable<PhysicsImpostor>;
  121672. /**
  121673. * Gets or sets impostor used for physic simulation
  121674. * @see http://doc.babylonjs.com/features/physics_engine
  121675. */
  121676. physicsImpostor: Nullable<PhysicsImpostor>;
  121677. /**
  121678. * Gets the current physics impostor
  121679. * @see http://doc.babylonjs.com/features/physics_engine
  121680. * @returns a physics impostor or null
  121681. */
  121682. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  121683. /** Apply a physic impulse to the mesh
  121684. * @param force defines the force to apply
  121685. * @param contactPoint defines where to apply the force
  121686. * @returns the current mesh
  121687. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  121688. */
  121689. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  121690. /**
  121691. * Creates a physic joint between two meshes
  121692. * @param otherMesh defines the other mesh to use
  121693. * @param pivot1 defines the pivot to use on this mesh
  121694. * @param pivot2 defines the pivot to use on the other mesh
  121695. * @param options defines additional options (can be plugin dependent)
  121696. * @returns the current mesh
  121697. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  121698. */
  121699. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  121700. /** @hidden */
  121701. _disposePhysicsObserver: Nullable<Observer<Node>>;
  121702. }
  121703. /**
  121704. * Defines the physics engine scene component responsible to manage a physics engine
  121705. */
  121706. export class PhysicsEngineSceneComponent implements ISceneComponent {
  121707. /**
  121708. * The component name helpful to identify the component in the list of scene components.
  121709. */
  121710. readonly name: string;
  121711. /**
  121712. * The scene the component belongs to.
  121713. */
  121714. scene: Scene;
  121715. /**
  121716. * Creates a new instance of the component for the given scene
  121717. * @param scene Defines the scene to register the component in
  121718. */
  121719. constructor(scene: Scene);
  121720. /**
  121721. * Registers the component in a given scene
  121722. */
  121723. register(): void;
  121724. /**
  121725. * Rebuilds the elements related to this component in case of
  121726. * context lost for instance.
  121727. */
  121728. rebuild(): void;
  121729. /**
  121730. * Disposes the component and the associated ressources
  121731. */
  121732. dispose(): void;
  121733. }
  121734. }
  121735. declare module BABYLON {
  121736. /**
  121737. * A helper for physics simulations
  121738. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  121739. */
  121740. export class PhysicsHelper {
  121741. private _scene;
  121742. private _physicsEngine;
  121743. /**
  121744. * Initializes the Physics helper
  121745. * @param scene Babylon.js scene
  121746. */
  121747. constructor(scene: Scene);
  121748. /**
  121749. * Applies a radial explosion impulse
  121750. * @param origin the origin of the explosion
  121751. * @param radiusOrEventOptions the radius or the options of radial explosion
  121752. * @param strength the explosion strength
  121753. * @param falloff possible options: Constant & Linear. Defaults to Constant
  121754. * @returns A physics radial explosion event, or null
  121755. */
  121756. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  121757. /**
  121758. * Applies a radial explosion force
  121759. * @param origin the origin of the explosion
  121760. * @param radiusOrEventOptions the radius or the options of radial explosion
  121761. * @param strength the explosion strength
  121762. * @param falloff possible options: Constant & Linear. Defaults to Constant
  121763. * @returns A physics radial explosion event, or null
  121764. */
  121765. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  121766. /**
  121767. * Creates a gravitational field
  121768. * @param origin the origin of the explosion
  121769. * @param radiusOrEventOptions the radius or the options of radial explosion
  121770. * @param strength the explosion strength
  121771. * @param falloff possible options: Constant & Linear. Defaults to Constant
  121772. * @returns A physics gravitational field event, or null
  121773. */
  121774. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  121775. /**
  121776. * Creates a physics updraft event
  121777. * @param origin the origin of the updraft
  121778. * @param radiusOrEventOptions the radius or the options of the updraft
  121779. * @param strength the strength of the updraft
  121780. * @param height the height of the updraft
  121781. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  121782. * @returns A physics updraft event, or null
  121783. */
  121784. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  121785. /**
  121786. * Creates a physics vortex event
  121787. * @param origin the of the vortex
  121788. * @param radiusOrEventOptions the radius or the options of the vortex
  121789. * @param strength the strength of the vortex
  121790. * @param height the height of the vortex
  121791. * @returns a Physics vortex event, or null
  121792. * A physics vortex event or null
  121793. */
  121794. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  121795. }
  121796. /**
  121797. * Represents a physics radial explosion event
  121798. */
  121799. class PhysicsRadialExplosionEvent {
  121800. private _scene;
  121801. private _options;
  121802. private _sphere;
  121803. private _dataFetched;
  121804. /**
  121805. * Initializes a radial explosioin event
  121806. * @param _scene BabylonJS scene
  121807. * @param _options The options for the vortex event
  121808. */
  121809. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  121810. /**
  121811. * Returns the data related to the radial explosion event (sphere).
  121812. * @returns The radial explosion event data
  121813. */
  121814. getData(): PhysicsRadialExplosionEventData;
  121815. /**
  121816. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  121817. * @param impostor A physics imposter
  121818. * @param origin the origin of the explosion
  121819. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  121820. */
  121821. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  121822. /**
  121823. * Triggers affecterd impostors callbacks
  121824. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  121825. */
  121826. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  121827. /**
  121828. * Disposes the sphere.
  121829. * @param force Specifies if the sphere should be disposed by force
  121830. */
  121831. dispose(force?: boolean): void;
  121832. /*** Helpers ***/
  121833. private _prepareSphere;
  121834. private _intersectsWithSphere;
  121835. }
  121836. /**
  121837. * Represents a gravitational field event
  121838. */
  121839. class PhysicsGravitationalFieldEvent {
  121840. private _physicsHelper;
  121841. private _scene;
  121842. private _origin;
  121843. private _options;
  121844. private _tickCallback;
  121845. private _sphere;
  121846. private _dataFetched;
  121847. /**
  121848. * Initializes the physics gravitational field event
  121849. * @param _physicsHelper A physics helper
  121850. * @param _scene BabylonJS scene
  121851. * @param _origin The origin position of the gravitational field event
  121852. * @param _options The options for the vortex event
  121853. */
  121854. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  121855. /**
  121856. * Returns the data related to the gravitational field event (sphere).
  121857. * @returns A gravitational field event
  121858. */
  121859. getData(): PhysicsGravitationalFieldEventData;
  121860. /**
  121861. * Enables the gravitational field.
  121862. */
  121863. enable(): void;
  121864. /**
  121865. * Disables the gravitational field.
  121866. */
  121867. disable(): void;
  121868. /**
  121869. * Disposes the sphere.
  121870. * @param force The force to dispose from the gravitational field event
  121871. */
  121872. dispose(force?: boolean): void;
  121873. private _tick;
  121874. }
  121875. /**
  121876. * Represents a physics updraft event
  121877. */
  121878. class PhysicsUpdraftEvent {
  121879. private _scene;
  121880. private _origin;
  121881. private _options;
  121882. private _physicsEngine;
  121883. private _originTop;
  121884. private _originDirection;
  121885. private _tickCallback;
  121886. private _cylinder;
  121887. private _cylinderPosition;
  121888. private _dataFetched;
  121889. /**
  121890. * Initializes the physics updraft event
  121891. * @param _scene BabylonJS scene
  121892. * @param _origin The origin position of the updraft
  121893. * @param _options The options for the updraft event
  121894. */
  121895. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  121896. /**
  121897. * Returns the data related to the updraft event (cylinder).
  121898. * @returns A physics updraft event
  121899. */
  121900. getData(): PhysicsUpdraftEventData;
  121901. /**
  121902. * Enables the updraft.
  121903. */
  121904. enable(): void;
  121905. /**
  121906. * Disables the updraft.
  121907. */
  121908. disable(): void;
  121909. /**
  121910. * Disposes the cylinder.
  121911. * @param force Specifies if the updraft should be disposed by force
  121912. */
  121913. dispose(force?: boolean): void;
  121914. private getImpostorHitData;
  121915. private _tick;
  121916. /*** Helpers ***/
  121917. private _prepareCylinder;
  121918. private _intersectsWithCylinder;
  121919. }
  121920. /**
  121921. * Represents a physics vortex event
  121922. */
  121923. class PhysicsVortexEvent {
  121924. private _scene;
  121925. private _origin;
  121926. private _options;
  121927. private _physicsEngine;
  121928. private _originTop;
  121929. private _tickCallback;
  121930. private _cylinder;
  121931. private _cylinderPosition;
  121932. private _dataFetched;
  121933. /**
  121934. * Initializes the physics vortex event
  121935. * @param _scene The BabylonJS scene
  121936. * @param _origin The origin position of the vortex
  121937. * @param _options The options for the vortex event
  121938. */
  121939. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  121940. /**
  121941. * Returns the data related to the vortex event (cylinder).
  121942. * @returns The physics vortex event data
  121943. */
  121944. getData(): PhysicsVortexEventData;
  121945. /**
  121946. * Enables the vortex.
  121947. */
  121948. enable(): void;
  121949. /**
  121950. * Disables the cortex.
  121951. */
  121952. disable(): void;
  121953. /**
  121954. * Disposes the sphere.
  121955. * @param force
  121956. */
  121957. dispose(force?: boolean): void;
  121958. private getImpostorHitData;
  121959. private _tick;
  121960. /*** Helpers ***/
  121961. private _prepareCylinder;
  121962. private _intersectsWithCylinder;
  121963. }
  121964. /**
  121965. * Options fot the radial explosion event
  121966. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  121967. */
  121968. export class PhysicsRadialExplosionEventOptions {
  121969. /**
  121970. * The radius of the sphere for the radial explosion.
  121971. */
  121972. radius: number;
  121973. /**
  121974. * The strenth of the explosion.
  121975. */
  121976. strength: number;
  121977. /**
  121978. * The strenght of the force in correspondence to the distance of the affected object
  121979. */
  121980. falloff: PhysicsRadialImpulseFalloff;
  121981. /**
  121982. * Sphere options for the radial explosion.
  121983. */
  121984. sphere: {
  121985. segments: number;
  121986. diameter: number;
  121987. };
  121988. /**
  121989. * Sphere options for the radial explosion.
  121990. */
  121991. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  121992. }
  121993. /**
  121994. * Options fot the updraft event
  121995. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  121996. */
  121997. export class PhysicsUpdraftEventOptions {
  121998. /**
  121999. * The radius of the cylinder for the vortex
  122000. */
  122001. radius: number;
  122002. /**
  122003. * The strenth of the updraft.
  122004. */
  122005. strength: number;
  122006. /**
  122007. * The height of the cylinder for the updraft.
  122008. */
  122009. height: number;
  122010. /**
  122011. * The mode for the the updraft.
  122012. */
  122013. updraftMode: PhysicsUpdraftMode;
  122014. }
  122015. /**
  122016. * Options fot the vortex event
  122017. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  122018. */
  122019. export class PhysicsVortexEventOptions {
  122020. /**
  122021. * The radius of the cylinder for the vortex
  122022. */
  122023. radius: number;
  122024. /**
  122025. * The strenth of the vortex.
  122026. */
  122027. strength: number;
  122028. /**
  122029. * The height of the cylinder for the vortex.
  122030. */
  122031. height: number;
  122032. /**
  122033. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  122034. */
  122035. centripetalForceThreshold: number;
  122036. /**
  122037. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  122038. */
  122039. centripetalForceMultiplier: number;
  122040. /**
  122041. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  122042. */
  122043. centrifugalForceMultiplier: number;
  122044. /**
  122045. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  122046. */
  122047. updraftForceMultiplier: number;
  122048. }
  122049. /**
  122050. * The strenght of the force in correspondence to the distance of the affected object
  122051. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  122052. */
  122053. export enum PhysicsRadialImpulseFalloff {
  122054. /** Defines that impulse is constant in strength across it's whole radius */
  122055. Constant = 0,
  122056. /** Defines that impulse gets weaker if it's further from the origin */
  122057. Linear = 1
  122058. }
  122059. /**
  122060. * The strength of the force in correspondence to the distance of the affected object
  122061. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  122062. */
  122063. export enum PhysicsUpdraftMode {
  122064. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  122065. Center = 0,
  122066. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  122067. Perpendicular = 1
  122068. }
  122069. /**
  122070. * Interface for a physics hit data
  122071. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  122072. */
  122073. export interface PhysicsHitData {
  122074. /**
  122075. * The force applied at the contact point
  122076. */
  122077. force: Vector3;
  122078. /**
  122079. * The contact point
  122080. */
  122081. contactPoint: Vector3;
  122082. /**
  122083. * The distance from the origin to the contact point
  122084. */
  122085. distanceFromOrigin: number;
  122086. }
  122087. /**
  122088. * Interface for radial explosion event data
  122089. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  122090. */
  122091. export interface PhysicsRadialExplosionEventData {
  122092. /**
  122093. * A sphere used for the radial explosion event
  122094. */
  122095. sphere: Mesh;
  122096. }
  122097. /**
  122098. * Interface for gravitational field event data
  122099. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  122100. */
  122101. export interface PhysicsGravitationalFieldEventData {
  122102. /**
  122103. * A sphere mesh used for the gravitational field event
  122104. */
  122105. sphere: Mesh;
  122106. }
  122107. /**
  122108. * Interface for updraft event data
  122109. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  122110. */
  122111. export interface PhysicsUpdraftEventData {
  122112. /**
  122113. * A cylinder used for the updraft event
  122114. */
  122115. cylinder: Mesh;
  122116. }
  122117. /**
  122118. * Interface for vortex event data
  122119. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  122120. */
  122121. export interface PhysicsVortexEventData {
  122122. /**
  122123. * A cylinder used for the vortex event
  122124. */
  122125. cylinder: Mesh;
  122126. }
  122127. /**
  122128. * Interface for an affected physics impostor
  122129. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  122130. */
  122131. export interface PhysicsAffectedImpostorWithData {
  122132. /**
  122133. * The impostor affected by the effect
  122134. */
  122135. impostor: PhysicsImpostor;
  122136. /**
  122137. * The data about the hit/horce from the explosion
  122138. */
  122139. hitData: PhysicsHitData;
  122140. }
  122141. }
  122142. declare module BABYLON {
  122143. /** @hidden */
  122144. export var blackAndWhitePixelShader: {
  122145. name: string;
  122146. shader: string;
  122147. };
  122148. }
  122149. declare module BABYLON {
  122150. /**
  122151. * Post process used to render in black and white
  122152. */
  122153. export class BlackAndWhitePostProcess extends PostProcess {
  122154. /**
  122155. * Linear about to convert he result to black and white (default: 1)
  122156. */
  122157. degree: number;
  122158. /**
  122159. * Creates a black and white post process
  122160. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  122161. * @param name The name of the effect.
  122162. * @param options The required width/height ratio to downsize to before computing the render pass.
  122163. * @param camera The camera to apply the render pass to.
  122164. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122165. * @param engine The engine which the post process will be applied. (default: current engine)
  122166. * @param reusable If the post process can be reused on the same frame. (default: false)
  122167. */
  122168. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  122169. }
  122170. }
  122171. declare module BABYLON {
  122172. /**
  122173. * This represents a set of one or more post processes in Babylon.
  122174. * A post process can be used to apply a shader to a texture after it is rendered.
  122175. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  122176. */
  122177. export class PostProcessRenderEffect {
  122178. private _postProcesses;
  122179. private _getPostProcesses;
  122180. private _singleInstance;
  122181. private _cameras;
  122182. private _indicesForCamera;
  122183. /**
  122184. * Name of the effect
  122185. * @hidden
  122186. */
  122187. _name: string;
  122188. /**
  122189. * Instantiates a post process render effect.
  122190. * A post process can be used to apply a shader to a texture after it is rendered.
  122191. * @param engine The engine the effect is tied to
  122192. * @param name The name of the effect
  122193. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  122194. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  122195. */
  122196. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  122197. /**
  122198. * Checks if all the post processes in the effect are supported.
  122199. */
  122200. readonly isSupported: boolean;
  122201. /**
  122202. * Updates the current state of the effect
  122203. * @hidden
  122204. */
  122205. _update(): void;
  122206. /**
  122207. * Attaches the effect on cameras
  122208. * @param cameras The camera to attach to.
  122209. * @hidden
  122210. */
  122211. _attachCameras(cameras: Camera): void;
  122212. /**
  122213. * Attaches the effect on cameras
  122214. * @param cameras The camera to attach to.
  122215. * @hidden
  122216. */
  122217. _attachCameras(cameras: Camera[]): void;
  122218. /**
  122219. * Detaches the effect on cameras
  122220. * @param cameras The camera to detatch from.
  122221. * @hidden
  122222. */
  122223. _detachCameras(cameras: Camera): void;
  122224. /**
  122225. * Detatches the effect on cameras
  122226. * @param cameras The camera to detatch from.
  122227. * @hidden
  122228. */
  122229. _detachCameras(cameras: Camera[]): void;
  122230. /**
  122231. * Enables the effect on given cameras
  122232. * @param cameras The camera to enable.
  122233. * @hidden
  122234. */
  122235. _enable(cameras: Camera): void;
  122236. /**
  122237. * Enables the effect on given cameras
  122238. * @param cameras The camera to enable.
  122239. * @hidden
  122240. */
  122241. _enable(cameras: Nullable<Camera[]>): void;
  122242. /**
  122243. * Disables the effect on the given cameras
  122244. * @param cameras The camera to disable.
  122245. * @hidden
  122246. */
  122247. _disable(cameras: Camera): void;
  122248. /**
  122249. * Disables the effect on the given cameras
  122250. * @param cameras The camera to disable.
  122251. * @hidden
  122252. */
  122253. _disable(cameras: Nullable<Camera[]>): void;
  122254. /**
  122255. * Gets a list of the post processes contained in the effect.
  122256. * @param camera The camera to get the post processes on.
  122257. * @returns The list of the post processes in the effect.
  122258. */
  122259. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  122260. }
  122261. }
  122262. declare module BABYLON {
  122263. /** @hidden */
  122264. export var extractHighlightsPixelShader: {
  122265. name: string;
  122266. shader: string;
  122267. };
  122268. }
  122269. declare module BABYLON {
  122270. /**
  122271. * 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.
  122272. */
  122273. export class ExtractHighlightsPostProcess extends PostProcess {
  122274. /**
  122275. * The luminance threshold, pixels below this value will be set to black.
  122276. */
  122277. threshold: number;
  122278. /** @hidden */
  122279. _exposure: number;
  122280. /**
  122281. * Post process which has the input texture to be used when performing highlight extraction
  122282. * @hidden
  122283. */
  122284. _inputPostProcess: Nullable<PostProcess>;
  122285. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  122286. }
  122287. }
  122288. declare module BABYLON {
  122289. /** @hidden */
  122290. export var bloomMergePixelShader: {
  122291. name: string;
  122292. shader: string;
  122293. };
  122294. }
  122295. declare module BABYLON {
  122296. /**
  122297. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  122298. */
  122299. export class BloomMergePostProcess extends PostProcess {
  122300. /** Weight of the bloom to be added to the original input. */
  122301. weight: number;
  122302. /**
  122303. * Creates a new instance of @see BloomMergePostProcess
  122304. * @param name The name of the effect.
  122305. * @param originalFromInput Post process which's input will be used for the merge.
  122306. * @param blurred Blurred highlights post process which's output will be used.
  122307. * @param weight Weight of the bloom to be added to the original input.
  122308. * @param options The required width/height ratio to downsize to before computing the render pass.
  122309. * @param camera The camera to apply the render pass to.
  122310. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122311. * @param engine The engine which the post process will be applied. (default: current engine)
  122312. * @param reusable If the post process can be reused on the same frame. (default: false)
  122313. * @param textureType Type of textures used when performing the post process. (default: 0)
  122314. * @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)
  122315. */
  122316. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  122317. /** Weight of the bloom to be added to the original input. */
  122318. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  122319. }
  122320. }
  122321. declare module BABYLON {
  122322. /**
  122323. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  122324. */
  122325. export class BloomEffect extends PostProcessRenderEffect {
  122326. private bloomScale;
  122327. /**
  122328. * @hidden Internal
  122329. */
  122330. _effects: Array<PostProcess>;
  122331. /**
  122332. * @hidden Internal
  122333. */
  122334. _downscale: ExtractHighlightsPostProcess;
  122335. private _blurX;
  122336. private _blurY;
  122337. private _merge;
  122338. /**
  122339. * The luminance threshold to find bright areas of the image to bloom.
  122340. */
  122341. threshold: number;
  122342. /**
  122343. * The strength of the bloom.
  122344. */
  122345. weight: number;
  122346. /**
  122347. * Specifies the size of the bloom blur kernel, relative to the final output size
  122348. */
  122349. kernel: number;
  122350. /**
  122351. * Creates a new instance of @see BloomEffect
  122352. * @param scene The scene the effect belongs to.
  122353. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  122354. * @param bloomKernel The size of the kernel to be used when applying the blur.
  122355. * @param bloomWeight The the strength of bloom.
  122356. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  122357. * @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)
  122358. */
  122359. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  122360. /**
  122361. * Disposes each of the internal effects for a given camera.
  122362. * @param camera The camera to dispose the effect on.
  122363. */
  122364. disposeEffects(camera: Camera): void;
  122365. /**
  122366. * @hidden Internal
  122367. */
  122368. _updateEffects(): void;
  122369. /**
  122370. * Internal
  122371. * @returns if all the contained post processes are ready.
  122372. * @hidden
  122373. */
  122374. _isReady(): boolean;
  122375. }
  122376. }
  122377. declare module BABYLON {
  122378. /** @hidden */
  122379. export var chromaticAberrationPixelShader: {
  122380. name: string;
  122381. shader: string;
  122382. };
  122383. }
  122384. declare module BABYLON {
  122385. /**
  122386. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  122387. */
  122388. export class ChromaticAberrationPostProcess extends PostProcess {
  122389. /**
  122390. * The amount of seperation of rgb channels (default: 30)
  122391. */
  122392. aberrationAmount: number;
  122393. /**
  122394. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  122395. */
  122396. radialIntensity: number;
  122397. /**
  122398. * 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))
  122399. */
  122400. direction: Vector2;
  122401. /**
  122402. * 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))
  122403. */
  122404. centerPosition: Vector2;
  122405. /**
  122406. * Creates a new instance ChromaticAberrationPostProcess
  122407. * @param name The name of the effect.
  122408. * @param screenWidth The width of the screen to apply the effect on.
  122409. * @param screenHeight The height of the screen to apply the effect on.
  122410. * @param options The required width/height ratio to downsize to before computing the render pass.
  122411. * @param camera The camera to apply the render pass to.
  122412. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122413. * @param engine The engine which the post process will be applied. (default: current engine)
  122414. * @param reusable If the post process can be reused on the same frame. (default: false)
  122415. * @param textureType Type of textures used when performing the post process. (default: 0)
  122416. * @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)
  122417. */
  122418. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  122419. }
  122420. }
  122421. declare module BABYLON {
  122422. /** @hidden */
  122423. export var circleOfConfusionPixelShader: {
  122424. name: string;
  122425. shader: string;
  122426. };
  122427. }
  122428. declare module BABYLON {
  122429. /**
  122430. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  122431. */
  122432. export class CircleOfConfusionPostProcess extends PostProcess {
  122433. /**
  122434. * 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.
  122435. */
  122436. lensSize: number;
  122437. /**
  122438. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  122439. */
  122440. fStop: number;
  122441. /**
  122442. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  122443. */
  122444. focusDistance: number;
  122445. /**
  122446. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  122447. */
  122448. focalLength: number;
  122449. private _depthTexture;
  122450. /**
  122451. * Creates a new instance CircleOfConfusionPostProcess
  122452. * @param name The name of the effect.
  122453. * @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.
  122454. * @param options The required width/height ratio to downsize to before computing the render pass.
  122455. * @param camera The camera to apply the render pass to.
  122456. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122457. * @param engine The engine which the post process will be applied. (default: current engine)
  122458. * @param reusable If the post process can be reused on the same frame. (default: false)
  122459. * @param textureType Type of textures used when performing the post process. (default: 0)
  122460. * @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)
  122461. */
  122462. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  122463. /**
  122464. * 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.
  122465. */
  122466. depthTexture: RenderTargetTexture;
  122467. }
  122468. }
  122469. declare module BABYLON {
  122470. /** @hidden */
  122471. export var colorCorrectionPixelShader: {
  122472. name: string;
  122473. shader: string;
  122474. };
  122475. }
  122476. declare module BABYLON {
  122477. /**
  122478. *
  122479. * This post-process allows the modification of rendered colors by using
  122480. * a 'look-up table' (LUT). This effect is also called Color Grading.
  122481. *
  122482. * The object needs to be provided an url to a texture containing the color
  122483. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  122484. * Use an image editing software to tweak the LUT to match your needs.
  122485. *
  122486. * For an example of a color LUT, see here:
  122487. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  122488. * For explanations on color grading, see here:
  122489. * @see http://udn.epicgames.com/Three/ColorGrading.html
  122490. *
  122491. */
  122492. export class ColorCorrectionPostProcess extends PostProcess {
  122493. private _colorTableTexture;
  122494. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  122495. }
  122496. }
  122497. declare module BABYLON {
  122498. /** @hidden */
  122499. export var convolutionPixelShader: {
  122500. name: string;
  122501. shader: string;
  122502. };
  122503. }
  122504. declare module BABYLON {
  122505. /**
  122506. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  122507. * input texture to perform effects such as edge detection or sharpening
  122508. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  122509. */
  122510. export class ConvolutionPostProcess extends PostProcess {
  122511. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  122512. kernel: number[];
  122513. /**
  122514. * Creates a new instance ConvolutionPostProcess
  122515. * @param name The name of the effect.
  122516. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  122517. * @param options The required width/height ratio to downsize to before computing the render pass.
  122518. * @param camera The camera to apply the render pass to.
  122519. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122520. * @param engine The engine which the post process will be applied. (default: current engine)
  122521. * @param reusable If the post process can be reused on the same frame. (default: false)
  122522. * @param textureType Type of textures used when performing the post process. (default: 0)
  122523. */
  122524. constructor(name: string,
  122525. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  122526. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  122527. /**
  122528. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  122529. */
  122530. static EdgeDetect0Kernel: number[];
  122531. /**
  122532. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  122533. */
  122534. static EdgeDetect1Kernel: number[];
  122535. /**
  122536. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  122537. */
  122538. static EdgeDetect2Kernel: number[];
  122539. /**
  122540. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  122541. */
  122542. static SharpenKernel: number[];
  122543. /**
  122544. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  122545. */
  122546. static EmbossKernel: number[];
  122547. /**
  122548. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  122549. */
  122550. static GaussianKernel: number[];
  122551. }
  122552. }
  122553. declare module BABYLON {
  122554. /**
  122555. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  122556. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  122557. * based on samples that have a large difference in distance than the center pixel.
  122558. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  122559. */
  122560. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  122561. direction: Vector2;
  122562. /**
  122563. * Creates a new instance CircleOfConfusionPostProcess
  122564. * @param name The name of the effect.
  122565. * @param scene The scene the effect belongs to.
  122566. * @param direction The direction the blur should be applied.
  122567. * @param kernel The size of the kernel used to blur.
  122568. * @param options The required width/height ratio to downsize to before computing the render pass.
  122569. * @param camera The camera to apply the render pass to.
  122570. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  122571. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  122572. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122573. * @param engine The engine which the post process will be applied. (default: current engine)
  122574. * @param reusable If the post process can be reused on the same frame. (default: false)
  122575. * @param textureType Type of textures used when performing the post process. (default: 0)
  122576. * @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)
  122577. */
  122578. 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);
  122579. }
  122580. }
  122581. declare module BABYLON {
  122582. /** @hidden */
  122583. export var depthOfFieldMergePixelShader: {
  122584. name: string;
  122585. shader: string;
  122586. };
  122587. }
  122588. declare module BABYLON {
  122589. /**
  122590. * Options to be set when merging outputs from the default pipeline.
  122591. */
  122592. export class DepthOfFieldMergePostProcessOptions {
  122593. /**
  122594. * The original image to merge on top of
  122595. */
  122596. originalFromInput: PostProcess;
  122597. /**
  122598. * Parameters to perform the merge of the depth of field effect
  122599. */
  122600. depthOfField?: {
  122601. circleOfConfusion: PostProcess;
  122602. blurSteps: Array<PostProcess>;
  122603. };
  122604. /**
  122605. * Parameters to perform the merge of bloom effect
  122606. */
  122607. bloom?: {
  122608. blurred: PostProcess;
  122609. weight: number;
  122610. };
  122611. }
  122612. /**
  122613. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  122614. */
  122615. export class DepthOfFieldMergePostProcess extends PostProcess {
  122616. private blurSteps;
  122617. /**
  122618. * Creates a new instance of DepthOfFieldMergePostProcess
  122619. * @param name The name of the effect.
  122620. * @param originalFromInput Post process which's input will be used for the merge.
  122621. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  122622. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  122623. * @param options The required width/height ratio to downsize to before computing the render pass.
  122624. * @param camera The camera to apply the render pass to.
  122625. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122626. * @param engine The engine which the post process will be applied. (default: current engine)
  122627. * @param reusable If the post process can be reused on the same frame. (default: false)
  122628. * @param textureType Type of textures used when performing the post process. (default: 0)
  122629. * @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)
  122630. */
  122631. 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);
  122632. /**
  122633. * Updates the effect with the current post process compile time values and recompiles the shader.
  122634. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  122635. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  122636. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  122637. * @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
  122638. * @param onCompiled Called when the shader has been compiled.
  122639. * @param onError Called if there is an error when compiling a shader.
  122640. */
  122641. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  122642. }
  122643. }
  122644. declare module BABYLON {
  122645. /**
  122646. * Specifies the level of max blur that should be applied when using the depth of field effect
  122647. */
  122648. export enum DepthOfFieldEffectBlurLevel {
  122649. /**
  122650. * Subtle blur
  122651. */
  122652. Low = 0,
  122653. /**
  122654. * Medium blur
  122655. */
  122656. Medium = 1,
  122657. /**
  122658. * Large blur
  122659. */
  122660. High = 2
  122661. }
  122662. /**
  122663. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  122664. */
  122665. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  122666. private _circleOfConfusion;
  122667. /**
  122668. * @hidden Internal, blurs from high to low
  122669. */
  122670. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  122671. private _depthOfFieldBlurY;
  122672. private _dofMerge;
  122673. /**
  122674. * @hidden Internal post processes in depth of field effect
  122675. */
  122676. _effects: Array<PostProcess>;
  122677. /**
  122678. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  122679. */
  122680. focalLength: number;
  122681. /**
  122682. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  122683. */
  122684. fStop: number;
  122685. /**
  122686. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  122687. */
  122688. focusDistance: number;
  122689. /**
  122690. * 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.
  122691. */
  122692. lensSize: number;
  122693. /**
  122694. * Creates a new instance DepthOfFieldEffect
  122695. * @param scene The scene the effect belongs to.
  122696. * @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.
  122697. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  122698. * @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)
  122699. */
  122700. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  122701. /**
  122702. * Get the current class name of the current effet
  122703. * @returns "DepthOfFieldEffect"
  122704. */
  122705. getClassName(): string;
  122706. /**
  122707. * 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.
  122708. */
  122709. depthTexture: RenderTargetTexture;
  122710. /**
  122711. * Disposes each of the internal effects for a given camera.
  122712. * @param camera The camera to dispose the effect on.
  122713. */
  122714. disposeEffects(camera: Camera): void;
  122715. /**
  122716. * @hidden Internal
  122717. */
  122718. _updateEffects(): void;
  122719. /**
  122720. * Internal
  122721. * @returns if all the contained post processes are ready.
  122722. * @hidden
  122723. */
  122724. _isReady(): boolean;
  122725. }
  122726. }
  122727. declare module BABYLON {
  122728. /** @hidden */
  122729. export var displayPassPixelShader: {
  122730. name: string;
  122731. shader: string;
  122732. };
  122733. }
  122734. declare module BABYLON {
  122735. /**
  122736. * DisplayPassPostProcess which produces an output the same as it's input
  122737. */
  122738. export class DisplayPassPostProcess extends PostProcess {
  122739. /**
  122740. * Creates the DisplayPassPostProcess
  122741. * @param name The name of the effect.
  122742. * @param options The required width/height ratio to downsize to before computing the render pass.
  122743. * @param camera The camera to apply the render pass to.
  122744. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122745. * @param engine The engine which the post process will be applied. (default: current engine)
  122746. * @param reusable If the post process can be reused on the same frame. (default: false)
  122747. */
  122748. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  122749. }
  122750. }
  122751. declare module BABYLON {
  122752. /** @hidden */
  122753. export var filterPixelShader: {
  122754. name: string;
  122755. shader: string;
  122756. };
  122757. }
  122758. declare module BABYLON {
  122759. /**
  122760. * Applies a kernel filter to the image
  122761. */
  122762. export class FilterPostProcess extends PostProcess {
  122763. /** The matrix to be applied to the image */
  122764. kernelMatrix: Matrix;
  122765. /**
  122766. *
  122767. * @param name The name of the effect.
  122768. * @param kernelMatrix The matrix to be applied to the image
  122769. * @param options The required width/height ratio to downsize to before computing the render pass.
  122770. * @param camera The camera to apply the render pass to.
  122771. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122772. * @param engine The engine which the post process will be applied. (default: current engine)
  122773. * @param reusable If the post process can be reused on the same frame. (default: false)
  122774. */
  122775. constructor(name: string,
  122776. /** The matrix to be applied to the image */
  122777. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  122778. }
  122779. }
  122780. declare module BABYLON {
  122781. /** @hidden */
  122782. export var fxaaPixelShader: {
  122783. name: string;
  122784. shader: string;
  122785. };
  122786. }
  122787. declare module BABYLON {
  122788. /** @hidden */
  122789. export var fxaaVertexShader: {
  122790. name: string;
  122791. shader: string;
  122792. };
  122793. }
  122794. declare module BABYLON {
  122795. /**
  122796. * Fxaa post process
  122797. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  122798. */
  122799. export class FxaaPostProcess extends PostProcess {
  122800. /** @hidden */
  122801. texelWidth: number;
  122802. /** @hidden */
  122803. texelHeight: number;
  122804. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  122805. private _getDefines;
  122806. }
  122807. }
  122808. declare module BABYLON {
  122809. /** @hidden */
  122810. export var grainPixelShader: {
  122811. name: string;
  122812. shader: string;
  122813. };
  122814. }
  122815. declare module BABYLON {
  122816. /**
  122817. * The GrainPostProcess adds noise to the image at mid luminance levels
  122818. */
  122819. export class GrainPostProcess extends PostProcess {
  122820. /**
  122821. * The intensity of the grain added (default: 30)
  122822. */
  122823. intensity: number;
  122824. /**
  122825. * If the grain should be randomized on every frame
  122826. */
  122827. animated: boolean;
  122828. /**
  122829. * Creates a new instance of @see GrainPostProcess
  122830. * @param name The name of the effect.
  122831. * @param options The required width/height ratio to downsize to before computing the render pass.
  122832. * @param camera The camera to apply the render pass to.
  122833. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122834. * @param engine The engine which the post process will be applied. (default: current engine)
  122835. * @param reusable If the post process can be reused on the same frame. (default: false)
  122836. * @param textureType Type of textures used when performing the post process. (default: 0)
  122837. * @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)
  122838. */
  122839. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  122840. }
  122841. }
  122842. declare module BABYLON {
  122843. /** @hidden */
  122844. export var highlightsPixelShader: {
  122845. name: string;
  122846. shader: string;
  122847. };
  122848. }
  122849. declare module BABYLON {
  122850. /**
  122851. * Extracts highlights from the image
  122852. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  122853. */
  122854. export class HighlightsPostProcess extends PostProcess {
  122855. /**
  122856. * Extracts highlights from the image
  122857. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  122858. * @param name The name of the effect.
  122859. * @param options The required width/height ratio to downsize to before computing the render pass.
  122860. * @param camera The camera to apply the render pass to.
  122861. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122862. * @param engine The engine which the post process will be applied. (default: current engine)
  122863. * @param reusable If the post process can be reused on the same frame. (default: false)
  122864. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  122865. */
  122866. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  122867. }
  122868. }
  122869. declare module BABYLON {
  122870. /** @hidden */
  122871. export var mrtFragmentDeclaration: {
  122872. name: string;
  122873. shader: string;
  122874. };
  122875. }
  122876. declare module BABYLON {
  122877. /** @hidden */
  122878. export var geometryPixelShader: {
  122879. name: string;
  122880. shader: string;
  122881. };
  122882. }
  122883. declare module BABYLON {
  122884. /** @hidden */
  122885. export var geometryVertexShader: {
  122886. name: string;
  122887. shader: string;
  122888. };
  122889. }
  122890. declare module BABYLON {
  122891. /** @hidden */
  122892. interface ISavedTransformationMatrix {
  122893. world: Matrix;
  122894. viewProjection: Matrix;
  122895. }
  122896. /**
  122897. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  122898. */
  122899. export class GeometryBufferRenderer {
  122900. /**
  122901. * Constant used to retrieve the position texture index in the G-Buffer textures array
  122902. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  122903. */
  122904. static readonly POSITION_TEXTURE_TYPE: number;
  122905. /**
  122906. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  122907. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  122908. */
  122909. static readonly VELOCITY_TEXTURE_TYPE: number;
  122910. /**
  122911. * Dictionary used to store the previous transformation matrices of each rendered mesh
  122912. * in order to compute objects velocities when enableVelocity is set to "true"
  122913. * @hidden
  122914. */
  122915. _previousTransformationMatrices: {
  122916. [index: number]: ISavedTransformationMatrix;
  122917. };
  122918. /**
  122919. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  122920. * in order to compute objects velocities when enableVelocity is set to "true"
  122921. * @hidden
  122922. */
  122923. _previousBonesTransformationMatrices: {
  122924. [index: number]: Float32Array;
  122925. };
  122926. /**
  122927. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  122928. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  122929. */
  122930. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  122931. private _scene;
  122932. private _multiRenderTarget;
  122933. private _ratio;
  122934. private _enablePosition;
  122935. private _enableVelocity;
  122936. private _positionIndex;
  122937. private _velocityIndex;
  122938. protected _effect: Effect;
  122939. protected _cachedDefines: string;
  122940. /**
  122941. * Set the render list (meshes to be rendered) used in the G buffer.
  122942. */
  122943. renderList: Mesh[];
  122944. /**
  122945. * Gets wether or not G buffer are supported by the running hardware.
  122946. * This requires draw buffer supports
  122947. */
  122948. readonly isSupported: boolean;
  122949. /**
  122950. * Returns the index of the given texture type in the G-Buffer textures array
  122951. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  122952. * @returns the index of the given texture type in the G-Buffer textures array
  122953. */
  122954. getTextureIndex(textureType: number): number;
  122955. /**
  122956. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  122957. */
  122958. /**
  122959. * Sets whether or not objects positions are enabled for the G buffer.
  122960. */
  122961. enablePosition: boolean;
  122962. /**
  122963. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  122964. */
  122965. /**
  122966. * Sets wether or not objects velocities are enabled for the G buffer.
  122967. */
  122968. enableVelocity: boolean;
  122969. /**
  122970. * Gets the scene associated with the buffer.
  122971. */
  122972. readonly scene: Scene;
  122973. /**
  122974. * Gets the ratio used by the buffer during its creation.
  122975. * How big is the buffer related to the main canvas.
  122976. */
  122977. readonly ratio: number;
  122978. /** @hidden */
  122979. static _SceneComponentInitialization: (scene: Scene) => void;
  122980. /**
  122981. * Creates a new G Buffer for the scene
  122982. * @param scene The scene the buffer belongs to
  122983. * @param ratio How big is the buffer related to the main canvas.
  122984. */
  122985. constructor(scene: Scene, ratio?: number);
  122986. /**
  122987. * Checks wether everything is ready to render a submesh to the G buffer.
  122988. * @param subMesh the submesh to check readiness for
  122989. * @param useInstances is the mesh drawn using instance or not
  122990. * @returns true if ready otherwise false
  122991. */
  122992. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  122993. /**
  122994. * Gets the current underlying G Buffer.
  122995. * @returns the buffer
  122996. */
  122997. getGBuffer(): MultiRenderTarget;
  122998. /**
  122999. * Gets the number of samples used to render the buffer (anti aliasing).
  123000. */
  123001. /**
  123002. * Sets the number of samples used to render the buffer (anti aliasing).
  123003. */
  123004. samples: number;
  123005. /**
  123006. * Disposes the renderer and frees up associated resources.
  123007. */
  123008. dispose(): void;
  123009. protected _createRenderTargets(): void;
  123010. private _copyBonesTransformationMatrices;
  123011. }
  123012. }
  123013. declare module BABYLON {
  123014. interface Scene {
  123015. /** @hidden (Backing field) */
  123016. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  123017. /**
  123018. * Gets or Sets the current geometry buffer associated to the scene.
  123019. */
  123020. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  123021. /**
  123022. * Enables a GeometryBufferRender and associates it with the scene
  123023. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  123024. * @returns the GeometryBufferRenderer
  123025. */
  123026. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  123027. /**
  123028. * Disables the GeometryBufferRender associated with the scene
  123029. */
  123030. disableGeometryBufferRenderer(): void;
  123031. }
  123032. /**
  123033. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  123034. * in several rendering techniques.
  123035. */
  123036. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  123037. /**
  123038. * The component name helpful to identify the component in the list of scene components.
  123039. */
  123040. readonly name: string;
  123041. /**
  123042. * The scene the component belongs to.
  123043. */
  123044. scene: Scene;
  123045. /**
  123046. * Creates a new instance of the component for the given scene
  123047. * @param scene Defines the scene to register the component in
  123048. */
  123049. constructor(scene: Scene);
  123050. /**
  123051. * Registers the component in a given scene
  123052. */
  123053. register(): void;
  123054. /**
  123055. * Rebuilds the elements related to this component in case of
  123056. * context lost for instance.
  123057. */
  123058. rebuild(): void;
  123059. /**
  123060. * Disposes the component and the associated ressources
  123061. */
  123062. dispose(): void;
  123063. private _gatherRenderTargets;
  123064. }
  123065. }
  123066. declare module BABYLON {
  123067. /** @hidden */
  123068. export var motionBlurPixelShader: {
  123069. name: string;
  123070. shader: string;
  123071. };
  123072. }
  123073. declare module BABYLON {
  123074. /**
  123075. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  123076. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  123077. * As an example, all you have to do is to create the post-process:
  123078. * var mb = new BABYLON.MotionBlurPostProcess(
  123079. * 'mb', // The name of the effect.
  123080. * scene, // The scene containing the objects to blur according to their velocity.
  123081. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  123082. * camera // The camera to apply the render pass to.
  123083. * );
  123084. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  123085. */
  123086. export class MotionBlurPostProcess extends PostProcess {
  123087. /**
  123088. * Defines how much the image is blurred by the movement. Default value is equal to 1
  123089. */
  123090. motionStrength: number;
  123091. /**
  123092. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  123093. */
  123094. /**
  123095. * Sets the number of iterations to be used for motion blur quality
  123096. */
  123097. motionBlurSamples: number;
  123098. private _motionBlurSamples;
  123099. private _geometryBufferRenderer;
  123100. /**
  123101. * Creates a new instance MotionBlurPostProcess
  123102. * @param name The name of the effect.
  123103. * @param scene The scene containing the objects to blur according to their velocity.
  123104. * @param options The required width/height ratio to downsize to before computing the render pass.
  123105. * @param camera The camera to apply the render pass to.
  123106. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123107. * @param engine The engine which the post process will be applied. (default: current engine)
  123108. * @param reusable If the post process can be reused on the same frame. (default: false)
  123109. * @param textureType Type of textures used when performing the post process. (default: 0)
  123110. * @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)
  123111. */
  123112. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  123113. /**
  123114. * Excludes the given skinned mesh from computing bones velocities.
  123115. * 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.
  123116. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  123117. */
  123118. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  123119. /**
  123120. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  123121. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  123122. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  123123. */
  123124. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  123125. /**
  123126. * Disposes the post process.
  123127. * @param camera The camera to dispose the post process on.
  123128. */
  123129. dispose(camera?: Camera): void;
  123130. }
  123131. }
  123132. declare module BABYLON {
  123133. /** @hidden */
  123134. export var refractionPixelShader: {
  123135. name: string;
  123136. shader: string;
  123137. };
  123138. }
  123139. declare module BABYLON {
  123140. /**
  123141. * Post process which applies a refractin texture
  123142. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  123143. */
  123144. export class RefractionPostProcess extends PostProcess {
  123145. /** the base color of the refraction (used to taint the rendering) */
  123146. color: Color3;
  123147. /** simulated refraction depth */
  123148. depth: number;
  123149. /** the coefficient of the base color (0 to remove base color tainting) */
  123150. colorLevel: number;
  123151. private _refTexture;
  123152. private _ownRefractionTexture;
  123153. /**
  123154. * Gets or sets the refraction texture
  123155. * Please note that you are responsible for disposing the texture if you set it manually
  123156. */
  123157. refractionTexture: Texture;
  123158. /**
  123159. * Initializes the RefractionPostProcess
  123160. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  123161. * @param name The name of the effect.
  123162. * @param refractionTextureUrl Url of the refraction texture to use
  123163. * @param color the base color of the refraction (used to taint the rendering)
  123164. * @param depth simulated refraction depth
  123165. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  123166. * @param camera The camera to apply the render pass to.
  123167. * @param options The required width/height ratio to downsize to before computing the render pass.
  123168. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123169. * @param engine The engine which the post process will be applied. (default: current engine)
  123170. * @param reusable If the post process can be reused on the same frame. (default: false)
  123171. */
  123172. constructor(name: string, refractionTextureUrl: string,
  123173. /** the base color of the refraction (used to taint the rendering) */
  123174. color: Color3,
  123175. /** simulated refraction depth */
  123176. depth: number,
  123177. /** the coefficient of the base color (0 to remove base color tainting) */
  123178. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  123179. /**
  123180. * Disposes of the post process
  123181. * @param camera Camera to dispose post process on
  123182. */
  123183. dispose(camera: Camera): void;
  123184. }
  123185. }
  123186. declare module BABYLON {
  123187. /** @hidden */
  123188. export var sharpenPixelShader: {
  123189. name: string;
  123190. shader: string;
  123191. };
  123192. }
  123193. declare module BABYLON {
  123194. /**
  123195. * The SharpenPostProcess applies a sharpen kernel to every pixel
  123196. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  123197. */
  123198. export class SharpenPostProcess extends PostProcess {
  123199. /**
  123200. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  123201. */
  123202. colorAmount: number;
  123203. /**
  123204. * How much sharpness should be applied (default: 0.3)
  123205. */
  123206. edgeAmount: number;
  123207. /**
  123208. * Creates a new instance ConvolutionPostProcess
  123209. * @param name The name of the effect.
  123210. * @param options The required width/height ratio to downsize to before computing the render pass.
  123211. * @param camera The camera to apply the render pass to.
  123212. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123213. * @param engine The engine which the post process will be applied. (default: current engine)
  123214. * @param reusable If the post process can be reused on the same frame. (default: false)
  123215. * @param textureType Type of textures used when performing the post process. (default: 0)
  123216. * @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)
  123217. */
  123218. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  123219. }
  123220. }
  123221. declare module BABYLON {
  123222. /**
  123223. * PostProcessRenderPipeline
  123224. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  123225. */
  123226. export class PostProcessRenderPipeline {
  123227. private engine;
  123228. private _renderEffects;
  123229. private _renderEffectsForIsolatedPass;
  123230. /**
  123231. * List of inspectable custom properties (used by the Inspector)
  123232. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  123233. */
  123234. inspectableCustomProperties: IInspectable[];
  123235. /**
  123236. * @hidden
  123237. */
  123238. protected _cameras: Camera[];
  123239. /** @hidden */
  123240. _name: string;
  123241. /**
  123242. * Gets pipeline name
  123243. */
  123244. readonly name: string;
  123245. /**
  123246. * Initializes a PostProcessRenderPipeline
  123247. * @param engine engine to add the pipeline to
  123248. * @param name name of the pipeline
  123249. */
  123250. constructor(engine: Engine, name: string);
  123251. /**
  123252. * Gets the class name
  123253. * @returns "PostProcessRenderPipeline"
  123254. */
  123255. getClassName(): string;
  123256. /**
  123257. * If all the render effects in the pipeline are supported
  123258. */
  123259. readonly isSupported: boolean;
  123260. /**
  123261. * Adds an effect to the pipeline
  123262. * @param renderEffect the effect to add
  123263. */
  123264. addEffect(renderEffect: PostProcessRenderEffect): void;
  123265. /** @hidden */
  123266. _rebuild(): void;
  123267. /** @hidden */
  123268. _enableEffect(renderEffectName: string, cameras: Camera): void;
  123269. /** @hidden */
  123270. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  123271. /** @hidden */
  123272. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  123273. /** @hidden */
  123274. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  123275. /** @hidden */
  123276. _attachCameras(cameras: Camera, unique: boolean): void;
  123277. /** @hidden */
  123278. _attachCameras(cameras: Camera[], unique: boolean): void;
  123279. /** @hidden */
  123280. _detachCameras(cameras: Camera): void;
  123281. /** @hidden */
  123282. _detachCameras(cameras: Nullable<Camera[]>): void;
  123283. /** @hidden */
  123284. _update(): void;
  123285. /** @hidden */
  123286. _reset(): void;
  123287. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  123288. /**
  123289. * Disposes of the pipeline
  123290. */
  123291. dispose(): void;
  123292. }
  123293. }
  123294. declare module BABYLON {
  123295. /**
  123296. * PostProcessRenderPipelineManager class
  123297. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  123298. */
  123299. export class PostProcessRenderPipelineManager {
  123300. private _renderPipelines;
  123301. /**
  123302. * Initializes a PostProcessRenderPipelineManager
  123303. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  123304. */
  123305. constructor();
  123306. /**
  123307. * Gets the list of supported render pipelines
  123308. */
  123309. readonly supportedPipelines: PostProcessRenderPipeline[];
  123310. /**
  123311. * Adds a pipeline to the manager
  123312. * @param renderPipeline The pipeline to add
  123313. */
  123314. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  123315. /**
  123316. * Attaches a camera to the pipeline
  123317. * @param renderPipelineName The name of the pipeline to attach to
  123318. * @param cameras the camera to attach
  123319. * @param unique if the camera can be attached multiple times to the pipeline
  123320. */
  123321. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  123322. /**
  123323. * Detaches a camera from the pipeline
  123324. * @param renderPipelineName The name of the pipeline to detach from
  123325. * @param cameras the camera to detach
  123326. */
  123327. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  123328. /**
  123329. * Enables an effect by name on a pipeline
  123330. * @param renderPipelineName the name of the pipeline to enable the effect in
  123331. * @param renderEffectName the name of the effect to enable
  123332. * @param cameras the cameras that the effect should be enabled on
  123333. */
  123334. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  123335. /**
  123336. * Disables an effect by name on a pipeline
  123337. * @param renderPipelineName the name of the pipeline to disable the effect in
  123338. * @param renderEffectName the name of the effect to disable
  123339. * @param cameras the cameras that the effect should be disabled on
  123340. */
  123341. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  123342. /**
  123343. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  123344. */
  123345. update(): void;
  123346. /** @hidden */
  123347. _rebuild(): void;
  123348. /**
  123349. * Disposes of the manager and pipelines
  123350. */
  123351. dispose(): void;
  123352. }
  123353. }
  123354. declare module BABYLON {
  123355. interface Scene {
  123356. /** @hidden (Backing field) */
  123357. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  123358. /**
  123359. * Gets the postprocess render pipeline manager
  123360. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  123361. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  123362. */
  123363. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  123364. }
  123365. /**
  123366. * Defines the Render Pipeline scene component responsible to rendering pipelines
  123367. */
  123368. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  123369. /**
  123370. * The component name helpfull to identify the component in the list of scene components.
  123371. */
  123372. readonly name: string;
  123373. /**
  123374. * The scene the component belongs to.
  123375. */
  123376. scene: Scene;
  123377. /**
  123378. * Creates a new instance of the component for the given scene
  123379. * @param scene Defines the scene to register the component in
  123380. */
  123381. constructor(scene: Scene);
  123382. /**
  123383. * Registers the component in a given scene
  123384. */
  123385. register(): void;
  123386. /**
  123387. * Rebuilds the elements related to this component in case of
  123388. * context lost for instance.
  123389. */
  123390. rebuild(): void;
  123391. /**
  123392. * Disposes the component and the associated ressources
  123393. */
  123394. dispose(): void;
  123395. private _gatherRenderTargets;
  123396. }
  123397. }
  123398. declare module BABYLON {
  123399. /**
  123400. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  123401. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  123402. */
  123403. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  123404. private _scene;
  123405. private _camerasToBeAttached;
  123406. /**
  123407. * ID of the sharpen post process,
  123408. */
  123409. private readonly SharpenPostProcessId;
  123410. /**
  123411. * @ignore
  123412. * ID of the image processing post process;
  123413. */
  123414. readonly ImageProcessingPostProcessId: string;
  123415. /**
  123416. * @ignore
  123417. * ID of the Fast Approximate Anti-Aliasing post process;
  123418. */
  123419. readonly FxaaPostProcessId: string;
  123420. /**
  123421. * ID of the chromatic aberration post process,
  123422. */
  123423. private readonly ChromaticAberrationPostProcessId;
  123424. /**
  123425. * ID of the grain post process
  123426. */
  123427. private readonly GrainPostProcessId;
  123428. /**
  123429. * Sharpen post process which will apply a sharpen convolution to enhance edges
  123430. */
  123431. sharpen: SharpenPostProcess;
  123432. private _sharpenEffect;
  123433. private bloom;
  123434. /**
  123435. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  123436. */
  123437. depthOfField: DepthOfFieldEffect;
  123438. /**
  123439. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  123440. */
  123441. fxaa: FxaaPostProcess;
  123442. /**
  123443. * Image post processing pass used to perform operations such as tone mapping or color grading.
  123444. */
  123445. imageProcessing: ImageProcessingPostProcess;
  123446. /**
  123447. * Chromatic aberration post process which will shift rgb colors in the image
  123448. */
  123449. chromaticAberration: ChromaticAberrationPostProcess;
  123450. private _chromaticAberrationEffect;
  123451. /**
  123452. * Grain post process which add noise to the image
  123453. */
  123454. grain: GrainPostProcess;
  123455. private _grainEffect;
  123456. /**
  123457. * Glow post process which adds a glow to emissive areas of the image
  123458. */
  123459. private _glowLayer;
  123460. /**
  123461. * Animations which can be used to tweak settings over a period of time
  123462. */
  123463. animations: Animation[];
  123464. private _imageProcessingConfigurationObserver;
  123465. private _sharpenEnabled;
  123466. private _bloomEnabled;
  123467. private _depthOfFieldEnabled;
  123468. private _depthOfFieldBlurLevel;
  123469. private _fxaaEnabled;
  123470. private _imageProcessingEnabled;
  123471. private _defaultPipelineTextureType;
  123472. private _bloomScale;
  123473. private _chromaticAberrationEnabled;
  123474. private _grainEnabled;
  123475. private _buildAllowed;
  123476. /**
  123477. * Gets active scene
  123478. */
  123479. readonly scene: Scene;
  123480. /**
  123481. * Enable or disable the sharpen process from the pipeline
  123482. */
  123483. sharpenEnabled: boolean;
  123484. private _resizeObserver;
  123485. private _hardwareScaleLevel;
  123486. private _bloomKernel;
  123487. /**
  123488. * Specifies the size of the bloom blur kernel, relative to the final output size
  123489. */
  123490. bloomKernel: number;
  123491. /**
  123492. * Specifies the weight of the bloom in the final rendering
  123493. */
  123494. private _bloomWeight;
  123495. /**
  123496. * Specifies the luma threshold for the area that will be blurred by the bloom
  123497. */
  123498. private _bloomThreshold;
  123499. private _hdr;
  123500. /**
  123501. * The strength of the bloom.
  123502. */
  123503. bloomWeight: number;
  123504. /**
  123505. * The strength of the bloom.
  123506. */
  123507. bloomThreshold: number;
  123508. /**
  123509. * The scale of the bloom, lower value will provide better performance.
  123510. */
  123511. bloomScale: number;
  123512. /**
  123513. * Enable or disable the bloom from the pipeline
  123514. */
  123515. bloomEnabled: boolean;
  123516. private _rebuildBloom;
  123517. /**
  123518. * If the depth of field is enabled.
  123519. */
  123520. depthOfFieldEnabled: boolean;
  123521. /**
  123522. * Blur level of the depth of field effect. (Higher blur will effect performance)
  123523. */
  123524. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  123525. /**
  123526. * If the anti aliasing is enabled.
  123527. */
  123528. fxaaEnabled: boolean;
  123529. private _samples;
  123530. /**
  123531. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  123532. */
  123533. samples: number;
  123534. /**
  123535. * If image processing is enabled.
  123536. */
  123537. imageProcessingEnabled: boolean;
  123538. /**
  123539. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  123540. */
  123541. glowLayerEnabled: boolean;
  123542. /**
  123543. * Gets the glow layer (or null if not defined)
  123544. */
  123545. readonly glowLayer: Nullable<GlowLayer>;
  123546. /**
  123547. * Enable or disable the chromaticAberration process from the pipeline
  123548. */
  123549. chromaticAberrationEnabled: boolean;
  123550. /**
  123551. * Enable or disable the grain process from the pipeline
  123552. */
  123553. grainEnabled: boolean;
  123554. /**
  123555. * @constructor
  123556. * @param name - The rendering pipeline name (default: "")
  123557. * @param hdr - If high dynamic range textures should be used (default: true)
  123558. * @param scene - The scene linked to this pipeline (default: the last created scene)
  123559. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  123560. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  123561. */
  123562. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  123563. /**
  123564. * Get the class name
  123565. * @returns "DefaultRenderingPipeline"
  123566. */
  123567. getClassName(): string;
  123568. /**
  123569. * Force the compilation of the entire pipeline.
  123570. */
  123571. prepare(): void;
  123572. private _hasCleared;
  123573. private _prevPostProcess;
  123574. private _prevPrevPostProcess;
  123575. private _setAutoClearAndTextureSharing;
  123576. private _depthOfFieldSceneObserver;
  123577. private _buildPipeline;
  123578. private _disposePostProcesses;
  123579. /**
  123580. * Adds a camera to the pipeline
  123581. * @param camera the camera to be added
  123582. */
  123583. addCamera(camera: Camera): void;
  123584. /**
  123585. * Removes a camera from the pipeline
  123586. * @param camera the camera to remove
  123587. */
  123588. removeCamera(camera: Camera): void;
  123589. /**
  123590. * Dispose of the pipeline and stop all post processes
  123591. */
  123592. dispose(): void;
  123593. /**
  123594. * Serialize the rendering pipeline (Used when exporting)
  123595. * @returns the serialized object
  123596. */
  123597. serialize(): any;
  123598. /**
  123599. * Parse the serialized pipeline
  123600. * @param source Source pipeline.
  123601. * @param scene The scene to load the pipeline to.
  123602. * @param rootUrl The URL of the serialized pipeline.
  123603. * @returns An instantiated pipeline from the serialized object.
  123604. */
  123605. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  123606. }
  123607. }
  123608. declare module BABYLON {
  123609. /** @hidden */
  123610. export var lensHighlightsPixelShader: {
  123611. name: string;
  123612. shader: string;
  123613. };
  123614. }
  123615. declare module BABYLON {
  123616. /** @hidden */
  123617. export var depthOfFieldPixelShader: {
  123618. name: string;
  123619. shader: string;
  123620. };
  123621. }
  123622. declare module BABYLON {
  123623. /**
  123624. * BABYLON.JS Chromatic Aberration GLSL Shader
  123625. * Author: Olivier Guyot
  123626. * Separates very slightly R, G and B colors on the edges of the screen
  123627. * Inspired by Francois Tarlier & Martins Upitis
  123628. */
  123629. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  123630. /**
  123631. * @ignore
  123632. * The chromatic aberration PostProcess id in the pipeline
  123633. */
  123634. LensChromaticAberrationEffect: string;
  123635. /**
  123636. * @ignore
  123637. * The highlights enhancing PostProcess id in the pipeline
  123638. */
  123639. HighlightsEnhancingEffect: string;
  123640. /**
  123641. * @ignore
  123642. * The depth-of-field PostProcess id in the pipeline
  123643. */
  123644. LensDepthOfFieldEffect: string;
  123645. private _scene;
  123646. private _depthTexture;
  123647. private _grainTexture;
  123648. private _chromaticAberrationPostProcess;
  123649. private _highlightsPostProcess;
  123650. private _depthOfFieldPostProcess;
  123651. private _edgeBlur;
  123652. private _grainAmount;
  123653. private _chromaticAberration;
  123654. private _distortion;
  123655. private _highlightsGain;
  123656. private _highlightsThreshold;
  123657. private _dofDistance;
  123658. private _dofAperture;
  123659. private _dofDarken;
  123660. private _dofPentagon;
  123661. private _blurNoise;
  123662. /**
  123663. * @constructor
  123664. *
  123665. * Effect parameters are as follow:
  123666. * {
  123667. * chromatic_aberration: number; // from 0 to x (1 for realism)
  123668. * edge_blur: number; // from 0 to x (1 for realism)
  123669. * distortion: number; // from 0 to x (1 for realism)
  123670. * grain_amount: number; // from 0 to 1
  123671. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  123672. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  123673. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  123674. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  123675. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  123676. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  123677. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  123678. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  123679. * }
  123680. * Note: if an effect parameter is unset, effect is disabled
  123681. *
  123682. * @param name The rendering pipeline name
  123683. * @param parameters - An object containing all parameters (see above)
  123684. * @param scene The scene linked to this pipeline
  123685. * @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)
  123686. * @param cameras The array of cameras that the rendering pipeline will be attached to
  123687. */
  123688. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  123689. /**
  123690. * Get the class name
  123691. * @returns "LensRenderingPipeline"
  123692. */
  123693. getClassName(): string;
  123694. /**
  123695. * Gets associated scene
  123696. */
  123697. readonly scene: Scene;
  123698. /**
  123699. * Gets or sets the edge blur
  123700. */
  123701. edgeBlur: number;
  123702. /**
  123703. * Gets or sets the grain amount
  123704. */
  123705. grainAmount: number;
  123706. /**
  123707. * Gets or sets the chromatic aberration amount
  123708. */
  123709. chromaticAberration: number;
  123710. /**
  123711. * Gets or sets the depth of field aperture
  123712. */
  123713. dofAperture: number;
  123714. /**
  123715. * Gets or sets the edge distortion
  123716. */
  123717. edgeDistortion: number;
  123718. /**
  123719. * Gets or sets the depth of field distortion
  123720. */
  123721. dofDistortion: number;
  123722. /**
  123723. * Gets or sets the darken out of focus amount
  123724. */
  123725. darkenOutOfFocus: number;
  123726. /**
  123727. * Gets or sets a boolean indicating if blur noise is enabled
  123728. */
  123729. blurNoise: boolean;
  123730. /**
  123731. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  123732. */
  123733. pentagonBokeh: boolean;
  123734. /**
  123735. * Gets or sets the highlight grain amount
  123736. */
  123737. highlightsGain: number;
  123738. /**
  123739. * Gets or sets the highlight threshold
  123740. */
  123741. highlightsThreshold: number;
  123742. /**
  123743. * Sets the amount of blur at the edges
  123744. * @param amount blur amount
  123745. */
  123746. setEdgeBlur(amount: number): void;
  123747. /**
  123748. * Sets edge blur to 0
  123749. */
  123750. disableEdgeBlur(): void;
  123751. /**
  123752. * Sets the amout of grain
  123753. * @param amount Amount of grain
  123754. */
  123755. setGrainAmount(amount: number): void;
  123756. /**
  123757. * Set grain amount to 0
  123758. */
  123759. disableGrain(): void;
  123760. /**
  123761. * Sets the chromatic aberration amount
  123762. * @param amount amount of chromatic aberration
  123763. */
  123764. setChromaticAberration(amount: number): void;
  123765. /**
  123766. * Sets chromatic aberration amount to 0
  123767. */
  123768. disableChromaticAberration(): void;
  123769. /**
  123770. * Sets the EdgeDistortion amount
  123771. * @param amount amount of EdgeDistortion
  123772. */
  123773. setEdgeDistortion(amount: number): void;
  123774. /**
  123775. * Sets edge distortion to 0
  123776. */
  123777. disableEdgeDistortion(): void;
  123778. /**
  123779. * Sets the FocusDistance amount
  123780. * @param amount amount of FocusDistance
  123781. */
  123782. setFocusDistance(amount: number): void;
  123783. /**
  123784. * Disables depth of field
  123785. */
  123786. disableDepthOfField(): void;
  123787. /**
  123788. * Sets the Aperture amount
  123789. * @param amount amount of Aperture
  123790. */
  123791. setAperture(amount: number): void;
  123792. /**
  123793. * Sets the DarkenOutOfFocus amount
  123794. * @param amount amount of DarkenOutOfFocus
  123795. */
  123796. setDarkenOutOfFocus(amount: number): void;
  123797. private _pentagonBokehIsEnabled;
  123798. /**
  123799. * Creates a pentagon bokeh effect
  123800. */
  123801. enablePentagonBokeh(): void;
  123802. /**
  123803. * Disables the pentagon bokeh effect
  123804. */
  123805. disablePentagonBokeh(): void;
  123806. /**
  123807. * Enables noise blur
  123808. */
  123809. enableNoiseBlur(): void;
  123810. /**
  123811. * Disables noise blur
  123812. */
  123813. disableNoiseBlur(): void;
  123814. /**
  123815. * Sets the HighlightsGain amount
  123816. * @param amount amount of HighlightsGain
  123817. */
  123818. setHighlightsGain(amount: number): void;
  123819. /**
  123820. * Sets the HighlightsThreshold amount
  123821. * @param amount amount of HighlightsThreshold
  123822. */
  123823. setHighlightsThreshold(amount: number): void;
  123824. /**
  123825. * Disables highlights
  123826. */
  123827. disableHighlights(): void;
  123828. /**
  123829. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  123830. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  123831. */
  123832. dispose(disableDepthRender?: boolean): void;
  123833. private _createChromaticAberrationPostProcess;
  123834. private _createHighlightsPostProcess;
  123835. private _createDepthOfFieldPostProcess;
  123836. private _createGrainTexture;
  123837. }
  123838. }
  123839. declare module BABYLON {
  123840. /** @hidden */
  123841. export var ssao2PixelShader: {
  123842. name: string;
  123843. shader: string;
  123844. };
  123845. }
  123846. declare module BABYLON {
  123847. /** @hidden */
  123848. export var ssaoCombinePixelShader: {
  123849. name: string;
  123850. shader: string;
  123851. };
  123852. }
  123853. declare module BABYLON {
  123854. /**
  123855. * Render pipeline to produce ssao effect
  123856. */
  123857. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  123858. /**
  123859. * @ignore
  123860. * The PassPostProcess id in the pipeline that contains the original scene color
  123861. */
  123862. SSAOOriginalSceneColorEffect: string;
  123863. /**
  123864. * @ignore
  123865. * The SSAO PostProcess id in the pipeline
  123866. */
  123867. SSAORenderEffect: string;
  123868. /**
  123869. * @ignore
  123870. * The horizontal blur PostProcess id in the pipeline
  123871. */
  123872. SSAOBlurHRenderEffect: string;
  123873. /**
  123874. * @ignore
  123875. * The vertical blur PostProcess id in the pipeline
  123876. */
  123877. SSAOBlurVRenderEffect: string;
  123878. /**
  123879. * @ignore
  123880. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  123881. */
  123882. SSAOCombineRenderEffect: string;
  123883. /**
  123884. * The output strength of the SSAO post-process. Default value is 1.0.
  123885. */
  123886. totalStrength: number;
  123887. /**
  123888. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  123889. */
  123890. maxZ: number;
  123891. /**
  123892. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  123893. */
  123894. minZAspect: number;
  123895. private _samples;
  123896. /**
  123897. * Number of samples used for the SSAO calculations. Default value is 8
  123898. */
  123899. samples: number;
  123900. private _textureSamples;
  123901. /**
  123902. * Number of samples to use for antialiasing
  123903. */
  123904. textureSamples: number;
  123905. /**
  123906. * Ratio object used for SSAO ratio and blur ratio
  123907. */
  123908. private _ratio;
  123909. /**
  123910. * Dynamically generated sphere sampler.
  123911. */
  123912. private _sampleSphere;
  123913. /**
  123914. * Blur filter offsets
  123915. */
  123916. private _samplerOffsets;
  123917. private _expensiveBlur;
  123918. /**
  123919. * If bilateral blur should be used
  123920. */
  123921. expensiveBlur: boolean;
  123922. /**
  123923. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  123924. */
  123925. radius: number;
  123926. /**
  123927. * The base color of the SSAO post-process
  123928. * The final result is "base + ssao" between [0, 1]
  123929. */
  123930. base: number;
  123931. /**
  123932. * Support test.
  123933. */
  123934. static readonly IsSupported: boolean;
  123935. private _scene;
  123936. private _depthTexture;
  123937. private _normalTexture;
  123938. private _randomTexture;
  123939. private _originalColorPostProcess;
  123940. private _ssaoPostProcess;
  123941. private _blurHPostProcess;
  123942. private _blurVPostProcess;
  123943. private _ssaoCombinePostProcess;
  123944. private _firstUpdate;
  123945. /**
  123946. * Gets active scene
  123947. */
  123948. readonly scene: Scene;
  123949. /**
  123950. * @constructor
  123951. * @param name The rendering pipeline name
  123952. * @param scene The scene linked to this pipeline
  123953. * @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 }
  123954. * @param cameras The array of cameras that the rendering pipeline will be attached to
  123955. */
  123956. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  123957. /**
  123958. * Get the class name
  123959. * @returns "SSAO2RenderingPipeline"
  123960. */
  123961. getClassName(): string;
  123962. /**
  123963. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  123964. */
  123965. dispose(disableGeometryBufferRenderer?: boolean): void;
  123966. private _createBlurPostProcess;
  123967. /** @hidden */
  123968. _rebuild(): void;
  123969. private _bits;
  123970. private _radicalInverse_VdC;
  123971. private _hammersley;
  123972. private _hemisphereSample_uniform;
  123973. private _generateHemisphere;
  123974. private _createSSAOPostProcess;
  123975. private _createSSAOCombinePostProcess;
  123976. private _createRandomTexture;
  123977. /**
  123978. * Serialize the rendering pipeline (Used when exporting)
  123979. * @returns the serialized object
  123980. */
  123981. serialize(): any;
  123982. /**
  123983. * Parse the serialized pipeline
  123984. * @param source Source pipeline.
  123985. * @param scene The scene to load the pipeline to.
  123986. * @param rootUrl The URL of the serialized pipeline.
  123987. * @returns An instantiated pipeline from the serialized object.
  123988. */
  123989. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  123990. }
  123991. }
  123992. declare module BABYLON {
  123993. /** @hidden */
  123994. export var ssaoPixelShader: {
  123995. name: string;
  123996. shader: string;
  123997. };
  123998. }
  123999. declare module BABYLON {
  124000. /**
  124001. * Render pipeline to produce ssao effect
  124002. */
  124003. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  124004. /**
  124005. * @ignore
  124006. * The PassPostProcess id in the pipeline that contains the original scene color
  124007. */
  124008. SSAOOriginalSceneColorEffect: string;
  124009. /**
  124010. * @ignore
  124011. * The SSAO PostProcess id in the pipeline
  124012. */
  124013. SSAORenderEffect: string;
  124014. /**
  124015. * @ignore
  124016. * The horizontal blur PostProcess id in the pipeline
  124017. */
  124018. SSAOBlurHRenderEffect: string;
  124019. /**
  124020. * @ignore
  124021. * The vertical blur PostProcess id in the pipeline
  124022. */
  124023. SSAOBlurVRenderEffect: string;
  124024. /**
  124025. * @ignore
  124026. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  124027. */
  124028. SSAOCombineRenderEffect: string;
  124029. /**
  124030. * The output strength of the SSAO post-process. Default value is 1.0.
  124031. */
  124032. totalStrength: number;
  124033. /**
  124034. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  124035. */
  124036. radius: number;
  124037. /**
  124038. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  124039. * Must not be equal to fallOff and superior to fallOff.
  124040. * Default value is 0.0075
  124041. */
  124042. area: number;
  124043. /**
  124044. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  124045. * Must not be equal to area and inferior to area.
  124046. * Default value is 0.000001
  124047. */
  124048. fallOff: number;
  124049. /**
  124050. * The base color of the SSAO post-process
  124051. * The final result is "base + ssao" between [0, 1]
  124052. */
  124053. base: number;
  124054. private _scene;
  124055. private _depthTexture;
  124056. private _randomTexture;
  124057. private _originalColorPostProcess;
  124058. private _ssaoPostProcess;
  124059. private _blurHPostProcess;
  124060. private _blurVPostProcess;
  124061. private _ssaoCombinePostProcess;
  124062. private _firstUpdate;
  124063. /**
  124064. * Gets active scene
  124065. */
  124066. readonly scene: Scene;
  124067. /**
  124068. * @constructor
  124069. * @param name - The rendering pipeline name
  124070. * @param scene - The scene linked to this pipeline
  124071. * @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 }
  124072. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  124073. */
  124074. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  124075. /**
  124076. * Get the class name
  124077. * @returns "SSAORenderingPipeline"
  124078. */
  124079. getClassName(): string;
  124080. /**
  124081. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  124082. */
  124083. dispose(disableDepthRender?: boolean): void;
  124084. private _createBlurPostProcess;
  124085. /** @hidden */
  124086. _rebuild(): void;
  124087. private _createSSAOPostProcess;
  124088. private _createSSAOCombinePostProcess;
  124089. private _createRandomTexture;
  124090. }
  124091. }
  124092. declare module BABYLON {
  124093. /** @hidden */
  124094. export var standardPixelShader: {
  124095. name: string;
  124096. shader: string;
  124097. };
  124098. }
  124099. declare module BABYLON {
  124100. /**
  124101. * Standard rendering pipeline
  124102. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  124103. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  124104. */
  124105. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  124106. /**
  124107. * Public members
  124108. */
  124109. /**
  124110. * Post-process which contains the original scene color before the pipeline applies all the effects
  124111. */
  124112. originalPostProcess: Nullable<PostProcess>;
  124113. /**
  124114. * Post-process used to down scale an image x4
  124115. */
  124116. downSampleX4PostProcess: Nullable<PostProcess>;
  124117. /**
  124118. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  124119. */
  124120. brightPassPostProcess: Nullable<PostProcess>;
  124121. /**
  124122. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  124123. */
  124124. blurHPostProcesses: PostProcess[];
  124125. /**
  124126. * Post-process array storing all the vertical blur post-processes used by the pipeline
  124127. */
  124128. blurVPostProcesses: PostProcess[];
  124129. /**
  124130. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  124131. */
  124132. textureAdderPostProcess: Nullable<PostProcess>;
  124133. /**
  124134. * Post-process used to create volumetric lighting effect
  124135. */
  124136. volumetricLightPostProcess: Nullable<PostProcess>;
  124137. /**
  124138. * Post-process used to smooth the previous volumetric light post-process on the X axis
  124139. */
  124140. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  124141. /**
  124142. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  124143. */
  124144. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  124145. /**
  124146. * Post-process used to merge the volumetric light effect and the real scene color
  124147. */
  124148. volumetricLightMergePostProces: Nullable<PostProcess>;
  124149. /**
  124150. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  124151. */
  124152. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  124153. /**
  124154. * Base post-process used to calculate the average luminance of the final image for HDR
  124155. */
  124156. luminancePostProcess: Nullable<PostProcess>;
  124157. /**
  124158. * Post-processes used to create down sample post-processes in order to get
  124159. * the average luminance of the final image for HDR
  124160. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  124161. */
  124162. luminanceDownSamplePostProcesses: PostProcess[];
  124163. /**
  124164. * Post-process used to create a HDR effect (light adaptation)
  124165. */
  124166. hdrPostProcess: Nullable<PostProcess>;
  124167. /**
  124168. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  124169. */
  124170. textureAdderFinalPostProcess: Nullable<PostProcess>;
  124171. /**
  124172. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  124173. */
  124174. lensFlareFinalPostProcess: Nullable<PostProcess>;
  124175. /**
  124176. * Post-process used to merge the final HDR post-process and the real scene color
  124177. */
  124178. hdrFinalPostProcess: Nullable<PostProcess>;
  124179. /**
  124180. * Post-process used to create a lens flare effect
  124181. */
  124182. lensFlarePostProcess: Nullable<PostProcess>;
  124183. /**
  124184. * Post-process that merges the result of the lens flare post-process and the real scene color
  124185. */
  124186. lensFlareComposePostProcess: Nullable<PostProcess>;
  124187. /**
  124188. * Post-process used to create a motion blur effect
  124189. */
  124190. motionBlurPostProcess: Nullable<PostProcess>;
  124191. /**
  124192. * Post-process used to create a depth of field effect
  124193. */
  124194. depthOfFieldPostProcess: Nullable<PostProcess>;
  124195. /**
  124196. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  124197. */
  124198. fxaaPostProcess: Nullable<FxaaPostProcess>;
  124199. /**
  124200. * Represents the brightness threshold in order to configure the illuminated surfaces
  124201. */
  124202. brightThreshold: number;
  124203. /**
  124204. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  124205. */
  124206. blurWidth: number;
  124207. /**
  124208. * Sets if the blur for highlighted surfaces must be only horizontal
  124209. */
  124210. horizontalBlur: boolean;
  124211. /**
  124212. * Gets the overall exposure used by the pipeline
  124213. */
  124214. /**
  124215. * Sets the overall exposure used by the pipeline
  124216. */
  124217. exposure: number;
  124218. /**
  124219. * Texture used typically to simulate "dirty" on camera lens
  124220. */
  124221. lensTexture: Nullable<Texture>;
  124222. /**
  124223. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  124224. */
  124225. volumetricLightCoefficient: number;
  124226. /**
  124227. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  124228. */
  124229. volumetricLightPower: number;
  124230. /**
  124231. * Used the set the blur intensity to smooth the volumetric lights
  124232. */
  124233. volumetricLightBlurScale: number;
  124234. /**
  124235. * Light (spot or directional) used to generate the volumetric lights rays
  124236. * The source light must have a shadow generate so the pipeline can get its
  124237. * depth map
  124238. */
  124239. sourceLight: Nullable<SpotLight | DirectionalLight>;
  124240. /**
  124241. * For eye adaptation, represents the minimum luminance the eye can see
  124242. */
  124243. hdrMinimumLuminance: number;
  124244. /**
  124245. * For eye adaptation, represents the decrease luminance speed
  124246. */
  124247. hdrDecreaseRate: number;
  124248. /**
  124249. * For eye adaptation, represents the increase luminance speed
  124250. */
  124251. hdrIncreaseRate: number;
  124252. /**
  124253. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  124254. */
  124255. /**
  124256. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  124257. */
  124258. hdrAutoExposure: boolean;
  124259. /**
  124260. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  124261. */
  124262. lensColorTexture: Nullable<Texture>;
  124263. /**
  124264. * The overall strengh for the lens flare effect
  124265. */
  124266. lensFlareStrength: number;
  124267. /**
  124268. * Dispersion coefficient for lens flare ghosts
  124269. */
  124270. lensFlareGhostDispersal: number;
  124271. /**
  124272. * Main lens flare halo width
  124273. */
  124274. lensFlareHaloWidth: number;
  124275. /**
  124276. * Based on the lens distortion effect, defines how much the lens flare result
  124277. * is distorted
  124278. */
  124279. lensFlareDistortionStrength: number;
  124280. /**
  124281. * Configures the blur intensity used for for lens flare (halo)
  124282. */
  124283. lensFlareBlurWidth: number;
  124284. /**
  124285. * Lens star texture must be used to simulate rays on the flares and is available
  124286. * in the documentation
  124287. */
  124288. lensStarTexture: Nullable<Texture>;
  124289. /**
  124290. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  124291. * flare effect by taking account of the dirt texture
  124292. */
  124293. lensFlareDirtTexture: Nullable<Texture>;
  124294. /**
  124295. * Represents the focal length for the depth of field effect
  124296. */
  124297. depthOfFieldDistance: number;
  124298. /**
  124299. * Represents the blur intensity for the blurred part of the depth of field effect
  124300. */
  124301. depthOfFieldBlurWidth: number;
  124302. /**
  124303. * Gets how much the image is blurred by the movement while using the motion blur post-process
  124304. */
  124305. /**
  124306. * Sets how much the image is blurred by the movement while using the motion blur post-process
  124307. */
  124308. motionStrength: number;
  124309. /**
  124310. * Gets wether or not the motion blur post-process is object based or screen based.
  124311. */
  124312. /**
  124313. * Sets wether or not the motion blur post-process should be object based or screen based
  124314. */
  124315. objectBasedMotionBlur: boolean;
  124316. /**
  124317. * List of animations for the pipeline (IAnimatable implementation)
  124318. */
  124319. animations: Animation[];
  124320. /**
  124321. * Private members
  124322. */
  124323. private _scene;
  124324. private _currentDepthOfFieldSource;
  124325. private _basePostProcess;
  124326. private _fixedExposure;
  124327. private _currentExposure;
  124328. private _hdrAutoExposure;
  124329. private _hdrCurrentLuminance;
  124330. private _motionStrength;
  124331. private _isObjectBasedMotionBlur;
  124332. private _floatTextureType;
  124333. private _camerasToBeAttached;
  124334. private _ratio;
  124335. private _bloomEnabled;
  124336. private _depthOfFieldEnabled;
  124337. private _vlsEnabled;
  124338. private _lensFlareEnabled;
  124339. private _hdrEnabled;
  124340. private _motionBlurEnabled;
  124341. private _fxaaEnabled;
  124342. private _motionBlurSamples;
  124343. private _volumetricLightStepsCount;
  124344. private _samples;
  124345. /**
  124346. * @ignore
  124347. * Specifies if the bloom pipeline is enabled
  124348. */
  124349. BloomEnabled: boolean;
  124350. /**
  124351. * @ignore
  124352. * Specifies if the depth of field pipeline is enabed
  124353. */
  124354. DepthOfFieldEnabled: boolean;
  124355. /**
  124356. * @ignore
  124357. * Specifies if the lens flare pipeline is enabed
  124358. */
  124359. LensFlareEnabled: boolean;
  124360. /**
  124361. * @ignore
  124362. * Specifies if the HDR pipeline is enabled
  124363. */
  124364. HDREnabled: boolean;
  124365. /**
  124366. * @ignore
  124367. * Specifies if the volumetric lights scattering effect is enabled
  124368. */
  124369. VLSEnabled: boolean;
  124370. /**
  124371. * @ignore
  124372. * Specifies if the motion blur effect is enabled
  124373. */
  124374. MotionBlurEnabled: boolean;
  124375. /**
  124376. * Specifies if anti-aliasing is enabled
  124377. */
  124378. fxaaEnabled: boolean;
  124379. /**
  124380. * Specifies the number of steps used to calculate the volumetric lights
  124381. * Typically in interval [50, 200]
  124382. */
  124383. volumetricLightStepsCount: number;
  124384. /**
  124385. * Specifies the number of samples used for the motion blur effect
  124386. * Typically in interval [16, 64]
  124387. */
  124388. motionBlurSamples: number;
  124389. /**
  124390. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  124391. */
  124392. samples: number;
  124393. /**
  124394. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  124395. * @constructor
  124396. * @param name The rendering pipeline name
  124397. * @param scene The scene linked to this pipeline
  124398. * @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)
  124399. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  124400. * @param cameras The array of cameras that the rendering pipeline will be attached to
  124401. */
  124402. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  124403. private _buildPipeline;
  124404. private _createDownSampleX4PostProcess;
  124405. private _createBrightPassPostProcess;
  124406. private _createBlurPostProcesses;
  124407. private _createTextureAdderPostProcess;
  124408. private _createVolumetricLightPostProcess;
  124409. private _createLuminancePostProcesses;
  124410. private _createHdrPostProcess;
  124411. private _createLensFlarePostProcess;
  124412. private _createDepthOfFieldPostProcess;
  124413. private _createMotionBlurPostProcess;
  124414. private _getDepthTexture;
  124415. private _disposePostProcesses;
  124416. /**
  124417. * Dispose of the pipeline and stop all post processes
  124418. */
  124419. dispose(): void;
  124420. /**
  124421. * Serialize the rendering pipeline (Used when exporting)
  124422. * @returns the serialized object
  124423. */
  124424. serialize(): any;
  124425. /**
  124426. * Parse the serialized pipeline
  124427. * @param source Source pipeline.
  124428. * @param scene The scene to load the pipeline to.
  124429. * @param rootUrl The URL of the serialized pipeline.
  124430. * @returns An instantiated pipeline from the serialized object.
  124431. */
  124432. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  124433. /**
  124434. * Luminance steps
  124435. */
  124436. static LuminanceSteps: number;
  124437. }
  124438. }
  124439. declare module BABYLON {
  124440. /** @hidden */
  124441. export var tonemapPixelShader: {
  124442. name: string;
  124443. shader: string;
  124444. };
  124445. }
  124446. declare module BABYLON {
  124447. /** Defines operator used for tonemapping */
  124448. export enum TonemappingOperator {
  124449. /** Hable */
  124450. Hable = 0,
  124451. /** Reinhard */
  124452. Reinhard = 1,
  124453. /** HejiDawson */
  124454. HejiDawson = 2,
  124455. /** Photographic */
  124456. Photographic = 3
  124457. }
  124458. /**
  124459. * Defines a post process to apply tone mapping
  124460. */
  124461. export class TonemapPostProcess extends PostProcess {
  124462. private _operator;
  124463. /** Defines the required exposure adjustement */
  124464. exposureAdjustment: number;
  124465. /**
  124466. * Creates a new TonemapPostProcess
  124467. * @param name defines the name of the postprocess
  124468. * @param _operator defines the operator to use
  124469. * @param exposureAdjustment defines the required exposure adjustement
  124470. * @param camera defines the camera to use (can be null)
  124471. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  124472. * @param engine defines the hosting engine (can be ignore if camera is set)
  124473. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  124474. */
  124475. constructor(name: string, _operator: TonemappingOperator,
  124476. /** Defines the required exposure adjustement */
  124477. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  124478. }
  124479. }
  124480. declare module BABYLON {
  124481. /** @hidden */
  124482. export var depthVertexShader: {
  124483. name: string;
  124484. shader: string;
  124485. };
  124486. }
  124487. declare module BABYLON {
  124488. /** @hidden */
  124489. export var volumetricLightScatteringPixelShader: {
  124490. name: string;
  124491. shader: string;
  124492. };
  124493. }
  124494. declare module BABYLON {
  124495. /** @hidden */
  124496. export var volumetricLightScatteringPassVertexShader: {
  124497. name: string;
  124498. shader: string;
  124499. };
  124500. }
  124501. declare module BABYLON {
  124502. /** @hidden */
  124503. export var volumetricLightScatteringPassPixelShader: {
  124504. name: string;
  124505. shader: string;
  124506. };
  124507. }
  124508. declare module BABYLON {
  124509. /**
  124510. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  124511. */
  124512. export class VolumetricLightScatteringPostProcess extends PostProcess {
  124513. private _volumetricLightScatteringPass;
  124514. private _volumetricLightScatteringRTT;
  124515. private _viewPort;
  124516. private _screenCoordinates;
  124517. private _cachedDefines;
  124518. /**
  124519. * If not undefined, the mesh position is computed from the attached node position
  124520. */
  124521. attachedNode: {
  124522. position: Vector3;
  124523. };
  124524. /**
  124525. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  124526. */
  124527. customMeshPosition: Vector3;
  124528. /**
  124529. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  124530. */
  124531. useCustomMeshPosition: boolean;
  124532. /**
  124533. * If the post-process should inverse the light scattering direction
  124534. */
  124535. invert: boolean;
  124536. /**
  124537. * The internal mesh used by the post-process
  124538. */
  124539. mesh: Mesh;
  124540. /**
  124541. * @hidden
  124542. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  124543. */
  124544. useDiffuseColor: boolean;
  124545. /**
  124546. * Array containing the excluded meshes not rendered in the internal pass
  124547. */
  124548. excludedMeshes: AbstractMesh[];
  124549. /**
  124550. * Controls the overall intensity of the post-process
  124551. */
  124552. exposure: number;
  124553. /**
  124554. * Dissipates each sample's contribution in range [0, 1]
  124555. */
  124556. decay: number;
  124557. /**
  124558. * Controls the overall intensity of each sample
  124559. */
  124560. weight: number;
  124561. /**
  124562. * Controls the density of each sample
  124563. */
  124564. density: number;
  124565. /**
  124566. * @constructor
  124567. * @param name The post-process name
  124568. * @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)
  124569. * @param camera The camera that the post-process will be attached to
  124570. * @param mesh The mesh used to create the light scattering
  124571. * @param samples The post-process quality, default 100
  124572. * @param samplingModeThe post-process filtering mode
  124573. * @param engine The babylon engine
  124574. * @param reusable If the post-process is reusable
  124575. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  124576. */
  124577. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  124578. /**
  124579. * Returns the string "VolumetricLightScatteringPostProcess"
  124580. * @returns "VolumetricLightScatteringPostProcess"
  124581. */
  124582. getClassName(): string;
  124583. private _isReady;
  124584. /**
  124585. * Sets the new light position for light scattering effect
  124586. * @param position The new custom light position
  124587. */
  124588. setCustomMeshPosition(position: Vector3): void;
  124589. /**
  124590. * Returns the light position for light scattering effect
  124591. * @return Vector3 The custom light position
  124592. */
  124593. getCustomMeshPosition(): Vector3;
  124594. /**
  124595. * Disposes the internal assets and detaches the post-process from the camera
  124596. */
  124597. dispose(camera: Camera): void;
  124598. /**
  124599. * Returns the render target texture used by the post-process
  124600. * @return the render target texture used by the post-process
  124601. */
  124602. getPass(): RenderTargetTexture;
  124603. private _meshExcluded;
  124604. private _createPass;
  124605. private _updateMeshScreenCoordinates;
  124606. /**
  124607. * Creates a default mesh for the Volumeric Light Scattering post-process
  124608. * @param name The mesh name
  124609. * @param scene The scene where to create the mesh
  124610. * @return the default mesh
  124611. */
  124612. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  124613. }
  124614. }
  124615. declare module BABYLON {
  124616. interface Scene {
  124617. /** @hidden (Backing field) */
  124618. _boundingBoxRenderer: BoundingBoxRenderer;
  124619. /** @hidden (Backing field) */
  124620. _forceShowBoundingBoxes: boolean;
  124621. /**
  124622. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  124623. */
  124624. forceShowBoundingBoxes: boolean;
  124625. /**
  124626. * Gets the bounding box renderer associated with the scene
  124627. * @returns a BoundingBoxRenderer
  124628. */
  124629. getBoundingBoxRenderer(): BoundingBoxRenderer;
  124630. }
  124631. interface AbstractMesh {
  124632. /** @hidden (Backing field) */
  124633. _showBoundingBox: boolean;
  124634. /**
  124635. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  124636. */
  124637. showBoundingBox: boolean;
  124638. }
  124639. /**
  124640. * Component responsible of rendering the bounding box of the meshes in a scene.
  124641. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  124642. */
  124643. export class BoundingBoxRenderer implements ISceneComponent {
  124644. /**
  124645. * The component name helpfull to identify the component in the list of scene components.
  124646. */
  124647. readonly name: string;
  124648. /**
  124649. * The scene the component belongs to.
  124650. */
  124651. scene: Scene;
  124652. /**
  124653. * Color of the bounding box lines placed in front of an object
  124654. */
  124655. frontColor: Color3;
  124656. /**
  124657. * Color of the bounding box lines placed behind an object
  124658. */
  124659. backColor: Color3;
  124660. /**
  124661. * Defines if the renderer should show the back lines or not
  124662. */
  124663. showBackLines: boolean;
  124664. /**
  124665. * @hidden
  124666. */
  124667. renderList: SmartArray<BoundingBox>;
  124668. private _colorShader;
  124669. private _vertexBuffers;
  124670. private _indexBuffer;
  124671. private _fillIndexBuffer;
  124672. private _fillIndexData;
  124673. /**
  124674. * Instantiates a new bounding box renderer in a scene.
  124675. * @param scene the scene the renderer renders in
  124676. */
  124677. constructor(scene: Scene);
  124678. /**
  124679. * Registers the component in a given scene
  124680. */
  124681. register(): void;
  124682. private _evaluateSubMesh;
  124683. private _activeMesh;
  124684. private _prepareRessources;
  124685. private _createIndexBuffer;
  124686. /**
  124687. * Rebuilds the elements related to this component in case of
  124688. * context lost for instance.
  124689. */
  124690. rebuild(): void;
  124691. /**
  124692. * @hidden
  124693. */
  124694. reset(): void;
  124695. /**
  124696. * Render the bounding boxes of a specific rendering group
  124697. * @param renderingGroupId defines the rendering group to render
  124698. */
  124699. render(renderingGroupId: number): void;
  124700. /**
  124701. * In case of occlusion queries, we can render the occlusion bounding box through this method
  124702. * @param mesh Define the mesh to render the occlusion bounding box for
  124703. */
  124704. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  124705. /**
  124706. * Dispose and release the resources attached to this renderer.
  124707. */
  124708. dispose(): void;
  124709. }
  124710. }
  124711. declare module BABYLON {
  124712. /** @hidden */
  124713. export var depthPixelShader: {
  124714. name: string;
  124715. shader: string;
  124716. };
  124717. }
  124718. declare module BABYLON {
  124719. /**
  124720. * This represents a depth renderer in Babylon.
  124721. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  124722. */
  124723. export class DepthRenderer {
  124724. private _scene;
  124725. private _depthMap;
  124726. private _effect;
  124727. private readonly _storeNonLinearDepth;
  124728. private readonly _clearColor;
  124729. /** Get if the depth renderer is using packed depth or not */
  124730. readonly isPacked: boolean;
  124731. private _cachedDefines;
  124732. private _camera;
  124733. /**
  124734. * Specifiess that the depth renderer will only be used within
  124735. * the camera it is created for.
  124736. * This can help forcing its rendering during the camera processing.
  124737. */
  124738. useOnlyInActiveCamera: boolean;
  124739. /** @hidden */
  124740. static _SceneComponentInitialization: (scene: Scene) => void;
  124741. /**
  124742. * Instantiates a depth renderer
  124743. * @param scene The scene the renderer belongs to
  124744. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  124745. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  124746. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  124747. */
  124748. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  124749. /**
  124750. * Creates the depth rendering effect and checks if the effect is ready.
  124751. * @param subMesh The submesh to be used to render the depth map of
  124752. * @param useInstances If multiple world instances should be used
  124753. * @returns if the depth renderer is ready to render the depth map
  124754. */
  124755. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  124756. /**
  124757. * Gets the texture which the depth map will be written to.
  124758. * @returns The depth map texture
  124759. */
  124760. getDepthMap(): RenderTargetTexture;
  124761. /**
  124762. * Disposes of the depth renderer.
  124763. */
  124764. dispose(): void;
  124765. }
  124766. }
  124767. declare module BABYLON {
  124768. interface Scene {
  124769. /** @hidden (Backing field) */
  124770. _depthRenderer: {
  124771. [id: string]: DepthRenderer;
  124772. };
  124773. /**
  124774. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  124775. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  124776. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  124777. * @returns the created depth renderer
  124778. */
  124779. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  124780. /**
  124781. * Disables a depth renderer for a given camera
  124782. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  124783. */
  124784. disableDepthRenderer(camera?: Nullable<Camera>): void;
  124785. }
  124786. /**
  124787. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  124788. * in several rendering techniques.
  124789. */
  124790. export class DepthRendererSceneComponent implements ISceneComponent {
  124791. /**
  124792. * The component name helpfull to identify the component in the list of scene components.
  124793. */
  124794. readonly name: string;
  124795. /**
  124796. * The scene the component belongs to.
  124797. */
  124798. scene: Scene;
  124799. /**
  124800. * Creates a new instance of the component for the given scene
  124801. * @param scene Defines the scene to register the component in
  124802. */
  124803. constructor(scene: Scene);
  124804. /**
  124805. * Registers the component in a given scene
  124806. */
  124807. register(): void;
  124808. /**
  124809. * Rebuilds the elements related to this component in case of
  124810. * context lost for instance.
  124811. */
  124812. rebuild(): void;
  124813. /**
  124814. * Disposes the component and the associated ressources
  124815. */
  124816. dispose(): void;
  124817. private _gatherRenderTargets;
  124818. private _gatherActiveCameraRenderTargets;
  124819. }
  124820. }
  124821. declare module BABYLON {
  124822. /** @hidden */
  124823. export var outlinePixelShader: {
  124824. name: string;
  124825. shader: string;
  124826. };
  124827. }
  124828. declare module BABYLON {
  124829. /** @hidden */
  124830. export var outlineVertexShader: {
  124831. name: string;
  124832. shader: string;
  124833. };
  124834. }
  124835. declare module BABYLON {
  124836. interface Scene {
  124837. /** @hidden */
  124838. _outlineRenderer: OutlineRenderer;
  124839. /**
  124840. * Gets the outline renderer associated with the scene
  124841. * @returns a OutlineRenderer
  124842. */
  124843. getOutlineRenderer(): OutlineRenderer;
  124844. }
  124845. interface AbstractMesh {
  124846. /** @hidden (Backing field) */
  124847. _renderOutline: boolean;
  124848. /**
  124849. * Gets or sets a boolean indicating if the outline must be rendered as well
  124850. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  124851. */
  124852. renderOutline: boolean;
  124853. /** @hidden (Backing field) */
  124854. _renderOverlay: boolean;
  124855. /**
  124856. * Gets or sets a boolean indicating if the overlay must be rendered as well
  124857. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  124858. */
  124859. renderOverlay: boolean;
  124860. }
  124861. /**
  124862. * This class is responsible to draw bothe outline/overlay of meshes.
  124863. * It should not be used directly but through the available method on mesh.
  124864. */
  124865. export class OutlineRenderer implements ISceneComponent {
  124866. /**
  124867. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  124868. */
  124869. private static _StencilReference;
  124870. /**
  124871. * The name of the component. Each component must have a unique name.
  124872. */
  124873. name: string;
  124874. /**
  124875. * The scene the component belongs to.
  124876. */
  124877. scene: Scene;
  124878. /**
  124879. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  124880. */
  124881. zOffset: number;
  124882. private _engine;
  124883. private _effect;
  124884. private _cachedDefines;
  124885. private _savedDepthWrite;
  124886. /**
  124887. * Instantiates a new outline renderer. (There could be only one per scene).
  124888. * @param scene Defines the scene it belongs to
  124889. */
  124890. constructor(scene: Scene);
  124891. /**
  124892. * Register the component to one instance of a scene.
  124893. */
  124894. register(): void;
  124895. /**
  124896. * Rebuilds the elements related to this component in case of
  124897. * context lost for instance.
  124898. */
  124899. rebuild(): void;
  124900. /**
  124901. * Disposes the component and the associated ressources.
  124902. */
  124903. dispose(): void;
  124904. /**
  124905. * Renders the outline in the canvas.
  124906. * @param subMesh Defines the sumesh to render
  124907. * @param batch Defines the batch of meshes in case of instances
  124908. * @param useOverlay Defines if the rendering is for the overlay or the outline
  124909. */
  124910. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  124911. /**
  124912. * Returns whether or not the outline renderer is ready for a given submesh.
  124913. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  124914. * @param subMesh Defines the submesh to check readyness for
  124915. * @param useInstances Defines wheter wee are trying to render instances or not
  124916. * @returns true if ready otherwise false
  124917. */
  124918. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  124919. private _beforeRenderingMesh;
  124920. private _afterRenderingMesh;
  124921. }
  124922. }
  124923. declare module BABYLON {
  124924. /**
  124925. * Class used to manage multiple sprites of different sizes on the same spritesheet
  124926. * @see http://doc.babylonjs.com/babylon101/sprites
  124927. */
  124928. export class SpritePackedManager extends SpriteManager {
  124929. /** defines the packed manager's name */
  124930. name: string;
  124931. /**
  124932. * Creates a new sprite manager from a packed sprite sheet
  124933. * @param name defines the manager's name
  124934. * @param imgUrl defines the sprite sheet url
  124935. * @param capacity defines the maximum allowed number of sprites
  124936. * @param scene defines the hosting scene
  124937. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  124938. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  124939. * @param samplingMode defines the smapling mode to use with spritesheet
  124940. * @param fromPacked set to true; do not alter
  124941. */
  124942. constructor(
  124943. /** defines the packed manager's name */
  124944. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  124945. }
  124946. }
  124947. declare module BABYLON {
  124948. /**
  124949. * Defines the list of states available for a task inside a AssetsManager
  124950. */
  124951. export enum AssetTaskState {
  124952. /**
  124953. * Initialization
  124954. */
  124955. INIT = 0,
  124956. /**
  124957. * Running
  124958. */
  124959. RUNNING = 1,
  124960. /**
  124961. * Done
  124962. */
  124963. DONE = 2,
  124964. /**
  124965. * Error
  124966. */
  124967. ERROR = 3
  124968. }
  124969. /**
  124970. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  124971. */
  124972. export abstract class AbstractAssetTask {
  124973. /**
  124974. * Task name
  124975. */ name: string;
  124976. /**
  124977. * Callback called when the task is successful
  124978. */
  124979. onSuccess: (task: any) => void;
  124980. /**
  124981. * Callback called when the task is not successful
  124982. */
  124983. onError: (task: any, message?: string, exception?: any) => void;
  124984. /**
  124985. * Creates a new AssetsManager
  124986. * @param name defines the name of the task
  124987. */
  124988. constructor(
  124989. /**
  124990. * Task name
  124991. */ name: string);
  124992. private _isCompleted;
  124993. private _taskState;
  124994. private _errorObject;
  124995. /**
  124996. * Get if the task is completed
  124997. */
  124998. readonly isCompleted: boolean;
  124999. /**
  125000. * Gets the current state of the task
  125001. */
  125002. readonly taskState: AssetTaskState;
  125003. /**
  125004. * Gets the current error object (if task is in error)
  125005. */
  125006. readonly errorObject: {
  125007. message?: string;
  125008. exception?: any;
  125009. };
  125010. /**
  125011. * Internal only
  125012. * @hidden
  125013. */
  125014. _setErrorObject(message?: string, exception?: any): void;
  125015. /**
  125016. * Execute the current task
  125017. * @param scene defines the scene where you want your assets to be loaded
  125018. * @param onSuccess is a callback called when the task is successfully executed
  125019. * @param onError is a callback called if an error occurs
  125020. */
  125021. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  125022. /**
  125023. * Execute the current task
  125024. * @param scene defines the scene where you want your assets to be loaded
  125025. * @param onSuccess is a callback called when the task is successfully executed
  125026. * @param onError is a callback called if an error occurs
  125027. */
  125028. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  125029. /**
  125030. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  125031. * This can be used with failed tasks that have the reason for failure fixed.
  125032. */
  125033. reset(): void;
  125034. private onErrorCallback;
  125035. private onDoneCallback;
  125036. }
  125037. /**
  125038. * Define the interface used by progress events raised during assets loading
  125039. */
  125040. export interface IAssetsProgressEvent {
  125041. /**
  125042. * Defines the number of remaining tasks to process
  125043. */
  125044. remainingCount: number;
  125045. /**
  125046. * Defines the total number of tasks
  125047. */
  125048. totalCount: number;
  125049. /**
  125050. * Defines the task that was just processed
  125051. */
  125052. task: AbstractAssetTask;
  125053. }
  125054. /**
  125055. * Class used to share progress information about assets loading
  125056. */
  125057. export class AssetsProgressEvent implements IAssetsProgressEvent {
  125058. /**
  125059. * Defines the number of remaining tasks to process
  125060. */
  125061. remainingCount: number;
  125062. /**
  125063. * Defines the total number of tasks
  125064. */
  125065. totalCount: number;
  125066. /**
  125067. * Defines the task that was just processed
  125068. */
  125069. task: AbstractAssetTask;
  125070. /**
  125071. * Creates a AssetsProgressEvent
  125072. * @param remainingCount defines the number of remaining tasks to process
  125073. * @param totalCount defines the total number of tasks
  125074. * @param task defines the task that was just processed
  125075. */
  125076. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  125077. }
  125078. /**
  125079. * Define a task used by AssetsManager to load meshes
  125080. */
  125081. export class MeshAssetTask extends AbstractAssetTask {
  125082. /**
  125083. * Defines the name of the task
  125084. */
  125085. name: string;
  125086. /**
  125087. * Defines the list of mesh's names you want to load
  125088. */
  125089. meshesNames: any;
  125090. /**
  125091. * Defines the root url to use as a base to load your meshes and associated resources
  125092. */
  125093. rootUrl: string;
  125094. /**
  125095. * Defines the filename of the scene to load from
  125096. */
  125097. sceneFilename: string;
  125098. /**
  125099. * Gets the list of loaded meshes
  125100. */
  125101. loadedMeshes: Array<AbstractMesh>;
  125102. /**
  125103. * Gets the list of loaded particle systems
  125104. */
  125105. loadedParticleSystems: Array<IParticleSystem>;
  125106. /**
  125107. * Gets the list of loaded skeletons
  125108. */
  125109. loadedSkeletons: Array<Skeleton>;
  125110. /**
  125111. * Gets the list of loaded animation groups
  125112. */
  125113. loadedAnimationGroups: Array<AnimationGroup>;
  125114. /**
  125115. * Callback called when the task is successful
  125116. */
  125117. onSuccess: (task: MeshAssetTask) => void;
  125118. /**
  125119. * Callback called when the task is successful
  125120. */
  125121. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  125122. /**
  125123. * Creates a new MeshAssetTask
  125124. * @param name defines the name of the task
  125125. * @param meshesNames defines the list of mesh's names you want to load
  125126. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  125127. * @param sceneFilename defines the filename of the scene to load from
  125128. */
  125129. constructor(
  125130. /**
  125131. * Defines the name of the task
  125132. */
  125133. name: string,
  125134. /**
  125135. * Defines the list of mesh's names you want to load
  125136. */
  125137. meshesNames: any,
  125138. /**
  125139. * Defines the root url to use as a base to load your meshes and associated resources
  125140. */
  125141. rootUrl: string,
  125142. /**
  125143. * Defines the filename of the scene to load from
  125144. */
  125145. sceneFilename: string);
  125146. /**
  125147. * Execute the current task
  125148. * @param scene defines the scene where you want your assets to be loaded
  125149. * @param onSuccess is a callback called when the task is successfully executed
  125150. * @param onError is a callback called if an error occurs
  125151. */
  125152. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  125153. }
  125154. /**
  125155. * Define a task used by AssetsManager to load text content
  125156. */
  125157. export class TextFileAssetTask extends AbstractAssetTask {
  125158. /**
  125159. * Defines the name of the task
  125160. */
  125161. name: string;
  125162. /**
  125163. * Defines the location of the file to load
  125164. */
  125165. url: string;
  125166. /**
  125167. * Gets the loaded text string
  125168. */
  125169. text: string;
  125170. /**
  125171. * Callback called when the task is successful
  125172. */
  125173. onSuccess: (task: TextFileAssetTask) => void;
  125174. /**
  125175. * Callback called when the task is successful
  125176. */
  125177. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  125178. /**
  125179. * Creates a new TextFileAssetTask object
  125180. * @param name defines the name of the task
  125181. * @param url defines the location of the file to load
  125182. */
  125183. constructor(
  125184. /**
  125185. * Defines the name of the task
  125186. */
  125187. name: string,
  125188. /**
  125189. * Defines the location of the file to load
  125190. */
  125191. url: string);
  125192. /**
  125193. * Execute the current task
  125194. * @param scene defines the scene where you want your assets to be loaded
  125195. * @param onSuccess is a callback called when the task is successfully executed
  125196. * @param onError is a callback called if an error occurs
  125197. */
  125198. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  125199. }
  125200. /**
  125201. * Define a task used by AssetsManager to load binary data
  125202. */
  125203. export class BinaryFileAssetTask extends AbstractAssetTask {
  125204. /**
  125205. * Defines the name of the task
  125206. */
  125207. name: string;
  125208. /**
  125209. * Defines the location of the file to load
  125210. */
  125211. url: string;
  125212. /**
  125213. * Gets the lodaded data (as an array buffer)
  125214. */
  125215. data: ArrayBuffer;
  125216. /**
  125217. * Callback called when the task is successful
  125218. */
  125219. onSuccess: (task: BinaryFileAssetTask) => void;
  125220. /**
  125221. * Callback called when the task is successful
  125222. */
  125223. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  125224. /**
  125225. * Creates a new BinaryFileAssetTask object
  125226. * @param name defines the name of the new task
  125227. * @param url defines the location of the file to load
  125228. */
  125229. constructor(
  125230. /**
  125231. * Defines the name of the task
  125232. */
  125233. name: string,
  125234. /**
  125235. * Defines the location of the file to load
  125236. */
  125237. url: string);
  125238. /**
  125239. * Execute the current task
  125240. * @param scene defines the scene where you want your assets to be loaded
  125241. * @param onSuccess is a callback called when the task is successfully executed
  125242. * @param onError is a callback called if an error occurs
  125243. */
  125244. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  125245. }
  125246. /**
  125247. * Define a task used by AssetsManager to load images
  125248. */
  125249. export class ImageAssetTask extends AbstractAssetTask {
  125250. /**
  125251. * Defines the name of the task
  125252. */
  125253. name: string;
  125254. /**
  125255. * Defines the location of the image to load
  125256. */
  125257. url: string;
  125258. /**
  125259. * Gets the loaded images
  125260. */
  125261. image: HTMLImageElement;
  125262. /**
  125263. * Callback called when the task is successful
  125264. */
  125265. onSuccess: (task: ImageAssetTask) => void;
  125266. /**
  125267. * Callback called when the task is successful
  125268. */
  125269. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  125270. /**
  125271. * Creates a new ImageAssetTask
  125272. * @param name defines the name of the task
  125273. * @param url defines the location of the image to load
  125274. */
  125275. constructor(
  125276. /**
  125277. * Defines the name of the task
  125278. */
  125279. name: string,
  125280. /**
  125281. * Defines the location of the image to load
  125282. */
  125283. url: string);
  125284. /**
  125285. * Execute the current task
  125286. * @param scene defines the scene where you want your assets to be loaded
  125287. * @param onSuccess is a callback called when the task is successfully executed
  125288. * @param onError is a callback called if an error occurs
  125289. */
  125290. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  125291. }
  125292. /**
  125293. * Defines the interface used by texture loading tasks
  125294. */
  125295. export interface ITextureAssetTask<TEX extends BaseTexture> {
  125296. /**
  125297. * Gets the loaded texture
  125298. */
  125299. texture: TEX;
  125300. }
  125301. /**
  125302. * Define a task used by AssetsManager to load 2D textures
  125303. */
  125304. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  125305. /**
  125306. * Defines the name of the task
  125307. */
  125308. name: string;
  125309. /**
  125310. * Defines the location of the file to load
  125311. */
  125312. url: string;
  125313. /**
  125314. * Defines if mipmap should not be generated (default is false)
  125315. */
  125316. noMipmap?: boolean | undefined;
  125317. /**
  125318. * Defines if texture must be inverted on Y axis (default is false)
  125319. */
  125320. invertY?: boolean | undefined;
  125321. /**
  125322. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  125323. */
  125324. samplingMode: number;
  125325. /**
  125326. * Gets the loaded texture
  125327. */
  125328. texture: Texture;
  125329. /**
  125330. * Callback called when the task is successful
  125331. */
  125332. onSuccess: (task: TextureAssetTask) => void;
  125333. /**
  125334. * Callback called when the task is successful
  125335. */
  125336. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  125337. /**
  125338. * Creates a new TextureAssetTask object
  125339. * @param name defines the name of the task
  125340. * @param url defines the location of the file to load
  125341. * @param noMipmap defines if mipmap should not be generated (default is false)
  125342. * @param invertY defines if texture must be inverted on Y axis (default is false)
  125343. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  125344. */
  125345. constructor(
  125346. /**
  125347. * Defines the name of the task
  125348. */
  125349. name: string,
  125350. /**
  125351. * Defines the location of the file to load
  125352. */
  125353. url: string,
  125354. /**
  125355. * Defines if mipmap should not be generated (default is false)
  125356. */
  125357. noMipmap?: boolean | undefined,
  125358. /**
  125359. * Defines if texture must be inverted on Y axis (default is false)
  125360. */
  125361. invertY?: boolean | undefined,
  125362. /**
  125363. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  125364. */
  125365. samplingMode?: number);
  125366. /**
  125367. * Execute the current task
  125368. * @param scene defines the scene where you want your assets to be loaded
  125369. * @param onSuccess is a callback called when the task is successfully executed
  125370. * @param onError is a callback called if an error occurs
  125371. */
  125372. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  125373. }
  125374. /**
  125375. * Define a task used by AssetsManager to load cube textures
  125376. */
  125377. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  125378. /**
  125379. * Defines the name of the task
  125380. */
  125381. name: string;
  125382. /**
  125383. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  125384. */
  125385. url: string;
  125386. /**
  125387. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  125388. */
  125389. extensions?: string[] | undefined;
  125390. /**
  125391. * Defines if mipmaps should not be generated (default is false)
  125392. */
  125393. noMipmap?: boolean | undefined;
  125394. /**
  125395. * Defines the explicit list of files (undefined by default)
  125396. */
  125397. files?: string[] | undefined;
  125398. /**
  125399. * Gets the loaded texture
  125400. */
  125401. texture: CubeTexture;
  125402. /**
  125403. * Callback called when the task is successful
  125404. */
  125405. onSuccess: (task: CubeTextureAssetTask) => void;
  125406. /**
  125407. * Callback called when the task is successful
  125408. */
  125409. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  125410. /**
  125411. * Creates a new CubeTextureAssetTask
  125412. * @param name defines the name of the task
  125413. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  125414. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  125415. * @param noMipmap defines if mipmaps should not be generated (default is false)
  125416. * @param files defines the explicit list of files (undefined by default)
  125417. */
  125418. constructor(
  125419. /**
  125420. * Defines the name of the task
  125421. */
  125422. name: string,
  125423. /**
  125424. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  125425. */
  125426. url: string,
  125427. /**
  125428. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  125429. */
  125430. extensions?: string[] | undefined,
  125431. /**
  125432. * Defines if mipmaps should not be generated (default is false)
  125433. */
  125434. noMipmap?: boolean | undefined,
  125435. /**
  125436. * Defines the explicit list of files (undefined by default)
  125437. */
  125438. files?: string[] | undefined);
  125439. /**
  125440. * Execute the current task
  125441. * @param scene defines the scene where you want your assets to be loaded
  125442. * @param onSuccess is a callback called when the task is successfully executed
  125443. * @param onError is a callback called if an error occurs
  125444. */
  125445. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  125446. }
  125447. /**
  125448. * Define a task used by AssetsManager to load HDR cube textures
  125449. */
  125450. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  125451. /**
  125452. * Defines the name of the task
  125453. */
  125454. name: string;
  125455. /**
  125456. * Defines the location of the file to load
  125457. */
  125458. url: string;
  125459. /**
  125460. * Defines the desired size (the more it increases the longer the generation will be)
  125461. */
  125462. size: number;
  125463. /**
  125464. * Defines if mipmaps should not be generated (default is false)
  125465. */
  125466. noMipmap: boolean;
  125467. /**
  125468. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  125469. */
  125470. generateHarmonics: boolean;
  125471. /**
  125472. * 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)
  125473. */
  125474. gammaSpace: boolean;
  125475. /**
  125476. * Internal Use Only
  125477. */
  125478. reserved: boolean;
  125479. /**
  125480. * Gets the loaded texture
  125481. */
  125482. texture: HDRCubeTexture;
  125483. /**
  125484. * Callback called when the task is successful
  125485. */
  125486. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  125487. /**
  125488. * Callback called when the task is successful
  125489. */
  125490. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  125491. /**
  125492. * Creates a new HDRCubeTextureAssetTask object
  125493. * @param name defines the name of the task
  125494. * @param url defines the location of the file to load
  125495. * @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.
  125496. * @param noMipmap defines if mipmaps should not be generated (default is false)
  125497. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  125498. * @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)
  125499. * @param reserved Internal use only
  125500. */
  125501. constructor(
  125502. /**
  125503. * Defines the name of the task
  125504. */
  125505. name: string,
  125506. /**
  125507. * Defines the location of the file to load
  125508. */
  125509. url: string,
  125510. /**
  125511. * Defines the desired size (the more it increases the longer the generation will be)
  125512. */
  125513. size: number,
  125514. /**
  125515. * Defines if mipmaps should not be generated (default is false)
  125516. */
  125517. noMipmap?: boolean,
  125518. /**
  125519. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  125520. */
  125521. generateHarmonics?: boolean,
  125522. /**
  125523. * 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)
  125524. */
  125525. gammaSpace?: boolean,
  125526. /**
  125527. * Internal Use Only
  125528. */
  125529. reserved?: boolean);
  125530. /**
  125531. * Execute the current task
  125532. * @param scene defines the scene where you want your assets to be loaded
  125533. * @param onSuccess is a callback called when the task is successfully executed
  125534. * @param onError is a callback called if an error occurs
  125535. */
  125536. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  125537. }
  125538. /**
  125539. * Define a task used by AssetsManager to load Equirectangular cube textures
  125540. */
  125541. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  125542. /**
  125543. * Defines the name of the task
  125544. */
  125545. name: string;
  125546. /**
  125547. * Defines the location of the file to load
  125548. */
  125549. url: string;
  125550. /**
  125551. * Defines the desired size (the more it increases the longer the generation will be)
  125552. */
  125553. size: number;
  125554. /**
  125555. * Defines if mipmaps should not be generated (default is false)
  125556. */
  125557. noMipmap: boolean;
  125558. /**
  125559. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  125560. * but the standard material would require them in Gamma space) (default is true)
  125561. */
  125562. gammaSpace: boolean;
  125563. /**
  125564. * Gets the loaded texture
  125565. */
  125566. texture: EquiRectangularCubeTexture;
  125567. /**
  125568. * Callback called when the task is successful
  125569. */
  125570. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  125571. /**
  125572. * Callback called when the task is successful
  125573. */
  125574. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  125575. /**
  125576. * Creates a new EquiRectangularCubeTextureAssetTask object
  125577. * @param name defines the name of the task
  125578. * @param url defines the location of the file to load
  125579. * @param size defines the desired size (the more it increases the longer the generation will be)
  125580. * If the size is omitted this implies you are using a preprocessed cubemap.
  125581. * @param noMipmap defines if mipmaps should not be generated (default is false)
  125582. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  125583. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  125584. * (default is true)
  125585. */
  125586. constructor(
  125587. /**
  125588. * Defines the name of the task
  125589. */
  125590. name: string,
  125591. /**
  125592. * Defines the location of the file to load
  125593. */
  125594. url: string,
  125595. /**
  125596. * Defines the desired size (the more it increases the longer the generation will be)
  125597. */
  125598. size: number,
  125599. /**
  125600. * Defines if mipmaps should not be generated (default is false)
  125601. */
  125602. noMipmap?: boolean,
  125603. /**
  125604. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  125605. * but the standard material would require them in Gamma space) (default is true)
  125606. */
  125607. gammaSpace?: boolean);
  125608. /**
  125609. * Execute the current task
  125610. * @param scene defines the scene where you want your assets to be loaded
  125611. * @param onSuccess is a callback called when the task is successfully executed
  125612. * @param onError is a callback called if an error occurs
  125613. */
  125614. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  125615. }
  125616. /**
  125617. * This class can be used to easily import assets into a scene
  125618. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  125619. */
  125620. export class AssetsManager {
  125621. private _scene;
  125622. private _isLoading;
  125623. protected _tasks: AbstractAssetTask[];
  125624. protected _waitingTasksCount: number;
  125625. protected _totalTasksCount: number;
  125626. /**
  125627. * Callback called when all tasks are processed
  125628. */
  125629. onFinish: (tasks: AbstractAssetTask[]) => void;
  125630. /**
  125631. * Callback called when a task is successful
  125632. */
  125633. onTaskSuccess: (task: AbstractAssetTask) => void;
  125634. /**
  125635. * Callback called when a task had an error
  125636. */
  125637. onTaskError: (task: AbstractAssetTask) => void;
  125638. /**
  125639. * Callback called when a task is done (whatever the result is)
  125640. */
  125641. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  125642. /**
  125643. * Observable called when all tasks are processed
  125644. */
  125645. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  125646. /**
  125647. * Observable called when a task had an error
  125648. */
  125649. onTaskErrorObservable: Observable<AbstractAssetTask>;
  125650. /**
  125651. * Observable called when all tasks were executed
  125652. */
  125653. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  125654. /**
  125655. * Observable called when a task is done (whatever the result is)
  125656. */
  125657. onProgressObservable: Observable<IAssetsProgressEvent>;
  125658. /**
  125659. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  125660. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  125661. */
  125662. useDefaultLoadingScreen: boolean;
  125663. /**
  125664. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  125665. * when all assets have been downloaded.
  125666. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  125667. */
  125668. autoHideLoadingUI: boolean;
  125669. /**
  125670. * Creates a new AssetsManager
  125671. * @param scene defines the scene to work on
  125672. */
  125673. constructor(scene: Scene);
  125674. /**
  125675. * Add a MeshAssetTask to the list of active tasks
  125676. * @param taskName defines the name of the new task
  125677. * @param meshesNames defines the name of meshes to load
  125678. * @param rootUrl defines the root url to use to locate files
  125679. * @param sceneFilename defines the filename of the scene file
  125680. * @returns a new MeshAssetTask object
  125681. */
  125682. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  125683. /**
  125684. * Add a TextFileAssetTask to the list of active tasks
  125685. * @param taskName defines the name of the new task
  125686. * @param url defines the url of the file to load
  125687. * @returns a new TextFileAssetTask object
  125688. */
  125689. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  125690. /**
  125691. * Add a BinaryFileAssetTask to the list of active tasks
  125692. * @param taskName defines the name of the new task
  125693. * @param url defines the url of the file to load
  125694. * @returns a new BinaryFileAssetTask object
  125695. */
  125696. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  125697. /**
  125698. * Add a ImageAssetTask to the list of active tasks
  125699. * @param taskName defines the name of the new task
  125700. * @param url defines the url of the file to load
  125701. * @returns a new ImageAssetTask object
  125702. */
  125703. addImageTask(taskName: string, url: string): ImageAssetTask;
  125704. /**
  125705. * Add a TextureAssetTask to the list of active tasks
  125706. * @param taskName defines the name of the new task
  125707. * @param url defines the url of the file to load
  125708. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  125709. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  125710. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  125711. * @returns a new TextureAssetTask object
  125712. */
  125713. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  125714. /**
  125715. * Add a CubeTextureAssetTask to the list of active tasks
  125716. * @param taskName defines the name of the new task
  125717. * @param url defines the url of the file to load
  125718. * @param extensions defines the extension to use to load the cube map (can be null)
  125719. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  125720. * @param files defines the list of files to load (can be null)
  125721. * @returns a new CubeTextureAssetTask object
  125722. */
  125723. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  125724. /**
  125725. *
  125726. * Add a HDRCubeTextureAssetTask to the list of active tasks
  125727. * @param taskName defines the name of the new task
  125728. * @param url defines the url of the file to load
  125729. * @param size defines the size you want for the cubemap (can be null)
  125730. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  125731. * @param generateHarmonics defines if you want to automatically generate (true by default)
  125732. * @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)
  125733. * @param reserved Internal use only
  125734. * @returns a new HDRCubeTextureAssetTask object
  125735. */
  125736. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  125737. /**
  125738. *
  125739. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  125740. * @param taskName defines the name of the new task
  125741. * @param url defines the url of the file to load
  125742. * @param size defines the size you want for the cubemap (can be null)
  125743. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  125744. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  125745. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  125746. * @returns a new EquiRectangularCubeTextureAssetTask object
  125747. */
  125748. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  125749. /**
  125750. * Remove a task from the assets manager.
  125751. * @param task the task to remove
  125752. */
  125753. removeTask(task: AbstractAssetTask): void;
  125754. private _decreaseWaitingTasksCount;
  125755. private _runTask;
  125756. /**
  125757. * Reset the AssetsManager and remove all tasks
  125758. * @return the current instance of the AssetsManager
  125759. */
  125760. reset(): AssetsManager;
  125761. /**
  125762. * Start the loading process
  125763. * @return the current instance of the AssetsManager
  125764. */
  125765. load(): AssetsManager;
  125766. /**
  125767. * Start the loading process as an async operation
  125768. * @return a promise returning the list of failed tasks
  125769. */
  125770. loadAsync(): Promise<void>;
  125771. }
  125772. }
  125773. declare module BABYLON {
  125774. /**
  125775. * Wrapper class for promise with external resolve and reject.
  125776. */
  125777. export class Deferred<T> {
  125778. /**
  125779. * The promise associated with this deferred object.
  125780. */
  125781. readonly promise: Promise<T>;
  125782. private _resolve;
  125783. private _reject;
  125784. /**
  125785. * The resolve method of the promise associated with this deferred object.
  125786. */
  125787. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  125788. /**
  125789. * The reject method of the promise associated with this deferred object.
  125790. */
  125791. readonly reject: (reason?: any) => void;
  125792. /**
  125793. * Constructor for this deferred object.
  125794. */
  125795. constructor();
  125796. }
  125797. }
  125798. declare module BABYLON {
  125799. /**
  125800. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  125801. */
  125802. export class MeshExploder {
  125803. private _centerMesh;
  125804. private _meshes;
  125805. private _meshesOrigins;
  125806. private _toCenterVectors;
  125807. private _scaledDirection;
  125808. private _newPosition;
  125809. private _centerPosition;
  125810. /**
  125811. * Explodes meshes from a center mesh.
  125812. * @param meshes The meshes to explode.
  125813. * @param centerMesh The mesh to be center of explosion.
  125814. */
  125815. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  125816. private _setCenterMesh;
  125817. /**
  125818. * Get class name
  125819. * @returns "MeshExploder"
  125820. */
  125821. getClassName(): string;
  125822. /**
  125823. * "Exploded meshes"
  125824. * @returns Array of meshes with the centerMesh at index 0.
  125825. */
  125826. getMeshes(): Array<Mesh>;
  125827. /**
  125828. * Explodes meshes giving a specific direction
  125829. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  125830. */
  125831. explode(direction?: number): void;
  125832. }
  125833. }
  125834. declare module BABYLON {
  125835. /**
  125836. * Class used to help managing file picking and drag'n'drop
  125837. */
  125838. export class FilesInput {
  125839. /**
  125840. * List of files ready to be loaded
  125841. */
  125842. static readonly FilesToLoad: {
  125843. [key: string]: File;
  125844. };
  125845. /**
  125846. * Callback called when a file is processed
  125847. */
  125848. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  125849. private _engine;
  125850. private _currentScene;
  125851. private _sceneLoadedCallback;
  125852. private _progressCallback;
  125853. private _additionalRenderLoopLogicCallback;
  125854. private _textureLoadingCallback;
  125855. private _startingProcessingFilesCallback;
  125856. private _onReloadCallback;
  125857. private _errorCallback;
  125858. private _elementToMonitor;
  125859. private _sceneFileToLoad;
  125860. private _filesToLoad;
  125861. /**
  125862. * Creates a new FilesInput
  125863. * @param engine defines the rendering engine
  125864. * @param scene defines the hosting scene
  125865. * @param sceneLoadedCallback callback called when scene is loaded
  125866. * @param progressCallback callback called to track progress
  125867. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  125868. * @param textureLoadingCallback callback called when a texture is loading
  125869. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  125870. * @param onReloadCallback callback called when a reload is requested
  125871. * @param errorCallback callback call if an error occurs
  125872. */
  125873. 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);
  125874. private _dragEnterHandler;
  125875. private _dragOverHandler;
  125876. private _dropHandler;
  125877. /**
  125878. * Calls this function to listen to drag'n'drop events on a specific DOM element
  125879. * @param elementToMonitor defines the DOM element to track
  125880. */
  125881. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  125882. /**
  125883. * Release all associated resources
  125884. */
  125885. dispose(): void;
  125886. private renderFunction;
  125887. private drag;
  125888. private drop;
  125889. private _traverseFolder;
  125890. private _processFiles;
  125891. /**
  125892. * Load files from a drop event
  125893. * @param event defines the drop event to use as source
  125894. */
  125895. loadFiles(event: any): void;
  125896. private _processReload;
  125897. /**
  125898. * Reload the current scene from the loaded files
  125899. */
  125900. reload(): void;
  125901. }
  125902. }
  125903. declare module BABYLON {
  125904. /**
  125905. * Defines the root class used to create scene optimization to use with SceneOptimizer
  125906. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  125907. */
  125908. export class SceneOptimization {
  125909. /**
  125910. * Defines the priority of this optimization (0 by default which means first in the list)
  125911. */
  125912. priority: number;
  125913. /**
  125914. * Gets a string describing the action executed by the current optimization
  125915. * @returns description string
  125916. */
  125917. getDescription(): string;
  125918. /**
  125919. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  125920. * @param scene defines the current scene where to apply this optimization
  125921. * @param optimizer defines the current optimizer
  125922. * @returns true if everything that can be done was applied
  125923. */
  125924. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  125925. /**
  125926. * Creates the SceneOptimization object
  125927. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  125928. * @param desc defines the description associated with the optimization
  125929. */
  125930. constructor(
  125931. /**
  125932. * Defines the priority of this optimization (0 by default which means first in the list)
  125933. */
  125934. priority?: number);
  125935. }
  125936. /**
  125937. * Defines an optimization used to reduce the size of render target textures
  125938. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  125939. */
  125940. export class TextureOptimization extends SceneOptimization {
  125941. /**
  125942. * Defines the priority of this optimization (0 by default which means first in the list)
  125943. */
  125944. priority: number;
  125945. /**
  125946. * 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
  125947. */
  125948. maximumSize: number;
  125949. /**
  125950. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  125951. */
  125952. step: number;
  125953. /**
  125954. * Gets a string describing the action executed by the current optimization
  125955. * @returns description string
  125956. */
  125957. getDescription(): string;
  125958. /**
  125959. * Creates the TextureOptimization object
  125960. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  125961. * @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
  125962. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  125963. */
  125964. constructor(
  125965. /**
  125966. * Defines the priority of this optimization (0 by default which means first in the list)
  125967. */
  125968. priority?: number,
  125969. /**
  125970. * 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
  125971. */
  125972. maximumSize?: number,
  125973. /**
  125974. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  125975. */
  125976. step?: number);
  125977. /**
  125978. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  125979. * @param scene defines the current scene where to apply this optimization
  125980. * @param optimizer defines the current optimizer
  125981. * @returns true if everything that can be done was applied
  125982. */
  125983. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  125984. }
  125985. /**
  125986. * Defines an optimization used to increase or decrease the rendering resolution
  125987. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  125988. */
  125989. export class HardwareScalingOptimization extends SceneOptimization {
  125990. /**
  125991. * Defines the priority of this optimization (0 by default which means first in the list)
  125992. */
  125993. priority: number;
  125994. /**
  125995. * Defines the maximum scale to use (2 by default)
  125996. */
  125997. maximumScale: number;
  125998. /**
  125999. * Defines the step to use between two passes (0.5 by default)
  126000. */
  126001. step: number;
  126002. private _currentScale;
  126003. private _directionOffset;
  126004. /**
  126005. * Gets a string describing the action executed by the current optimization
  126006. * @return description string
  126007. */
  126008. getDescription(): string;
  126009. /**
  126010. * Creates the HardwareScalingOptimization object
  126011. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  126012. * @param maximumScale defines the maximum scale to use (2 by default)
  126013. * @param step defines the step to use between two passes (0.5 by default)
  126014. */
  126015. constructor(
  126016. /**
  126017. * Defines the priority of this optimization (0 by default which means first in the list)
  126018. */
  126019. priority?: number,
  126020. /**
  126021. * Defines the maximum scale to use (2 by default)
  126022. */
  126023. maximumScale?: number,
  126024. /**
  126025. * Defines the step to use between two passes (0.5 by default)
  126026. */
  126027. step?: number);
  126028. /**
  126029. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  126030. * @param scene defines the current scene where to apply this optimization
  126031. * @param optimizer defines the current optimizer
  126032. * @returns true if everything that can be done was applied
  126033. */
  126034. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  126035. }
  126036. /**
  126037. * Defines an optimization used to remove shadows
  126038. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  126039. */
  126040. export class ShadowsOptimization extends SceneOptimization {
  126041. /**
  126042. * Gets a string describing the action executed by the current optimization
  126043. * @return description string
  126044. */
  126045. getDescription(): string;
  126046. /**
  126047. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  126048. * @param scene defines the current scene where to apply this optimization
  126049. * @param optimizer defines the current optimizer
  126050. * @returns true if everything that can be done was applied
  126051. */
  126052. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  126053. }
  126054. /**
  126055. * Defines an optimization used to turn post-processes off
  126056. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  126057. */
  126058. export class PostProcessesOptimization extends SceneOptimization {
  126059. /**
  126060. * Gets a string describing the action executed by the current optimization
  126061. * @return description string
  126062. */
  126063. getDescription(): string;
  126064. /**
  126065. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  126066. * @param scene defines the current scene where to apply this optimization
  126067. * @param optimizer defines the current optimizer
  126068. * @returns true if everything that can be done was applied
  126069. */
  126070. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  126071. }
  126072. /**
  126073. * Defines an optimization used to turn lens flares off
  126074. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  126075. */
  126076. export class LensFlaresOptimization extends SceneOptimization {
  126077. /**
  126078. * Gets a string describing the action executed by the current optimization
  126079. * @return description string
  126080. */
  126081. getDescription(): string;
  126082. /**
  126083. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  126084. * @param scene defines the current scene where to apply this optimization
  126085. * @param optimizer defines the current optimizer
  126086. * @returns true if everything that can be done was applied
  126087. */
  126088. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  126089. }
  126090. /**
  126091. * Defines an optimization based on user defined callback.
  126092. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  126093. */
  126094. export class CustomOptimization extends SceneOptimization {
  126095. /**
  126096. * Callback called to apply the custom optimization.
  126097. */
  126098. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  126099. /**
  126100. * Callback called to get custom description
  126101. */
  126102. onGetDescription: () => string;
  126103. /**
  126104. * Gets a string describing the action executed by the current optimization
  126105. * @returns description string
  126106. */
  126107. getDescription(): string;
  126108. /**
  126109. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  126110. * @param scene defines the current scene where to apply this optimization
  126111. * @param optimizer defines the current optimizer
  126112. * @returns true if everything that can be done was applied
  126113. */
  126114. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  126115. }
  126116. /**
  126117. * Defines an optimization used to turn particles off
  126118. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  126119. */
  126120. export class ParticlesOptimization extends SceneOptimization {
  126121. /**
  126122. * Gets a string describing the action executed by the current optimization
  126123. * @return description string
  126124. */
  126125. getDescription(): string;
  126126. /**
  126127. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  126128. * @param scene defines the current scene where to apply this optimization
  126129. * @param optimizer defines the current optimizer
  126130. * @returns true if everything that can be done was applied
  126131. */
  126132. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  126133. }
  126134. /**
  126135. * Defines an optimization used to turn render targets off
  126136. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  126137. */
  126138. export class RenderTargetsOptimization extends SceneOptimization {
  126139. /**
  126140. * Gets a string describing the action executed by the current optimization
  126141. * @return description string
  126142. */
  126143. getDescription(): string;
  126144. /**
  126145. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  126146. * @param scene defines the current scene where to apply this optimization
  126147. * @param optimizer defines the current optimizer
  126148. * @returns true if everything that can be done was applied
  126149. */
  126150. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  126151. }
  126152. /**
  126153. * Defines an optimization used to merge meshes with compatible materials
  126154. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  126155. */
  126156. export class MergeMeshesOptimization extends SceneOptimization {
  126157. private static _UpdateSelectionTree;
  126158. /**
  126159. * Gets or sets a boolean which defines if optimization octree has to be updated
  126160. */
  126161. /**
  126162. * Gets or sets a boolean which defines if optimization octree has to be updated
  126163. */
  126164. static UpdateSelectionTree: boolean;
  126165. /**
  126166. * Gets a string describing the action executed by the current optimization
  126167. * @return description string
  126168. */
  126169. getDescription(): string;
  126170. private _canBeMerged;
  126171. /**
  126172. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  126173. * @param scene defines the current scene where to apply this optimization
  126174. * @param optimizer defines the current optimizer
  126175. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  126176. * @returns true if everything that can be done was applied
  126177. */
  126178. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  126179. }
  126180. /**
  126181. * Defines a list of options used by SceneOptimizer
  126182. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  126183. */
  126184. export class SceneOptimizerOptions {
  126185. /**
  126186. * Defines the target frame rate to reach (60 by default)
  126187. */
  126188. targetFrameRate: number;
  126189. /**
  126190. * Defines the interval between two checkes (2000ms by default)
  126191. */
  126192. trackerDuration: number;
  126193. /**
  126194. * Gets the list of optimizations to apply
  126195. */
  126196. optimizations: SceneOptimization[];
  126197. /**
  126198. * Creates a new list of options used by SceneOptimizer
  126199. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  126200. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  126201. */
  126202. constructor(
  126203. /**
  126204. * Defines the target frame rate to reach (60 by default)
  126205. */
  126206. targetFrameRate?: number,
  126207. /**
  126208. * Defines the interval between two checkes (2000ms by default)
  126209. */
  126210. trackerDuration?: number);
  126211. /**
  126212. * Add a new optimization
  126213. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  126214. * @returns the current SceneOptimizerOptions
  126215. */
  126216. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  126217. /**
  126218. * Add a new custom optimization
  126219. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  126220. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  126221. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  126222. * @returns the current SceneOptimizerOptions
  126223. */
  126224. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  126225. /**
  126226. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  126227. * @param targetFrameRate defines the target frame rate (60 by default)
  126228. * @returns a SceneOptimizerOptions object
  126229. */
  126230. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  126231. /**
  126232. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  126233. * @param targetFrameRate defines the target frame rate (60 by default)
  126234. * @returns a SceneOptimizerOptions object
  126235. */
  126236. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  126237. /**
  126238. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  126239. * @param targetFrameRate defines the target frame rate (60 by default)
  126240. * @returns a SceneOptimizerOptions object
  126241. */
  126242. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  126243. }
  126244. /**
  126245. * Class used to run optimizations in order to reach a target frame rate
  126246. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  126247. */
  126248. export class SceneOptimizer implements IDisposable {
  126249. private _isRunning;
  126250. private _options;
  126251. private _scene;
  126252. private _currentPriorityLevel;
  126253. private _targetFrameRate;
  126254. private _trackerDuration;
  126255. private _currentFrameRate;
  126256. private _sceneDisposeObserver;
  126257. private _improvementMode;
  126258. /**
  126259. * Defines an observable called when the optimizer reaches the target frame rate
  126260. */
  126261. onSuccessObservable: Observable<SceneOptimizer>;
  126262. /**
  126263. * Defines an observable called when the optimizer enables an optimization
  126264. */
  126265. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  126266. /**
  126267. * Defines an observable called when the optimizer is not able to reach the target frame rate
  126268. */
  126269. onFailureObservable: Observable<SceneOptimizer>;
  126270. /**
  126271. * Gets a boolean indicating if the optimizer is in improvement mode
  126272. */
  126273. readonly isInImprovementMode: boolean;
  126274. /**
  126275. * Gets the current priority level (0 at start)
  126276. */
  126277. readonly currentPriorityLevel: number;
  126278. /**
  126279. * Gets the current frame rate checked by the SceneOptimizer
  126280. */
  126281. readonly currentFrameRate: number;
  126282. /**
  126283. * Gets or sets the current target frame rate (60 by default)
  126284. */
  126285. /**
  126286. * Gets or sets the current target frame rate (60 by default)
  126287. */
  126288. targetFrameRate: number;
  126289. /**
  126290. * Gets or sets the current interval between two checks (every 2000ms by default)
  126291. */
  126292. /**
  126293. * Gets or sets the current interval between two checks (every 2000ms by default)
  126294. */
  126295. trackerDuration: number;
  126296. /**
  126297. * Gets the list of active optimizations
  126298. */
  126299. readonly optimizations: SceneOptimization[];
  126300. /**
  126301. * Creates a new SceneOptimizer
  126302. * @param scene defines the scene to work on
  126303. * @param options defines the options to use with the SceneOptimizer
  126304. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  126305. * @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)
  126306. */
  126307. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  126308. /**
  126309. * Stops the current optimizer
  126310. */
  126311. stop(): void;
  126312. /**
  126313. * Reset the optimizer to initial step (current priority level = 0)
  126314. */
  126315. reset(): void;
  126316. /**
  126317. * Start the optimizer. By default it will try to reach a specific framerate
  126318. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  126319. */
  126320. start(): void;
  126321. private _checkCurrentState;
  126322. /**
  126323. * Release all resources
  126324. */
  126325. dispose(): void;
  126326. /**
  126327. * Helper function to create a SceneOptimizer with one single line of code
  126328. * @param scene defines the scene to work on
  126329. * @param options defines the options to use with the SceneOptimizer
  126330. * @param onSuccess defines a callback to call on success
  126331. * @param onFailure defines a callback to call on failure
  126332. * @returns the new SceneOptimizer object
  126333. */
  126334. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  126335. }
  126336. }
  126337. declare module BABYLON {
  126338. /**
  126339. * Class used to serialize a scene into a string
  126340. */
  126341. export class SceneSerializer {
  126342. /**
  126343. * Clear cache used by a previous serialization
  126344. */
  126345. static ClearCache(): void;
  126346. /**
  126347. * Serialize a scene into a JSON compatible object
  126348. * @param scene defines the scene to serialize
  126349. * @returns a JSON compatible object
  126350. */
  126351. static Serialize(scene: Scene): any;
  126352. /**
  126353. * Serialize a mesh into a JSON compatible object
  126354. * @param toSerialize defines the mesh to serialize
  126355. * @param withParents defines if parents must be serialized as well
  126356. * @param withChildren defines if children must be serialized as well
  126357. * @returns a JSON compatible object
  126358. */
  126359. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  126360. }
  126361. }
  126362. declare module BABYLON {
  126363. /**
  126364. * Class used to host texture specific utilities
  126365. */
  126366. export class TextureTools {
  126367. /**
  126368. * Uses the GPU to create a copy texture rescaled at a given size
  126369. * @param texture Texture to copy from
  126370. * @param width defines the desired width
  126371. * @param height defines the desired height
  126372. * @param useBilinearMode defines if bilinear mode has to be used
  126373. * @return the generated texture
  126374. */
  126375. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  126376. }
  126377. }
  126378. declare module BABYLON {
  126379. /**
  126380. * This represents the different options available for the video capture.
  126381. */
  126382. export interface VideoRecorderOptions {
  126383. /** Defines the mime type of the video. */
  126384. mimeType: string;
  126385. /** Defines the FPS the video should be recorded at. */
  126386. fps: number;
  126387. /** Defines the chunk size for the recording data. */
  126388. recordChunckSize: number;
  126389. /** The audio tracks to attach to the recording. */
  126390. audioTracks?: MediaStreamTrack[];
  126391. }
  126392. /**
  126393. * This can help with recording videos from BabylonJS.
  126394. * This is based on the available WebRTC functionalities of the browser.
  126395. *
  126396. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  126397. */
  126398. export class VideoRecorder {
  126399. private static readonly _defaultOptions;
  126400. /**
  126401. * Returns whether or not the VideoRecorder is available in your browser.
  126402. * @param engine Defines the Babylon Engine.
  126403. * @returns true if supported otherwise false.
  126404. */
  126405. static IsSupported(engine: Engine): boolean;
  126406. private readonly _options;
  126407. private _canvas;
  126408. private _mediaRecorder;
  126409. private _recordedChunks;
  126410. private _fileName;
  126411. private _resolve;
  126412. private _reject;
  126413. /**
  126414. * True when a recording is already in progress.
  126415. */
  126416. readonly isRecording: boolean;
  126417. /**
  126418. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  126419. * @param engine Defines the BabylonJS Engine you wish to record.
  126420. * @param options Defines options that can be used to customize the capture.
  126421. */
  126422. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  126423. /**
  126424. * Stops the current recording before the default capture timeout passed in the startRecording function.
  126425. */
  126426. stopRecording(): void;
  126427. /**
  126428. * Starts recording the canvas for a max duration specified in parameters.
  126429. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  126430. * If null no automatic download will start and you can rely on the promise to get the data back.
  126431. * @param maxDuration Defines the maximum recording time in seconds.
  126432. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  126433. * @return A promise callback at the end of the recording with the video data in Blob.
  126434. */
  126435. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  126436. /**
  126437. * Releases internal resources used during the recording.
  126438. */
  126439. dispose(): void;
  126440. private _handleDataAvailable;
  126441. private _handleError;
  126442. private _handleStop;
  126443. }
  126444. }
  126445. declare module BABYLON {
  126446. /**
  126447. * Class containing a set of static utilities functions for screenshots
  126448. */
  126449. export class ScreenshotTools {
  126450. /**
  126451. * Captures a screenshot of the current rendering
  126452. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  126453. * @param engine defines the rendering engine
  126454. * @param camera defines the source camera
  126455. * @param size This parameter can be set to a single number or to an object with the
  126456. * following (optional) properties: precision, width, height. If a single number is passed,
  126457. * it will be used for both width and height. If an object is passed, the screenshot size
  126458. * will be derived from the parameters. The precision property is a multiplier allowing
  126459. * rendering at a higher or lower resolution
  126460. * @param successCallback defines the callback receives a single parameter which contains the
  126461. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  126462. * src parameter of an <img> to display it
  126463. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  126464. * Check your browser for supported MIME types
  126465. */
  126466. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  126467. /**
  126468. * Captures a screenshot of the current rendering
  126469. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  126470. * @param engine defines the rendering engine
  126471. * @param camera defines the source camera
  126472. * @param size This parameter can be set to a single number or to an object with the
  126473. * following (optional) properties: precision, width, height. If a single number is passed,
  126474. * it will be used for both width and height. If an object is passed, the screenshot size
  126475. * will be derived from the parameters. The precision property is a multiplier allowing
  126476. * rendering at a higher or lower resolution
  126477. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  126478. * Check your browser for supported MIME types
  126479. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  126480. * to the src parameter of an <img> to display it
  126481. */
  126482. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  126483. /**
  126484. * Generates an image screenshot from the specified camera.
  126485. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  126486. * @param engine The engine to use for rendering
  126487. * @param camera The camera to use for rendering
  126488. * @param size This parameter can be set to a single number or to an object with the
  126489. * following (optional) properties: precision, width, height. If a single number is passed,
  126490. * it will be used for both width and height. If an object is passed, the screenshot size
  126491. * will be derived from the parameters. The precision property is a multiplier allowing
  126492. * rendering at a higher or lower resolution
  126493. * @param successCallback The callback receives a single parameter which contains the
  126494. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  126495. * src parameter of an <img> to display it
  126496. * @param mimeType The MIME type of the screenshot image (default: image/png).
  126497. * Check your browser for supported MIME types
  126498. * @param samples Texture samples (default: 1)
  126499. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  126500. * @param fileName A name for for the downloaded file.
  126501. */
  126502. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  126503. /**
  126504. * Generates an image screenshot from the specified camera.
  126505. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  126506. * @param engine The engine to use for rendering
  126507. * @param camera The camera to use for rendering
  126508. * @param size This parameter can be set to a single number or to an object with the
  126509. * following (optional) properties: precision, width, height. If a single number is passed,
  126510. * it will be used for both width and height. If an object is passed, the screenshot size
  126511. * will be derived from the parameters. The precision property is a multiplier allowing
  126512. * rendering at a higher or lower resolution
  126513. * @param mimeType The MIME type of the screenshot image (default: image/png).
  126514. * Check your browser for supported MIME types
  126515. * @param samples Texture samples (default: 1)
  126516. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  126517. * @param fileName A name for for the downloaded file.
  126518. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  126519. * to the src parameter of an <img> to display it
  126520. */
  126521. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  126522. /**
  126523. * Gets height and width for screenshot size
  126524. * @private
  126525. */
  126526. private static _getScreenshotSize;
  126527. }
  126528. }
  126529. declare module BABYLON {
  126530. /**
  126531. * A cursor which tracks a point on a path
  126532. */
  126533. export class PathCursor {
  126534. private path;
  126535. /**
  126536. * Stores path cursor callbacks for when an onchange event is triggered
  126537. */
  126538. private _onchange;
  126539. /**
  126540. * The value of the path cursor
  126541. */
  126542. value: number;
  126543. /**
  126544. * The animation array of the path cursor
  126545. */
  126546. animations: Animation[];
  126547. /**
  126548. * Initializes the path cursor
  126549. * @param path The path to track
  126550. */
  126551. constructor(path: Path2);
  126552. /**
  126553. * Gets the cursor point on the path
  126554. * @returns A point on the path cursor at the cursor location
  126555. */
  126556. getPoint(): Vector3;
  126557. /**
  126558. * Moves the cursor ahead by the step amount
  126559. * @param step The amount to move the cursor forward
  126560. * @returns This path cursor
  126561. */
  126562. moveAhead(step?: number): PathCursor;
  126563. /**
  126564. * Moves the cursor behind by the step amount
  126565. * @param step The amount to move the cursor back
  126566. * @returns This path cursor
  126567. */
  126568. moveBack(step?: number): PathCursor;
  126569. /**
  126570. * Moves the cursor by the step amount
  126571. * If the step amount is greater than one, an exception is thrown
  126572. * @param step The amount to move the cursor
  126573. * @returns This path cursor
  126574. */
  126575. move(step: number): PathCursor;
  126576. /**
  126577. * Ensures that the value is limited between zero and one
  126578. * @returns This path cursor
  126579. */
  126580. private ensureLimits;
  126581. /**
  126582. * Runs onchange callbacks on change (used by the animation engine)
  126583. * @returns This path cursor
  126584. */
  126585. private raiseOnChange;
  126586. /**
  126587. * Executes a function on change
  126588. * @param f A path cursor onchange callback
  126589. * @returns This path cursor
  126590. */
  126591. onchange(f: (cursor: PathCursor) => void): PathCursor;
  126592. }
  126593. }
  126594. declare module BABYLON {
  126595. /** @hidden */
  126596. export var blurPixelShader: {
  126597. name: string;
  126598. shader: string;
  126599. };
  126600. }
  126601. declare module BABYLON {
  126602. /** @hidden */
  126603. export var pointCloudVertexDeclaration: {
  126604. name: string;
  126605. shader: string;
  126606. };
  126607. }
  126608. // Mixins
  126609. interface Window {
  126610. mozIndexedDB: IDBFactory;
  126611. webkitIndexedDB: IDBFactory;
  126612. msIndexedDB: IDBFactory;
  126613. webkitURL: typeof URL;
  126614. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  126615. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  126616. WebGLRenderingContext: WebGLRenderingContext;
  126617. MSGesture: MSGesture;
  126618. CANNON: any;
  126619. AudioContext: AudioContext;
  126620. webkitAudioContext: AudioContext;
  126621. PointerEvent: any;
  126622. Math: Math;
  126623. Uint8Array: Uint8ArrayConstructor;
  126624. Float32Array: Float32ArrayConstructor;
  126625. mozURL: typeof URL;
  126626. msURL: typeof URL;
  126627. VRFrameData: any; // WebVR, from specs 1.1
  126628. DracoDecoderModule: any;
  126629. setImmediate(handler: (...args: any[]) => void): number;
  126630. }
  126631. interface HTMLCanvasElement {
  126632. requestPointerLock(): void;
  126633. msRequestPointerLock?(): void;
  126634. mozRequestPointerLock?(): void;
  126635. webkitRequestPointerLock?(): void;
  126636. /** Track wether a record is in progress */
  126637. isRecording: boolean;
  126638. /** Capture Stream method defined by some browsers */
  126639. captureStream(fps?: number): MediaStream;
  126640. }
  126641. interface CanvasRenderingContext2D {
  126642. msImageSmoothingEnabled: boolean;
  126643. }
  126644. interface MouseEvent {
  126645. mozMovementX: number;
  126646. mozMovementY: number;
  126647. webkitMovementX: number;
  126648. webkitMovementY: number;
  126649. msMovementX: number;
  126650. msMovementY: number;
  126651. }
  126652. interface Navigator {
  126653. mozGetVRDevices: (any: any) => any;
  126654. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  126655. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  126656. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  126657. webkitGetGamepads(): Gamepad[];
  126658. msGetGamepads(): Gamepad[];
  126659. webkitGamepads(): Gamepad[];
  126660. }
  126661. interface HTMLVideoElement {
  126662. mozSrcObject: any;
  126663. }
  126664. interface Math {
  126665. fround(x: number): number;
  126666. imul(a: number, b: number): number;
  126667. }
  126668. interface WebGLRenderingContext {
  126669. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  126670. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  126671. vertexAttribDivisor(index: number, divisor: number): void;
  126672. createVertexArray(): any;
  126673. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  126674. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  126675. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  126676. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  126677. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  126678. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  126679. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  126680. // Queries
  126681. createQuery(): WebGLQuery;
  126682. deleteQuery(query: WebGLQuery): void;
  126683. beginQuery(target: number, query: WebGLQuery): void;
  126684. endQuery(target: number): void;
  126685. getQueryParameter(query: WebGLQuery, pname: number): any;
  126686. getQuery(target: number, pname: number): any;
  126687. MAX_SAMPLES: number;
  126688. RGBA8: number;
  126689. READ_FRAMEBUFFER: number;
  126690. DRAW_FRAMEBUFFER: number;
  126691. UNIFORM_BUFFER: number;
  126692. HALF_FLOAT_OES: number;
  126693. RGBA16F: number;
  126694. RGBA32F: number;
  126695. R32F: number;
  126696. RG32F: number;
  126697. RGB32F: number;
  126698. R16F: number;
  126699. RG16F: number;
  126700. RGB16F: number;
  126701. RED: number;
  126702. RG: number;
  126703. R8: number;
  126704. RG8: number;
  126705. UNSIGNED_INT_24_8: number;
  126706. DEPTH24_STENCIL8: number;
  126707. /* Multiple Render Targets */
  126708. drawBuffers(buffers: number[]): void;
  126709. readBuffer(src: number): void;
  126710. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  126711. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  126712. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  126713. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  126714. // Occlusion Query
  126715. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  126716. ANY_SAMPLES_PASSED: number;
  126717. QUERY_RESULT_AVAILABLE: number;
  126718. QUERY_RESULT: number;
  126719. }
  126720. interface WebGLProgram {
  126721. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  126722. }
  126723. interface EXT_disjoint_timer_query {
  126724. QUERY_COUNTER_BITS_EXT: number;
  126725. TIME_ELAPSED_EXT: number;
  126726. TIMESTAMP_EXT: number;
  126727. GPU_DISJOINT_EXT: number;
  126728. QUERY_RESULT_EXT: number;
  126729. QUERY_RESULT_AVAILABLE_EXT: number;
  126730. queryCounterEXT(query: WebGLQuery, target: number): void;
  126731. createQueryEXT(): WebGLQuery;
  126732. beginQueryEXT(target: number, query: WebGLQuery): void;
  126733. endQueryEXT(target: number): void;
  126734. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  126735. deleteQueryEXT(query: WebGLQuery): void;
  126736. }
  126737. interface WebGLUniformLocation {
  126738. _currentState: any;
  126739. }
  126740. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  126741. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  126742. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  126743. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  126744. interface WebGLRenderingContext {
  126745. readonly RASTERIZER_DISCARD: number;
  126746. readonly DEPTH_COMPONENT24: number;
  126747. readonly TEXTURE_3D: number;
  126748. readonly TEXTURE_2D_ARRAY: number;
  126749. readonly TEXTURE_COMPARE_FUNC: number;
  126750. readonly TEXTURE_COMPARE_MODE: number;
  126751. readonly COMPARE_REF_TO_TEXTURE: number;
  126752. readonly TEXTURE_WRAP_R: number;
  126753. readonly HALF_FLOAT: number;
  126754. readonly RGB8: number;
  126755. readonly RED_INTEGER: number;
  126756. readonly RG_INTEGER: number;
  126757. readonly RGB_INTEGER: number;
  126758. readonly RGBA_INTEGER: number;
  126759. readonly R8_SNORM: number;
  126760. readonly RG8_SNORM: number;
  126761. readonly RGB8_SNORM: number;
  126762. readonly RGBA8_SNORM: number;
  126763. readonly R8I: number;
  126764. readonly RG8I: number;
  126765. readonly RGB8I: number;
  126766. readonly RGBA8I: number;
  126767. readonly R8UI: number;
  126768. readonly RG8UI: number;
  126769. readonly RGB8UI: number;
  126770. readonly RGBA8UI: number;
  126771. readonly R16I: number;
  126772. readonly RG16I: number;
  126773. readonly RGB16I: number;
  126774. readonly RGBA16I: number;
  126775. readonly R16UI: number;
  126776. readonly RG16UI: number;
  126777. readonly RGB16UI: number;
  126778. readonly RGBA16UI: number;
  126779. readonly R32I: number;
  126780. readonly RG32I: number;
  126781. readonly RGB32I: number;
  126782. readonly RGBA32I: number;
  126783. readonly R32UI: number;
  126784. readonly RG32UI: number;
  126785. readonly RGB32UI: number;
  126786. readonly RGBA32UI: number;
  126787. readonly RGB10_A2UI: number;
  126788. readonly R11F_G11F_B10F: number;
  126789. readonly RGB9_E5: number;
  126790. readonly RGB10_A2: number;
  126791. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  126792. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  126793. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  126794. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  126795. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  126796. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  126797. 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;
  126798. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  126799. readonly TRANSFORM_FEEDBACK: number;
  126800. readonly INTERLEAVED_ATTRIBS: number;
  126801. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  126802. createTransformFeedback(): WebGLTransformFeedback;
  126803. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  126804. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  126805. beginTransformFeedback(primitiveMode: number): void;
  126806. endTransformFeedback(): void;
  126807. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  126808. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  126809. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  126810. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  126811. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  126812. }
  126813. interface ImageBitmap {
  126814. readonly width: number;
  126815. readonly height: number;
  126816. close(): void;
  126817. }
  126818. interface WebGLQuery extends WebGLObject {
  126819. }
  126820. declare var WebGLQuery: {
  126821. prototype: WebGLQuery;
  126822. new(): WebGLQuery;
  126823. };
  126824. interface WebGLSampler extends WebGLObject {
  126825. }
  126826. declare var WebGLSampler: {
  126827. prototype: WebGLSampler;
  126828. new(): WebGLSampler;
  126829. };
  126830. interface WebGLSync extends WebGLObject {
  126831. }
  126832. declare var WebGLSync: {
  126833. prototype: WebGLSync;
  126834. new(): WebGLSync;
  126835. };
  126836. interface WebGLTransformFeedback extends WebGLObject {
  126837. }
  126838. declare var WebGLTransformFeedback: {
  126839. prototype: WebGLTransformFeedback;
  126840. new(): WebGLTransformFeedback;
  126841. };
  126842. interface WebGLVertexArrayObject extends WebGLObject {
  126843. }
  126844. declare var WebGLVertexArrayObject: {
  126845. prototype: WebGLVertexArrayObject;
  126846. new(): WebGLVertexArrayObject;
  126847. };
  126848. // Type definitions for WebVR API
  126849. // Project: https://w3c.github.io/webvr/
  126850. // Definitions by: six a <https://github.com/lostfictions>
  126851. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  126852. interface VRDisplay extends EventTarget {
  126853. /**
  126854. * Dictionary of capabilities describing the VRDisplay.
  126855. */
  126856. readonly capabilities: VRDisplayCapabilities;
  126857. /**
  126858. * z-depth defining the far plane of the eye view frustum
  126859. * enables mapping of values in the render target depth
  126860. * attachment to scene coordinates. Initially set to 10000.0.
  126861. */
  126862. depthFar: number;
  126863. /**
  126864. * z-depth defining the near plane of the eye view frustum
  126865. * enables mapping of values in the render target depth
  126866. * attachment to scene coordinates. Initially set to 0.01.
  126867. */
  126868. depthNear: number;
  126869. /**
  126870. * An identifier for this distinct VRDisplay. Used as an
  126871. * association point in the Gamepad API.
  126872. */
  126873. readonly displayId: number;
  126874. /**
  126875. * A display name, a user-readable name identifying it.
  126876. */
  126877. readonly displayName: string;
  126878. readonly isConnected: boolean;
  126879. readonly isPresenting: boolean;
  126880. /**
  126881. * If this VRDisplay supports room-scale experiences, the optional
  126882. * stage attribute contains details on the room-scale parameters.
  126883. */
  126884. readonly stageParameters: VRStageParameters | null;
  126885. /**
  126886. * Passing the value returned by `requestAnimationFrame` to
  126887. * `cancelAnimationFrame` will unregister the callback.
  126888. * @param handle Define the hanle of the request to cancel
  126889. */
  126890. cancelAnimationFrame(handle: number): void;
  126891. /**
  126892. * Stops presenting to the VRDisplay.
  126893. * @returns a promise to know when it stopped
  126894. */
  126895. exitPresent(): Promise<void>;
  126896. /**
  126897. * Return the current VREyeParameters for the given eye.
  126898. * @param whichEye Define the eye we want the parameter for
  126899. * @returns the eye parameters
  126900. */
  126901. getEyeParameters(whichEye: string): VREyeParameters;
  126902. /**
  126903. * Populates the passed VRFrameData with the information required to render
  126904. * the current frame.
  126905. * @param frameData Define the data structure to populate
  126906. * @returns true if ok otherwise false
  126907. */
  126908. getFrameData(frameData: VRFrameData): boolean;
  126909. /**
  126910. * Get the layers currently being presented.
  126911. * @returns the list of VR layers
  126912. */
  126913. getLayers(): VRLayer[];
  126914. /**
  126915. * Return a VRPose containing the future predicted pose of the VRDisplay
  126916. * when the current frame will be presented. The value returned will not
  126917. * change until JavaScript has returned control to the browser.
  126918. *
  126919. * The VRPose will contain the position, orientation, velocity,
  126920. * and acceleration of each of these properties.
  126921. * @returns the pose object
  126922. */
  126923. getPose(): VRPose;
  126924. /**
  126925. * Return the current instantaneous pose of the VRDisplay, with no
  126926. * prediction applied.
  126927. * @returns the current instantaneous pose
  126928. */
  126929. getImmediatePose(): VRPose;
  126930. /**
  126931. * The callback passed to `requestAnimationFrame` will be called
  126932. * any time a new frame should be rendered. When the VRDisplay is
  126933. * presenting the callback will be called at the native refresh
  126934. * rate of the HMD. When not presenting this function acts
  126935. * identically to how window.requestAnimationFrame acts. Content should
  126936. * make no assumptions of frame rate or vsync behavior as the HMD runs
  126937. * asynchronously from other displays and at differing refresh rates.
  126938. * @param callback Define the eaction to run next frame
  126939. * @returns the request handle it
  126940. */
  126941. requestAnimationFrame(callback: FrameRequestCallback): number;
  126942. /**
  126943. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  126944. * Repeat calls while already presenting will update the VRLayers being displayed.
  126945. * @param layers Define the list of layer to present
  126946. * @returns a promise to know when the request has been fulfilled
  126947. */
  126948. requestPresent(layers: VRLayer[]): Promise<void>;
  126949. /**
  126950. * Reset the pose for this display, treating its current position and
  126951. * orientation as the "origin/zero" values. VRPose.position,
  126952. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  126953. * updated when calling resetPose(). This should be called in only
  126954. * sitting-space experiences.
  126955. */
  126956. resetPose(): void;
  126957. /**
  126958. * The VRLayer provided to the VRDisplay will be captured and presented
  126959. * in the HMD. Calling this function has the same effect on the source
  126960. * canvas as any other operation that uses its source image, and canvases
  126961. * created without preserveDrawingBuffer set to true will be cleared.
  126962. * @param pose Define the pose to submit
  126963. */
  126964. submitFrame(pose?: VRPose): void;
  126965. }
  126966. declare var VRDisplay: {
  126967. prototype: VRDisplay;
  126968. new(): VRDisplay;
  126969. };
  126970. interface VRLayer {
  126971. leftBounds?: number[] | Float32Array | null;
  126972. rightBounds?: number[] | Float32Array | null;
  126973. source?: HTMLCanvasElement | null;
  126974. }
  126975. interface VRDisplayCapabilities {
  126976. readonly canPresent: boolean;
  126977. readonly hasExternalDisplay: boolean;
  126978. readonly hasOrientation: boolean;
  126979. readonly hasPosition: boolean;
  126980. readonly maxLayers: number;
  126981. }
  126982. interface VREyeParameters {
  126983. /** @deprecated */
  126984. readonly fieldOfView: VRFieldOfView;
  126985. readonly offset: Float32Array;
  126986. readonly renderHeight: number;
  126987. readonly renderWidth: number;
  126988. }
  126989. interface VRFieldOfView {
  126990. readonly downDegrees: number;
  126991. readonly leftDegrees: number;
  126992. readonly rightDegrees: number;
  126993. readonly upDegrees: number;
  126994. }
  126995. interface VRFrameData {
  126996. readonly leftProjectionMatrix: Float32Array;
  126997. readonly leftViewMatrix: Float32Array;
  126998. readonly pose: VRPose;
  126999. readonly rightProjectionMatrix: Float32Array;
  127000. readonly rightViewMatrix: Float32Array;
  127001. readonly timestamp: number;
  127002. }
  127003. interface VRPose {
  127004. readonly angularAcceleration: Float32Array | null;
  127005. readonly angularVelocity: Float32Array | null;
  127006. readonly linearAcceleration: Float32Array | null;
  127007. readonly linearVelocity: Float32Array | null;
  127008. readonly orientation: Float32Array | null;
  127009. readonly position: Float32Array | null;
  127010. readonly timestamp: number;
  127011. }
  127012. interface VRStageParameters {
  127013. sittingToStandingTransform?: Float32Array;
  127014. sizeX?: number;
  127015. sizeY?: number;
  127016. }
  127017. interface Navigator {
  127018. getVRDisplays(): Promise<VRDisplay[]>;
  127019. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  127020. }
  127021. interface Window {
  127022. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  127023. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  127024. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  127025. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  127026. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  127027. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  127028. }
  127029. interface Gamepad {
  127030. readonly displayId: number;
  127031. }
  127032. type XRSessionMode =
  127033. | "inline"
  127034. | "immersive-vr"
  127035. | "immersive-ar";
  127036. type XRReferenceSpaceType =
  127037. | "viewer"
  127038. | "local"
  127039. | "local-floor"
  127040. | "bounded-floor"
  127041. | "unbounded";
  127042. type XREnvironmentBlendMode =
  127043. | "opaque"
  127044. | "additive"
  127045. | "alpha-blend";
  127046. type XRVisibilityState =
  127047. | "visible"
  127048. | "visible-blurred"
  127049. | "hidden";
  127050. type XRHandedness =
  127051. | "none"
  127052. | "left"
  127053. | "right";
  127054. type XRTargetRayMode =
  127055. | "gaze"
  127056. | "tracked-pointer"
  127057. | "screen";
  127058. type XREye =
  127059. | "none"
  127060. | "left"
  127061. | "right";
  127062. interface XRSpace extends EventTarget {
  127063. }
  127064. interface XRRenderState {
  127065. depthNear?: number;
  127066. depthFar?: number;
  127067. inlineVerticalFieldOfView?: number;
  127068. baseLayer?: XRWebGLLayer;
  127069. }
  127070. interface XRInputSource {
  127071. handedness: XRHandedness;
  127072. targetRayMode: XRTargetRayMode;
  127073. targetRaySpace: XRSpace;
  127074. gripSpace: XRSpace | undefined;
  127075. gamepad: Gamepad | undefined;
  127076. profiles: Array<string>;
  127077. }
  127078. interface XRSession {
  127079. addEventListener: Function;
  127080. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  127081. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  127082. requestAnimationFrame: Function;
  127083. end(): Promise<void>;
  127084. renderState: XRRenderState;
  127085. inputSources: Array<XRInputSource>;
  127086. }
  127087. interface XRReferenceSpace extends XRSpace {
  127088. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  127089. onreset: any;
  127090. }
  127091. interface XRFrame {
  127092. session: XRSession;
  127093. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  127094. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  127095. }
  127096. interface XRViewerPose extends XRPose {
  127097. views: Array<XRView>;
  127098. }
  127099. interface XRPose {
  127100. transform: XRRigidTransform;
  127101. emulatedPosition: boolean;
  127102. }
  127103. declare var XRWebGLLayer: {
  127104. prototype: XRWebGLLayer;
  127105. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  127106. };
  127107. interface XRWebGLLayer {
  127108. framebuffer: WebGLFramebuffer;
  127109. framebufferWidth: number;
  127110. framebufferHeight: number;
  127111. getViewport: Function;
  127112. }
  127113. interface XRRigidTransform {
  127114. position: DOMPointReadOnly;
  127115. orientation: DOMPointReadOnly;
  127116. matrix: Float32Array;
  127117. inverse: XRRigidTransform;
  127118. }
  127119. interface XRView {
  127120. eye: XREye;
  127121. projectionMatrix: Float32Array;
  127122. transform: XRRigidTransform;
  127123. }
  127124. interface XRInputSourceChangeEvent {
  127125. session: XRSession;
  127126. removed: Array<XRInputSource>;
  127127. added: Array<XRInputSource>;
  127128. }